[Mplayer-cvslog] CVS: main/libmpcodecs ad_ffmpeg.c,1.7,1.8

Arpi of Ize arpi at mplayerhq.hu
Mon Oct 28 01:40:45 CET 2002


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv22424

Modified Files:
	ad_ffmpeg.c 
Log Message:
pass extradata to the codec
patch by Fabrice Bellard <fabrice.bellard at free.fr>


Index: ad_ffmpeg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_ffmpeg.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ad_ffmpeg.c	31 Aug 2002 13:09:23 -0000	1.7
+++ ad_ffmpeg.c	28 Oct 2002 00:40:42 -0000	1.8
@@ -58,10 +58,23 @@
 	return 0;
     }
     
-    lavc_context = malloc(sizeof(AVCodecContext));
-    memset(lavc_context, 0, sizeof(AVCodecContext));
+    lavc_context = avcodec_alloc_context();
     sh_audio->context=lavc_context;
-    
+
+    lavc_context->channels = sh_audio->wf->nChannels;
+    lavc_context->sample_rate = sh_audio->wf->nSamplesPerSec;
+    lavc_context->bit_rate = sh_audio->wf->nAvgBytesPerSec * 8;
+    lavc_context->fourcc = sh_audio->format;
+    lavc_context->block_align = sh_audio->wf->nBlockAlign;
+
+    /* alloc extra data */
+    if (sh_audio->wf->cbSize > 0) {
+        lavc_context->extradata = malloc(sh_audio->wf->cbSize);
+        lavc_context->extradata_size = sh_audio->wf->cbSize;
+        memcpy(lavc_context->extradata, (char *)sh_audio->wf + sizeof(WAVEFORMATEX), 
+               lavc_context->extradata_size);
+    }
+
     /* open it */
     if (avcodec_open(lavc_context, lavc_codec) < 0) {
         mp_msg(MSGT_DECAUDIO,MSGL_ERR, MSGTR_CantOpenCodec);
@@ -87,9 +100,13 @@
 
 static void uninit(sh_audio_t *sh)
 {
-    if (avcodec_close(sh->context) < 0)
+    AVCodecContext *lavc_context = sh->context;
+
+    if (avcodec_close(lavc_context) < 0)
 	mp_msg(MSGT_DECVIDEO, MSGL_ERR, MSGTR_CantCloseCodec);
-    free(sh->context);
+    if (lavc_context->extradata)
+        free(lavc_context->extradata);
+    free(lavc_context);
 }
 
 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
@@ -120,3 +137,5 @@
 }
 
 #endif
+
+




More information about the MPlayer-cvslog mailing list