[Mplayer-cvslog] CVS: main/libmpcodecs dec_audio.c,1.21,1.22

Arpi of Ize arpi at mplayerhq.hu
Sat Jan 18 18:34:12 CET 2003


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

Modified Files:
	dec_audio.c 
Log Message:
2-pass libaf initialization to get better filter chain.
-channels, -format, -srate function changed, they affect codec & preinit
outformat only, use -af resample=XXX,channels=YYY,format=ZZZ to override.


Index: dec_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/dec_audio.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- dec_audio.c	17 Jan 2003 00:59:45 -0000	1.21
+++ dec_audio.c	18 Jan 2003 17:34:02 -0000	1.22
@@ -277,12 +277,60 @@
 }
 
  /* Init audio filters */
+int preinit_audio_filters(sh_audio_t *sh_audio, 
+	int in_samplerate, int in_channels, int in_format, int in_bps,
+	int* out_samplerate, int* out_channels, int* out_format, int out_bps){
+  char strbuf[200];
+  af_stream_t* afs=malloc(sizeof(af_stream_t));
+  memset(afs,0,sizeof(af_stream_t));
+
+  // input format: same as codec's output format:
+  afs->input.rate   = in_samplerate;
+  afs->input.nch    = in_channels;
+  afs->input.format = af_format_decode(in_format);
+  afs->input.bps    = in_bps;
+
+  // output format: same as ao driver's input format (if missing, fallback to input)
+  afs->output.rate   = *out_samplerate ? *out_samplerate : afs->input.rate;
+  afs->output.nch    = *out_channels ? *out_channels : afs->input.nch;
+  afs->output.format = af_format_decode(*out_format ? *out_format : afs->input.format);
+  afs->output.bps    = out_bps ? out_bps : afs->input.bps;
+
+  // filter config:  
+  memcpy(&afs->cfg,&af_cfg,sizeof(af_cfg_t));
+  
+  mp_msg(MSGT_DECAUDIO, MSGL_INFO, "Checking audio filter chain for %dHz/%dch/%dbit -> %dHz/%dch/%dbit...\n",
+      afs->input.rate,afs->input.nch,afs->input.bps*8,
+      afs->output.rate,afs->output.nch,afs->output.bps*8);
+  
+  // let's autoprobe it!
+  if(0 != af_init(afs,0)){
+    free(afs);
+    return 0; // failed :(
+  }
+  
+  *out_samplerate=afs->output.rate;
+  *out_channels=afs->output.nch;
+  *out_format=af_format_encode((void*)(&afs->output));
+  
+  mp_msg(MSGT_DECAUDIO, MSGL_INFO, "AF_pre: af format: %d bps, %d ch, %d hz, %s\n",
+      afs->output.bps, afs->output.nch, afs->output.rate,
+      fmt2str(afs->output.format,strbuf,200));
+  
+  sh_audio->afilter=(void*)afs;
+  return 1;
+}
+
+ /* Init audio filters */
 int init_audio_filters(sh_audio_t *sh_audio, 
 	int in_samplerate, int in_channels, int in_format, int in_bps,
 	int out_samplerate, int out_channels, int out_format, int out_bps,
 	int out_minsize, int out_maxsize){
-  af_stream_t* afs=malloc(sizeof(af_stream_t));
-  memset(afs,0,sizeof(af_stream_t));
+  af_stream_t* afs=sh_audio->afilter;
+  if(!afs){
+    malloc(sizeof(af_stream_t));
+    memset(afs,0,sizeof(af_stream_t));
+  }
 
   // input format: same as codec's output format:
   afs->input.rate   = in_samplerate;



More information about the MPlayer-cvslog mailing list