Skip to content

Commit

Permalink
Add cartwheel mtl y210le support patch
Browse files Browse the repository at this point in the history
Patch added from Intel Tiber Braodcast Suite
after some clean-up.
  • Loading branch information
skolelis committed Dec 23, 2024
1 parent ea0540c commit 4622ac7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ecosystem/ffmpeg_plugin/mtl_st20p_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#ifdef MTL_GPU_DIRECT_ENABLED
#include <mtl_gpu_direct/gpu.h>
#endif /* MTL_GPU_DIRECT_ENABLED */
#include <mtl/st_convert_api.h>

typedef struct MtlSt20pDemuxerContext {
const AVClass* class; /**< Class for private options. */
Expand Down Expand Up @@ -120,6 +121,10 @@ static int mtl_st20p_read_header(AVFormatContext* ctx) {
ops_rx.transport_fmt = ST20_FMT_YUV_422_10BIT;
ops_rx.output_fmt = ST_FRAME_FMT_YUV422PLANAR10LE;
break;
case AV_PIX_FMT_Y210LE:
ops_rx.transport_fmt = ST20_FMT_YUV_422_10BIT;
ops_rx.output_fmt = ST_FRAME_FMT_Y210;
break;
case AV_PIX_FMT_RGB24:
ops_rx.transport_fmt = ST20_FMT_RGB_8BIT;
ops_rx.output_fmt = ST_FRAME_FMT_RGB8;
Expand Down Expand Up @@ -256,6 +261,18 @@ static int mtl_st20p_read_packet(AVFormatContext* ctx, AVPacket* pkt) {
st20p_rx_put_frame(s->rx_handle, frame);
return ret;
}

if (s->pixel_format == AV_PIX_FMT_Y210LE) {
ret = st20_rfc4175_422be10_to_y210(
(struct st20_rfc4175_422_10_pg2_be*)frame, (uint16_t*)pkt->data,
s->width, s->height);
if (ret != 0) {
av_log(ctx, AV_LOG_ERROR,
"st20_rfc4175_422be10_to_y210le failed with %d\n", ret);
return ret;
}
}

/* todo: zero copy with external frame mode */
mtl_memcpy(pkt->data, frame->addr[0], ctx->packet_size);
st20p_rx_put_frame(s->rx_handle, frame);
Expand Down
12 changes: 12 additions & 0 deletions ecosystem/ffmpeg_plugin/mtl_st20p_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include "mtl_common.h"
#include <mtl/st_convert_api.h>

typedef struct mtlSt20pMuxerContext {
const AVClass* class; /**< Class for private options. */
Expand Down Expand Up @@ -94,6 +95,10 @@ static int mtl_st20p_write_header(AVFormatContext* ctx) {
ops_tx.input_fmt = ST_FRAME_FMT_YUV422PLANAR10LE;
ops_tx.transport_fmt = ST20_FMT_YUV_422_10BIT;
break;
case AV_PIX_FMT_Y210LE:
ops_tx.transport_fmt = ST20_FMT_YUV_422_10BIT;
ops_tx.input_fmt = ST_FRAME_FMT_Y210;
break;
case AV_PIX_FMT_RGB24:
ops_tx.input_fmt = ST_FRAME_FMT_RGB8;
ops_tx.transport_fmt = ST20_FMT_RGB_8BIT;
Expand Down Expand Up @@ -152,6 +157,13 @@ static int mtl_st20p_write_packet(AVFormatContext* ctx, AVPacket* pkt) {
return AVERROR(EIO);
}
dbg(ctx, "%s(%d), st20p_tx_get_frame: %p\n", __func__, s->idx, frame);

if (s->pixel_format == AV_PIX_FMT_Y210LE) {
st20_y210_to_rfc4175_422be10(
(uint16_t*)pkt->data, (struct st20_rfc4175_422_10_pg2_be*)(frame->addr[0]),
s->width, s->height);
}

/* todo: zero copy with external frame mode */
mtl_memcpy(frame->addr[0], pkt->data, s->frame_size);

Expand Down

0 comments on commit 4622ac7

Please sign in to comment.