changeset 7852:e4f87bbf682c

- using avcodec_alloc_context() - fixed 10l bug (double free() ) causing random mem corruption...
author arpi
date Tue, 22 Oct 2002 22:25:17 +0000
parents 626c13032310
children 974f7756c7e0
files libmpcodecs/vf_lavc.c
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf_lavc.c	Tue Oct 22 20:47:38 2002 +0000
+++ b/libmpcodecs/vf_lavc.c	Tue Oct 22 22:25:17 2002 +0000
@@ -26,12 +26,12 @@
 struct vf_priv_s {
     unsigned char* outbuf;
     int outbuf_size;
-    AVCodecContext context;
-    AVCodec *codec;
+    AVCodecContext* context;
+    AVCodec* codec;
     vo_mpegpes_t pes;
 };
 
-#define lavc_venc_context (vf->priv->context)
+#define lavc_venc_context (*vf->priv->context)
 
 //===========================================================================//
 
@@ -62,7 +62,6 @@
     if(vf->priv->outbuf) free(vf->priv->outbuf);
 
     vf->priv->outbuf_size=10000+width*height;  // must be enough!
-    if(vf->priv->outbuf) free(vf->priv->outbuf);
     vf->priv->outbuf = malloc(vf->priv->outbuf_size);
 
     if (avcodec_open(&lavc_venc_context, vf->priv->codec) != 0) {
@@ -142,6 +141,8 @@
 	mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_MissingLAVCcodec, "mpeg1video");
 	return 0;
     }
+    
+    vf->priv->context=avcodec_alloc_context();
 
     // TODO: parse args ->
     if(args) sscanf(args, "%d:%f", &p_quality, &p_fps);