[FFmpeg-devel] [PATCH] h264: Correctly initialize interlaced_frame if tff is set

Vittorio Giovara vittorio.giovara at gmail.com
Sat Feb 11 00:21:00 EET 2017


In particular cases, it is possible to initialize top_field_first
but not interlaced_frame. Make sure to correctly tag a frame
as interlaced when this happens.

Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
---
Please CC.
Vittorio

 libavcodec/h264_slice.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 91a3b25..eeb5202 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1174,20 +1174,23 @@ static int h264_export_frame_props(H264Context *h)
 
     if (cur->field_poc[0] != cur->field_poc[1]) {
         /* Derive top_field_first from field pocs. */
-        cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1];
+        cur->f->interlaced_frame =
+        cur->f->top_field_first  = cur->field_poc[0] < cur->field_poc[1];
     } else {
         if (sps->pic_struct_present_flag) {
             /* Use picture timing SEI information. Even if it is a
              * information of a past frame, better than nothing. */
             if (h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM ||
-                h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)
-                cur->f->top_field_first = 1;
-            else
+                h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP) {
+                cur->f->interlaced_frame =
+                cur->f->top_field_first  = 1;
+            } else
                 cur->f->top_field_first = 0;
         } else if (cur->f->interlaced_frame) {
             /* Default to top field first when pic_struct_present_flag
              * is not set but interlaced frame detected */
-            cur->f->top_field_first = 1;
+            cur->f->interlaced_frame =
+            cur->f->top_field_first  = 1;
         } else {
             /* Most likely progressive */
             cur->f->top_field_first = 0;
-- 
2.10.0



More information about the ffmpeg-devel mailing list