[FFmpeg-devel] [RFC] support for Cam_PAL_D1_inter_Field_25fps_2.5MBS.mp4

Reimar Döffinger Reimar.Doeffinger
Thu Mar 20 15:43:34 CET 2008


Hello,
I made a patch that works for:
http://samples.mplayerhq.hu/V-codecs/h264/PAFF/Cam_PAL_D1_inter_Field_25fps_2.5MBS.mp4
I think this is probably the wrong approach and instead we need an
AVParser for H.264 in mov, but I am not entirely sure, so please
have a look at attached patch.
And also while we are at it, please have a look at the
"if(context_count) {" part, I think it is not necessary with the current
code, but at least the comments are confusing and assuming that
"context_count == h->max_contexts" is true whenever slice header
decoding returns 1 at least seems a bit brittle to me (I might be
missing something though).

Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavcodec/h264.c
===================================================================
--- libavcodec/h264.c	(revision 12478)
+++ libavcodec/h264.c	(working copy)
@@ -3884,6 +3884,7 @@
 
     if((s->flags2 & CODEC_FLAG2_CHUNKS) && first_mb_in_slice == 0){
         h0->current_slice = 0;
+        h0->block_available_fields = 0;
         if (!s0->first_field)
             s->current_picture_ptr= NULL;
     }
@@ -4003,7 +4004,20 @@
         s->picture_structure= PICT_FRAME;
     }else{
         if(get_bits1(&s->gb)) { //field_pic_flag
-            s->picture_structure= PICT_TOP_FIELD + get_bits1(&s->gb); //bottom_field_flag
+            int next_picture_structure = PICT_TOP_FIELD + get_bits1(&s->gb); //bottom_field_flag
+            int mask = next_picture_structure == PICT_TOP_FIELD ? 1 : 2;
+            if(h0->block_available_fields == (mask ^ 3)) {
+                if(!s->dropable) {
+                    h0->prev_poc_msb = h0->poc_msb;
+                    h0->prev_poc_lsb = h0->poc_lsb;
+                    execute_ref_pic_marking(h0, h0->mmco, h0->mmco_index);
+                }
+                h0->current_slice = 0;
+                h0->block_available_fields |= mask;
+                return 1;
+            }
+            h0->block_available_fields |= mask;
+            s->picture_structure = next_picture_structure;
         } else {
             s->picture_structure= PICT_FRAME;
             h->mb_aff_frame = h->sps.mb_aff;
@@ -7442,6 +7456,7 @@
 #endif
     if(!(s->flags2 & CODEC_FLAG2_CHUNKS)){
         h->current_slice = 0;
+        h->block_available_fields = 0;
         if (!s->first_field)
             s->current_picture_ptr= NULL;
     }
@@ -7600,6 +7615,10 @@
              * NAL unit stuff to context 0 and restart. Note that
              * rbsp_buffer is not transfered, but since we no longer
              * run in parallel mode this should not be an issue. */
+            if(context_count) {
+                execute_decode_slices(h, context_count);
+                context_count = 0;
+            }
             h->nal_unit_type = hx->nal_unit_type;
             h->nal_ref_idc   = hx->nal_ref_idc;
             hx = h;



More information about the ffmpeg-devel mailing list