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

16 changes: 16 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,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:
skolelis marked this conversation as resolved.
Show resolved Hide resolved
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 +262,16 @@ 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) {
skolelis marked this conversation as resolved.
Show resolved Hide resolved
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
13 changes: 13 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,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 +158,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
Loading