[FFmpeg-devel] [PATCH] According to SMPTE 370M (rev.2002), page 15 : "FS: First/second field flag",

Александр Слободенюк alexander.slobodeniuk at bramtech.ru
Fri Apr 1 14:26:12 CEST 2016


quoting:
        FS indicates a field which is delivered during the field one period (see table 16)

now quoting table 16:

FF      FS       Output field
-------------------------------
1       1        Field 1 and field 2 are output in this order (1,2 sequence).
-------------------------------
1       0        Field 2 and field 1 are output in this order (2,1 sequence).
-------------------------------
0       1        Field 1 is output twice.
-------------------------------
0       0        Field 2 is output twice.

this actually means, that:

AVFrame->top_field_first = FS .

But in today's FFmpeg's dv encoding and decoding realisation it's inverted:

AVFrame->top_field_first = !FS .

I tried to ask question about it by sending an email "DV frame field order" to ffmpeg-devel at ffmpeg.org ,
but got no answer, and actually even didn't got this email from the mailing list (no idea is it normal).

I've found this case from practice, where DVCProHD coded video (by Matrox device) with image, recorded as "top_field_first"
got AVFrame->top_field_first == 0 (with interlaced_frame == 1 ofcource).

I'm not really sure of this commit's correctness, because DV SD stream is decoded as AVFrame->top_field_first == 0 , and people say
this is right. Checked it with gdb while decoding http://samples.ffmpeg.org/V-codecs/DVSD/pond.dv
---
 libavcodec/dvdec.c | 2 +-
 libavcodec/dvenc.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index 0b4c1bc..23757fc 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -546,7 +546,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, void *data,
 
     /* Determine the codec's field order from the packet */
     if ( *vsc_pack == dv_video_control ) {
-        frame->top_field_first = !(vsc_pack[3] & 0x40);
+        frame->top_field_first = vsc_pack[3] & 0x40;
     }
 
     s->buf = buf;
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 5de12cc..9b5938f 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -574,7 +574,7 @@ static inline int dv_write_pack(enum dv_pack_type pack_id, DVVideoContext *c,
      *      compression scheme (if any).
      */
     int apt = (c->sys->pix_fmt == AV_PIX_FMT_YUV420P ? 0 : 1);
-    int fs  = c->frame->top_field_first ? 0x00 : 0x40;
+    int fs  = c->frame->top_field_first ? 0x40 : 0x00;
 
     uint8_t aspect = 0;
     if ((int) (av_q2d(c->avctx->sample_aspect_ratio) *
-- 
2.7.1.windows.1




More information about the ffmpeg-devel mailing list