[FFmpeg-cvslog] r14339 - trunk/libavcodec/h264.c

Jeff Downs heydowns
Sat Jul 26 23:22:54 CEST 2008


On Thu, 24 Jul 2008, Michael Niedermayer wrote:

> On Wed, Jul 23, 2008 at 04:30:18PM -0400, Jeff Downs wrote:
> > On Wed, 23 Jul 2008, Uoti Urpala wrote:
> > 
> > > On Wed, 2008-07-23 at 04:12 +0200, michael wrote:
> > > > Author: michael
> > > > Date: Wed Jul 23 04:12:54 2008
> > > > New Revision: 14339
> > > > 
> > > > Log:
> > > > Support gaps in the frame num.
> > > > Fixes at least:
> > > > MR3_TANDBERG_B.264
> > > > MR4_TANDBERG_C.264
> > > > MR5_TANDBERG_C.264
> > > 
> > > After this commit I'm getting lots of "number of reference frames
> > > exceeds max (probably corrupt input), discarding one" messages. Happens
> > > with every file I tried. Not affected by the latest "typo fix" commit.
> > 
> > I get that too on some files, because they start out with 
> > frame nums != 0 and max frame num being very large.
> > 
> > The new gaps in frame num code is missing the delete part of the sliding 
> > window operation for reference picture marking; it calls 
> > execute_ref_pic_marking directly (sliding window implementation is in 
> > decode_ref_pic_marking) so no ref frames get unreferenced until the hard 
> > limit (code w/ error message you cite) is hit.
> 
> The limit is the same, sps->ref_frame_count, besides the reference bitstreams
> with it decode correctly thus i would assume it is doing the sliding window
> operation correctly, and that rather the code is duplicated in 
> decode_ref_pic_marking().
> If true, this duplicated code should maybe be removed.

Indeed. Take a look at attached.  Removes MMCO synthesis for sliding 
window and lets it be handled at the end of mmco execution. 
The error message for too many reference frames is lost, though;  there's 
no way to tell if it is sliding window or bad MMCO that put us over the 
limit without some additional book-keeping. 
If you think the error is valuable enough, I can add a var to the context 
to track that.

	-Jeff
-------------- next part --------------
Index: libavcodec/h264.c
===================================================================
--- libavcodec/h264.c	(revision 14424)
+++ libavcodec/h264.c	(working copy)
@@ -3325,6 +3325,8 @@
     if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0)
         av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n");
 
+    assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);
+
     for(i=0; i<mmco_count; i++){
         int structure, frame_num;
         if(s->avctx->debug&FF_DEBUG_MMCO)
@@ -3445,14 +3447,12 @@
 
     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
-         * short_ref and long_ref buffers.
+        /* We have too many reference frames; either due to sliding window or
+         * corrupted stream. Need to discard one frame. Also prevents overrun
+         * of the short_ref and long_ref buffers.
+         * One is sufficient, since we added at most one picture this mmco
+         * processing cycle.
          */
-        av_log(h->s.avctx, AV_LOG_ERROR,
-               "number of reference frames exceeds max (probably "
-               "corrupt input), discarding one\n");
-
         if (h->long_ref_count && !h->short_ref_count) {
             for (i = 0; i < 16; ++i)
                 if (h->long_ref[i])
@@ -3513,21 +3513,6 @@
                     break;
             }
             h->mmco_index= i;
-        }else{
-            assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);
-
-            if(h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count &&
-                    !(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->reference)) {
-                h->mmco[0].opcode= MMCO_SHORT2UNUSED;
-                h->mmco[0].short_pic_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num;
-                h->mmco_index= 1;
-                if (FIELD_PICTURE) {
-                    h->mmco[0].short_pic_num *= 2;
-                    h->mmco[1].opcode= MMCO_SHORT2UNUSED;
-                    h->mmco[1].short_pic_num= h->mmco[0].short_pic_num + 1;
-                    h->mmco_index= 2;
-                }
-            }
         }
     }
 



More information about the ffmpeg-cvslog mailing list