[Mplayer-cvslog] CVS: main cfg-common.h,1.61,1.62 cfg-mplayer.h,1.168,1.169 mencoder.c,1.171,1.172 mplayer.c,1.585,1.586
Arpi of Ize
arpi at mplayerhq.hu
Sun Oct 6 00:55:47 CEST 2002
Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv25169
Modified Files:
cfg-common.h cfg-mplayer.h mencoder.c mplayer.c
Log Message:
aufio filter layer (libaf) integration to libmpcodecs, mplayer and mencoder
Index: cfg-common.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-common.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- cfg-common.h 28 Sep 2002 18:45:47 -0000 1.61
+++ cfg-common.h 5 Oct 2002 22:55:44 -0000 1.62
@@ -91,6 +91,7 @@
// force video/audio rate:
{"fps", &force_fps, CONF_TYPE_FLOAT, CONF_MIN, 0, 0, NULL},
{"srate", &force_srate, CONF_TYPE_INT, CONF_RANGE, 1000, 8*48000, NULL},
+ {"channels", &audio_output_channels, CONF_TYPE_INT, CONF_RANGE, 1, 6, NULL},
// ------------------------- codec/vfilter options --------------------
@@ -186,6 +187,9 @@
extern float movie_aspect;
extern int softzoom;
extern int flip;
+
+/* from dec_audio, currently used for ac3surround decoder only */
+extern int audio_output_channels;
#ifdef STREAMING
/* defined in network.c */
Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -r1.168 -r1.169
--- cfg-mplayer.h 1 Oct 2002 22:29:03 -0000 1.168
+++ cfg-mplayer.h 5 Oct 2002 22:55:44 -0000 1.169
@@ -111,9 +111,6 @@
/* from libvo/aspect.c */
extern float monitor_aspect;
-/* from dec_audio, currently used for ac3surround decoder only */
-extern int audio_output_channels;
-
/* Options related to audio out plugins */
struct config ao_plugin_conf[]={
{"list", &ao_plugin_cfg.plugin_list, CONF_TYPE_STRING, 0, 0, 0, NULL},
@@ -173,7 +170,6 @@
{"dsp", "Use -ao oss:dsp_path!\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
{"mixer", &mixer_device, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"master", "Option -master has been removed, use -aop list=volume instead.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
- {"channels", &audio_output_channels, CONF_TYPE_INT, CONF_RANGE, 2, 6, NULL},
// override audio buffer size (used only by -ao oss, anyway obsolete...)
{"abs", &ao_data.buffersize, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
Index: mencoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/mencoder.c,v
retrieving revision 1.171
retrieving revision 1.172
diff -u -r1.171 -r1.172
--- mencoder.c 29 Sep 2002 19:26:39 -0000 1.171
+++ mencoder.c 5 Oct 2002 22:55:44 -0000 1.172
@@ -45,6 +45,8 @@
#include "libvo/video_out.h"
+#include "libao2/afmt.h"
+
#include "libmpcodecs/mp_image.h"
#include "libmpcodecs/dec_audio.h"
#include "libmpcodecs/dec_video.h"
@@ -249,19 +251,19 @@
while(size<total && !at_eof){
int len=total-size;
if(len>MAX_OUTBURST) len=MAX_OUTBURST;
- if(len>sh_audio->a_buffer_size) len=sh_audio->a_buffer_size;
- if(len>sh_audio->a_buffer_len){
+ if(len>sh_audio->a_out_buffer_size) len=sh_audio->a_out_buffer_size;
+ if(len>sh_audio->a_out_buffer_len){
int ret=decode_audio(sh_audio,
- &sh_audio->a_buffer[sh_audio->a_buffer_len],
- len-sh_audio->a_buffer_len,
- sh_audio->a_buffer_size-sh_audio->a_buffer_len);
- if(ret>0) sh_audio->a_buffer_len+=ret; else at_eof=1;
+ &sh_audio->a_out_buffer[sh_audio->a_out_buffer_len],
+ len-sh_audio->a_out_buffer_len,
+ sh_audio->a_out_buffer_size-sh_audio->a_out_buffer_len);
+ if(ret>0) sh_audio->a_out_buffer_len+=ret; else at_eof=1;
}
- if(len>sh_audio->a_buffer_len) len=sh_audio->a_buffer_len;
- memcpy(buffer+size,sh_audio->a_buffer,len);
- sh_audio->a_buffer_len-=len; size+=len;
- if(sh_audio->a_buffer_len>0)
- memcpy(sh_audio->a_buffer,&sh_audio->a_buffer[len],sh_audio->a_buffer_len);
+ if(len>sh_audio->a_out_buffer_len) len=sh_audio->a_out_buffer_len;
+ memcpy(buffer+size,sh_audio->a_out_buffer,len);
+ sh_audio->a_out_buffer_len-=len; size+=len;
+ if(sh_audio->a_out_buffer_len>0)
+ memcpy(sh_audio->a_out_buffer,&sh_audio->a_out_buffer[len],sh_audio->a_out_buffer_len);
}
return size;
}
@@ -694,15 +696,25 @@
printf("CBR PCM audio selected\n");
mux_a->h.dwSampleSize=2*sh_audio->channels;
mux_a->h.dwScale=1;
- mux_a->h.dwRate=sh_audio->samplerate;
+ mux_a->h.dwRate=force_srate?force_srate:sh_audio->samplerate;
mux_a->wf=malloc(sizeof(WAVEFORMATEX));
mux_a->wf->nBlockAlign=mux_a->h.dwSampleSize;
mux_a->wf->wFormatTag=0x1; // PCM
- mux_a->wf->nChannels=sh_audio->channels;
- mux_a->wf->nSamplesPerSec=sh_audio->samplerate;
+ mux_a->wf->nChannels=audio_output_channels?audio_output_channels:sh_audio->channels;
+ mux_a->wf->nSamplesPerSec=mux_a->h.dwRate;
mux_a->wf->nAvgBytesPerSec=mux_a->h.dwSampleSize*mux_a->wf->nSamplesPerSec;
mux_a->wf->wBitsPerSample=16;
mux_a->wf->cbSize=0; // FIXME for l3codeca.acm
+ // setup filter:
+ if(!init_audio_filters(sh_audio,
+ sh_audio->samplerate,
+ sh_audio->channels, sh_audio->sample_format, sh_audio->samplesize,
+ mux_a->wf->nSamplesPerSec, mux_a->wf->nChannels,
+ (mux_a->wf->wBitsPerSample==8)? AFMT_U8:AFMT_S16_LE,
+ mux_a->wf->wBitsPerSample/8,
+ 16384, mux_a->wf->nAvgBytesPerSec)){
+ mp_msg(MSGT_CPLAYER,MSGL_ERR,"Couldn't find matching filter / ao format!\n");
+ }
break;
case ACODEC_VBRMP3:
printf("MP3 audio selected\n");
@@ -712,8 +724,9 @@
if(sizeof(MPEGLAYER3WAVEFORMAT)!=30) mp_msg(MSGT_MENCODER,MSGL_WARN,"sizeof(MPEGLAYER3WAVEFORMAT)==%d!=30, maybe broken C compiler?\n",sizeof(MPEGLAYER3WAVEFORMAT));
mux_a->wf=malloc(sizeof(MPEGLAYER3WAVEFORMAT)); // should be 30
mux_a->wf->wFormatTag=0x55; // MP3
- mux_a->wf->nChannels= sh_audio->channels;
- mux_a->wf->nSamplesPerSec=force_srate?force_srate:sh_audio->samplerate;
+ mux_a->wf->nChannels= (lame_param_mode<0) ? sh_audio->channels :
+ ((lame_param_mode==3) ? 1 : 2);
+ mux_a->wf->nSamplesPerSec=mux_a->h.dwRate;
mux_a->wf->nAvgBytesPerSec=192000/8; // FIXME!
mux_a->wf->nBlockAlign=(mux_a->h.dwRate<32000)?576:1152; // required for l3codeca.acm + WMP 6.4
mux_a->wf->wBitsPerSample=0; //16;
@@ -724,6 +737,15 @@
((MPEGLAYER3WAVEFORMAT*)(mux_a->wf))->nBlockSize=(mux_a->h.dwRate<32000)?576:1152; // ???
((MPEGLAYER3WAVEFORMAT*)(mux_a->wf))->nFramesPerBlock=1;
((MPEGLAYER3WAVEFORMAT*)(mux_a->wf))->nCodecDelay=0;
+ // setup filter:
+ if(!init_audio_filters(sh_audio,
+ sh_audio->samplerate,
+ sh_audio->channels, sh_audio->sample_format, sh_audio->samplesize,
+ mux_a->wf->nSamplesPerSec, mux_a->wf->nChannels,
+ AFMT_S16_LE, 2,
+ 4608, mux_a->h.dwRate*mux_a->wf->nChannels*2)){
+ mp_msg(MSGT_CPLAYER,MSGL_ERR,"Couldn't find matching filter / ao format!\n");
+ }
break;
}
@@ -748,7 +770,8 @@
lame=lame_init();
lame_set_bWriteVbrTag(lame,0);
-lame_set_in_samplerate(lame,sh_audio->samplerate);
+lame_set_in_samplerate(lame,mux_a->wf->nSamplesPerSec);
+//lame_set_in_samplerate(lame,sh_audio->samplerate); // if resampling done by lame
lame_set_num_channels(lame,mux_a->wf->nChannels);
lame_set_out_samplerate(lame,mux_a->wf->nSamplesPerSec);
lame_set_quality(lame,lame_param_algqual); // 0 = best q
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.585
retrieving revision 1.586
diff -u -r1.585 -r1.586
--- mplayer.c 2 Oct 2002 13:16:03 -0000 1.585
+++ mplayer.c 5 Oct 2002 22:55:44 -0000 1.586
@@ -1237,6 +1237,7 @@
if(!(audio_out=init_best_audio_out(audio_driver_list,
(ao_plugin_cfg.plugin_list), // plugin flag
force_srate?force_srate:sh_audio->samplerate,
+ audio_output_channels?audio_output_channels:
sh_audio->channels,sh_audio->sample_format,0))){
// FAILED:
mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotInitAO);
@@ -1244,7 +1245,7 @@
} else {
// SUCCESS:
inited_flags|=INITED_AO;
- mp_msg(MSGT_CPLAYER,MSGL_INFO,"AO: [%s] %iHz %dch %s\n",
+ mp_msg(MSGT_CPLAYER,MSGL_INFO,"AO: [%s] %dHz %dch %s\n",
audio_out->info->short_name,
force_srate?force_srate:sh_audio->samplerate,
sh_audio->channels,
@@ -1253,6 +1254,19 @@
audio_out->info->name, audio_out->info->author);
if(strlen(audio_out->info->comment) > 0)
mp_msg(MSGT_CPLAYER,MSGL_V,MSGTR_AOComment, audio_out->info->comment);
+ // init audio filters:
+#if 1
+ current_module="af_init";
+ if(!init_audio_filters(sh_audio,
+ sh_audio->samplerate,
+ sh_audio->channels, sh_audio->sample_format, sh_audio->samplesize,
+ ao_data.samplerate, ao_data.channels, ao_data.format,
+ audio_out_format_bits(ao_data.format)/8, /* ao_data.bps, */
+ ao_data.outburst*4, ao_data.buffersize)){
+ mp_msg(MSGT_CPLAYER,MSGL_ERR,"Couldn't find matching filter / ao format, -> nosound\n");
+ sh_audio=d_audio->sh=NULL; // -> nosound
+ }
+#endif
}
}
@@ -1338,24 +1352,25 @@
// Fill buffer if needed:
current_module="decode_audio"; // Enter AUDIO decoder module
t=GetTimer();
- while(sh_audio->a_buffer_len<playsize && !d_audio->eof){
- int ret=decode_audio(sh_audio,&sh_audio->a_buffer[sh_audio->a_buffer_len],
- playsize-sh_audio->a_buffer_len,sh_audio->a_buffer_size-sh_audio->a_buffer_len);
+ while(sh_audio->a_out_buffer_len<playsize && !d_audio->eof){
+ int ret=decode_audio(sh_audio,&sh_audio->a_out_buffer[sh_audio->a_out_buffer_len],
+ playsize-sh_audio->a_out_buffer_len,sh_audio->a_out_buffer_size-sh_audio->a_out_buffer_len);
if(ret<=0) break; // EOF?
- sh_audio->a_buffer_len+=ret;
+ sh_audio->a_out_buffer_len+=ret;
}
t=GetTimer()-t;
tt = t*0.000001f; audio_time_usage+=tt;
- if(playsize>sh_audio->a_buffer_len) playsize=sh_audio->a_buffer_len;
+ if(playsize>sh_audio->a_out_buffer_len) playsize=sh_audio->a_out_buffer_len;
// play audio:
current_module="play_audio";
- playsize=audio_out->play(sh_audio->a_buffer,playsize,0);
+ playsize=audio_out->play(sh_audio->a_out_buffer,playsize,0);
if(playsize>0){
- sh_audio->a_buffer_len-=playsize;
- memmove(sh_audio->a_buffer,&sh_audio->a_buffer[playsize],sh_audio->a_buffer_len);
- sh_audio->timer+=playsize/(float)(sh_audio->o_bps);
+ sh_audio->a_out_buffer_len-=playsize;
+ memmove(sh_audio->a_out_buffer,&sh_audio->a_out_buffer[playsize],sh_audio->a_out_buffer_len);
+ sh_audio->timer+=playsize/((float)((ao_data.bps && sh_audio->afilter) ?
+ ao_data.bps : sh_audio->o_bps));
}
break;
More information about the MPlayer-cvslog
mailing list