summaryrefslogtreecommitdiff
path: root/src/libfaad
diff options
context:
space:
mode:
authorMatthias Dahl <ml_xine@mortal-soul.de>2008-11-07 14:00:17 +0000
committerMatthias Dahl <ml_xine@mortal-soul.de>2008-11-07 14:00:17 +0000
commitf2b3546e6dd920f2bb737f270adf78e04f5c7df6 (patch)
tree78a8eb416aac7d5bd95abb3e88fe35ea95c68537 /src/libfaad
parent0b674723578edf84ba9823927c89034b0630a7f8 (diff)
downloadxine-lib-f2b3546e6dd920f2bb737f270adf78e04f5c7df6.tar.gz
xine-lib-f2b3546e6dd920f2bb737f270adf78e04f5c7df6.tar.bz2
aac channel ordering for multi-channel audio
Date: Sun, 28 Sep 2008 20:17:54 +0200 The channel order of aac 5.1 audio is wrong during playback. IIRC, the internal channels order for this kind of streams is the same as dts: dts output is reordered according to alsa specs (and ac3 5.1 also works), but aac is not and - for instance - front center is send to front left. The audio channels configuration table should be something like this ## --------------------- ## | Config: 5.1 Ch | ## ---- ---------------- -------------- -------------- ## | Ch | AAC/DTS | ALSA | AC3 | ## ---- ---------------- --------------- -------------- ## | 00 | Center front | Left front | Left front | ## | 01 | Left front | Right front | Center | ## | 02 | Right front | Left back | Right front | ## | 03 | Left back | Right back | Left back | ## | 04 | Right back | Center | Right back | ## | 05 | LFE | LFE | LFE | ## ---- ---------------- --------------- --------------
Diffstat (limited to 'src/libfaad')
-rw-r--r--src/libfaad/xine_faad_decoder.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/libfaad/xine_faad_decoder.c b/src/libfaad/xine_faad_decoder.c
index ae71af155..9c657610e 100644
--- a/src/libfaad/xine_faad_decoder.c
+++ b/src/libfaad/xine_faad_decoder.c
@@ -275,7 +275,32 @@ static void faad_decode_audio ( faad_decoder_t *this, int end_frame ) {
lprintf("decoded %d/%d output %ld\n",
used, this->size, this->faac_finfo.samples );
-
+
+ /* Performing necessary channel reordering because aac uses a different
+ * layout than alsa:
+ *
+ * aac 5.1 channel layout: c l r ls rs lfe
+ * alsa 5.1 channel layout: l r ls rs c lfe
+ *
+ * Reordering is only necessary for 5.0 and above. Currently only 5.0
+ * and 5.1 is being taken care of, the rest will stay in the wrong order
+ * for now.
+ *
+ * WARNING: the following needs a output format of 16 bits per sample.
+ * TODO: - reorder while copying (in the while() loop) and optimizing
+ */
+ if(this->num_channels == 5 || this->num_channels == 6)
+ {
+ int i = 0;
+ uint16_t* buf = (uint16_t*)(sample_buffer);
+
+ for(; i < this->faac_finfo.samples; i += this->num_channels) {
+ uint16_t center = buf[i];
+ *((uint64_t*)(buf + i)) = *((uint64_t*)(buf + i + 1));
+ buf[i + 4] = center;
+ }
+ }
+
while( decoded ) {
audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);