[FFmpeg-devel] [PATCH] libavcodec: fix field_order labelling

Alex Converse alex.converse at gmail.com
Wed Aug 16 06:54:26 EEST 2017


On Sat, Aug 12, 2017 at 9:47 AM, Dave Rice <dave at dericed.com> wrote:
>
> Hello all,
> This issue originated in this thread https://github.com/amiaopensource/vrecord/issues/170. On Field Order, in the QuickTime specification at https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html (and similarly in the Matroska specification which adopted similar language) it states the following meanings for field order values:
>
> > 9 – B is displayed earliest, T is stored first in the file. 14 – T is displayed earliest, B is stored first in the file.
>
>  This definition is contradicted by other Apple documentation such as https://developer.apple.com/library/content/technotes/tn2162/_index.html#//apple_ref/doc/uid/DTS40013070-CH1-TNTAG10-THE__FIEL__IMAGEDESCRIPTION_EXTENSION__FIELD_FRAME_INFORMATION.
>
> An Apple engineer confirmed that the QuickTime specification’s definitions for those Field Order values is wrong and does not match Apple’s (of FFmpeg’s) practice, see https://github.com/amiaopensource/vrecord/issues/170#issuecomment-321937668.
>
> However I think that some of the commenting in ffmpeg is based upon the inaccurate definitions from Apple. For instance, in that thread David Singer confirms:
>
> > Ah, not quite. 1 and 6 are indeed 'planar' (all of one field before all of the other). They don't concern us. Both 9 and 14 are stored in spatial order (i.e. you could do terrible de-interlacing by simply displaying the buffer as a frame), and the 9 or 14 value tells you which field is to be displayed first.
> >
> > 9 – T is earlier than B. 14 – B is earlier than T
>
> mov.c associates AV_FIELD_TB with 9 and AV_FIELD_BT with 14 (similar associations in matroska.h), but avcodec.h states:
>
> > AV_FIELD_TB,          //< Top coded first, bottom displayed first
> > AV_FIELD_BT,          //< Bottom coded first, bottom displayed first
>
> IMHO in both cases of AV_FIELD_TB and AV_FIELD_BT the coding should be referred as interleaved rather than ‘bottom coded first’ or ‘top coded first’. In the case of AV_FIELD_TT and AV_FIELD_BB the fields are stored as planar images where storage order is notable, but with TB and BT the fields are interleaved.
>
> Also utils.c associates these field order values with the following labels:
>
> > AV_FIELD_TB  -> "top coded first (swapped)";
> > AV_FIELD_BT -> "bottom coded first (swapped)";
>
> From my reading, I infer that "top coded first (swapped)” means "top coded first, bottom displayed first”; however in practice from files generated by QuickTime and FFmpeg files with a value of TB have the top field displayed first, so I think the labels are swapped. In the patch below I suggest using “top first (interleaved)” for TB and “bottom first (interleaved)” for BT.
>
> Comments?
>

Icefloe019 agrees with your changes:
http://mirror.informatimago.com/next/developer.apple.com/quicktime/icefloe/dispatch019.html#fiel

They seems reasonable to me. when I made this change originally my
primary concern was getting the field info out of extradata.


More information about the ffmpeg-devel mailing list