annotate libaf/reorder_ch.c @ 35975:16f60d1a3b7f

Rename extern GTK widget fsFileSelect FileSelector.
author ib
date Thu, 28 Mar 2013 16:35:59 +0000
parents 91d62f0e2952
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1 /*
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
2 * common functions for reordering audio channels
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
3 *
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
4 * Copyright (C) 2007 Ulion <ulion A gmail P com>
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
5 *
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
6 * This file is part of MPlayer.
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
7 *
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
8 * MPlayer is free software; you can redistribute it and/or modify
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
11 * (at your option) any later version.
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
12 *
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
13 * MPlayer is distributed in the hope that it will be useful,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
16 * GNU General Public License for more details.
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
17 *
26740
b3a38b361fef Use standard license headers with standard formatting.
diego
parents: 26132
diff changeset
18 * You should have received a copy of the GNU General Public License along
b3a38b361fef Use standard license headers with standard formatting.
diego
parents: 26132
diff changeset
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
b3a38b361fef Use standard license headers with standard formatting.
diego
parents: 26132
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
21 */
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
22
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
23 #include <stdio.h>
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
24 #include <stdlib.h>
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
25 #include <inttypes.h>
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
26 #include <string.h>
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
27 #include "libvo/fastmemcpy.h"
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
28
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
29 #include "reorder_ch.h"
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
30
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
31 #ifdef TEST
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
32 #define mp_msg(mod,lev, fmt, args... ) printf( fmt, ## args )
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
33 #else
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
34 #include "mp_msg.h"
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
35 #endif
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
36
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
37
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
38 #define REORDER_COPY_5(DEST,SRC,SAMPLES,S0,S1,S2,S3,S4) \
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
39 for (i = 0; i < SAMPLES; i += 5) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
40 DEST[i] = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
41 DEST[i+1] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
42 DEST[i+2] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
43 DEST[i+3] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
44 DEST[i+4] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
45 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
46
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
47 static int reorder_copy_5ch(void *dest, const void *src,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
48 unsigned int samples, unsigned int samplesize,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
49 int s0, int s1, int s2, int s3, int s4)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
50 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
51 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
52 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
53 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
54 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
55 int8_t *dest_8 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
56 const int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
57 REORDER_COPY_5(dest_8,src_8,samples,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
58 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
59 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
60 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
61 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
62 int16_t *dest_16 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
63 const int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
64 REORDER_COPY_5(dest_16,src_16,samples,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
65 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
66 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
67 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
68 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
69 int8_t *dest_8 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
70 const int8_t *src_8 = src;
29929
49c6bb4f97aa Fix mangling of 24-bit audio during channel reorder.
tack
parents: 29826
diff changeset
71 for (i = 0; i < samples * 3; i += 15) {
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
72 dest_8[i] = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
73 dest_8[i+1] = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
74 dest_8[i+2] = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
75 dest_8[i+3] = src_8[i+s1*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
76 dest_8[i+4] = src_8[i+s1*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
77 dest_8[i+5] = src_8[i+s1*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
78 dest_8[i+6] = src_8[i+s2*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
79 dest_8[i+7] = src_8[i+s2*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
80 dest_8[i+8] = src_8[i+s2*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
81 dest_8[i+9] = src_8[i+s3*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
82 dest_8[i+10] = src_8[i+s3*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
83 dest_8[i+11] = src_8[i+s3*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
84 dest_8[i+12] = src_8[i+s4*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
85 dest_8[i+13] = src_8[i+s4*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
86 dest_8[i+14] = src_8[i+s4*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
87 }
29499
e8072b90858e Fix channel reordering when using 24-bit samples by adding breaks to cases
tack
parents: 29491
diff changeset
88 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
89 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
90 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
91 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
92 int32_t *dest_32 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
93 const int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
94 REORDER_COPY_5(dest_32,src_32,samples,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
95 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
96 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
97 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
98 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
99 int64_t *dest_64 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
100 const int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
101 REORDER_COPY_5(dest_64,src_64,samples,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
102 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
103 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
104 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
105 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
106 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
107 "report this error on the MPlayer mailing list.\n",samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
108 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
109 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
110 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
111 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
112
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
113 #define REORDER_COPY_6(DEST,SRC,SAMPLES,S0,S1,S2,S3,S4,S5) \
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
114 for (i = 0; i < SAMPLES; i += 6) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
115 DEST[i] = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
116 DEST[i+1] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
117 DEST[i+2] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
118 DEST[i+3] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
119 DEST[i+4] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
120 DEST[i+5] = SRC[i+S5];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
121 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
122
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
123 static int reorder_copy_6ch(void *dest, const void *src,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
124 unsigned int samples, uint8_t samplesize,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
125 int s0, int s1, int s2, int s3, int s4, int s5)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
126 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
127 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
128 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
129 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
130 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
131 int8_t *dest_8 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
132 const int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
133 REORDER_COPY_6(dest_8,src_8,samples,s0,s1,s2,s3,s4,s5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
134 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
135 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
136 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
137 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
138 int16_t *dest_16 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
139 const int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
140 REORDER_COPY_6(dest_16,src_16,samples,s0,s1,s2,s3,s4,s5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
141 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
142 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
143 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
144 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
145 int8_t *dest_8 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
146 const int8_t *src_8 = src;
29929
49c6bb4f97aa Fix mangling of 24-bit audio during channel reorder.
tack
parents: 29826
diff changeset
147 for (i = 0; i < samples * 3; i += 18) {
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
148 dest_8[i] = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
149 dest_8[i+1] = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
150 dest_8[i+2] = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
151 dest_8[i+3] = src_8[i+s1*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
152 dest_8[i+4] = src_8[i+s1*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
153 dest_8[i+5] = src_8[i+s1*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
154 dest_8[i+6] = src_8[i+s2*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
155 dest_8[i+7] = src_8[i+s2*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
156 dest_8[i+8] = src_8[i+s2*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
157 dest_8[i+9] = src_8[i+s3*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
158 dest_8[i+10] = src_8[i+s3*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
159 dest_8[i+11] = src_8[i+s3*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
160 dest_8[i+12] = src_8[i+s4*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
161 dest_8[i+13] = src_8[i+s4*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
162 dest_8[i+14] = src_8[i+s4*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
163 dest_8[i+15] = src_8[i+s5*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
164 dest_8[i+16] = src_8[i+s5*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
165 dest_8[i+17] = src_8[i+s5*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
166 }
29499
e8072b90858e Fix channel reordering when using 24-bit samples by adding breaks to cases
tack
parents: 29491
diff changeset
167 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
168 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
169 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
170 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
171 int32_t *dest_32 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
172 const int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
173 REORDER_COPY_6(dest_32,src_32,samples,s0,s1,s2,s3,s4,s5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
174 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
175 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
176 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
177 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
178 int64_t *dest_64 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
179 const int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
180 REORDER_COPY_6(dest_64,src_64,samples,s0,s1,s2,s3,s4,s5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
181 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
182 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
183 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
184 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
185 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
186 "report this error on the MPlayer mailing list.\n",samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
187 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
188 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
189 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
190 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
191
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
192 #define REORDER_COPY_8(DEST,SRC,SAMPLES,S0,S1,S2,S3,S4,S5,S6,S7) \
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
193 for (i = 0; i < SAMPLES; i += 8) {\
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
194 DEST[i] = SRC[i+S0];\
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
195 DEST[i+1] = SRC[i+S1];\
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
196 DEST[i+2] = SRC[i+S2];\
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
197 DEST[i+3] = SRC[i+S3];\
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
198 DEST[i+4] = SRC[i+S4];\
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
199 DEST[i+5] = SRC[i+S5];\
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
200 DEST[i+6] = SRC[i+S6];\
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
201 DEST[i+7] = SRC[i+S7];\
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
202 }
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
203
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
204 static int reorder_copy_8ch(void *dest, const void *src,
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
205 unsigned int samples, uint8_t samplesize,
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
206 int s0, int s1, int s2, int s3,
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
207 int s4, int s5, int s6, int s7)
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
208 {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
209 int i;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
210 switch (samplesize) {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
211 case 1:
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
212 {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
213 int8_t *dest_8 = dest;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
214 const int8_t *src_8 = src;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
215 REORDER_COPY_8(dest_8,src_8,samples,s0,s1,s2,s3,s4,s5,s6,s7);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
216 break;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
217 }
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
218 case 2:
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
219 {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
220 int16_t *dest_16 = dest;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
221 const int16_t *src_16 = src;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
222 REORDER_COPY_8(dest_16,src_16,samples,s0,s1,s2,s3,s4,s5,s6,s7);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
223 break;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
224 }
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
225 case 3:
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
226 {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
227 int8_t *dest_8 = dest;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
228 const int8_t *src_8 = src;
29929
49c6bb4f97aa Fix mangling of 24-bit audio during channel reorder.
tack
parents: 29826
diff changeset
229 for (i = 0; i < samples * 3; i += 24) {
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
230 dest_8[i] = src_8[i+s0*3];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
231 dest_8[i+1] = src_8[i+s0*3+1];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
232 dest_8[i+2] = src_8[i+s0*3+2];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
233 dest_8[i+3] = src_8[i+s1*3];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
234 dest_8[i+4] = src_8[i+s1*3+1];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
235 dest_8[i+5] = src_8[i+s1*3+2];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
236 dest_8[i+6] = src_8[i+s2*3];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
237 dest_8[i+7] = src_8[i+s2*3+1];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
238 dest_8[i+8] = src_8[i+s2*3+2];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
239 dest_8[i+9] = src_8[i+s3*3];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
240 dest_8[i+10] = src_8[i+s3*3+1];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
241 dest_8[i+11] = src_8[i+s3*3+2];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
242 dest_8[i+12] = src_8[i+s4*3];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
243 dest_8[i+13] = src_8[i+s4*3+1];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
244 dest_8[i+14] = src_8[i+s4*3+2];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
245 dest_8[i+15] = src_8[i+s5*3];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
246 dest_8[i+16] = src_8[i+s5*3+1];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
247 dest_8[i+17] = src_8[i+s5*3+2];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
248 dest_8[i+18] = src_8[i+s6*3];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
249 dest_8[i+19] = src_8[i+s6*3+1];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
250 dest_8[i+20] = src_8[i+s6*3+2];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
251 dest_8[i+21] = src_8[i+s7*3];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
252 dest_8[i+22] = src_8[i+s7*3+1];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
253 dest_8[i+23] = src_8[i+s7*3+2];
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
254 }
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
255 break;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
256 }
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
257 case 4:
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
258 {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
259 int32_t *dest_32 = dest;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
260 const int32_t *src_32 = src;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
261 REORDER_COPY_8(dest_32,src_32,samples,s0,s1,s2,s3,s4,s5,s6,s7);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
262 break;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
263 }
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
264 case 8:
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
265 {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
266 int64_t *dest_64 = dest;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
267 const int64_t *src_64 = src;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
268 REORDER_COPY_8(dest_64,src_64,samples,s0,s1,s2,s3,s4,s5,s6,s7);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
269 break;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
270 }
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
271 default:
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
272 mp_msg(MSGT_GLOBAL, MSGL_WARN,
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
273 "[reorder_ch] Unsupported sample size: %d, please "
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
274 "report this error on the MPlayer mailing list.\n",samplesize);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
275 return 0;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
276 }
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
277 return 1;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
278 }
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
279
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
280 void reorder_channel_copy(void *src,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
281 int src_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
282 void *dest,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
283 int dest_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
284 int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
285 int samplesize)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
286 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
287 if (dest_layout==src_layout) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
288 fast_memcpy(dest, src, samples*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
289 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
290 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
291 if (!AF_IS_SAME_CH_NUM(dest_layout,src_layout)) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
292 mp_msg(MSGT_GLOBAL, MSGL_WARN, "[reorder_ch] different channel count "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
293 "between src and dest: %x, %x\n",
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
294 AF_GET_CH_NUM_WITH_LFE(src_layout),
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
295 AF_GET_CH_NUM_WITH_LFE(dest_layout));
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
296 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
297 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
298 switch ((src_layout<<16)|dest_layout) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
299 // AF_CHANNEL_LAYOUT_5_0_A L R C Ls Rs
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
300 // AF_CHANNEL_LAYOUT_5_0_B L R Ls Rs C
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
301 // AF_CHANNEL_LAYOUT_5_0_C L C R Ls Rs
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
302 // AF_CHANNEL_LAYOUT_5_0_D C L R Ls Rs
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
303 case AF_CHANNEL_LAYOUT_5_0_A << 16 | AF_CHANNEL_LAYOUT_5_0_B:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
304 reorder_copy_5ch(dest, src, samples, samplesize, 0, 1, 3, 4, 2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
305 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
306 case AF_CHANNEL_LAYOUT_5_0_A << 16 | AF_CHANNEL_LAYOUT_5_0_C:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
307 reorder_copy_5ch(dest, src, samples, samplesize, 0, 2, 1, 3, 4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
308 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
309 case AF_CHANNEL_LAYOUT_5_0_A << 16 | AF_CHANNEL_LAYOUT_5_0_D:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
310 reorder_copy_5ch(dest, src, samples, samplesize, 2, 0, 1, 3, 4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
311 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
312 case AF_CHANNEL_LAYOUT_5_0_B << 16 | AF_CHANNEL_LAYOUT_5_0_A:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
313 reorder_copy_5ch(dest, src, samples, samplesize, 0, 1, 4, 2, 3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
314 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
315 case AF_CHANNEL_LAYOUT_5_0_B << 16 | AF_CHANNEL_LAYOUT_5_0_C:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
316 reorder_copy_5ch(dest, src, samples, samplesize, 0, 4, 1, 2, 3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
317 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
318 case AF_CHANNEL_LAYOUT_5_0_B << 16 | AF_CHANNEL_LAYOUT_5_0_D:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
319 reorder_copy_5ch(dest, src, samples, samplesize, 4, 0, 1, 2, 3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
320 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
321 case AF_CHANNEL_LAYOUT_5_0_C << 16 | AF_CHANNEL_LAYOUT_5_0_A:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
322 reorder_copy_5ch(dest, src, samples, samplesize, 0, 2, 1, 3, 4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
323 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
324 case AF_CHANNEL_LAYOUT_5_0_C << 16 | AF_CHANNEL_LAYOUT_5_0_B:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
325 reorder_copy_5ch(dest, src, samples, samplesize, 0, 2, 3, 4, 1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
326 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
327 case AF_CHANNEL_LAYOUT_5_0_C << 16 | AF_CHANNEL_LAYOUT_5_0_D:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
328 reorder_copy_5ch(dest, src, samples, samplesize, 1, 0, 2, 3, 4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
329 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
330 case AF_CHANNEL_LAYOUT_5_0_D << 16 | AF_CHANNEL_LAYOUT_5_0_A:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
331 reorder_copy_5ch(dest, src, samples, samplesize, 1, 2, 0, 3, 4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
332 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
333 case AF_CHANNEL_LAYOUT_5_0_D << 16 | AF_CHANNEL_LAYOUT_5_0_B:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
334 reorder_copy_5ch(dest, src, samples, samplesize, 1, 2, 3, 4, 0);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
335 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
336 case AF_CHANNEL_LAYOUT_5_0_D << 16 | AF_CHANNEL_LAYOUT_5_0_C:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
337 reorder_copy_5ch(dest, src, samples, samplesize, 1, 0, 2, 3, 4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
338 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
339 // AF_CHANNEL_LAYOUT_5_1_A L R C LFE Ls Rs
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
340 // AF_CHANNEL_LAYOUT_5_1_B L R Ls Rs C LFE
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
341 // AF_CHANNEL_LAYOUT_5_1_C L C R Ls Rs LFE
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
342 // AF_CHANNEL_LAYOUT_5_1_D C L R Ls Rs LFE
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
343 // AF_CHANNEL_LAYOUT_5_1_E LFE L C R Ls Rs
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
344 case AF_CHANNEL_LAYOUT_5_1_A << 16 | AF_CHANNEL_LAYOUT_5_1_B:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
345 reorder_copy_6ch(dest, src, samples, samplesize, 0, 1, 4, 5, 2, 3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
346 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
347 case AF_CHANNEL_LAYOUT_5_1_A << 16 | AF_CHANNEL_LAYOUT_5_1_C:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
348 reorder_copy_6ch(dest, src, samples, samplesize, 0, 2, 1, 4, 5, 3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
349 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
350 case AF_CHANNEL_LAYOUT_5_1_A << 16 | AF_CHANNEL_LAYOUT_5_1_D:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
351 reorder_copy_6ch(dest, src, samples, samplesize, 2, 0, 1, 4, 5, 3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
352 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
353 case AF_CHANNEL_LAYOUT_5_1_B << 16 | AF_CHANNEL_LAYOUT_5_1_A:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
354 reorder_copy_6ch(dest, src, samples, samplesize, 0, 1, 4, 5, 2, 3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
355 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
356 case AF_CHANNEL_LAYOUT_5_1_B << 16 | AF_CHANNEL_LAYOUT_5_1_C:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
357 reorder_copy_6ch(dest, src, samples, samplesize, 0, 4, 1, 2, 3, 5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
358 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
359 case AF_CHANNEL_LAYOUT_5_1_B << 16 | AF_CHANNEL_LAYOUT_5_1_D:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
360 reorder_copy_6ch(dest, src, samples, samplesize, 4, 0, 1, 2, 3, 5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
361 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
362 case AF_CHANNEL_LAYOUT_5_1_B << 16 | AF_CHANNEL_LAYOUT_5_1_E:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
363 reorder_copy_6ch(dest, src, samples, samplesize, 5, 0, 4, 1, 2, 3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
364 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
365 case AF_CHANNEL_LAYOUT_5_1_C << 16 | AF_CHANNEL_LAYOUT_5_1_A:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
366 reorder_copy_6ch(dest, src, samples, samplesize, 0, 2, 1, 5, 3, 4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
367 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
368 case AF_CHANNEL_LAYOUT_5_1_C << 16 | AF_CHANNEL_LAYOUT_5_1_B:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
369 reorder_copy_6ch(dest, src, samples, samplesize, 0, 2, 3, 4, 1, 5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
370 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
371 case AF_CHANNEL_LAYOUT_5_1_C << 16 | AF_CHANNEL_LAYOUT_5_1_D:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
372 reorder_copy_6ch(dest, src, samples, samplesize, 1, 0, 2, 3, 4, 5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
373 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
374 case AF_CHANNEL_LAYOUT_5_1_D << 16 | AF_CHANNEL_LAYOUT_5_1_A:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
375 reorder_copy_6ch(dest, src, samples, samplesize, 1, 2, 0, 5, 3, 4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
376 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
377 case AF_CHANNEL_LAYOUT_5_1_D << 16 | AF_CHANNEL_LAYOUT_5_1_B:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
378 reorder_copy_6ch(dest, src, samples, samplesize, 1, 2, 3, 4, 0, 5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
379 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
380 case AF_CHANNEL_LAYOUT_5_1_D << 16 | AF_CHANNEL_LAYOUT_5_1_C:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
381 reorder_copy_6ch(dest, src, samples, samplesize, 1, 0, 2, 3, 4, 5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
382 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
383 case AF_CHANNEL_LAYOUT_5_1_E << 16 | AF_CHANNEL_LAYOUT_5_1_B:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
384 reorder_copy_6ch(dest, src, samples, samplesize, 1, 3, 4, 5, 2, 0);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
385 break;
29491
99eda963d27a Fix incorrect channel ordering for lavc audio codecs (specifically ffac3,
tack
parents: 29385
diff changeset
386 case AF_CHANNEL_LAYOUT_5_1_F << 16 | AF_CHANNEL_LAYOUT_5_1_B:
99eda963d27a Fix incorrect channel ordering for lavc audio codecs (specifically ffac3,
tack
parents: 29385
diff changeset
387 reorder_copy_6ch(dest, src, samples, samplesize, 1, 2, 4, 5, 0, 3);
99eda963d27a Fix incorrect channel ordering for lavc audio codecs (specifically ffac3,
tack
parents: 29385
diff changeset
388 break;
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
389 // AF_CHANNEL_LAYOUT_7_1_A L R C LFE Ls Rs Rls Rrs
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
390 // AF_CHANNEL_LAYOUT_7_1_B L R Ls Rs C LFE Rls Rrs
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
391 // AF_CHANNEL_LAYOUT_7_1_D C L R Ls Rs Rls Rrs LFE
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
392 case AF_CHANNEL_LAYOUT_7_1_A << 16 | AF_CHANNEL_LAYOUT_7_1_B:
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
393 case AF_CHANNEL_LAYOUT_7_1_B << 16 | AF_CHANNEL_LAYOUT_7_1_A:
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
394 reorder_copy_8ch(dest, src, samples, samplesize, 0, 1, 4, 5, 2, 3, 6, 7);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
395 break;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
396 case AF_CHANNEL_LAYOUT_7_1_D << 16 | AF_CHANNEL_LAYOUT_7_1_B:
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
397 reorder_copy_8ch(dest, src, samples, samplesize, 1, 2, 3, 4, 0, 7, 5, 6);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
398 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
399 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
400 mp_msg(MSGT_GLOBAL, MSGL_WARN, "[reorder_channel_copy] unsupport "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
401 "from %x to %x, %d * %d\n", src_layout, dest_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
402 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
403 fast_memcpy(dest, src, samples*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
404 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
405 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
406
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
407
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
408 #define REORDER_SELF_SWAP_2(SRC,TMP,SAMPLES,CHNUM,S0,S1) \
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
409 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
410 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
411 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
412 SRC[i+S1] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
413 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
414
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
415 static int reorder_self_2(void *src, unsigned int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
416 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
417 int s0, int s1)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
418 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
419 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
420 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
421 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
422 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
423 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
424 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
425 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
426 REORDER_SELF_SWAP_2(src_8,tmp,samples,6,s0,s1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
427 }
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
428 else if (chnum==8) {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
429 REORDER_SELF_SWAP_2(src_8,tmp,samples,8,s0,s1);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
430 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
431 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
432 REORDER_SELF_SWAP_2(src_8,tmp,samples,5,s0,s1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
433 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
434 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
435 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
436 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
437 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
438 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
439 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
440 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
441 REORDER_SELF_SWAP_2(src_16,tmp,samples,6,s0,s1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
442 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
443 else if (chnum==3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
444 REORDER_SELF_SWAP_2(src_16,tmp,samples,3,s0,s1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
445 }
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
446 else if (chnum==4) {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
447 REORDER_SELF_SWAP_2(src_16,tmp,samples,3,s0,s1);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
448 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
449 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
450 REORDER_SELF_SWAP_2(src_16,tmp,samples,5,s0,s1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
451 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
452 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
453 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
454 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
455 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
456 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
457 int8_t tmp0, tmp1, tmp2;
29929
49c6bb4f97aa Fix mangling of 24-bit audio during channel reorder.
tack
parents: 29826
diff changeset
458 for (i = 0; i < samples * 3; i += chnum * 3) {
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
459 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
460 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
461 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
462 src_8[i+s0*3] = src_8[i+s1*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
463 src_8[i+s0*3+1] = src_8[i+s1*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
464 src_8[i+s0*3+2] = src_8[i+s1*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
465 src_8[i+s1*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
466 src_8[i+s1*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
467 src_8[i+s1*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
468 }
29499
e8072b90858e Fix channel reordering when using 24-bit samples by adding breaks to cases
tack
parents: 29491
diff changeset
469 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
470 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
471 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
472 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
473 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
474 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
475 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
476 REORDER_SELF_SWAP_2(src_32,tmp,samples,6,s0,s1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
477 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
478 else if (chnum==3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
479 REORDER_SELF_SWAP_2(src_32,tmp,samples,3,s0,s1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
480 }
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
481 else if (chnum==4) {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
482 REORDER_SELF_SWAP_2(src_32,tmp,samples,4,s0,s1);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
483 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
484 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
485 REORDER_SELF_SWAP_2(src_32,tmp,samples,5,s0,s1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
486 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
487 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
488 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
489 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
490 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
491 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
492 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
493 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
494 REORDER_SELF_SWAP_2(src_64,tmp,samples,6,s0,s1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
495 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
496 else if (chnum==3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
497 REORDER_SELF_SWAP_2(src_64,tmp,samples,3,s0,s1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
498 }
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
499 else if (chnum==4) {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
500 REORDER_SELF_SWAP_2(src_64,tmp,samples,4,s0,s1);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
501 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
502 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
503 REORDER_SELF_SWAP_2(src_64,tmp,samples,5,s0,s1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
504 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
505 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
506 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
507 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
508 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
509 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
510 "report this error on the MPlayer mailing list.\n",samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
511 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
512 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
513 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
514 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
515
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
516 #define REORDER_SELF_SWAP_3(SRC,TMP,SAMPLES,CHNUM,S0,S1,S2) \
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
517 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
518 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
519 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
520 SRC[i+S1] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
521 SRC[i+S2] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
522 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
523
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
524 static int reorder_self_3(void *src, unsigned int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
525 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
526 int s0, int s1, int s2)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
527 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
528 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
529 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
530 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
531 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
532 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
533 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
534 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
535 REORDER_SELF_SWAP_3(src_8,tmp,samples,6,s0,s1,s2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
536 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
537 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
538 REORDER_SELF_SWAP_3(src_8,tmp,samples,5,s0,s1,s2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
539 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
540 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
541 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
542 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
543 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
544 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
545 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
546 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
547 REORDER_SELF_SWAP_3(src_16,tmp,samples,6,s0,s1,s2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
548 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
549 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
550 REORDER_SELF_SWAP_3(src_16,tmp,samples,5,s0,s1,s2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
551 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
552 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
553 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
554 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
555 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
556 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
557 int8_t tmp0, tmp1, tmp2;
29929
49c6bb4f97aa Fix mangling of 24-bit audio during channel reorder.
tack
parents: 29826
diff changeset
558 for (i = 0; i < samples * 3; i += chnum * 3) {
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
559 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
560 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
561 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
562 src_8[i+s0*3] = src_8[i+s1*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
563 src_8[i+s0*3+1] = src_8[i+s1*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
564 src_8[i+s0*3+2] = src_8[i+s1*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
565 src_8[i+s1*3] = src_8[i+s2*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
566 src_8[i+s1*3+1] = src_8[i+s2*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
567 src_8[i+s1*3+2] = src_8[i+s2*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
568 src_8[i+s2*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
569 src_8[i+s2*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
570 src_8[i+s2*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
571 }
29385
f9ae25067fe0 Fix 24bit audio playback.
iive
parents: 27700
diff changeset
572 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
573 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
574 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
575 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
576 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
577 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
578 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
579 REORDER_SELF_SWAP_3(src_32,tmp,samples,6,s0,s1,s2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
580 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
581 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
582 REORDER_SELF_SWAP_3(src_32,tmp,samples,5,s0,s1,s2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
583 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
584 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
585 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
586 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
587 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
588 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
589 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
590 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
591 REORDER_SELF_SWAP_3(src_64,tmp,samples,6,s0,s1,s2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
592 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
593 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
594 REORDER_SELF_SWAP_3(src_64,tmp,samples,5,s0,s1,s2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
595 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
596 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
597 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
598 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
599 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
600 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
601 "report this error on the MPlayer mailing list.\n",samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
602 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
603 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
604 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
605 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
606
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
607 #define REORDER_SELF_SWAP_4_STEP_1(SRC,TMP,SAMPLES,CHNUM,S0,S1,S2,S3) \
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
608 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
609 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
610 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
611 SRC[i+S1] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
612 SRC[i+S2] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
613 SRC[i+S3] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
614 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
615
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
616 static int reorder_self_4_step_1(void *src, unsigned int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
617 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
618 int s0, int s1, int s2, int s3)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
619 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
620 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
621 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
622 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
623 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
624 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
625 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
626 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
627 REORDER_SELF_SWAP_4_STEP_1(src_8,tmp,samples,6,s0,s1,s2,s3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
628 }
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
629 else if (chnum==8) {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
630 REORDER_SELF_SWAP_4_STEP_1(src_8,tmp,samples,8,s0,s1,s2,s3);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
631 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
632 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
633 REORDER_SELF_SWAP_4_STEP_1(src_8,tmp,samples,5,s0,s1,s2,s3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
634 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
635 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
636 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
637 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
638 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
639 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
640 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
641 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
642 REORDER_SELF_SWAP_4_STEP_1(src_16,tmp,samples,6,s0,s1,s2,s3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
643 }
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
644 else if (chnum==8) {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
645 REORDER_SELF_SWAP_4_STEP_1(src_16,tmp,samples,8,s0,s1,s2,s3);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
646 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
647 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
648 REORDER_SELF_SWAP_4_STEP_1(src_16,tmp,samples,5,s0,s1,s2,s3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
649 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
650 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
651 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
652 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
653 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
654 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
655 int8_t tmp0, tmp1, tmp2;
29929
49c6bb4f97aa Fix mangling of 24-bit audio during channel reorder.
tack
parents: 29826
diff changeset
656 for (i = 0; i < samples * 3; i += chnum * 3) {
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
657 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
658 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
659 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
660 src_8[i+s0*3] = src_8[i+s1*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
661 src_8[i+s0*3+1] = src_8[i+s1*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
662 src_8[i+s0*3+2] = src_8[i+s1*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
663 src_8[i+s1*3] = src_8[i+s2*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
664 src_8[i+s1*3+1] = src_8[i+s2*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
665 src_8[i+s1*3+2] = src_8[i+s2*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
666 src_8[i+s2*3] = src_8[i+s3*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
667 src_8[i+s2*3+1] = src_8[i+s3*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
668 src_8[i+s2*3+2] = src_8[i+s3*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
669 src_8[i+s3*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
670 src_8[i+s3*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
671 src_8[i+s3*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
672 }
29385
f9ae25067fe0 Fix 24bit audio playback.
iive
parents: 27700
diff changeset
673 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
674 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
675 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
676 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
677 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
678 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
679 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
680 REORDER_SELF_SWAP_4_STEP_1(src_32,tmp,samples,6,s0,s1,s2,s3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
681 }
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
682 else if (chnum==8) {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
683 REORDER_SELF_SWAP_4_STEP_1(src_32,tmp,samples,8,s0,s1,s2,s3);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
684 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
685 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
686 REORDER_SELF_SWAP_4_STEP_1(src_32,tmp,samples,5,s0,s1,s2,s3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
687 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
688 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
689 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
690 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
691 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
692 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
693 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
694 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
695 REORDER_SELF_SWAP_4_STEP_1(src_64,tmp,samples,6,s0,s1,s2,s3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
696 }
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
697 else if (chnum==8) {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
698 REORDER_SELF_SWAP_4_STEP_1(src_64,tmp,samples,8,s0,s1,s2,s3);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
699 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
700 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
701 REORDER_SELF_SWAP_4_STEP_1(src_64,tmp,samples,5,s0,s1,s2,s3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
702 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
703 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
704 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
705 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
706 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
707 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
708 "report this error on the MPlayer mailing list.\n",samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
709 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
710 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
711 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
712 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
713
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
714 #define REORDER_SELF_SWAP_4_STEP_2(SRC,TMP,SAMPLES,CHNUM,S0,S1,S2,S3) \
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
715 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
716 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
717 SRC[i+S0] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
718 SRC[i+S2] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
719 TMP = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
720 SRC[i+S1] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
721 SRC[i+S3] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
722 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
723
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
724 static int reorder_self_4_step_2(void *src, unsigned int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
725 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
726 int s0, int s1, int s2, int s3)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
727 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
728 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
729 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
730 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
731 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
732 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
733 int8_t tmp0, tmp1, tmp2;
29929
49c6bb4f97aa Fix mangling of 24-bit audio during channel reorder.
tack
parents: 29826
diff changeset
734 for (i = 0; i < samples * 3; i += chnum * 3) {
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
735 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
736 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
737 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
738 src_8[i+s0*3] = src_8[i+s2*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
739 src_8[i+s0*3+1] = src_8[i+s2*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
740 src_8[i+s0*3+2] = src_8[i+s2*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
741 src_8[i+s2*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
742 src_8[i+s2*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
743 src_8[i+s2*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
744 tmp0 = src_8[i+s1*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
745 tmp1 = src_8[i+s1*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
746 tmp2 = src_8[i+s1*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
747 src_8[i+s1*3] = src_8[i+s3*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
748 src_8[i+s1*3+1] = src_8[i+s3*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
749 src_8[i+s1*3+2] = src_8[i+s3*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
750 src_8[i+s3*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
751 src_8[i+s3*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
752 src_8[i+s3*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
753 }
29499
e8072b90858e Fix channel reordering when using 24-bit samples by adding breaks to cases
tack
parents: 29491
diff changeset
754 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
755 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
756 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
757 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
758 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
759 "report this error on the MPlayer mailing list.\n",samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
760 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
761 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
762 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
763 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
764
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
765 #define REORDER_SELF_SWAP_5_STEP_1(SRC,TMP,SAMPLES,CHNUM,S0,S1,S2,S3,S4) \
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
766 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
767 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
768 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
769 SRC[i+S1] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
770 SRC[i+S2] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
771 SRC[i+S3] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
772 SRC[i+S4] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
773 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
774
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
775 static int reorder_self_5_step_1(void *src, unsigned int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
776 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
777 int s0, int s1, int s2, int s3, int s4)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
778 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
779 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
780 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
781 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
782 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
783 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
784 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
785 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
786 REORDER_SELF_SWAP_5_STEP_1(src_8,tmp,samples,6,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
787 }
34789
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
788 else if (chnum==8) {
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
789 REORDER_SELF_SWAP_5_STEP_1(src_8,tmp,samples,8,s0,s1,s2,s3,s4);
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
790 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
791 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
792 REORDER_SELF_SWAP_5_STEP_1(src_8,tmp,samples,5,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
793 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
794 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
795 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
796 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
797 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
798 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
799 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
800 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
801 REORDER_SELF_SWAP_5_STEP_1(src_16,tmp,samples,6,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
802 }
34789
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
803 else if (chnum==8) {
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
804 REORDER_SELF_SWAP_5_STEP_1(src_16,tmp,samples,8,s0,s1,s2,s3,s4);
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
805 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
806 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
807 REORDER_SELF_SWAP_5_STEP_1(src_16,tmp,samples,5,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
808 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
809 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
810 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
811 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
812 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
813 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
814 int8_t tmp0, tmp1, tmp2;
29929
49c6bb4f97aa Fix mangling of 24-bit audio during channel reorder.
tack
parents: 29826
diff changeset
815 for (i = 0; i < samples * 3; i += chnum * 3) {
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
816 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
817 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
818 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
819 src_8[i+s0*3] = src_8[i+s1*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
820 src_8[i+s0*3+1] = src_8[i+s1*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
821 src_8[i+s0*3+2] = src_8[i+s1*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
822 src_8[i+s1*3] = src_8[i+s2*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
823 src_8[i+s1*3+1] = src_8[i+s2*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
824 src_8[i+s1*3+2] = src_8[i+s2*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
825 src_8[i+s2*3] = src_8[i+s3*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
826 src_8[i+s2*3+1] = src_8[i+s3*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
827 src_8[i+s2*3+2] = src_8[i+s3*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
828 src_8[i+s3*3] = src_8[i+s4*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
829 src_8[i+s3*3+1] = src_8[i+s4*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
830 src_8[i+s3*3+2] = src_8[i+s4*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
831 src_8[i+s4*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
832 src_8[i+s4*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
833 src_8[i+s4*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
834 }
29385
f9ae25067fe0 Fix 24bit audio playback.
iive
parents: 27700
diff changeset
835 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
836 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
837 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
838 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
839 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
840 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
841 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
842 REORDER_SELF_SWAP_5_STEP_1(src_32,tmp,samples,6,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
843 }
34789
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
844 else if (chnum==8) {
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
845 REORDER_SELF_SWAP_5_STEP_1(src_32,tmp,samples,8,s0,s1,s2,s3,s4);
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
846 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
847 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
848 REORDER_SELF_SWAP_5_STEP_1(src_32,tmp,samples,5,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
849 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
850 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
851 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
852 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
853 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
854 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
855 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
856 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
857 REORDER_SELF_SWAP_5_STEP_1(src_64,tmp,samples,6,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
858 }
34789
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
859 else if (chnum==8) {
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
860 REORDER_SELF_SWAP_5_STEP_1(src_64,tmp,samples,8,s0,s1,s2,s3,s4);
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
861 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
862 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
863 REORDER_SELF_SWAP_5_STEP_1(src_64,tmp,samples,5,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
864 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
865 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
866 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
867 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
868 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
869 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
870 "report this error on the MPlayer mailing list.\n",samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
871 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
872 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
873 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
874 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
875
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
876 #define REORDER_SELF_SWAP_2_3(SRC,TMP,SAMPLES,CHNUM,S0,S1,S2,S3,S4) \
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
877 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
878 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
879 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
880 SRC[i+S1] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
881 TMP = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
882 SRC[i+S2] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
883 SRC[i+S3] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
884 SRC[i+S4] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
885 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
886
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
887 static int reorder_self_2_3(void *src, unsigned int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
888 unsigned int samplesize,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
889 int s0, int s1, int s2, int s3, int s4)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
890 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
891 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
892 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
893 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
894 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
895 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
896 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
897 REORDER_SELF_SWAP_2_3(src_8,tmp,samples,6,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
898 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
899 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
900 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
901 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
902 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
903 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
904 REORDER_SELF_SWAP_2_3(src_16,tmp,samples,6,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
905 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
906 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
907 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
908 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
909 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
910 int8_t tmp0, tmp1, tmp2;
29929
49c6bb4f97aa Fix mangling of 24-bit audio during channel reorder.
tack
parents: 29826
diff changeset
911 for (i = 0; i < samples * 3; i += 18) {
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
912 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
913 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
914 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
915 src_8[i+s0*3] = src_8[i+s1*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
916 src_8[i+s0*3+1] = src_8[i+s1*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
917 src_8[i+s0*3+2] = src_8[i+s1*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
918 src_8[i+s1*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
919 src_8[i+s1*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
920 src_8[i+s1*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
921 tmp0 = src_8[i+s2*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
922 tmp1 = src_8[i+s2*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
923 tmp2 = src_8[i+s2*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
924 src_8[i+s2*3] = src_8[i+s3*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
925 src_8[i+s2*3+1] = src_8[i+s3*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
926 src_8[i+s2*3+2] = src_8[i+s3*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
927 src_8[i+s3*3] = src_8[i+s4*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
928 src_8[i+s3*3+1] = src_8[i+s4*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
929 src_8[i+s3*3+2] = src_8[i+s4*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
930 src_8[i+s4*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
931 src_8[i+s4*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
932 src_8[i+s4*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
933 }
29385
f9ae25067fe0 Fix 24bit audio playback.
iive
parents: 27700
diff changeset
934 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
935 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
936 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
937 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
938 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
939 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
940 REORDER_SELF_SWAP_2_3(src_32,tmp,samples,6,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
941 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
942 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
943 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
944 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
945 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
946 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
947 REORDER_SELF_SWAP_2_3(src_64,tmp,samples,6,s0,s1,s2,s3,s4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
948 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
949 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
950 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
951 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
952 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
953 "report this error on the MPlayer mailing list.\n",samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
954 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
955 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
956 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
957 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
958
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
959 #define REORDER_SELF_SWAP_3_3(SRC,TMP,SAMPLES,CHNUM,S0,S1,S2,S3,S4,S5) \
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
960 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
961 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
962 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
963 SRC[i+S1] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
964 SRC[i+S2] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
965 TMP = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
966 SRC[i+S3] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
967 SRC[i+S4] = SRC[i+S5];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
968 SRC[i+S5] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
969 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
970
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
971 static int reorder_self_3_3(void *src, unsigned int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
972 unsigned int samplesize,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
973 int s0, int s1, int s2, int s3, int s4, int s5)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
974 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
975 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
976 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
977 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
978 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
979 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
980 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
981 REORDER_SELF_SWAP_3_3(src_8,tmp,samples,6,s0,s1,s2,s3,s4,s5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
982 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
983 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
984 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
985 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
986 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
987 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
988 REORDER_SELF_SWAP_3_3(src_16,tmp,samples,6,s0,s1,s2,s3,s4,s5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
989 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
990 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
991 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
992 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
993 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
994 int8_t tmp0, tmp1, tmp2;
29929
49c6bb4f97aa Fix mangling of 24-bit audio during channel reorder.
tack
parents: 29826
diff changeset
995 for (i = 0; i < samples * 3; i += 18) {
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
996 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
997 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
998 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
999 src_8[i+s0*3] = src_8[i+s1*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1000 src_8[i+s0*3+1] = src_8[i+s1*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1001 src_8[i+s0*3+2] = src_8[i+s1*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1002 src_8[i+s1*3] = src_8[i+s2*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1003 src_8[i+s1*3+1] = src_8[i+s2*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1004 src_8[i+s1*3+2] = src_8[i+s2*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1005 src_8[i+s2*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1006 src_8[i+s2*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1007 src_8[i+s2*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1008 tmp0 = src_8[i+s3*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1009 tmp1 = src_8[i+s3*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1010 tmp2 = src_8[i+s3*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1011 src_8[i+s3*3] = src_8[i+s4*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1012 src_8[i+s3*3+1] = src_8[i+s4*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1013 src_8[i+s3*3+2] = src_8[i+s4*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1014 src_8[i+s4*3] = src_8[i+s5*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1015 src_8[i+s4*3+1] = src_8[i+s5*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1016 src_8[i+s4*3+2] = src_8[i+s5*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1017 src_8[i+s5*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1018 src_8[i+s5*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1019 src_8[i+s5*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1020 }
29385
f9ae25067fe0 Fix 24bit audio playback.
iive
parents: 27700
diff changeset
1021 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1022 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1023 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1024 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1025 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1026 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1027 REORDER_SELF_SWAP_3_3(src_32,tmp,samples,6,s0,s1,s2,s3,s4,s5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1028 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1029 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1030 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1031 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1032 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1033 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1034 REORDER_SELF_SWAP_3_3(src_64,tmp,samples,6,s0,s1,s2,s3,s4,s5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1035 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1036 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1037 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1038 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1039 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1040 "report this error on the MPlayer mailing list.\n",samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1041 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1042 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1043 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1044 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1045
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1046 #define REORDER_SELF_SWAP_2_4(SRC,TMP,SAMPLES,CHNUM,S0,S1,S2,S3,S4,S5) \
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1047 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1048 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1049 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1050 SRC[i+S1] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1051 TMP = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1052 SRC[i+S2] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1053 SRC[i+S3] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1054 SRC[i+S4] = SRC[i+S5];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1055 SRC[i+S5] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1056 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1057
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1058 static int reorder_self_2_4(void *src, unsigned int samples,
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1059 unsigned int samplesize, int chnum,
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1060 int s0, int s1, int s2, int s3, int s4, int s5)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1061 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1062 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1063 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1064 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1065 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1066 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1067 int8_t tmp;
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1068 if (chnum==6) {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1069 REORDER_SELF_SWAP_2_4(src_8,tmp,samples,6,s0,s1,s2,s3,s4,s5);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1070 } else {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1071 REORDER_SELF_SWAP_2_4(src_8,tmp,samples,8,s0,s1,s2,s3,s4,s5);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1072 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1073 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1074 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1075 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1076 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1077 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1078 int16_t tmp;
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1079 if (chnum==6) {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1080 REORDER_SELF_SWAP_2_4(src_16,tmp,samples,6,s0,s1,s2,s3,s4,s5);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1081 } else {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1082 REORDER_SELF_SWAP_2_4(src_16,tmp,samples,8,s0,s1,s2,s3,s4,s5);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1083 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1084 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1085 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1086 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1087 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1088 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1089 int8_t tmp0, tmp1, tmp2;
29929
49c6bb4f97aa Fix mangling of 24-bit audio during channel reorder.
tack
parents: 29826
diff changeset
1090 for (i = 0; i < samples * 3; i += chnum * 3) {
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1091 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1092 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1093 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1094 src_8[i+s0*3] = src_8[i+s1*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1095 src_8[i+s0*3+1] = src_8[i+s1*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1096 src_8[i+s0*3+2] = src_8[i+s1*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1097 src_8[i+s1*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1098 src_8[i+s1*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1099 src_8[i+s1*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1100 tmp0 = src_8[i+s2*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1101 tmp1 = src_8[i+s2*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1102 tmp2 = src_8[i+s2*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1103 src_8[i+s2*3] = src_8[i+s3*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1104 src_8[i+s2*3+1] = src_8[i+s3*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1105 src_8[i+s2*3+2] = src_8[i+s3*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1106 src_8[i+s3*3] = src_8[i+s4*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1107 src_8[i+s3*3+1] = src_8[i+s4*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1108 src_8[i+s3*3+2] = src_8[i+s4*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1109 src_8[i+s4*3] = src_8[i+s5*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1110 src_8[i+s4*3+1] = src_8[i+s5*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1111 src_8[i+s4*3+2] = src_8[i+s5*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1112 src_8[i+s5*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1113 src_8[i+s5*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1114 src_8[i+s5*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1115 }
29385
f9ae25067fe0 Fix 24bit audio playback.
iive
parents: 27700
diff changeset
1116 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1117 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1118 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1119 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1120 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1121 int32_t tmp;
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1122 if (chnum==6) {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1123 REORDER_SELF_SWAP_2_4(src_32,tmp,samples,6,s0,s1,s2,s3,s4,s5);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1124 } else {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1125 REORDER_SELF_SWAP_2_4(src_32,tmp,samples,8,s0,s1,s2,s3,s4,s5);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1126 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1127 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1128 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1129 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1130 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1131 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1132 int64_t tmp;
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1133 if (chnum==6) {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1134 REORDER_SELF_SWAP_2_4(src_64,tmp,samples,6,s0,s1,s2,s3,s4,s5);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1135 } else {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1136 REORDER_SELF_SWAP_2_4(src_64,tmp,samples,8,s0,s1,s2,s3,s4,s5);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1137 }
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1138 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1139 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1140 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1141 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1142 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1143 "report this error on the MPlayer mailing list.\n",samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1144 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1145 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1146 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1147 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1148
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1149 void reorder_channel(void *src,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1150 int src_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1151 int dest_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1152 int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1153 int samplesize)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1154 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1155 if (dest_layout==src_layout)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1156 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1157 if (!AF_IS_SAME_CH_NUM(dest_layout,src_layout)) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1158 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1159 "[reorder_channel] different channel count "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1160 "between current and target: %x, %x\n",
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1161 AF_GET_CH_NUM_WITH_LFE(src_layout),
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1162 AF_GET_CH_NUM_WITH_LFE(dest_layout));
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1163 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1164 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1165 switch ((src_layout<<16)|dest_layout) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1166 // AF_CHANNEL_LAYOUT_5_0_A L R C Ls Rs
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1167 // AF_CHANNEL_LAYOUT_5_0_B L R Ls Rs C
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1168 // AF_CHANNEL_LAYOUT_5_0_C L C R Ls Rs
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1169 // AF_CHANNEL_LAYOUT_5_0_D C L R Ls Rs
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1170 case AF_CHANNEL_LAYOUT_5_0_A << 16 | AF_CHANNEL_LAYOUT_5_0_B:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1171 reorder_self_3(src, samples, samplesize, 5, 2, 3, 4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1172 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1173 case AF_CHANNEL_LAYOUT_5_0_A << 16 | AF_CHANNEL_LAYOUT_5_0_C:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1174 reorder_self_2(src, samples, samplesize, 5, 1, 2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1175 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1176 case AF_CHANNEL_LAYOUT_5_0_A << 16 | AF_CHANNEL_LAYOUT_5_0_D:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1177 reorder_self_3(src, samples, samplesize, 5, 2, 1, 0);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1178 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1179 case AF_CHANNEL_LAYOUT_5_0_B << 16 | AF_CHANNEL_LAYOUT_5_0_A:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1180 reorder_self_3(src, samples, samplesize, 5, 4, 3, 2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1181 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1182 case AF_CHANNEL_LAYOUT_5_0_B << 16 | AF_CHANNEL_LAYOUT_5_0_C:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1183 reorder_self_4_step_1(src, samples, samplesize, 5, 4, 3, 2, 1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1184 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1185 case AF_CHANNEL_LAYOUT_5_0_B << 16 | AF_CHANNEL_LAYOUT_5_0_D:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1186 reorder_self_5_step_1(src, samples, samplesize, 5, 4, 3, 2, 1, 0);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1187 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1188 case AF_CHANNEL_LAYOUT_5_0_C << 16 | AF_CHANNEL_LAYOUT_5_0_A:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1189 reorder_self_2(src, samples, samplesize, 5, 1, 2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1190 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1191 case AF_CHANNEL_LAYOUT_5_0_C << 16 | AF_CHANNEL_LAYOUT_5_0_B:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1192 reorder_self_4_step_1(src, samples, samplesize, 5, 1, 2, 3, 4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1193 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1194 case AF_CHANNEL_LAYOUT_5_0_C << 16 | AF_CHANNEL_LAYOUT_5_0_D:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1195 reorder_self_2(src, samples, samplesize, 5, 0, 1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1196 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1197 case AF_CHANNEL_LAYOUT_5_0_D << 16 | AF_CHANNEL_LAYOUT_5_0_A:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1198 reorder_self_3(src, samples, samplesize, 5, 0, 1, 2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1199 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1200 case AF_CHANNEL_LAYOUT_5_0_D << 16 | AF_CHANNEL_LAYOUT_5_0_B:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1201 reorder_self_5_step_1(src, samples, samplesize, 5, 0, 1, 2, 3, 4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1202 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1203 case AF_CHANNEL_LAYOUT_5_0_D << 16 | AF_CHANNEL_LAYOUT_5_0_C:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1204 reorder_self_2(src, samples, samplesize, 5, 0, 1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1205 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1206 // AF_CHANNEL_LAYOUT_5_1_A L R C LFE Ls Rs
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1207 // AF_CHANNEL_LAYOUT_5_1_B L R Ls Rs C LFE
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1208 // AF_CHANNEL_LAYOUT_5_1_C L C R Ls Rs LFE
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1209 // AF_CHANNEL_LAYOUT_5_1_D C L R Ls Rs LFE
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1210 // AF_CHANNEL_LAYOUT_5_1_E LFE L C R Ls Rs
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1211 case AF_CHANNEL_LAYOUT_5_1_A << 16 | AF_CHANNEL_LAYOUT_5_1_B:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1212 if (samplesize != 3)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1213 reorder_self_2(src, samples/2, samplesize*2, 3, 1, 2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1214 else
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1215 reorder_self_4_step_2(src, samples, samplesize, 6, 2, 3, 4, 5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1216 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1217 case AF_CHANNEL_LAYOUT_5_1_A << 16 | AF_CHANNEL_LAYOUT_5_1_C:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1218 reorder_self_2_3(src, samples, samplesize, 1, 2, 3, 4, 5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1219 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1220 case AF_CHANNEL_LAYOUT_5_1_A << 16 | AF_CHANNEL_LAYOUT_5_1_D:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1221 reorder_self_3_3(src, samples, samplesize, 2, 1, 0, 3, 4, 5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1222 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1223 case AF_CHANNEL_LAYOUT_5_1_B << 16 | AF_CHANNEL_LAYOUT_5_1_A:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1224 if (samplesize != 3)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1225 reorder_self_2(src, samples/2, samplesize*2, 3, 1, 2);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1226 else
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1227 reorder_self_4_step_2(src, samples, samplesize, 6, 2, 3, 4, 5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1228 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1229 case AF_CHANNEL_LAYOUT_5_1_B << 16 | AF_CHANNEL_LAYOUT_5_1_C:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1230 reorder_self_4_step_1(src, samples, samplesize, 6, 4, 3, 2, 1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1231 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1232 case AF_CHANNEL_LAYOUT_5_1_B << 16 | AF_CHANNEL_LAYOUT_5_1_D:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1233 reorder_self_5_step_1(src, samples, samplesize, 6, 4, 3, 2, 1, 0);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1234 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1235 case AF_CHANNEL_LAYOUT_5_1_B << 16 | AF_CHANNEL_LAYOUT_5_1_E:
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1236 reorder_self_2_4(src, samples, samplesize, 6, 2, 4, 5, 3, 1, 0);
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1237 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1238 case AF_CHANNEL_LAYOUT_5_1_C << 16 | AF_CHANNEL_LAYOUT_5_1_A:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1239 reorder_self_2_3(src, samples, samplesize, 1, 2, 5, 4, 3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1240 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1241 case AF_CHANNEL_LAYOUT_5_1_C << 16 | AF_CHANNEL_LAYOUT_5_1_B:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1242 reorder_self_4_step_1(src, samples, samplesize, 6, 1, 2, 3, 4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1243 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1244 case AF_CHANNEL_LAYOUT_5_1_C << 16 | AF_CHANNEL_LAYOUT_5_1_D:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1245 reorder_self_2(src, samples, samplesize, 6, 0, 1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1246 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1247 case AF_CHANNEL_LAYOUT_5_1_D << 16 | AF_CHANNEL_LAYOUT_5_1_A:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1248 reorder_self_3_3(src, samples, samplesize, 0, 1, 2, 5, 4, 3);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1249 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1250 case AF_CHANNEL_LAYOUT_5_1_D << 16 | AF_CHANNEL_LAYOUT_5_1_B:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1251 reorder_self_5_step_1(src, samples, samplesize, 6, 0, 1, 2, 3, 4);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1252 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1253 case AF_CHANNEL_LAYOUT_5_1_D << 16 | AF_CHANNEL_LAYOUT_5_1_C:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1254 reorder_self_2(src, samples, samplesize, 6, 0, 1);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1255 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1256 case AF_CHANNEL_LAYOUT_5_1_E << 16 | AF_CHANNEL_LAYOUT_5_1_B:
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1257 reorder_self_2_4(src, samples, samplesize, 6, 2, 4, 0, 1, 3, 5);
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1258 break;
29491
99eda963d27a Fix incorrect channel ordering for lavc audio codecs (specifically ffac3,
tack
parents: 29385
diff changeset
1259 case AF_CHANNEL_LAYOUT_5_1_F << 16 | AF_CHANNEL_LAYOUT_5_1_B:
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1260 reorder_self_2_4(src, samples, samplesize, 6, 3, 5, 0, 1, 2, 4);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1261 break;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1262 // AF_CHANNEL_LAYOUT_7_1_A L R C LFE Ls Rs Rls Rrs
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1263 // AF_CHANNEL_LAYOUT_7_1_B L R Ls Rs C LFE Rls Rrs
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1264 // AF_CHANNEL_LAYOUT_7_1_C L C R Ls Rs LFE Rls Rrs
34789
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
1265 // AF_CHANNEL_LAYOUT_7_1_D C L R Ls Rs Rls Rrs LFE
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1266 // AF_CHANNEL_LAYOUT_7_1_F C L R LFE Ls Rs Rls Rrs
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1267 case AF_CHANNEL_LAYOUT_7_1_A << 16 | AF_CHANNEL_LAYOUT_7_1_B:
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1268 case AF_CHANNEL_LAYOUT_7_1_B << 16 | AF_CHANNEL_LAYOUT_7_1_A:
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1269 if (samplesize != 3)
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1270 reorder_self_2(src, samples/2, samplesize*2, 4, 1, 2);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1271 else
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1272 reorder_self_4_step_2(src, samples, samplesize, 8, 2, 3, 4, 5);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1273 break;
34789
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
1274 case AF_CHANNEL_LAYOUT_7_1_B << 16 | AF_CHANNEL_LAYOUT_7_1_D:
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
1275 // First convert to AF_CHANNEL_LAYOUT_7_1_F
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
1276 reorder_self_2_4(src, samples, samplesize, 8, 3, 5, 4, 2, 1, 0);
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
1277 // then convert to AF_CHANNEL_LAYOUT_7_1_D
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
1278 reorder_self_5_step_1(src, samples, samplesize, 8, 3, 4, 5, 6, 7);
91d62f0e2952 This will allow us to encode 7.1 audio AAC.
ranma
parents: 29929
diff changeset
1279 break;
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1280 case AF_CHANNEL_LAYOUT_7_1_C << 16 | AF_CHANNEL_LAYOUT_7_1_B:
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1281 reorder_self_4_step_1(src, samples, samplesize, 8, 1, 2, 3, 4);
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1282 break;
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1283 case AF_CHANNEL_LAYOUT_7_1_F << 16 | AF_CHANNEL_LAYOUT_7_1_B:
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1284 reorder_self_2_4(src, samples, samplesize, 8, 3, 5, 0, 1, 2, 4);
29491
99eda963d27a Fix incorrect channel ordering for lavc audio codecs (specifically ffac3,
tack
parents: 29385
diff changeset
1285 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1286 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1287 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1288 "[reorder_channel] unsupported from %x to %x, %d * %d\n",
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1289 src_layout, dest_layout, samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1290 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1291 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1292
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1293
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1294 static int channel_layout_mapping_5ch[AF_CHANNEL_LAYOUT_SOURCE_NUM] = {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1295 AF_CHANNEL_LAYOUT_ALSA_5CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1296 AF_CHANNEL_LAYOUT_AAC_5CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1297 AF_CHANNEL_LAYOUT_WAVEEX_5CH_DEFAULT,
29491
99eda963d27a Fix incorrect channel ordering for lavc audio codecs (specifically ffac3,
tack
parents: 29385
diff changeset
1298 AF_CHANNEL_LAYOUT_LAVC_5CH_DEFAULT,
26987
d3a0f537dbe8 rename AF_CHANNEL_LAYOUT_LAVC_VORBIS* => AF_CHANNEL_LAYOUT_VORBIS*.
ulion
parents: 26740
diff changeset
1299 AF_CHANNEL_LAYOUT_VORBIS_5CH_DEFAULT,
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1300 };
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1301
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1302 static int channel_layout_mapping_6ch[AF_CHANNEL_LAYOUT_SOURCE_NUM] = {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1303 AF_CHANNEL_LAYOUT_ALSA_6CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1304 AF_CHANNEL_LAYOUT_AAC_6CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1305 AF_CHANNEL_LAYOUT_WAVEEX_6CH_DEFAULT,
29491
99eda963d27a Fix incorrect channel ordering for lavc audio codecs (specifically ffac3,
tack
parents: 29385
diff changeset
1306 AF_CHANNEL_LAYOUT_LAVC_6CH_DEFAULT,
26987
d3a0f537dbe8 rename AF_CHANNEL_LAYOUT_LAVC_VORBIS* => AF_CHANNEL_LAYOUT_VORBIS*.
ulion
parents: 26740
diff changeset
1307 AF_CHANNEL_LAYOUT_VORBIS_6CH_DEFAULT,
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1308 };
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1309
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1310 static int channel_layout_mapping_8ch[AF_CHANNEL_LAYOUT_SOURCE_NUM] = {
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1311 AF_CHANNEL_LAYOUT_ALSA_8CH_DEFAULT,
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1312 AF_CHANNEL_LAYOUT_AAC_8CH_DEFAULT,
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1313 AF_CHANNEL_LAYOUT_WAVEEX_8CH_DEFAULT,
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1314 AF_CHANNEL_LAYOUT_LAVC_8CH_DEFAULT,
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1315 AF_CHANNEL_LAYOUT_VORBIS_8CH_DEFAULT,
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1316 };
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1317
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1318 void reorder_channel_copy_nch(void *src,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1319 int src_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1320 void *dest,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1321 int dest_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1322 int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1323 int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1324 int samplesize)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1325 {
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1326 if (chnum < 5 || chnum == 7 || chnum > 8 ||
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1327 src_layout < 0 || dest_layout < 0 ||
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1328 src_layout >= AF_CHANNEL_LAYOUT_SOURCE_NUM ||
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1329 dest_layout >= AF_CHANNEL_LAYOUT_SOURCE_NUM)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1330 fast_memcpy(dest, src, samples*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1331 else if (chnum == 6)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1332 reorder_channel_copy(src, channel_layout_mapping_6ch[src_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1333 dest, channel_layout_mapping_6ch[dest_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1334 samples, samplesize);
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1335 else if (chnum == 8)
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1336 reorder_channel_copy(src, channel_layout_mapping_8ch[src_layout],
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1337 dest, channel_layout_mapping_8ch[dest_layout],
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1338 samples, samplesize);
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1339 else
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1340 reorder_channel_copy(src, channel_layout_mapping_5ch[src_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1341 dest, channel_layout_mapping_5ch[dest_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1342 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1343 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1344
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1345 void reorder_channel_nch(void *buf,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1346 int src_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1347 int dest_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1348 int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1349 int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1350 int samplesize)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1351 {
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1352 if (src_layout == dest_layout || chnum < 5 || chnum == 7 || chnum > 8 ||
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1353 src_layout < 0 || dest_layout < 0 ||
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1354 src_layout >= AF_CHANNEL_LAYOUT_SOURCE_NUM ||
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1355 dest_layout >= AF_CHANNEL_LAYOUT_SOURCE_NUM ||
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1356 src_layout == dest_layout)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1357 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1358 if (chnum == 6)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1359 reorder_channel(buf, channel_layout_mapping_6ch[src_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1360 channel_layout_mapping_6ch[dest_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1361 samples, samplesize);
29826
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1362 else if (chnum == 8)
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1363 reorder_channel(buf, channel_layout_mapping_8ch[src_layout],
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1364 channel_layout_mapping_8ch[dest_layout],
4eae69f3f4f4 Add support for 8 channel audio.
tack
parents: 29825
diff changeset
1365 samples, samplesize);
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1366 else
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1367 reorder_channel(buf, channel_layout_mapping_5ch[src_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1368 channel_layout_mapping_5ch[dest_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1369 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1370 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1371
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1372
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1373 #ifdef TEST
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1374
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1375 static void test_copy(int channels) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1376 int samples = 12*1024*1024;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1377 int samplesize = 2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1378 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1379 unsigned char *bufin = malloc((samples+100)*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1380 unsigned char *bufout = malloc((samples+100)*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1381 memset(bufin, 0xFF, samples*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1382 for (i = 0;i < 100; ++i)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1383 reorder_channel_copy(bufin, AF_CHANNEL_LAYOUT_5_1_A,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1384 bufout, AF_CHANNEL_LAYOUT_5_1_B,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1385 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1386 // reorder_channel(bufin, AF_CHANNEL_LAYOUT_5_1_B,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1387 // AF_CHANNEL_LAYOUT_5_1_D,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1388 // samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1389 free(bufin);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1390 free(bufout);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1391 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1392
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1393 int main(int argc, char *argv[]) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1394 int channels = 6;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1395 if (argc > 1)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1396 channels = atoi(argv[1]);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1397 test_copy(channels);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1398 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1399 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1400
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1401 #endif