[FFmpeg-devel] mpegvideo : interlaced_frame with picture_structure == PICT_FRAME

Michael Niedermayer michaelni at gmx.at
Mon Jan 5 23:32:03 CET 2015


On Mon, Jan 05, 2015 at 03:17:32PM -0500, Vanista Herion wrote:
> Some MPEG 2 video will give bad interlacing information in AVFrame. If the
> parameters are used by a deinterlace filter such as yadif, frames will be
> processed needlessly and impair the quality.

yes and i hope this will get resolved with idet or some other solution
also it might be possible to detect telecined content and do something
more sane in that case without the need of idet


> 
> By reviewing the code in mpegvideo.c which sets the interlaced_frame
> and top_field_first, I noticed that picture_structure is not considered
> whereas it probably supersedes everything else. The H.262 specification is
> not very clear on that but in the case of this sample, the stream is
> definitely progressive, picture_structure is equal to 3 (Frame picture) and
> top_field_first alternates true and false.
> 
> The result is that frames come out reported as tff, bff and progressive,
> cycling at every frame.
> I propose a simple patch to set interlaced_frame to false when
> picture_structure is equal to PICT_FRAME.

This is incorrect, and would break detecting actual interlaced frame
based MPEG-2

ISO/IEC 13818-2: 1995 (E)

    6.1.1.1
    Progressive and interlaced sequences
    This specification deals with coding of both progressive and interlaced sequences.
    The output of the decoding process, for interlaced sequences, consists of a series of reconstructed fields
    that are separated in time by a field period.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    The two fields of a frame may be coded separately (field-pictures).

This is s->picture_structure != PICT_FRAME


    Alternatively the two fields may be coded together as a frame (frame-pictures). Both frame

This is s->picture_structure == PICT_FRAME

    pictures and field pictures may be used in a single video sequence.

    In progressive sequences each picture in the sequence shall be a frame picture. The sequence, at the
    output of the decoding process, consists of a series of reconstructed frames that are separated in time by a
    frame period.


also see 6.1.1.8
    4:2:0 Format

    Figure 6-2 – Vertical and temporal positions of samples in an interlaced frame with top_field_first = 1.
    Figure 6-3 – Vertical and temporal positions of samples in an interlaced frame with top_field_first = 0
    Figure 6-4 – Vertical and temporal positions of samples in a progressive frame.


    6.3.9 Picture header
    ...

    progressive_frame -- If progressive_frame is set to 0 it indicates that the two fields of the frame are
    interlaced fields in which an interval of time of the field period exists between (corresponding spatial
    samples) of the two fields. In this case the following restriction applies:
    •
    repeat_first_field shall be zero (two field duration).
    If progressive_frame is set to 1 it indicates that the two fields (of the frame) are actually from the same
    time instant as one another. In this case a number of restrictions to other parameters and flags in the
    bitstream apply:
    • picture_structure shall be “Frame”
    • frame_pred_frame_dct shall be 1
    progressive_frame is used when the video sequence is used as the lower layer of a spatial scalable
    sequence. Here it affects the up-sampling process used in forming a prediction in the enhancement layer
    from the lower layer.



[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150105/87c42431/attachment.asc>


More information about the ffmpeg-devel mailing list