[FFmpeg-cvslog] avcodec/h264_sei: Check actual presence of SEI picture timing instead of implying it

Michael Niedermayer git at videolan.org
Wed Feb 15 01:20:39 EET 2017


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Tue Feb 14 23:45:01 2017 +0100| [6a37abc59af4d87d4c55f7d812ac62d4d6a7464b] | committer: Michael Niedermayer

avcodec/h264_sei: Check actual presence of SEI picture timing instead of implying it

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6a37abc59af4d87d4c55f7d812ac62d4d6a7464b
---

 libavcodec/h264_parser.c | 4 ++--
 libavcodec/h264_sei.c    | 3 +++
 libavcodec/h264_sei.h    | 1 +
 libavcodec/h264_slice.c  | 4 ++--
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index bca0071..bc35a61 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -471,7 +471,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
                 }
             }
 
-            if (sps->pic_struct_present_flag) {
+            if (sps->pic_struct_present_flag && p->sei.picture_timing.present) {
                 switch (p->sei.picture_timing.pic_struct) {
                 case SEI_PIC_STRUCT_TOP_FIELD:
                 case SEI_PIC_STRUCT_BOTTOM_FIELD:
@@ -502,7 +502,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
 
             if (p->picture_structure == PICT_FRAME) {
                 s->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
-                if (sps->pic_struct_present_flag) {
+                if (sps->pic_struct_present_flag && p->sei.picture_timing.present) {
                     switch (p->sei.picture_timing.pic_struct) {
                     case SEI_PIC_STRUCT_TOP_BOTTOM:
                     case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 5053962..a7e627e 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -45,6 +45,7 @@ void ff_h264_sei_uninit(H264SEIContext *h)
     h->picture_timing.dpb_output_delay  = 0;
     h->picture_timing.cpb_removal_delay = -1;
 
+    h->picture_timing.present      = 0;
     h->buffering_period.present    = 0;
     h->frame_packing.present       = 0;
     h->display_orientation.present = 0;
@@ -119,6 +120,8 @@ static int decode_picture_timing(H264SEIPictureTiming *h, GetBitContext *gb,
         av_log(logctx, AV_LOG_DEBUG, "ct_type:%X pic_struct:%d\n",
                h->ct_type, h->pic_struct);
     }
+
+    h->present = 1;
     return 0;
 }
 
diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index 9197795..da3b391 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -64,6 +64,7 @@ typedef enum {
 } SEI_FpaType;
 
 typedef struct H264SEIPictureTiming {
+    int present;
     SEI_PicStructType pic_struct;
 
     /**
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 91a3b25..a703853 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1131,7 +1131,7 @@ static int h264_export_frame_props(H264Context *h)
     /* Prioritize picture timing SEI information over used
      * decoding process if it exists. */
 
-    if (sps->pic_struct_present_flag) {
+    if (sps->pic_struct_present_flag && h->sei.picture_timing.present) {
         H264SEIPictureTiming *pt = &h->sei.picture_timing;
         switch (pt->pic_struct) {
         case SEI_PIC_STRUCT_FRAME:
@@ -1176,7 +1176,7 @@ static int h264_export_frame_props(H264Context *h)
         /* Derive top_field_first from field pocs. */
         cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1];
     } else {
-        if (sps->pic_struct_present_flag) {
+        if (sps->pic_struct_present_flag && h->sei.picture_timing.present) {
             /* 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 ||



More information about the ffmpeg-cvslog mailing list