[FFmpeg-devel] [PATCH] lavc: report frame field order in avctx

Rodger Combs rodger.combs at gmail.com
Fri Nov 18 12:28:34 EET 2016


> On Nov 17, 2016, at 18:47, Michael Niedermayer <michael at niedermayer.cc> wrote:
> 
> On Thu, Nov 17, 2016 at 04:48:07AM -0600, Rodger Combs wrote:
>> 
>>> On Nov 15, 2016, at 03:43, Michael Niedermayer <michael at niedermayer.cc> wrote:
>>> 
>>> On Mon, Nov 14, 2016 at 05:19:25PM -0600, Rodger Combs wrote:
>>>> ---
>>>> libavcodec/utils.c                   | 13 +++++++++++++
>>>> tests/api/api-codec-param-test.c     |  3 +++
>>>> tests/fate/matroska.mak              |  2 +-
>>>> tests/ref/fate/api-mjpeg-codec-param |  2 +-
>>>> tests/ref/fate/api-png-codec-param   |  2 +-
>>>> tests/ref/fate/mov-zombie            |  2 +-
>>>> 6 files changed, 20 insertions(+), 4 deletions(-)
>>>> 
>>>> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
>>>> index d6dca18..b9af880 100644
>>>> --- a/libavcodec/utils.c
>>>> +++ b/libavcodec/utils.c
>>>> @@ -2296,6 +2296,12 @@ fail:
>>>>                                               guess_correct_pts(avctx,
>>>>                                                                 picture->pts,
>>>>                                                                 picture->pkt_dts));
>>>> +
>>>> +            if (avctx->field_order == AV_FIELD_UNKNOWN) {
>>>> +                avctx->field_order = picture->interlaced_frame
>>>> +                                   ? (picture->top_field_first ? AV_FIELD_TT : AV_FIELD_BB)
>>>> +                                   : AV_FIELD_PROGRESSIVE;
>>>> +            }
>>>>        } else
>>>>            av_frame_unref(picture);
>>>>    } else
>>>> @@ -2895,6 +2901,13 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr
>>>>                av_frame_set_best_effort_timestamp(frame,
>>>>                    guess_correct_pts(avctx, frame->pts, frame->pkt_dts));
>>>>            }
>>>> +
>>>> +            if (avctx->field_order == AV_FIELD_UNKNOWN &&
>>>> +                avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
>>>> +                avctx->field_order = frame->interlaced_frame
>>>> +                                   ? (frame->top_field_first ? AV_FIELD_TT : AV_FIELD_BB)
>>>> +                                   : AV_FIELD_PROGRESSIVE;
>>>> +            }
>>>>        }
>>>>        return ret;
>>>>    }
>>> 
>>> This doesnt leave any "unknown" option left.
>>> What should a decoder do that knows the field order is unknown
>> 
>> Is this a real case?
> 
> any codec that doesnt have a interlaced flag couldnt set this
> rawvideo and various lossless codecs can store interlaced material
> without problems but lack such flags.

Eugh, but OK.

> 
> 
>> 
>> What I really need here is a stream-level "is interlaced" indicator; I've considered adding an AV_FIELD_INTERLACED_UNKNOWN value to indicate "This is interlaced, but I don't know the field order".
>> Thoughts?
> 
> I think AVFrame lacks a unknown between progressive and interlaced

Sorry, I meant "interlaced, but with unknown field order". I'd set that when `interlaced_frame` is set, and otherwise leave it as AV_FIELD_UNKNOWN. Does that sound reasonable?

> 
> If you want a video filter to fill in only unknown ones that distinction
> would be important
> 
> 
> [...]
> -- 
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Breaking DRM is a little like attempting to break through a door even
> though the window is wide open and the only thing in the house is a bunch
> of things you dont want and which you would get tomorrow for free anyway
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org <mailto:ffmpeg-devel at ffmpeg.org>
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel <http://ffmpeg.org/mailman/listinfo/ffmpeg-devel>


More information about the ffmpeg-devel mailing list