[FFmpeg-devel] [PATCH] Increase max_pic_num

Jeff Downs heydowns
Tue Oct 9 17:17:01 CEST 2007


Hi,

On Tue, 9 Oct 2007, Carl Eugen Hoyos wrote:

> Hi!
> 
> After enabling PAFF decoding, for one sample (PREMIERE HD), I get these
> errors together with heavy picture distortion:
> 
> [h264 @ 0x894cef0]abs_diff_pic_num overflow
> [h264 @ 0x894cef0]decode_slice_header error
> 
> Attached patch fixes both the errors and the picture for this sample.
> 

The distortion you receive is because the decoder drops those (reference) 
frames when this error trips.

> Index: libavcodec/h264.c
> ===================================================================
> --- libavcodec/h264.c	(Revision 10695)
> +++ libavcodec/h264.c	(Arbeitskopie)
> @@ -4064,7 +4064,7 @@
>          h->max_pic_num= 1<< h->sps.log2_max_frame_num;
>      }else{
>          h->curr_pic_num= 2*h->frame_num + 1;
> -        h->max_pic_num= 1<<(h->sps.log2_max_frame_num + 1);
> +        h->max_pic_num= (1<<(h->sps.log2_max_frame_num + 1)) + 1;
>      }
>  
>      if(h->nal_unit_type == NAL_IDR_SLICE){

This will likely cause issues with reference picture management and list 
building because max_pic_num will be wrong.

I think the actual problem (has been there since before paff) is in the 
check that causes that error to post.  The spec says its perfectly 
legitimate to have an abs_diff_pic_num == max_pic_num.

The following patch should fix this.

	-Jeff
-------------- next part --------------
Index: libavcodec/h264.c
===================================================================
--- libavcodec/h264.c	(revision 10697)
+++ libavcodec/h264.c	(working copy)
@@ -3076,7 +3076,7 @@
                         const unsigned int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1;
                         int frame_num;
 
-                        if(abs_diff_pic_num >= h->max_pic_num){
+                        if(abs_diff_pic_num > h->max_pic_num){
                             av_log(h->s.avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
                             return -1;
                         }



More information about the ffmpeg-devel mailing list