summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/ad_faad.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmpcodecs/ad_faad.c')
-rw-r--r--libmpcodecs/ad_faad.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libmpcodecs/ad_faad.c b/libmpcodecs/ad_faad.c
index 91253aba6c..efc91ea7e3 100644
--- a/libmpcodecs/ad_faad.c
+++ b/libmpcodecs/ad_faad.c
@@ -66,6 +66,7 @@ static int aac_probe(unsigned char *buffer, int len)
return pos;
}
+extern int audio_output_channels;
static int init(sh_audio_t *sh)
{
unsigned long faac_samplerate;
@@ -90,6 +91,7 @@ static int init(sh_audio_t *sh)
/* 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 @@ static int init(sh_audio_t *sh)
// 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 @@ static int init(sh_audio_t *sh)
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 @@ static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen)
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",