Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: y210le support in ffmpeg plugin #1029

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ecosystem/ffmpeg_plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cd ../

### 1.2 Build ffmpeg with MTL patches

Note: $mtl_source_code should be pointed to top source code tree of Media Transport Library.
Note: `$mtl_source_code` should be pointed to top source code tree of Media Transport Library.

```bash
git clone https://github.com/FFmpeg/FFmpeg.git
Expand Down Expand Up @@ -82,6 +82,10 @@ Reading from a yuv stream from a local file and sending a st2110-20 10bit YUV422
ffmpeg -stream_loop -1 -video_size 1920x1080 -f rawvideo -pix_fmt yuv422p10le -i yuv422p10le_1080p.yuv -filter:v fps=59.94 -p_port 0000:af:01.1 -p_sip 192.168.96.3 -p_tx_ip 239.168.85.20 -udp_port 20000 -payload_type 112 -f mtl_st20p -
```

### 2.3. y210 format

Note: The format y210 is not supported by the Ffmpeg plugins for MTL.

## 3. ST22 compressed video run guide

A typical workflow for processing an MTL ST22 compressed stream with FFMpeg is outlined in the following steps: Initially, FFMpeg reads a YUV frame from the input source, then forwards the frame to a codec to encode the raw video into a compressed codec stream. Finally, the codec stream is sent to the MTL ST22 plugin.
Expand Down
20 changes: 20 additions & 0 deletions ecosystem/ffmpeg_plugin/mtl_st20p_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <mtl/st_convert_api.h>

#include "mtl_common.h"
#ifdef MTL_GPU_DIRECT_ENABLED
#include <mtl_gpu_direct/gpu.h>
Expand Down Expand Up @@ -120,6 +122,12 @@ 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: /* This format is not supported by MTL plugin.
This is workaround
for Intel(R) Tiber(TM) Broadcast Suite */
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 +264,18 @@ static int mtl_st20p_read_packet(AVFormatContext* ctx, AVPacket* pkt) {
st20p_rx_put_frame(s->rx_handle, frame);
return ret;
}

/* This format is not supported by MTL plugin.
This is workaround for Intel(R) Tiber(TM) Broadcast Suite */
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
17 changes: 17 additions & 0 deletions ecosystem/ffmpeg_plugin/mtl_st20p_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <mtl/st_convert_api.h>

#include "mtl_common.h"

typedef struct mtlSt20pMuxerContext {
Expand Down Expand Up @@ -94,6 +96,12 @@ 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: /* This format is not supported by MTL plugin.
This is workaround
for Intel(R) Tiber(TM) Broadcast Suite */
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 +160,15 @@ 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);

/* This format is not supported by MTL plugin.
This is workaround for Intel(R) Tiber(TM) Broadcast Suite */
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
Loading