]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Add support for ct_type to correctly detect interlaced flag
authorschreter <schreter@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Wed, 4 Mar 2009 19:37:19 +0000 (19:37 +0000)
committerschreter <schreter@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Wed, 4 Mar 2009 19:37:19 +0000 (19:37 +0000)
git-svn-id: file:///var/local/repositories/ffmpeg/trunk@17811 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavcodec/h264.c
libavcodec/h264.h

index 0e1690d7de178da664282c51a46628e9317fbaeb..403d62e0b28ef053bff545cecbd132d8749522e6 100644 (file)
@@ -6795,6 +6795,7 @@ static int decode_picture_timing(H264Context *h){
     if(h->sps.pic_struct_present_flag){
         unsigned int i, num_clock_ts;
         h->sei_pic_struct = get_bits(&s->gb, 4);
+        h->sei_ct_type    = 0;
 
         if (h->sei_pic_struct > SEI_PIC_STRUCT_FRAME_TRIPLING)
             return -1;
@@ -6804,7 +6805,7 @@ static int decode_picture_timing(H264Context *h){
         for (i = 0 ; i < num_clock_ts ; i++){
             if(get_bits(&s->gb, 1)){                  /* clock_timestamp_flag */
                 unsigned int full_timestamp_flag;
-                skip_bits(&s->gb, 2);                 /* ct_type */
+                h->sei_ct_type |= 1<<get_bits(&s->gb, 2);
                 skip_bits(&s->gb, 1);                 /* nuit_field_based_flag */
                 skip_bits(&s->gb, 5);                 /* counting_type */
                 full_timestamp_flag = get_bits(&s->gb, 1);
@@ -7762,24 +7763,19 @@ static int decode_frame(AVCodecContext *avctx,
 
             /* Signal interlacing information externally. */
             /* Prioritize picture timing SEI information over used decoding process if it exists. */
+            if (h->sei_ct_type)
+                cur->interlaced_frame = (h->sei_ct_type & (1<<1)) != 0;
+            else
+                cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE;
+
             if(h->sps.pic_struct_present_flag){
                 switch (h->sei_pic_struct)
                 {
-                case SEI_PIC_STRUCT_FRAME:
-                    cur->interlaced_frame = 0;
-                    break;
-                case SEI_PIC_STRUCT_TOP_FIELD:
-                case SEI_PIC_STRUCT_BOTTOM_FIELD:
-                case SEI_PIC_STRUCT_TOP_BOTTOM:
-                case SEI_PIC_STRUCT_BOTTOM_TOP:
-                    cur->interlaced_frame = 1;
-                    break;
                 case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
                 case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
                     // Signal the possibility of telecined film externally (pic_struct 5,6)
                     // From these hints, let the applications decide if they apply deinterlacing.
                     cur->repeat_pict = 1;
-                    cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE;
                     break;
                 case SEI_PIC_STRUCT_FRAME_DOUBLING:
                     // Force progressive here, as doubling interlaced frame is a bad idea.
index 587f1e3f1c9963fb8b6497e451469aa8d4fe1360..fc9cef5d36a417d848d56d009d7ca7c2d5f0682b 100644 (file)
@@ -503,6 +503,13 @@ typedef struct H264Context{
      */
     SEI_PicStructType sei_pic_struct;
 
+    /**
+     * Bit set of clock types for fields/frames in picture timing SEI message.
+     * For each found ct_type, appropriate bit is set (e.g., bit 1 for
+     * interlaced).
+     */
+    int sei_ct_type;
+
     /**
      * dpb_output_delay in picture timing SEI message, see H.264 C.2.2
      */