[Mplayer-cvslog] CVS: main/libmpcodecs ad_a52.c,1.3,1.4 ad_dk3adpcm.c,1.2,1.3 ad_dk4adpcm.c,1.2,1.3 ad_dshow.c,1.3,1.4 ad_faad.c,1.2,1.3 ad_hwac3.c,1.2,1.3 ad_imaadpcm.c,1.2,1.3 ad_msadpcm.c,1.3,1.4 ad_roqaudio.c,1.3,1.4 dec_audio.c,1.1,1.2
Arpi of Ize
arpi at mplayer.dev.hu
Mon Apr 1 19:57:54 CEST 2002
Update of /cvsroot/mplayer/main/libmpcodecs
In directory mplayer:/var/tmp.root/cvs-serv19452
Modified Files:
ad_a52.c ad_dk3adpcm.c ad_dk4adpcm.c ad_dshow.c ad_faad.c
ad_hwac3.c ad_imaadpcm.c ad_msadpcm.c ad_roqaudio.c
dec_audio.c
Log Message:
audio input buffer allocation/free cleanup
Index: ad_a52.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_a52.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ad_a52.c 25 Mar 2002 22:03:33 -0000 1.3
+++ ad_a52.c 1 Apr 2002 17:57:51 -0000 1.4
@@ -96,6 +96,7 @@
/* Dolby AC3 audio: */
/* however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame */
sh->audio_out_minsize=audio_output_channels*2*256*6;
+ sh->audio_in_minsize=3840;
return 1;
}
@@ -115,9 +116,6 @@
mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 init failed\n");
return 0;
}
- sh_audio->a_in_buffer_size=3840;
- sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size);
- sh_audio->a_in_buffer_len=0;
if(a52_fillbuff(sh_audio)<0){
mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 sync failed\n");
return 0;
Index: ad_dk3adpcm.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_dk3adpcm.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ad_dk3adpcm.c 30 Mar 2002 22:27:44 -0000 1.2
+++ ad_dk3adpcm.c 1 Apr 2002 17:57:51 -0000 1.3
@@ -71,6 +71,7 @@
sh_audio->audio_out_minsize = sh_audio->wf->nBlockAlign * 6;
sh_audio->ds->ss_div =
(sh_audio->wf->nBlockAlign - DK3_ADPCM_PREAMBLE_SIZE) * 8 / 3;
+ sh_audio->audio_in_minsize=
sh_audio->ds->ss_mul = sh_audio->wf->nBlockAlign;
return 1;
}
@@ -81,17 +82,11 @@
sh_audio->samplerate = sh_audio->wf->nSamplesPerSec;
sh_audio->i_bps =
(sh_audio->ds->ss_mul * sh_audio->samplerate) / sh_audio->ds->ss_div;
-
- if ((sh_audio->a_in_buffer =
- (unsigned char *)malloc(sh_audio->ds->ss_mul)) == NULL)
- return 0;
-
return 1;
}
static void uninit(sh_audio_t *sh_audio)
{
- free(sh_audio->a_in_buffer);
}
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
Index: ad_dk4adpcm.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_dk4adpcm.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ad_dk4adpcm.c 26 Mar 2002 05:34:41 -0000 1.2
+++ ad_dk4adpcm.c 1 Apr 2002 17:57:51 -0000 1.3
@@ -25,8 +25,8 @@
(((sh_audio->wf->nBlockAlign - DK4_ADPCM_PREAMBLE_SIZE) * 2) + 1) * 4;
sh_audio->ds->ss_div =
((sh_audio->wf->nBlockAlign - DK4_ADPCM_PREAMBLE_SIZE) * 2) + 1;
+ sh_audio->audio_in_minsize=
sh_audio->ds->ss_mul=sh_audio->wf->nBlockAlign;
-
return 1;
}
@@ -37,17 +37,11 @@
sh_audio->i_bps = sh_audio->wf->nBlockAlign *
(sh_audio->channels*sh_audio->samplerate) /
(((sh_audio->wf->nBlockAlign - DK4_ADPCM_PREAMBLE_SIZE) * 2) + 1);
-
- if ((sh_audio->a_in_buffer =
- (unsigned char *)malloc(sh_audio->ds->ss_mul)) == NULL)
- return 0;
-
return 1;
}
static void uninit(sh_audio_t *sh_audio)
{
- free(sh_audio->a_in_buffer);
}
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
Index: ad_dshow.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_dshow.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ad_dshow.c 1 Apr 2002 13:14:54 -0000 1.3
+++ ad_dshow.c 1 Apr 2002 17:57:51 -0000 1.4
@@ -36,18 +36,14 @@
{
mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_audio->codec->dll);
return 0;
- } else {
+ }
sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
sh_audio->channels=sh_audio->wf->nChannels;
sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
sh_audio->audio_in_minsize=2*sh_audio->wf->nBlockAlign;
if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192;
- sh_audio->a_in_buffer_size=sh_audio->audio_in_minsize;
- sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size);
- sh_audio->a_in_buffer_len=0;
sh_audio->audio_out_minsize=16384;
sh_audio->context = ds_adec;
- }
mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow audio codec init OK!\n");
return 1;
}
Index: ad_faad.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_faad.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ad_faad.c 26 Mar 2002 16:37:42 -0000 1.2
+++ ad_faad.c 1 Apr 2002 17:57:51 -0000 1.3
@@ -39,13 +39,8 @@
static int preinit(sh_audio_t *sh)
{
- sh->audio_in_minsize=FAAD_BUFFLEN;
sh->audio_out_minsize=2048*FAAD_MAX_CHANNELS;
-
- // XXX: why is this duplicated in sh struct? ::atmos
- sh->a_in_buffer_size=sh->audio_in_minsize;
- sh->a_in_buffer=malloc(sh->a_in_buffer_size);
- sh->a_in_buffer_len=0;
+ sh->audio_in_minsize=FAAD_BUFFLEN;
return 1;
}
@@ -126,10 +121,6 @@
{
mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: Closing decoder!\n");
faacDecClose(faac_hdec);
- if(sh->a_in_buffer_size) {
- free(sh->a_in_buffer);
- sh->a_in_buffer = NULL;
- }
}
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
Index: ad_hwac3.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_hwac3.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ad_hwac3.c 27 Mar 2002 21:05:39 -0000 1.2
+++ ad_hwac3.c 1 Apr 2002 17:57:51 -0000 1.3
@@ -32,6 +32,7 @@
{
/* Dolby AC3 audio: */
sh->audio_out_minsize=4*256*6;
+ sh->audio_in_minsize=3840;
sh->channels=2;
return 1;
}
@@ -44,9 +45,6 @@
mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 init failed\n");
return 0;
}
- sh_audio->a_in_buffer_size=3840;
- sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size);
- sh_audio->a_in_buffer_len=0;
if(a52_fillbuff(sh_audio)<0) {
mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 sync failed\n");
return 0;
Index: ad_imaadpcm.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_imaadpcm.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ad_imaadpcm.c 30 Mar 2002 22:27:44 -0000 1.2
+++ ad_imaadpcm.c 1 Apr 2002 17:57:51 -0000 1.3
@@ -98,6 +98,7 @@
sh_audio->ds->ss_div = QT_IMA_ADPCM_SAMPLES_PER_BLOCK;
sh_audio->ds->ss_mul = QT_IMA_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels;
}
+ sh_audio->audio_in_minsize=sh_audio->ds->ss_mul;
return 1;
}
@@ -110,16 +111,11 @@
sh_audio->i_bps =
(sh_audio->ds->ss_mul * sh_audio->samplerate) / sh_audio->ds->ss_div;
- if ((sh_audio->a_in_buffer =
- (unsigned char *)malloc(sh_audio->ds->ss_mul)) == NULL)
- return 0;
-
return 1;
}
static void uninit(sh_audio_t *sh_audio)
{
- free(sh_audio->a_in_buffer);
}
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
Index: ad_msadpcm.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_msadpcm.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ad_msadpcm.c 30 Mar 2002 22:27:44 -0000 1.3
+++ ad_msadpcm.c 1 Apr 2002 17:57:51 -0000 1.4
@@ -66,8 +66,8 @@
sh_audio->audio_out_minsize = sh_audio->wf->nBlockAlign * 4;
sh_audio->ds->ss_div =
(sh_audio->wf->nBlockAlign - MS_ADPCM_PREAMBLE_SIZE) * 2;
+ sh_audio->audio_in_minsize =
sh_audio->ds->ss_mul = sh_audio->wf->nBlockAlign;
-
return 1;
}
@@ -78,16 +78,11 @@
sh_audio->i_bps = sh_audio->wf->nBlockAlign *
(sh_audio->channels*sh_audio->samplerate) / sh_audio->ds->ss_div;
- if ((sh_audio->a_in_buffer =
- (unsigned char *)malloc(sh_audio->ds->ss_mul)) == NULL)
- return 0;
-
return 1;
}
static void uninit(sh_audio_t *sh_audio)
{
- free(sh_audio->a_in_buffer);
}
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
Index: ad_roqaudio.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_roqaudio.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ad_roqaudio.c 31 Mar 2002 17:25:11 -0000 1.3
+++ ad_roqaudio.c 1 Apr 2002 17:57:51 -0000 1.4
@@ -22,6 +22,7 @@
{
// minsize was stored in wf->nBlockAlign by the RoQ demuxer
sh_audio->audio_out_minsize=sh_audio->wf->nBlockAlign;
+ sh_audio->audio_in_minsize=sh_audio->audio_out_minsize / 2; // FIXME?
sh_audio->context = roq_decode_audio_init();
return 1;
}
@@ -31,17 +32,11 @@
sh_audio->channels=sh_audio->wf->nChannels;
sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
sh_audio->i_bps = 44100;
-
- if ((sh_audio->a_in_buffer =
- (unsigned char *)malloc(sh_audio->audio_out_minsize / 2)) == NULL)
- return 0;
-
return 1;
}
static void uninit(sh_audio_t *sh_audio)
{
- free(sh_audio->a_in_buffer);
}
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
Index: dec_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/dec_audio.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dec_audio.c 25 Mar 2002 21:23:06 -0000 1.1
+++ dec_audio.c 1 Apr 2002 17:57:51 -0000 1.2
@@ -40,6 +40,14 @@
}
printf("Selecting Audio Decoder: [%s] %s\n",mpadec->info->short_name,mpadec->info->name);
+
+ // reset in/out buffer size/pointer:
+ sh_audio->a_buffer_size=0;
+ sh_audio->a_buffer=NULL;
+ sh_audio->a_in_buffer_size=0;
+ sh_audio->a_in_buffer=NULL;
+
+ // Set up some common usefull defaults. ad->preinit() can override these:
sh_audio->samplesize=2;
#ifdef WORDS_BIGENDIAN
@@ -48,15 +56,11 @@
sh_audio->sample_format=AFMT_S16_LE;
#endif
sh_audio->samplerate=0;
- sh_audio->o_bps=0;
+ sh_audio->i_bps=0; // input rate (bytes/sec)
+ sh_audio->o_bps=0; // output rate (bytes/sec)
- sh_audio->a_buffer_size=0;
- sh_audio->a_buffer=NULL;
-
- sh_audio->a_in_buffer_len=0;
-
- /* setup required min. in/out buffer size:*/
sh_audio->audio_out_minsize=8192;/* default size, maybe not enough for Win32/ACM*/
+ sh_audio->audio_in_minsize=0;
if(!mpadec->preinit(sh_audio))
{
@@ -64,6 +68,16 @@
return 0;
}
+/* allocate audio in buffer: */
+ if(sh_audio->audio_in_minsize>0){
+ sh_audio->a_in_buffer_size=sh_audio->audio_in_minsize;
+ mp_msg(MSGT_DECAUDIO,MSGL_V,"dec_audio: Allocating %d bytes for input buffer\n",
+ sh_audio->a_in_buffer_size);
+ sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size);
+ memset(sh_audio->a_in_buffer,0,sh_audio->a_in_buffer_size);
+ sh_audio->a_in_buffer_len=0;
+ }
+
/* allocate audio out buffer: */
sh_audio->a_buffer_size=sh_audio->audio_out_minsize+MAX_OUTBURST; /* worst case calc.*/
@@ -79,30 +93,34 @@
sh_audio->a_buffer_len=0;
if(!mpadec->init(sh_audio)){
- printf("ADecoder init failed :(\n");
+ mp_msg(MSGT_DECAUDIO,MSGL_WARN,"ADecoder init failed :(\n");
+ uninit_audio(sh_audio); // free buffers
return 0;
}
+
sh_audio->inited=1;
if(!sh_audio->channels || !sh_audio->samplerate){
mp_msg(MSGT_DECAUDIO,MSGL_WARN,MSGTR_UnknownAudio);
- if(sh_audio->a_buffer) free(sh_audio->a_buffer);
- sh_audio->a_buffer=NULL;
+ uninit_audio(sh_audio); // free buffers
return 0;
}
if(!sh_audio->o_bps)
sh_audio->o_bps=sh_audio->channels*sh_audio->samplerate*sh_audio->samplesize;
- return sh_audio->codec->driver;
+
+ return 1;
}
void uninit_audio(sh_audio_t *sh_audio)
{
+ if(sh_audio->a_buffer) free(sh_audio->a_buffer);
+ sh_audio->a_buffer=NULL;
+ if(sh_audio->a_in_buffer) free(sh_audio->a_in_buffer);
+ sh_audio->a_in_buffer=NULL;
if(!sh_audio->inited) return;
mp_msg(MSGT_DECAUDIO,MSGL_V,"uninit audio: %d \n",sh_audio->codec->driver);
mpadec->uninit(sh_audio);
- if(sh_audio->a_buffer) free(sh_audio->a_buffer);
- sh_audio->a_buffer=NULL;
sh_audio->inited=0;
}
More information about the MPlayer-cvslog
mailing list