[FFmpeg-devel] [PATCH v2 2/3] avcodec/bitpacked: add interlace support

Rostislav Pehlivanov atomnuker at gmail.com
Fri Apr 20 22:40:05 EEST 2018

On 20 April 2018 at 20:02, Patrick Keroulas <
patrick.keroulas at savoirfairelinux.com> wrote:

> From: Damien Riegel <damien.riegel at savoirfairelinux.com>
> This codec is already capable of depacking some combinations of pixel
> formats and depth as defined in the RFC4175. The only difference between
> progressive and interlace is that either a packet will contain the whole
> frame, or only a field of the frame.
> There is no mechanism for interlaced frames reconstruction at the rtp
> demux level, so it has to be handled by the codec which needs to
> partially recompose an AVFrame with every incoming field AVPacket.
> A frame is ouput only when the frame is completed with the 2nd field
> (bottom).
> Signed-off-by: Damien Riegel <damien.riegel at savoirfairelinux.com>
> Signed-off-by: Patrick Keroulas <patrick.keroulas at savoirfairelinux.com>
> ---
> Change v1 -> v2:
>  Replaced field packets cloning with partial frame decoding.
>  @ Rostislav Pehlivanov: Regarding your comment on v1 (thank you for
>  that), I think we can avoid using the bottom field flag because the
>  interlaced/progressive format is determined once, at the decoder
>  initialization, more precisely when the sdp is parsed. RFC4175
>  doesn't define any dynamic flag to switch from one to another.
>  So there is no doubt that 'not top field' means 'bottom field'.
Doesn't matter what RFC4175 says, the decoder needs to be able to handle
any field order sent at any time, including switching to progressive. This
isn't a theoretical situation. What if there's packet loss or the user
switches streams? What if the user doesn't use the decoder for RFC4175 but
rather uses it as a generic unpacker to decode something packed.

>  #define AV_PKT_FLAG_DISPOSABLE 0x0010
> +/**
> + * The packet contains a top field.
> + */
> +#define AV_PKT_FLAG_TOP_FIELD  0x0010


I think there must be a BOTTOM_FIELD flag along with a top field flag, with
neither of them flag meaning packet carries progressive.

More information about the ffmpeg-devel mailing list