[FFmpeg-devel] [PATCH 1/2] libavcodec/v4l2_buffers.c: set AVFrame interlaced flags
James Almer
jamrial at gmail.com
Mon Dec 16 05:25:32 EET 2024
On 12/15/2024 1:14 AM, Scott Theisen wrote:
> Originally from:
> https://github.com/MythTV/mythtv/commit/669955c6cb29196b4b5120451b5b998d67a65749
> ---
> libavcodec/v4l2_buffers.c | 38 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
> index 23474ee143..56a8f0825c 100644
> --- a/libavcodec/v4l2_buffers.c
> +++ b/libavcodec/v4l2_buffers.c
> @@ -210,6 +210,43 @@ static enum AVColorTransferCharacteristic v4l2_get_color_trc(V4L2Buffer *buf)
> return AVCOL_TRC_UNSPECIFIED;
> }
>
> +static void v4l2_get_interlacing(AVFrame *frame, V4L2Buffer *buf)
> +{
> + enum v4l2_field field;
> + field = V4L2_TYPE_IS_MULTIPLANAR(buf->buf.type) ?
> + buf->context->format.fmt.pix_mp.field :
> + buf->context->format.fmt.pix.field;
> +
> + if (field == V4L2_FIELD_INTERLACED || field == V4L2_FIELD_INTERLACED_TB) {
> + frame->flags |= AV_FRAME_FLAG_INTERLACED;
> + frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
> +#if FF_API_INTERLACED_FRAME
> +FF_DISABLE_DEPRECATION_WARNINGS
> + frame->interlaced_frame = 1;
> + frame->top_field_first = 1;
No need to set these two fields. It's done by the generic code.
> +FF_ENABLE_DEPRECATION_WARNINGS
> +#endif
> + } else if (field == V4L2_FIELD_INTERLACED_BT) {
> + frame->flags |= AV_FRAME_FLAG_INTERLACED;
> + frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
> +#if FF_API_INTERLACED_FRAME
> +FF_DISABLE_DEPRECATION_WARNINGS
> + frame->interlaced_frame = 1;
> + frame->top_field_first = 0;
> +FF_ENABLE_DEPRECATION_WARNINGS
> +#endif
> + } else {
> + frame->flags &= ~AV_FRAME_FLAG_INTERLACED;
> + frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
> +#if FF_API_INTERLACED_FRAME
> +FF_DISABLE_DEPRECATION_WARNINGS
> + frame->interlaced_frame = 0;
> + frame->top_field_first = 0;
> +FF_ENABLE_DEPRECATION_WARNINGS
> +#endif
> + }
> +}
> +
> static void v4l2_free_buffer(void *opaque, uint8_t *unused)
> {
> V4L2Buffer* avbuf = opaque;
> @@ -434,6 +471,7 @@ int ff_v4l2_buffer_buf_to_avframe(AVFrame *frame, V4L2Buffer *avbuf)
> frame->color_trc = v4l2_get_color_trc(avbuf);
> frame->pts = v4l2_get_pts(avbuf);
> frame->pkt_dts = AV_NOPTS_VALUE;
> + v4l2_get_interlacing(frame, avbuf);
>
> /* these values are updated also during re-init in v4l2_process_driver_event */
> frame->height = avbuf->context->height;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20241216/cba33588/attachment.sig>
More information about the ffmpeg-devel
mailing list