summaryrefslogtreecommitdiffstats
path: root/contrib/ffmpeg/A02-channel-layout-order.patch
blob: ce57af03811ab8f4e4dff342a5d07d56de6fc4a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 3852f6e..c7217c8 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -28,6 +28,7 @@
 
 #include "avcodec.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/channel_layout.h"
 #include "get_bits.h"
 #include "internal.h"
 #include "libavutil/crc.h"
@@ -435,6 +436,28 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
         s->ch_assign[ch_assign] = ch;
     }
 
+    if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD) {
+        switch (m->avctx->channel_layout) {
+        case AV_CH_LAYOUT_6POINT1:
+        case (AV_CH_LAYOUT_6POINT1|AV_CH_TOP_CENTER):
+        case (AV_CH_LAYOUT_6POINT1|AV_CH_TOP_FRONT_CENTER):
+        {
+            int i = s->ch_assign[6];
+            s->ch_assign[6] = s->ch_assign[5];
+            s->ch_assign[5] = s->ch_assign[4];
+            s->ch_assign[4] = i;
+            break;
+        }
+        case AV_CH_LAYOUT_7POINT1:
+        case (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER):
+            FFSWAP(int, s->ch_assign[4], s->ch_assign[6]);
+            FFSWAP(int, s->ch_assign[5], s->ch_assign[7]);
+            break;
+        default:
+            break;
+        }
+    }
+
     checksum = ff_mlp_restart_checksum(buf, get_bits_count(gbp) - start_count);
 
     if (checksum != get_bits(gbp, 8))