[MPlayer-cvslog] CVS: main/libmpcodecs ad_faad.c,1.17,1.18

Richard Felker CVS syncmail at mplayerhq.hu
Tue Mar 29 19:59:11 CEST 2005


CVS change done by Richard Felker CVS

Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var2/tmp/cvs-serv19801/libmpcodecs

Modified Files:
	ad_faad.c 
Log Message:
step 1 of fixing ad_faad:
use internal downmixing just like liba52 does if the output is <= 2 channels
actually this is broken since it makes it impossible to manually use
af_pan; however liba52 already has that limitation, and without this
patch, aac audio comes out TOTALLY wrong on 2-channel systems.
hopefully someone will find a better solution later.
next up: making ad_faad reorder the channels according to what mplayer
expects, so they won't all come out the wrong speakers...


Index: ad_faad.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_faad.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ad_faad.c	3 Feb 2005 17:35:49 -0000	1.17
+++ ad_faad.c	29 Mar 2005 17:59:08 -0000	1.18
@@ -66,6 +66,7 @@
   return pos;
 }
 	
+extern int audio_output_channels;
 static int init(sh_audio_t *sh)
 {
   unsigned long faac_samplerate;
@@ -90,6 +91,7 @@
     /* XXX: FAAD support FLOAT output, how do we handle
       * that (FAAD_FMT_FLOAT)? ::atmos
       */
+    if (audio_output_channels <= 2) faac_conf->downMatrix = 1;
       switch(sh->samplesize){
 	case 1: // 8Bit
 	  mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: 8Bit samplesize not supported by FAAD, assuming 16Bit!\n");
@@ -129,6 +131,12 @@
     // XXX FIXME: shouldn't we memcpy() here in a_in_buffer ?? --A'rpi
 
   } else { // We have ES DS in codecdata
+    faacDecConfigurationPtr faac_conf = faacDecGetCurrentConfiguration(faac_hdec);
+    if (audio_output_channels <= 2) {
+        faac_conf->downMatrix = 1;
+        faacDecSetConfiguration(faac_hdec, faac_conf);
+    }
+    
     /*int i;
     for(i = 0; i < sh_audio->codecdata_len; i++)
       printf("codecdata_dump %d: 0x%02X\n", i, sh_audio->codecdata[i]);*/
@@ -145,6 +153,7 @@
     mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: Decoder init done (%dBytes)!\n", sh->a_in_buffer_len); // XXX: remove or move to debug!
     mp_msg(MSGT_DECAUDIO,MSGL_V,"FAAD: Negotiated samplerate: %dHz  channels: %d\n", faac_samplerate, faac_channels);
     sh->channels = faac_channels;
+    if (audio_output_channels <= 2) sh->channels = faac_channels > 1 ? 2 : 1;
     sh->samplerate = faac_samplerate;
     sh->samplesize=2;
     //sh->o_bps = sh->samplesize*faac_channels*faac_samplerate;
@@ -245,8 +254,8 @@
     int buflen=ds_get_packet(sh->ds, &bufptr);
     if(buflen<=0) break;
     faac_sample_buffer = faacDecDecode(faac_hdec, &faac_finfo, bufptr, buflen);
-//    printf("FAAC decoded %d of %d  (err: %d)  \n",faac_finfo.bytesconsumed,buflen,faac_finfo.error);
   }
+  //for (j=0;j<faac_finfo.channels;j++) printf("%d:%d\n", j, faac_finfo.channel_position[j]);
   
     if(faac_finfo.error > 0) {
       mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: Failed to decode frame: %s \n",




More information about the MPlayer-cvslog mailing list