[Ffmpeg-devel] understanding unreference_pic()

Loren Merritt lorenm
Thu Jun 9 09:03:59 CEST 2005

On Thu, 9 Jun 2005, Chengji Zhao wrote:

> static inline void unreference_pic(H264Context *h, Picture *pic){
>   int i;
>   pic->reference=0;
>   if(pic == h->delayed_output_pic)
>       pic->reference=1;
>   else{
>       for(i = 0; h->delayed_pic[i]; i++)
>           if(pic == h->delayed_pic[i]){
>               pic->reference=1;
>               break;
>           }
>   }
> }
> The thing I feel confused is that  this function will be called when a 
> picture is marked as not used for reference anymore.
> so the first line is easy to understand. But what the rest of code is doing?
> Can somebody briefly explains it to me?

It checks whether the picture has been output yet. If not, it isn't
really unreferenced, only marked so that the output routine will 
unreference it when possible.
(This could alternately have been done by storing two flags in 
pic->reference instead of checking it against a list.)

--Loren Merritt

More information about the ffmpeg-devel mailing list