[Ffmpeg-devel] de/serializing AVFrames
Tilman Kranz
tilman.kranz
Tue Jan 17 14:07:57 CET 2006
Hello,
Michael Niedermayer wrote:
> Tilman Kranz wrote:
>> [...] I would like this cache to reside on disk if neccessary [...]
> you do know about AVCodecContext.get/release_buffer() and they arent
> doing what you want right?
No, I not really know them - thanks for pointing that out!
My main routine is (simplified):
--- pseudocode start ---
AVFrame *pFrame = avcodec_alloc_frame()
cache_t *cache = NULL;
// ... prepare decoder context with video stream ...
while
(decode_next_frame(formatCtx,codecCtx,videoStream,pFrame))
cache = cache_append
(cache, cache_new
(pFrame,
codecCtx->pix_fmt,
codecCtx->width,
codecCtx->height));
// ... encode in different order ...
// ... done.
--- pseudocode stop ---
A cache entry is initialized as follows (simplified):
--- pseudocode start ---
cache_t *cache_new
(AVFrame *frame, enum PixelFormat pix_fmt, int width, int height)
{
cache_t *result = new cache_t;
result->frame = avcodec_alloc_frame();
result->buffer = new uint8_t[avpicture_get_size(...)];
// ... keep pix_fmt, width, height ...
avpicture_fill(result->frame,result->buffer,...);
img_copy((AVPicture *)result->frame,(AVPicture *)frame, ...);
result->on_disk = false;
return result;
}
--- pseudocode stop ---
In "cache_new()" it saved me the "img_copy()" if I could reuse the
buffer from the AVFrame that is in codec context and let the codec
allocate a new one. Is this what "get/release_buffer()" do? If I
re-get a buffer, do I have to call "avpicture_fill()" afterwards
to assign offsets and sizes?
> [...]
>>Also, if there is a higher-level way to do it or it is
>>likely to break in the future please let me know.
> no highlevel way, unlikely to break once it works ...
Cool, thanks again.
Greetings, Tilman.
More information about the ffmpeg-devel
mailing list