diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-05-06 20:43:37 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-05-06 20:43:37 +0000 |
commit | e20c40697cb6b40804acac9a92005779382c6e7e (patch) | |
tree | 16ad773d668050a6c14a85e6ad4abcc7cbea6def /libavcodec/mpegvideo.c | |
parent | 61873c4a4436f2c516e14d6a00a2b856fa93f818 (diff) | |
download | ffmpeg-e20c40697cb6b40804acac9a92005779382c6e7e.tar.gz |
release buffer cleanup
Originally committed as revision 1839 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r-- | libavcodec/mpegvideo.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 0f57bee356..ea24c2a488 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -929,7 +929,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) s->mb_skiped = 0; assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264); - + /* mark&release old frames */ if (s->pict_type != B_TYPE && s->last_picture_ptr) { avctx->release_buffer(avctx, (AVFrame*)s->last_picture_ptr); @@ -945,9 +945,15 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) } } } - alloc: if(!s->encoding){ + /* release non refernce frames */ + for(i=0; i<MAX_PICTURE_COUNT; i++){ + if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){ + s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]); + } + } + i= find_unused_picture(s, 0); pic= (AVFrame*)&s->picture[i]; @@ -1041,12 +1047,14 @@ void MPV_frame_end(MpegEncContext *s) assert(i<MAX_PICTURE_COUNT); #endif - /* release non refernce frames */ - for(i=0; i<MAX_PICTURE_COUNT; i++){ - if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/) - s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]); + if(s->encoding){ + /* release non refernce frames */ + for(i=0; i<MAX_PICTURE_COUNT; i++){ + if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){ + s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]); + } + } } - // clear copies, to avoid confusion #if 0 memset(&s->last_picture, 0, sizeof(Picture)); |