[FFmpeg-devel] [PATCH] h264: fix mistake in r11216

Jeff Downs heydowns
Fri Dec 14 21:02:41 CET 2007


The patch I applied to fix part of issue 281 as r11216 was erroneous.

The attached fixes it by correctly checking for too many reference frames 
(as opposed to exactly equal to the max ref frame count).

Original also discarded pictures w/out unreferencing them. This adds that 
as well.

	-Jeff
-------------- next part --------------
Index: libavcodec/h264.c
===================================================================
--- libavcodec/h264.c	(revision 11217)
+++ libavcodec/h264.c	(working copy)
@@ -3612,8 +3612,7 @@
         s->current_picture_ptr->reference |= s->picture_structure;
     }
 
-    if (h->sps.ref_frame_count &&
-            h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count){
+    if (h->long_ref_count + h->short_ref_count > h->sps.ref_frame_count){
 
         /* We have too many reference frames, probably due to corrupted
          * stream. Need to discard one frame. Prevents overrun of the
@@ -3629,10 +3628,13 @@
                     break;
 
             assert(i < 16);
+            pic = h->long_ref[i];
             remove_long_at_index(h, i);
         } else {
+            pic = h->short_ref[h->short_ref_count - 1];
             remove_short_at_index(h, h->short_ref_count - 1);
         }
+        unreference_pic(h, pic, 0);
     }
 
     print_short_term(h);



More information about the ffmpeg-devel mailing list