[Ffmpeg-devel] Help - Trying to alter AVFrame buffer before calling avcodec_decode_video

Sam Barham sam
Tue Feb 27 00:23:26 CET 2007


We are trying to do something a bit weird with the ffmpeg decoding, and I
was hoping to get some help with figuring it out.

 

As far as I can tell, the usual way things work is to decode an I-Frame
packet into an AVFrame, then decode P-Frame packets over the top, with each
one altering the last frame, and so on.

 

What I want to do is decode each P-Frame packet on top of the original
I-Frame packet, rather than on top of the last decoded frame.  I've tried to
grab a copy of the data buffers after decoding the I-Frame packet, the
writing that data back into the AVFrame data buffers before decoding the
P-Frame packet, but that doesn't work, because the actual buffer that is
being decoded on to seems to be buried deep within the H264 codec context or
something.

 

For example, if I do this each frame:

 

avcodec_decode_video(mCodecContext, mVideoFrame, &frameFinished,
IFramePacket->data, IFramePacket->size);

avcodec_decode_video(mCodecContext, mVideoFrame, &frameFinished,
PFramePacket->data, PFramePacket->size);

 

everything is fine, but I want to do something like:

 

// Do this once.

avcodec_decode_video(mCodecContext, mVideoFrame, &frameFinished,
IFramePacket->data, IFramePacket->size);

memcpy(dataBuffer, mVideoFrame->data[0], frameSize);

 

// Each frame

memcpy(mVideoFrame->data[0], dataBuffer, frameSize); 

avcodec_decode_video(mCodecContext, mVideoFrame, &frameFinished,
PFramePacket->data, PFramePacket->size);

 

In the hope that I can avoid decoding the IFrame each frame.  The problem is
that somewhere within avcodec_decode_video, the mVideoFame data buffers are
reassigned to some buffers within the priv_data of mCodecContext, which is
the H264 context or something.  This means that memcpying the stored IFrame
in is a bit useless.

 

So, any ideas?

 

Cheers

Sam Barham

Straylight Studios

 

 





More information about the ffmpeg-devel mailing list