[FFmpeg-devel] [RFC] av_decode_video and CODEC_CAP_DR1

Cyril Russo stage.nexvision
Mon Jun 7 16:44:45 CEST 2010

Hi all,

   From the documentation, it's not possible to prevent av_decode_video2 
from reusing allocated frame, unless these two conditions are set:
1) Codec support CAP_DR1 capability
2) codecContext's get_buffer et al are overridden

As I understand it, some codec might not have the flag set and in that 
case, one must copy/duplicate the frame if it's stored for later 
consumption (like in another thread)

I've checked all source tree to find out which video decoder doesn't 
have this flag set, and only libschrodinger & libdirac doesn't.
So what about inverting/dropping the flag, and thus simplifying the code ?
Precisely, I think about adding some code in libschro&dirac like this:
// Pseudo code
int decode_frame(...)
     [... Previous decoding code...]
     if (codecContext.get_buffer != default_get_buffer)
         // If user overriden get_buffer, let's call it and copy the 
data in the generated buffer
        frame = codecContext.get_buffer(...)
        copyFrame(frame, frameFromOriginalCode);
This would result in easier documentation, and less complexity in user 
The final documentation would say:
if get_buffer et al are overridden, av_decode_video2 will not reuse the 
given frame internally.

When get_buffer is not overriden, then the current behaviour is kept as 
it is now.


More information about the ffmpeg-devel mailing list