[FFmpeg-devel] [PATCH v3] libavcodec/v4l2_buffers.c: set AVFrame interlaced flags
Zhao Zhili
quinkblack at foxmail.com
Thu Dec 19 14:45:33 EET 2024
> On Dec 19, 2024, at 08:28, James Almer <jamrial at gmail.com> wrote:
>
> On 12/18/2024 6:59 PM, Scott Theisen wrote:
>> Originally from:
>> https://github.com/MythTV/mythtv/commit/669955c6cb29196b4b5120451b5b998d67a65749
>> ---
>> v3:
>> remove unnecessary clearing of already 0 valued flags
>> use switch-case; I don't really think it is any simpler, but I do like the format better.
>> ---
>> libavcodec/v4l2_buffers.c | 19 +++++++++++++++++++
>> 1 file changed, 19 insertions(+)
>> diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
>> index 23474ee143..19cc86334b 100644
>> --- a/libavcodec/v4l2_buffers.c
>> +++ b/libavcodec/v4l2_buffers.c
>> @@ -210,6 +210,24 @@ 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;
>> +
>> + switch (field) {
>> + case V4L2_FIELD_INTERLACED:
>> + case V4L2_FIELD_INTERLACED_TB:
>> + frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
>> + /* fallthrough */
>> + case V4L2_FIELD_INTERLACED_BT:
>> + frame->flags |= AV_FRAME_FLAG_INTERLACED;
>> + break;
>> + }
>> +}
>> +
>> static void v4l2_free_buffer(void *opaque, uint8_t *unused)
>> {
>> V4L2Buffer* avbuf = opaque;
>> @@ -434,6 +452,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;
>
> Should be ok, but i don't maintain (nor can test) v4l2. So if nobody reviews it or pushes it in a few days, I'll.
I’m planing to do some test, maybe this weekend.
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list