changeset 1994:8d3540dddd1b libavcodec

cleanup & memleak fix
author michael
date Fri, 30 Apr 2004 17:42:58 +0000
parents 5086ee0ea559
children 38e77ac19836
files 4xm.c asv1.c avcodec.h cljr.c dv.c ffv1.c huffyuv.c mdec.c mjpeg.c mpegvideo.c utils.c vcr1.c
diffstat 12 files changed, 10 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/4xm.c	Fri Apr 30 16:06:20 2004 +0000
+++ b/4xm.c	Fri Apr 30 17:42:58 2004 +0000
@@ -738,8 +738,6 @@
     }
     free_vlc(&f->pre_vlc);
     
-    avcodec_default_free_buffers(avctx);
-
     return 0;
 }
 
--- a/asv1.c	Fri Apr 30 16:06:20 2004 +0000
+++ b/asv1.c	Fri Apr 30 17:42:58 2004 +0000
@@ -613,8 +613,6 @@
     av_freep(&a->picture.qscale_table);
     a->bitstream_buffer_size=0;
     
-    avcodec_default_free_buffers(avctx);
-
     return 0;
 }
 
--- a/avcodec.h	Fri Apr 30 16:06:20 2004 +0000
+++ b/avcodec.h	Fri Apr 30 17:42:58 2004 +0000
@@ -1934,7 +1934,6 @@
 
 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);
--- a/cljr.c	Fri Apr 30 16:06:20 2004 +0000
+++ b/cljr.c	Fri Apr 30 17:42:58 2004 +0000
@@ -133,13 +133,6 @@
     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 @@
     sizeof(CLJRContext),
     decode_init,
     NULL,
-    decode_end,
+    NULL,
     decode_frame,
     CODEC_CAP_DR1,
 };
--- a/dv.c	Fri Apr 30 16:06:20 2004 +0000
+++ b/dv.c	Fri Apr 30 17:42:58 2004 +0000
@@ -235,12 +235,6 @@
     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 @@
     sizeof(DVVideoContext),
     dvvideo_init,
     dvvideo_encode_frame,
-    dvvideo_end,
+    NULL,
     NULL,
     CODEC_CAP_DR1,
     NULL
@@ -967,7 +961,7 @@
     sizeof(DVVideoContext),
     dvvideo_init,
     NULL,
-    dvvideo_end,
+    NULL,
     dvvideo_decode_frame,
     CODEC_CAP_DR1,
     NULL
--- a/ffv1.c	Fri Apr 30 16:06:20 2004 +0000
+++ b/ffv1.c	Fri Apr 30 17:42:58 2004 +0000
@@ -1018,22 +1018,6 @@
     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 @@
     sizeof(FFV1Context),
     decode_init,
     NULL,
-    decode_end,
+    NULL,
     decode_frame,
     CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
     NULL
--- a/huffyuv.c	Fri Apr 30 16:06:20 2004 +0000
+++ b/huffyuv.c	Fri Apr 30 17:42:58 2004 +0000
@@ -916,8 +916,6 @@
     for(i=0; i<3; i++){
         free_vlc(&s->vlc[i]);
     }
-    
-    avcodec_default_free_buffers(avctx);
 
     return 0;
 }
--- a/mdec.c	Fri Apr 30 16:06:20 2004 +0000
+++ b/mdec.c	Fri Apr 30 17:42:58 2004 +0000
@@ -257,8 +257,6 @@
     av_freep(&a->picture.qscale_table);
     a->bitstream_buffer_size=0;
     
-    avcodec_default_free_buffers(avctx);
-
     return 0;
 }
 
--- a/mjpeg.c	Fri Apr 30 16:06:20 2004 +0000
+++ b/mjpeg.c	Fri Apr 30 17:42:58 2004 +0000
@@ -1340,7 +1340,7 @@
                         (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 @@
 
     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++)
--- a/mpegvideo.c	Fri Apr 30 16:06:20 2004 +0000
+++ b/mpegvideo.c	Fri Apr 30 17:42:58 2004 +0000
@@ -847,7 +847,6 @@
         }
     }
     av_freep(&s->picture);
-    avcodec_default_free_buffers(s->avctx);
     s->context_initialized = 0;
     s->last_picture_ptr=
     s->next_picture_ptr=
--- a/utils.c	Fri Apr 30 16:06:20 2004 +0000
+++ b/utils.c	Fri Apr 30 17:42:58 2004 +0000
@@ -29,6 +29,8 @@
 #include "mpegvideo.h"
 #include <stdarg.h>
 
+static void avcodec_default_free_buffers(AVCodecContext *s);
+
 void *av_mallocz(unsigned int size)
 {
     void *ptr;
@@ -514,6 +516,7 @@
 {
     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 @@
         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;
--- a/vcr1.c	Fri Apr 30 16:06:20 2004 +0000
+++ b/vcr1.c	Fri Apr 30 17:42:58 2004 +0000
@@ -165,13 +165,6 @@
     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 @@
     sizeof(VCR1Context),
     decode_init,
     NULL,
-    decode_end,
+    NULL,
     decode_frame,
     CODEC_CAP_DR1,
 };