[Ffmpeg-devel] A bug in H264.c

chengji zhao chengjizhao
Wed Jun 8 13:05:17 CEST 2005

Dear all, 

I remember about two weeks ago someone said that ffmpeg's h.264 decoder does not work properly when decoding multiple sliced bitstreams. 
I think it might because of the the following the bug:

the following code is copied from decode_ref_pic_marking( )

if(h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count)
{ //FIXME fields
                h->mmco[0].opcode= MMCO_SHORT2UNUSED;
                h->mmco[0].short_frame_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num;
                h->mmco_index= 1;
                h->mmco_index= 0;

we can see that whenever the total number of reference pictures equals to ref_frame_count, one mmco command will be 
inserted into the command queue. 
This is right only when the number of slices within a picture is 1. 
Imaging when we have multiple slices for a picture, function of decode_ref_pic_marking() will be called 
multiple times, therefore  mulitple commands of  MMCO_SHORT2UNUSED will be insert into
the command queue. As such, many reference frame in the ref_list will be erased. 
To fix this bug, we can simply move this part of the code to execute_ref_pic_marking().  

Best regards

More information about the ffmpeg-devel mailing list