From eea8c08fa82791378bd33769992a7435409394b7 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 30 Apr 2004 17:42:58 +0000 Subject: [PATCH] cleanup & memleak fix Originally committed as revision 3095 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/4xm.c | 2 -- libavcodec/asv1.c | 2 -- libavcodec/avcodec.h | 1 - libavcodec/cljr.c | 9 +-------- libavcodec/dv.c | 10 ++-------- libavcodec/ffv1.c | 18 +----------------- libavcodec/huffyuv.c | 2 -- libavcodec/mdec.c | 2 -- libavcodec/mjpeg.c | 3 +-- libavcodec/mpegvideo.c | 1 - libavcodec/utils.c | 5 ++++- libavcodec/vcr1.c | 9 +-------- 12 files changed, 10 insertions(+), 54 deletions(-) diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 6544d88d0f..50dc4a55bd 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -738,8 +738,6 @@ static int decode_end(AVCodecContext *avctx){ } free_vlc(&f->pre_vlc); - avcodec_default_free_buffers(avctx); - return 0; } diff --git a/libavcodec/asv1.c b/libavcodec/asv1.c index 87b13c637b..24916590f8 100644 --- a/libavcodec/asv1.c +++ b/libavcodec/asv1.c @@ -613,8 +613,6 @@ static int decode_end(AVCodecContext *avctx){ av_freep(&a->picture.qscale_table); a->bitstream_buffer_size=0; - avcodec_default_free_buffers(avctx); - return 0; } diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 6a4d223769..e6eb11f955 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1934,7 +1934,6 @@ AVFrame *avcodec_alloc_frame(void); int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic); void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic); -void avcodec_default_free_buffers(AVCodecContext *s); int avcodec_thread_init(AVCodecContext *s, int thread_count); void avcodec_thread_free(AVCodecContext *s); diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c index 382a77ac7d..912a050fbd 100644 --- a/libavcodec/cljr.c +++ b/libavcodec/cljr.c @@ -133,13 +133,6 @@ static int encode_init(AVCodecContext *avctx){ return 0; } -static int decode_end(AVCodecContext *avctx){ - - avcodec_default_free_buffers(avctx); - - return 0; -} - AVCodec cljr_decoder = { "cljr", CODEC_TYPE_VIDEO, @@ -147,7 +140,7 @@ AVCodec cljr_decoder = { sizeof(CLJRContext), decode_init, NULL, - decode_end, + NULL, decode_frame, CODEC_CAP_DR1, }; diff --git a/libavcodec/dv.c b/libavcodec/dv.c index 5f1eaaa3b4..c62c964fbc 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -235,12 +235,6 @@ static int dvvideo_init(AVCodecContext *avctx) return 0; } -static int dvvideo_end(AVCodecContext *avctx) -{ - avcodec_default_free_buffers(avctx); - return 0; -} - // #define VLC_DEBUG // #define printf(...) av_log(NULL, AV_LOG_ERROR, __VA_ARGS__) @@ -954,7 +948,7 @@ AVCodec dvvideo_encoder = { sizeof(DVVideoContext), dvvideo_init, dvvideo_encode_frame, - dvvideo_end, + NULL, NULL, CODEC_CAP_DR1, NULL @@ -967,7 +961,7 @@ AVCodec dvvideo_decoder = { sizeof(DVVideoContext), dvvideo_init, NULL, - dvvideo_end, + NULL, dvvideo_decode_frame, CODEC_CAP_DR1, NULL diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index eefce93705..aacbe3ed68 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -1018,22 +1018,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8 return bytes_read; } -static int decode_end(AVCodecContext *avctx) -{ - FFV1Context *s = avctx->priv_data; - int i; - - if(avctx->get_buffer == avcodec_default_get_buffer){ - for(i=0; i<4; i++){ - av_freep(&s->picture.base[i]); - s->picture.data[i]= NULL; - } - av_freep(&s->picture.opaque); - } - - return 0; -} - AVCodec ffv1_decoder = { "ffv1", CODEC_TYPE_VIDEO, @@ -1041,7 +1025,7 @@ AVCodec ffv1_decoder = { sizeof(FFV1Context), decode_init, NULL, - decode_end, + NULL, decode_frame, CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/, NULL diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index 4047a6a938..210d454190 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -916,8 +916,6 @@ static int decode_end(AVCodecContext *avctx) for(i=0; i<3; i++){ free_vlc(&s->vlc[i]); } - - avcodec_default_free_buffers(avctx); return 0; } diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index faf3cef316..219a39b257 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -257,8 +257,6 @@ static int decode_end(AVCodecContext *avctx){ av_freep(&a->picture.qscale_table); a->bitstream_buffer_size=0; - avcodec_default_free_buffers(avctx); - return 0; } diff --git a/libavcodec/mjpeg.c b/libavcodec/mjpeg.c index 255a82d2cb..78a620fd3c 100644 --- a/libavcodec/mjpeg.c +++ b/libavcodec/mjpeg.c @@ -1340,7 +1340,7 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s){ (h * mb_x + x) * 8; if (s->interlaced && s->bottom_field) ptr += s->linesize[c] >> 1; -//printf("%d %d %d %d %d %d %d %d \n", mb_x, mb_y, x, y, c, s->bottom_field, (v * mb_y + y) * 8, (h * mb_x + x) * 8); +//av_log(NULL, AV_LOG_DEBUG, "%d %d %d %d %d %d %d %d \n", mb_x, mb_y, x, y, c, s->bottom_field, (v * mb_y + y) * 8, (h * mb_x + x) * 8); s->idct_put(ptr, s->linesize[c], s->block); if (++x == h) { x = 0; @@ -2171,7 +2171,6 @@ static int mjpeg_decode_end(AVCodecContext *avctx) av_free(s->buffer); av_free(s->qscale_table); - avcodec_default_free_buffers(avctx); for(i=0;i<2;i++) { for(j=0;j<4;j++) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 1fa39e0f1f..196ba01853 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -847,7 +847,6 @@ void MPV_common_end(MpegEncContext *s) } } av_freep(&s->picture); - avcodec_default_free_buffers(s->avctx); s->context_initialized = 0; s->last_picture_ptr= s->next_picture_ptr= diff --git a/libavcodec/utils.c b/libavcodec/utils.c index ba4387c1c8..59e9a3058f 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -29,6 +29,8 @@ #include "mpegvideo.h" #include +static void avcodec_default_free_buffers(AVCodecContext *s); + void *av_mallocz(unsigned int size) { void *ptr; @@ -514,6 +516,7 @@ int avcodec_close(AVCodecContext *avctx) { if (avctx->codec->close) avctx->codec->close(avctx); + avcodec_default_free_buffers(avctx); av_freep(&avctx->priv_data); avctx->codec = NULL; return 0; @@ -738,7 +741,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx) avctx->codec->flush(avctx); } -void avcodec_default_free_buffers(AVCodecContext *s){ +static void avcodec_default_free_buffers(AVCodecContext *s){ int i, j; if(s->internal_buffer==NULL) return; diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c index 4b8c9fc41d..05539452a4 100644 --- a/libavcodec/vcr1.c +++ b/libavcodec/vcr1.c @@ -165,13 +165,6 @@ static int encode_init(AVCodecContext *avctx){ return 0; } -static int decode_end(AVCodecContext *avctx){ - - avcodec_default_free_buffers(avctx); - - return 0; -} - AVCodec vcr1_decoder = { "vcr1", CODEC_TYPE_VIDEO, @@ -179,7 +172,7 @@ AVCodec vcr1_decoder = { sizeof(VCR1Context), decode_init, NULL, - decode_end, + NULL, decode_frame, CODEC_CAP_DR1, };