2 * common functions for reordering audio channels
4 * Copyright (C) 2007 Ulion <ulion A gmail P com>
6 * This file is part of MPlayer.
8 * MPlayer is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * MPlayer is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "libvo/fastmemcpy.h"
29 #include "reorder_ch.h"
32 #define mp_msg(mod,lev, fmt, args... ) printf( fmt, ## args )
38 #define REORDER_COPY_5(DEST,SRC,SAMPLES,S0,S1,S2,S3,S4) \
39 for (i = 0; i < SAMPLES; i += 5) {\
41 DEST[i+1] = SRC[i+S1];\
42 DEST[i+2] = SRC[i+S2];\
43 DEST[i+3] = SRC[i+S3];\
44 DEST[i+4] = SRC[i+S4];\
47 static int reorder_copy_5ch(void *dest
, const void *src
,
48 unsigned int samples
, unsigned int samplesize
,
49 int s0
, int s1
, int s2
, int s3
, int s4
)
55 int8_t *dest_8
= dest
;
56 const int8_t *src_8
= src
;
57 REORDER_COPY_5(dest_8
,src_8
,samples
,s0
,s1
,s2
,s3
,s4
);
62 int16_t *dest_16
= dest
;
63 const int16_t *src_16
= src
;
64 REORDER_COPY_5(dest_16
,src_16
,samples
,s0
,s1
,s2
,s3
,s4
);
69 int8_t *dest_8
= dest
;
70 const int8_t *src_8
= src
;
71 for (i
= 0; i
< samples
; i
+= 15) {
72 dest_8
[i
] = src_8
[i
+s0
*3];
73 dest_8
[i
+1] = src_8
[i
+s0
*3+1];
74 dest_8
[i
+2] = src_8
[i
+s0
*3+2];
75 dest_8
[i
+3] = src_8
[i
+s1
*3];
76 dest_8
[i
+4] = src_8
[i
+s1
*3+1];
77 dest_8
[i
+5] = src_8
[i
+s1
*3+2];
78 dest_8
[i
+6] = src_8
[i
+s2
*3];
79 dest_8
[i
+7] = src_8
[i
+s2
*3+1];
80 dest_8
[i
+8] = src_8
[i
+s2
*3+2];
81 dest_8
[i
+9] = src_8
[i
+s3
*3];
82 dest_8
[i
+10] = src_8
[i
+s3
*3+1];
83 dest_8
[i
+11] = src_8
[i
+s3
*3+2];
84 dest_8
[i
+12] = src_8
[i
+s4
*3];
85 dest_8
[i
+13] = src_8
[i
+s4
*3+1];
86 dest_8
[i
+14] = src_8
[i
+s4
*3+2];
91 int32_t *dest_32
= dest
;
92 const int32_t *src_32
= src
;
93 REORDER_COPY_5(dest_32
,src_32
,samples
,s0
,s1
,s2
,s3
,s4
);
98 int64_t *dest_64
= dest
;
99 const int64_t *src_64
= src
;
100 REORDER_COPY_5(dest_64
,src_64
,samples
,s0
,s1
,s2
,s3
,s4
);
104 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,
105 "[reorder_ch] Unsupported sample size: %d, please "
106 "report this error on the MPlayer mailing list.\n",samplesize
);
112 #define REORDER_COPY_6(DEST,SRC,SAMPLES,S0,S1,S2,S3,S4,S5) \
113 for (i = 0; i < SAMPLES; i += 6) {\
114 DEST[i] = SRC[i+S0];\
115 DEST[i+1] = SRC[i+S1];\
116 DEST[i+2] = SRC[i+S2];\
117 DEST[i+3] = SRC[i+S3];\
118 DEST[i+4] = SRC[i+S4];\
119 DEST[i+5] = SRC[i+S5];\
122 static int reorder_copy_6ch(void *dest
, const void *src
,
123 unsigned int samples
, uint8_t samplesize
,
124 int s0
, int s1
, int s2
, int s3
, int s4
, int s5
)
127 switch (samplesize
) {
130 int8_t *dest_8
= dest
;
131 const int8_t *src_8
= src
;
132 REORDER_COPY_6(dest_8
,src_8
,samples
,s0
,s1
,s2
,s3
,s4
,s5
);
137 int16_t *dest_16
= dest
;
138 const int16_t *src_16
= src
;
139 REORDER_COPY_6(dest_16
,src_16
,samples
,s0
,s1
,s2
,s3
,s4
,s5
);
144 int8_t *dest_8
= dest
;
145 const int8_t *src_8
= src
;
146 for (i
= 0; i
< samples
; i
+= 18) {
147 dest_8
[i
] = src_8
[i
+s0
*3];
148 dest_8
[i
+1] = src_8
[i
+s0
*3+1];
149 dest_8
[i
+2] = src_8
[i
+s0
*3+2];
150 dest_8
[i
+3] = src_8
[i
+s1
*3];
151 dest_8
[i
+4] = src_8
[i
+s1
*3+1];
152 dest_8
[i
+5] = src_8
[i
+s1
*3+2];
153 dest_8
[i
+6] = src_8
[i
+s2
*3];
154 dest_8
[i
+7] = src_8
[i
+s2
*3+1];
155 dest_8
[i
+8] = src_8
[i
+s2
*3+2];
156 dest_8
[i
+9] = src_8
[i
+s3
*3];
157 dest_8
[i
+10] = src_8
[i
+s3
*3+1];
158 dest_8
[i
+11] = src_8
[i
+s3
*3+2];
159 dest_8
[i
+12] = src_8
[i
+s4
*3];
160 dest_8
[i
+13] = src_8
[i
+s4
*3+1];
161 dest_8
[i
+14] = src_8
[i
+s4
*3+2];
162 dest_8
[i
+15] = src_8
[i
+s5
*3];
163 dest_8
[i
+16] = src_8
[i
+s5
*3+1];
164 dest_8
[i
+17] = src_8
[i
+s5
*3+2];
169 int32_t *dest_32
= dest
;
170 const int32_t *src_32
= src
;
171 REORDER_COPY_6(dest_32
,src_32
,samples
,s0
,s1
,s2
,s3
,s4
,s5
);
176 int64_t *dest_64
= dest
;
177 const int64_t *src_64
= src
;
178 REORDER_COPY_6(dest_64
,src_64
,samples
,s0
,s1
,s2
,s3
,s4
,s5
);
182 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,
183 "[reorder_ch] Unsupported sample size: %d, please "
184 "report this error on the MPlayer mailing list.\n",samplesize
);
190 void reorder_channel_copy(void *src
,
197 if (dest_layout
==src_layout
) {
198 fast_memcpy(dest
, src
, samples
*samplesize
);
201 if (!AF_IS_SAME_CH_NUM(dest_layout
,src_layout
)) {
202 mp_msg(MSGT_GLOBAL
, MSGL_WARN
, "[reorder_ch] different channel count "
203 "between src and dest: %x, %x\n",
204 AF_GET_CH_NUM_WITH_LFE(src_layout
),
205 AF_GET_CH_NUM_WITH_LFE(dest_layout
));
208 switch ((src_layout
<<16)|dest_layout
) {
209 // AF_CHANNEL_LAYOUT_5_0_A L R C Ls Rs
210 // AF_CHANNEL_LAYOUT_5_0_B L R Ls Rs C
211 // AF_CHANNEL_LAYOUT_5_0_C L C R Ls Rs
212 // AF_CHANNEL_LAYOUT_5_0_D C L R Ls Rs
213 case AF_CHANNEL_LAYOUT_5_0_A
<< 16 | AF_CHANNEL_LAYOUT_5_0_B
:
214 reorder_copy_5ch(dest
, src
, samples
, samplesize
, 0, 1, 3, 4, 2);
216 case AF_CHANNEL_LAYOUT_5_0_A
<< 16 | AF_CHANNEL_LAYOUT_5_0_C
:
217 reorder_copy_5ch(dest
, src
, samples
, samplesize
, 0, 2, 1, 3, 4);
219 case AF_CHANNEL_LAYOUT_5_0_A
<< 16 | AF_CHANNEL_LAYOUT_5_0_D
:
220 reorder_copy_5ch(dest
, src
, samples
, samplesize
, 2, 0, 1, 3, 4);
222 case AF_CHANNEL_LAYOUT_5_0_B
<< 16 | AF_CHANNEL_LAYOUT_5_0_A
:
223 reorder_copy_5ch(dest
, src
, samples
, samplesize
, 0, 1, 4, 2, 3);
225 case AF_CHANNEL_LAYOUT_5_0_B
<< 16 | AF_CHANNEL_LAYOUT_5_0_C
:
226 reorder_copy_5ch(dest
, src
, samples
, samplesize
, 0, 4, 1, 2, 3);
228 case AF_CHANNEL_LAYOUT_5_0_B
<< 16 | AF_CHANNEL_LAYOUT_5_0_D
:
229 reorder_copy_5ch(dest
, src
, samples
, samplesize
, 4, 0, 1, 2, 3);
231 case AF_CHANNEL_LAYOUT_5_0_C
<< 16 | AF_CHANNEL_LAYOUT_5_0_A
:
232 reorder_copy_5ch(dest
, src
, samples
, samplesize
, 0, 2, 1, 3, 4);
234 case AF_CHANNEL_LAYOUT_5_0_C
<< 16 | AF_CHANNEL_LAYOUT_5_0_B
:
235 reorder_copy_5ch(dest
, src
, samples
, samplesize
, 0, 2, 3, 4, 1);
237 case AF_CHANNEL_LAYOUT_5_0_C
<< 16 | AF_CHANNEL_LAYOUT_5_0_D
:
238 reorder_copy_5ch(dest
, src
, samples
, samplesize
, 1, 0, 2, 3, 4);
240 case AF_CHANNEL_LAYOUT_5_0_D
<< 16 | AF_CHANNEL_LAYOUT_5_0_A
:
241 reorder_copy_5ch(dest
, src
, samples
, samplesize
, 1, 2, 0, 3, 4);
243 case AF_CHANNEL_LAYOUT_5_0_D
<< 16 | AF_CHANNEL_LAYOUT_5_0_B
:
244 reorder_copy_5ch(dest
, src
, samples
, samplesize
, 1, 2, 3, 4, 0);
246 case AF_CHANNEL_LAYOUT_5_0_D
<< 16 | AF_CHANNEL_LAYOUT_5_0_C
:
247 reorder_copy_5ch(dest
, src
, samples
, samplesize
, 1, 0, 2, 3, 4);
249 // AF_CHANNEL_LAYOUT_5_1_A L R C LFE Ls Rs
250 // AF_CHANNEL_LAYOUT_5_1_B L R Ls Rs C LFE
251 // AF_CHANNEL_LAYOUT_5_1_C L C R Ls Rs LFE
252 // AF_CHANNEL_LAYOUT_5_1_D C L R Ls Rs LFE
253 // AF_CHANNEL_LAYOUT_5_1_E LFE L C R Ls Rs
254 case AF_CHANNEL_LAYOUT_5_1_A
<< 16 | AF_CHANNEL_LAYOUT_5_1_B
:
255 reorder_copy_6ch(dest
, src
, samples
, samplesize
, 0, 1, 4, 5, 2, 3);
257 case AF_CHANNEL_LAYOUT_5_1_A
<< 16 | AF_CHANNEL_LAYOUT_5_1_C
:
258 reorder_copy_6ch(dest
, src
, samples
, samplesize
, 0, 2, 1, 4, 5, 3);
260 case AF_CHANNEL_LAYOUT_5_1_A
<< 16 | AF_CHANNEL_LAYOUT_5_1_D
:
261 reorder_copy_6ch(dest
, src
, samples
, samplesize
, 2, 0, 1, 4, 5, 3);
263 case AF_CHANNEL_LAYOUT_5_1_B
<< 16 | AF_CHANNEL_LAYOUT_5_1_A
:
264 reorder_copy_6ch(dest
, src
, samples
, samplesize
, 0, 1, 4, 5, 2, 3);
266 case AF_CHANNEL_LAYOUT_5_1_B
<< 16 | AF_CHANNEL_LAYOUT_5_1_C
:
267 reorder_copy_6ch(dest
, src
, samples
, samplesize
, 0, 4, 1, 2, 3, 5);
269 case AF_CHANNEL_LAYOUT_5_1_B
<< 16 | AF_CHANNEL_LAYOUT_5_1_D
:
270 reorder_copy_6ch(dest
, src
, samples
, samplesize
, 4, 0, 1, 2, 3, 5);
272 case AF_CHANNEL_LAYOUT_5_1_B
<< 16 | AF_CHANNEL_LAYOUT_5_1_E
:
273 reorder_copy_6ch(dest
, src
, samples
, samplesize
, 5, 0, 4, 1, 2, 3);
275 case AF_CHANNEL_LAYOUT_5_1_C
<< 16 | AF_CHANNEL_LAYOUT_5_1_A
:
276 reorder_copy_6ch(dest
, src
, samples
, samplesize
, 0, 2, 1, 5, 3, 4);
278 case AF_CHANNEL_LAYOUT_5_1_C
<< 16 | AF_CHANNEL_LAYOUT_5_1_B
:
279 reorder_copy_6ch(dest
, src
, samples
, samplesize
, 0, 2, 3, 4, 1, 5);
281 case AF_CHANNEL_LAYOUT_5_1_C
<< 16 | AF_CHANNEL_LAYOUT_5_1_D
:
282 reorder_copy_6ch(dest
, src
, samples
, samplesize
, 1, 0, 2, 3, 4, 5);
284 case AF_CHANNEL_LAYOUT_5_1_D
<< 16 | AF_CHANNEL_LAYOUT_5_1_A
:
285 reorder_copy_6ch(dest
, src
, samples
, samplesize
, 1, 2, 0, 5, 3, 4);
287 case AF_CHANNEL_LAYOUT_5_1_D
<< 16 | AF_CHANNEL_LAYOUT_5_1_B
:
288 reorder_copy_6ch(dest
, src
, samples
, samplesize
, 1, 2, 3, 4, 0, 5);
290 case AF_CHANNEL_LAYOUT_5_1_D
<< 16 | AF_CHANNEL_LAYOUT_5_1_C
:
291 reorder_copy_6ch(dest
, src
, samples
, samplesize
, 1, 0, 2, 3, 4, 5);
293 case AF_CHANNEL_LAYOUT_5_1_E
<< 16 | AF_CHANNEL_LAYOUT_5_1_B
:
294 reorder_copy_6ch(dest
, src
, samples
, samplesize
, 1, 3, 4, 5, 2, 0);
297 mp_msg(MSGT_GLOBAL
, MSGL_WARN
, "[reorder_channel_copy] unsupport "
298 "from %x to %x, %d * %d\n", src_layout
, dest_layout
,
299 samples
, samplesize
);
300 fast_memcpy(dest
, src
, samples
*samplesize
);
305 #define REORDER_SELF_SWAP_2(SRC,TMP,SAMPLES,CHNUM,S0,S1) \
306 for (i = 0; i < SAMPLES; i += CHNUM) {\
308 SRC[i+S0] = SRC[i+S1];\
312 static int reorder_self_2(void *src
, unsigned int samples
,
313 unsigned int samplesize
, unsigned int chnum
,
317 switch (samplesize
) {
323 REORDER_SELF_SWAP_2(src_8
,tmp
,samples
,6,s0
,s1
);
326 REORDER_SELF_SWAP_2(src_8
,tmp
,samples
,5,s0
,s1
);
332 int16_t *src_16
= src
;
335 REORDER_SELF_SWAP_2(src_16
,tmp
,samples
,6,s0
,s1
);
338 REORDER_SELF_SWAP_2(src_16
,tmp
,samples
,3,s0
,s1
);
341 REORDER_SELF_SWAP_2(src_16
,tmp
,samples
,5,s0
,s1
);
348 int8_t tmp0
, tmp1
, tmp2
;
349 for (i
= 0; i
< samples
; i
+= chnum
*3) {
350 tmp0
= src_8
[i
+s0
*3];
351 tmp1
= src_8
[i
+s0
*3+1];
352 tmp2
= src_8
[i
+s0
*3+2];
353 src_8
[i
+s0
*3] = src_8
[i
+s1
*3];
354 src_8
[i
+s0
*3+1] = src_8
[i
+s1
*3+1];
355 src_8
[i
+s0
*3+2] = src_8
[i
+s1
*3+2];
356 src_8
[i
+s1
*3] = tmp0
;
357 src_8
[i
+s1
*3+1] = tmp1
;
358 src_8
[i
+s1
*3+2] = tmp2
;
363 int32_t *src_32
= src
;
366 REORDER_SELF_SWAP_2(src_32
,tmp
,samples
,6,s0
,s1
);
369 REORDER_SELF_SWAP_2(src_32
,tmp
,samples
,3,s0
,s1
);
372 REORDER_SELF_SWAP_2(src_32
,tmp
,samples
,5,s0
,s1
);
378 int64_t *src_64
= src
;
381 REORDER_SELF_SWAP_2(src_64
,tmp
,samples
,6,s0
,s1
);
384 REORDER_SELF_SWAP_2(src_64
,tmp
,samples
,3,s0
,s1
);
387 REORDER_SELF_SWAP_2(src_64
,tmp
,samples
,5,s0
,s1
);
392 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,
393 "[reorder_ch] Unsupported sample size: %d, please "
394 "report this error on the MPlayer mailing list.\n",samplesize
);
400 #define REORDER_SELF_SWAP_3(SRC,TMP,SAMPLES,CHNUM,S0,S1,S2) \
401 for (i = 0; i < SAMPLES; i += CHNUM) {\
403 SRC[i+S0] = SRC[i+S1];\
404 SRC[i+S1] = SRC[i+S2];\
408 static int reorder_self_3(void *src
, unsigned int samples
,
409 unsigned int samplesize
, unsigned int chnum
,
410 int s0
, int s1
, int s2
)
413 switch (samplesize
) {
419 REORDER_SELF_SWAP_3(src_8
,tmp
,samples
,6,s0
,s1
,s2
);
422 REORDER_SELF_SWAP_3(src_8
,tmp
,samples
,5,s0
,s1
,s2
);
428 int16_t *src_16
= src
;
431 REORDER_SELF_SWAP_3(src_16
,tmp
,samples
,6,s0
,s1
,s2
);
434 REORDER_SELF_SWAP_3(src_16
,tmp
,samples
,5,s0
,s1
,s2
);
441 int8_t tmp0
, tmp1
, tmp2
;
442 for (i
= 0; i
< samples
; i
+= chnum
*3) {
443 tmp0
= src_8
[i
+s0
*3];
444 tmp1
= src_8
[i
+s0
*3+1];
445 tmp2
= src_8
[i
+s0
*3+2];
446 src_8
[i
+s0
*3] = src_8
[i
+s1
*3];
447 src_8
[i
+s0
*3+1] = src_8
[i
+s1
*3+1];
448 src_8
[i
+s0
*3+2] = src_8
[i
+s1
*3+2];
449 src_8
[i
+s1
*3] = src_8
[i
+s2
*3];
450 src_8
[i
+s1
*3+1] = src_8
[i
+s2
*3+1];
451 src_8
[i
+s1
*3+2] = src_8
[i
+s2
*3+2];
452 src_8
[i
+s2
*3] = tmp0
;
453 src_8
[i
+s2
*3+1] = tmp1
;
454 src_8
[i
+s2
*3+2] = tmp2
;
459 int32_t *src_32
= src
;
462 REORDER_SELF_SWAP_3(src_32
,tmp
,samples
,6,s0
,s1
,s2
);
465 REORDER_SELF_SWAP_3(src_32
,tmp
,samples
,5,s0
,s1
,s2
);
471 int64_t *src_64
= src
;
474 REORDER_SELF_SWAP_3(src_64
,tmp
,samples
,6,s0
,s1
,s2
);
477 REORDER_SELF_SWAP_3(src_64
,tmp
,samples
,5,s0
,s1
,s2
);
482 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,
483 "[reorder_ch] Unsupported sample size: %d, please "
484 "report this error on the MPlayer mailing list.\n",samplesize
);
490 #define REORDER_SELF_SWAP_4_STEP_1(SRC,TMP,SAMPLES,CHNUM,S0,S1,S2,S3) \
491 for (i = 0; i < SAMPLES; i += CHNUM) {\
493 SRC[i+S0] = SRC[i+S1];\
494 SRC[i+S1] = SRC[i+S2];\
495 SRC[i+S2] = SRC[i+S3];\
499 static int reorder_self_4_step_1(void *src
, unsigned int samples
,
500 unsigned int samplesize
, unsigned int chnum
,
501 int s0
, int s1
, int s2
, int s3
)
504 switch (samplesize
) {
510 REORDER_SELF_SWAP_4_STEP_1(src_8
,tmp
,samples
,6,s0
,s1
,s2
,s3
);
513 REORDER_SELF_SWAP_4_STEP_1(src_8
,tmp
,samples
,5,s0
,s1
,s2
,s3
);
519 int16_t *src_16
= src
;
522 REORDER_SELF_SWAP_4_STEP_1(src_16
,tmp
,samples
,6,s0
,s1
,s2
,s3
);
525 REORDER_SELF_SWAP_4_STEP_1(src_16
,tmp
,samples
,5,s0
,s1
,s2
,s3
);
532 int8_t tmp0
, tmp1
, tmp2
;
533 for (i
= 0; i
< samples
; i
+= chnum
*3) {
534 tmp0
= src_8
[i
+s0
*3];
535 tmp1
= src_8
[i
+s0
*3+1];
536 tmp2
= src_8
[i
+s0
*3+2];
537 src_8
[i
+s0
*3] = src_8
[i
+s1
*3];
538 src_8
[i
+s0
*3+1] = src_8
[i
+s1
*3+1];
539 src_8
[i
+s0
*3+2] = src_8
[i
+s1
*3+2];
540 src_8
[i
+s1
*3] = src_8
[i
+s2
*3];
541 src_8
[i
+s1
*3+1] = src_8
[i
+s2
*3+1];
542 src_8
[i
+s1
*3+2] = src_8
[i
+s2
*3+2];
543 src_8
[i
+s2
*3] = src_8
[i
+s3
*3];
544 src_8
[i
+s2
*3+1] = src_8
[i
+s3
*3+1];
545 src_8
[i
+s2
*3+2] = src_8
[i
+s3
*3+2];
546 src_8
[i
+s3
*3] = tmp0
;
547 src_8
[i
+s3
*3+1] = tmp1
;
548 src_8
[i
+s3
*3+2] = tmp2
;
553 int32_t *src_32
= src
;
556 REORDER_SELF_SWAP_4_STEP_1(src_32
,tmp
,samples
,6,s0
,s1
,s2
,s3
);
559 REORDER_SELF_SWAP_4_STEP_1(src_32
,tmp
,samples
,5,s0
,s1
,s2
,s3
);
565 int64_t *src_64
= src
;
568 REORDER_SELF_SWAP_4_STEP_1(src_64
,tmp
,samples
,6,s0
,s1
,s2
,s3
);
571 REORDER_SELF_SWAP_4_STEP_1(src_64
,tmp
,samples
,5,s0
,s1
,s2
,s3
);
576 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,
577 "[reorder_ch] Unsupported sample size: %d, please "
578 "report this error on the MPlayer mailing list.\n",samplesize
);
584 #define REORDER_SELF_SWAP_4_STEP_2(SRC,TMP,SAMPLES,CHNUM,S0,S1,S2,S3) \
585 for (i = 0; i < SAMPLES; i += CHNUM) {\
587 SRC[i+S0] = SRC[i+S2];\
590 SRC[i+S1] = SRC[i+S3];\
594 static int reorder_self_4_step_2(void *src
, unsigned int samples
,
595 unsigned int samplesize
, unsigned int chnum
,
596 int s0
, int s1
, int s2
, int s3
)
599 switch (samplesize
) {
603 int8_t tmp0
, tmp1
, tmp2
;
604 for (i
= 0; i
< samples
; i
+= chnum
*3) {
605 tmp0
= src_8
[i
+s0
*3];
606 tmp1
= src_8
[i
+s0
*3+1];
607 tmp2
= src_8
[i
+s0
*3+2];
608 src_8
[i
+s0
*3] = src_8
[i
+s2
*3];
609 src_8
[i
+s0
*3+1] = src_8
[i
+s2
*3+1];
610 src_8
[i
+s0
*3+2] = src_8
[i
+s2
*3+2];
611 src_8
[i
+s2
*3] = tmp0
;
612 src_8
[i
+s2
*3+1] = tmp1
;
613 src_8
[i
+s2
*3+2] = tmp2
;
614 tmp0
= src_8
[i
+s1
*3];
615 tmp1
= src_8
[i
+s1
*3+1];
616 tmp2
= src_8
[i
+s1
*3+2];
617 src_8
[i
+s1
*3] = src_8
[i
+s3
*3];
618 src_8
[i
+s1
*3+1] = src_8
[i
+s3
*3+1];
619 src_8
[i
+s1
*3+2] = src_8
[i
+s3
*3+2];
620 src_8
[i
+s3
*3] = tmp0
;
621 src_8
[i
+s3
*3+1] = tmp1
;
622 src_8
[i
+s3
*3+2] = tmp2
;
626 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,
627 "[reorder_ch] Unsupported sample size: %d, please "
628 "report this error on the MPlayer mailing list.\n",samplesize
);
634 #define REORDER_SELF_SWAP_5_STEP_1(SRC,TMP,SAMPLES,CHNUM,S0,S1,S2,S3,S4) \
635 for (i = 0; i < SAMPLES; i += CHNUM) {\
637 SRC[i+S0] = SRC[i+S1];\
638 SRC[i+S1] = SRC[i+S2];\
639 SRC[i+S2] = SRC[i+S3];\
640 SRC[i+S3] = SRC[i+S4];\
644 static int reorder_self_5_step_1(void *src
, unsigned int samples
,
645 unsigned int samplesize
, unsigned int chnum
,
646 int s0
, int s1
, int s2
, int s3
, int s4
)
649 switch (samplesize
) {
655 REORDER_SELF_SWAP_5_STEP_1(src_8
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
);
658 REORDER_SELF_SWAP_5_STEP_1(src_8
,tmp
,samples
,5,s0
,s1
,s2
,s3
,s4
);
664 int16_t *src_16
= src
;
667 REORDER_SELF_SWAP_5_STEP_1(src_16
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
);
670 REORDER_SELF_SWAP_5_STEP_1(src_16
,tmp
,samples
,5,s0
,s1
,s2
,s3
,s4
);
677 int8_t tmp0
, tmp1
, tmp2
;
678 for (i
= 0; i
< samples
; i
+= chnum
*3) {
679 tmp0
= src_8
[i
+s0
*3];
680 tmp1
= src_8
[i
+s0
*3+1];
681 tmp2
= src_8
[i
+s0
*3+2];
682 src_8
[i
+s0
*3] = src_8
[i
+s1
*3];
683 src_8
[i
+s0
*3+1] = src_8
[i
+s1
*3+1];
684 src_8
[i
+s0
*3+2] = src_8
[i
+s1
*3+2];
685 src_8
[i
+s1
*3] = src_8
[i
+s2
*3];
686 src_8
[i
+s1
*3+1] = src_8
[i
+s2
*3+1];
687 src_8
[i
+s1
*3+2] = src_8
[i
+s2
*3+2];
688 src_8
[i
+s2
*3] = src_8
[i
+s3
*3];
689 src_8
[i
+s2
*3+1] = src_8
[i
+s3
*3+1];
690 src_8
[i
+s2
*3+2] = src_8
[i
+s3
*3+2];
691 src_8
[i
+s3
*3] = src_8
[i
+s4
*3];
692 src_8
[i
+s3
*3+1] = src_8
[i
+s4
*3+1];
693 src_8
[i
+s3
*3+2] = src_8
[i
+s4
*3+2];
694 src_8
[i
+s4
*3] = tmp0
;
695 src_8
[i
+s4
*3+1] = tmp1
;
696 src_8
[i
+s4
*3+2] = tmp2
;
701 int32_t *src_32
= src
;
704 REORDER_SELF_SWAP_5_STEP_1(src_32
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
);
707 REORDER_SELF_SWAP_5_STEP_1(src_32
,tmp
,samples
,5,s0
,s1
,s2
,s3
,s4
);
713 int64_t *src_64
= src
;
716 REORDER_SELF_SWAP_5_STEP_1(src_64
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
);
719 REORDER_SELF_SWAP_5_STEP_1(src_64
,tmp
,samples
,5,s0
,s1
,s2
,s3
,s4
);
724 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,
725 "[reorder_ch] Unsupported sample size: %d, please "
726 "report this error on the MPlayer mailing list.\n",samplesize
);
732 #define REORDER_SELF_SWAP_2_3(SRC,TMP,SAMPLES,CHNUM,S0,S1,S2,S3,S4) \
733 for (i = 0; i < SAMPLES; i += CHNUM) {\
735 SRC[i+S0] = SRC[i+S1];\
738 SRC[i+S2] = SRC[i+S3];\
739 SRC[i+S3] = SRC[i+S4];\
743 static int reorder_self_2_3(void *src
, unsigned int samples
,
744 unsigned int samplesize
,
745 int s0
, int s1
, int s2
, int s3
, int s4
)
748 switch (samplesize
) {
753 REORDER_SELF_SWAP_2_3(src_8
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
);
758 int16_t *src_16
= src
;
760 REORDER_SELF_SWAP_2_3(src_16
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
);
766 int8_t tmp0
, tmp1
, tmp2
;
767 for (i
= 0; i
< samples
; i
+= 18) {
768 tmp0
= src_8
[i
+s0
*3];
769 tmp1
= src_8
[i
+s0
*3+1];
770 tmp2
= src_8
[i
+s0
*3+2];
771 src_8
[i
+s0
*3] = src_8
[i
+s1
*3];
772 src_8
[i
+s0
*3+1] = src_8
[i
+s1
*3+1];
773 src_8
[i
+s0
*3+2] = src_8
[i
+s1
*3+2];
774 src_8
[i
+s1
*3] = tmp0
;
775 src_8
[i
+s1
*3+1] = tmp1
;
776 src_8
[i
+s1
*3+2] = tmp2
;
777 tmp0
= src_8
[i
+s2
*3];
778 tmp1
= src_8
[i
+s2
*3+1];
779 tmp2
= src_8
[i
+s2
*3+2];
780 src_8
[i
+s2
*3] = src_8
[i
+s3
*3];
781 src_8
[i
+s2
*3+1] = src_8
[i
+s3
*3+1];
782 src_8
[i
+s2
*3+2] = src_8
[i
+s3
*3+2];
783 src_8
[i
+s3
*3] = src_8
[i
+s4
*3];
784 src_8
[i
+s3
*3+1] = src_8
[i
+s4
*3+1];
785 src_8
[i
+s3
*3+2] = src_8
[i
+s4
*3+2];
786 src_8
[i
+s4
*3] = tmp0
;
787 src_8
[i
+s4
*3+1] = tmp1
;
788 src_8
[i
+s4
*3+2] = tmp2
;
793 int32_t *src_32
= src
;
795 REORDER_SELF_SWAP_2_3(src_32
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
);
800 int64_t *src_64
= src
;
802 REORDER_SELF_SWAP_2_3(src_64
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
);
806 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,
807 "[reorder_ch] Unsupported sample size: %d, please "
808 "report this error on the MPlayer mailing list.\n",samplesize
);
814 #define REORDER_SELF_SWAP_3_3(SRC,TMP,SAMPLES,CHNUM,S0,S1,S2,S3,S4,S5) \
815 for (i = 0; i < SAMPLES; i += CHNUM) {\
817 SRC[i+S0] = SRC[i+S1];\
818 SRC[i+S1] = SRC[i+S2];\
821 SRC[i+S3] = SRC[i+S4];\
822 SRC[i+S4] = SRC[i+S5];\
826 static int reorder_self_3_3(void *src
, unsigned int samples
,
827 unsigned int samplesize
,
828 int s0
, int s1
, int s2
, int s3
, int s4
, int s5
)
831 switch (samplesize
) {
836 REORDER_SELF_SWAP_3_3(src_8
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
,s5
);
841 int16_t *src_16
= src
;
843 REORDER_SELF_SWAP_3_3(src_16
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
,s5
);
849 int8_t tmp0
, tmp1
, tmp2
;
850 for (i
= 0; i
< samples
; i
+= 18) {
851 tmp0
= src_8
[i
+s0
*3];
852 tmp1
= src_8
[i
+s0
*3+1];
853 tmp2
= src_8
[i
+s0
*3+2];
854 src_8
[i
+s0
*3] = src_8
[i
+s1
*3];
855 src_8
[i
+s0
*3+1] = src_8
[i
+s1
*3+1];
856 src_8
[i
+s0
*3+2] = src_8
[i
+s1
*3+2];
857 src_8
[i
+s1
*3] = src_8
[i
+s2
*3];
858 src_8
[i
+s1
*3+1] = src_8
[i
+s2
*3+1];
859 src_8
[i
+s1
*3+2] = src_8
[i
+s2
*3+2];
860 src_8
[i
+s2
*3] = tmp0
;
861 src_8
[i
+s2
*3+1] = tmp1
;
862 src_8
[i
+s2
*3+2] = tmp2
;
863 tmp0
= src_8
[i
+s3
*3];
864 tmp1
= src_8
[i
+s3
*3+1];
865 tmp2
= src_8
[i
+s3
*3+2];
866 src_8
[i
+s3
*3] = src_8
[i
+s4
*3];
867 src_8
[i
+s3
*3+1] = src_8
[i
+s4
*3+1];
868 src_8
[i
+s3
*3+2] = src_8
[i
+s4
*3+2];
869 src_8
[i
+s4
*3] = src_8
[i
+s5
*3];
870 src_8
[i
+s4
*3+1] = src_8
[i
+s5
*3+1];
871 src_8
[i
+s4
*3+2] = src_8
[i
+s5
*3+2];
872 src_8
[i
+s5
*3] = tmp0
;
873 src_8
[i
+s5
*3+1] = tmp1
;
874 src_8
[i
+s5
*3+2] = tmp2
;
879 int32_t *src_32
= src
;
881 REORDER_SELF_SWAP_3_3(src_32
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
,s5
);
886 int64_t *src_64
= src
;
888 REORDER_SELF_SWAP_3_3(src_64
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
,s5
);
892 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,
893 "[reorder_ch] Unsupported sample size: %d, please "
894 "report this error on the MPlayer mailing list.\n",samplesize
);
900 #define REORDER_SELF_SWAP_2_4(SRC,TMP,SAMPLES,CHNUM,S0,S1,S2,S3,S4,S5) \
901 for (i = 0; i < SAMPLES; i += CHNUM) {\
903 SRC[i+S0] = SRC[i+S1];\
906 SRC[i+S2] = SRC[i+S3];\
907 SRC[i+S3] = SRC[i+S4];\
908 SRC[i+S4] = SRC[i+S5];\
912 static int reorder_self_2_4(void *src
, unsigned int samples
,
913 unsigned int samplesize
,
914 int s0
, int s1
, int s2
, int s3
, int s4
, int s5
)
917 switch (samplesize
) {
922 REORDER_SELF_SWAP_2_4(src_8
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
,s5
);
927 int16_t *src_16
= src
;
929 REORDER_SELF_SWAP_2_4(src_16
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
,s5
);
935 int8_t tmp0
, tmp1
, tmp2
;
936 for (i
= 0; i
< samples
; i
+= 18) {
937 tmp0
= src_8
[i
+s0
*3];
938 tmp1
= src_8
[i
+s0
*3+1];
939 tmp2
= src_8
[i
+s0
*3+2];
940 src_8
[i
+s0
*3] = src_8
[i
+s1
*3];
941 src_8
[i
+s0
*3+1] = src_8
[i
+s1
*3+1];
942 src_8
[i
+s0
*3+2] = src_8
[i
+s1
*3+2];
943 src_8
[i
+s1
*3] = tmp0
;
944 src_8
[i
+s1
*3+1] = tmp1
;
945 src_8
[i
+s1
*3+2] = tmp2
;
946 tmp0
= src_8
[i
+s2
*3];
947 tmp1
= src_8
[i
+s2
*3+1];
948 tmp2
= src_8
[i
+s2
*3+2];
949 src_8
[i
+s2
*3] = src_8
[i
+s3
*3];
950 src_8
[i
+s2
*3+1] = src_8
[i
+s3
*3+1];
951 src_8
[i
+s2
*3+2] = src_8
[i
+s3
*3+2];
952 src_8
[i
+s3
*3] = src_8
[i
+s4
*3];
953 src_8
[i
+s3
*3+1] = src_8
[i
+s4
*3+1];
954 src_8
[i
+s3
*3+2] = src_8
[i
+s4
*3+2];
955 src_8
[i
+s4
*3] = src_8
[i
+s5
*3];
956 src_8
[i
+s4
*3+1] = src_8
[i
+s5
*3+1];
957 src_8
[i
+s4
*3+2] = src_8
[i
+s5
*3+2];
958 src_8
[i
+s5
*3] = tmp0
;
959 src_8
[i
+s5
*3+1] = tmp1
;
960 src_8
[i
+s5
*3+2] = tmp2
;
965 int32_t *src_32
= src
;
967 REORDER_SELF_SWAP_2_4(src_32
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
,s5
);
972 int64_t *src_64
= src
;
974 REORDER_SELF_SWAP_2_4(src_64
,tmp
,samples
,6,s0
,s1
,s2
,s3
,s4
,s5
);
978 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,
979 "[reorder_ch] Unsupported sample size: %d, please "
980 "report this error on the MPlayer mailing list.\n",samplesize
);
986 void reorder_channel(void *src
,
992 if (dest_layout
==src_layout
)
994 if (!AF_IS_SAME_CH_NUM(dest_layout
,src_layout
)) {
995 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,
996 "[reorder_channel] different channel count "
997 "between current and target: %x, %x\n",
998 AF_GET_CH_NUM_WITH_LFE(src_layout
),
999 AF_GET_CH_NUM_WITH_LFE(dest_layout
));
1002 switch ((src_layout
<<16)|dest_layout
) {
1003 // AF_CHANNEL_LAYOUT_5_0_A L R C Ls Rs
1004 // AF_CHANNEL_LAYOUT_5_0_B L R Ls Rs C
1005 // AF_CHANNEL_LAYOUT_5_0_C L C R Ls Rs
1006 // AF_CHANNEL_LAYOUT_5_0_D C L R Ls Rs
1007 case AF_CHANNEL_LAYOUT_5_0_A
<< 16 | AF_CHANNEL_LAYOUT_5_0_B
:
1008 reorder_self_3(src
, samples
, samplesize
, 5, 2, 3, 4);
1010 case AF_CHANNEL_LAYOUT_5_0_A
<< 16 | AF_CHANNEL_LAYOUT_5_0_C
:
1011 reorder_self_2(src
, samples
, samplesize
, 5, 1, 2);
1013 case AF_CHANNEL_LAYOUT_5_0_A
<< 16 | AF_CHANNEL_LAYOUT_5_0_D
:
1014 reorder_self_3(src
, samples
, samplesize
, 5, 2, 1, 0);
1016 case AF_CHANNEL_LAYOUT_5_0_B
<< 16 | AF_CHANNEL_LAYOUT_5_0_A
:
1017 reorder_self_3(src
, samples
, samplesize
, 5, 4, 3, 2);
1019 case AF_CHANNEL_LAYOUT_5_0_B
<< 16 | AF_CHANNEL_LAYOUT_5_0_C
:
1020 reorder_self_4_step_1(src
, samples
, samplesize
, 5, 4, 3, 2, 1);
1022 case AF_CHANNEL_LAYOUT_5_0_B
<< 16 | AF_CHANNEL_LAYOUT_5_0_D
:
1023 reorder_self_5_step_1(src
, samples
, samplesize
, 5, 4, 3, 2, 1, 0);
1025 case AF_CHANNEL_LAYOUT_5_0_C
<< 16 | AF_CHANNEL_LAYOUT_5_0_A
:
1026 reorder_self_2(src
, samples
, samplesize
, 5, 1, 2);
1028 case AF_CHANNEL_LAYOUT_5_0_C
<< 16 | AF_CHANNEL_LAYOUT_5_0_B
:
1029 reorder_self_4_step_1(src
, samples
, samplesize
, 5, 1, 2, 3, 4);
1031 case AF_CHANNEL_LAYOUT_5_0_C
<< 16 | AF_CHANNEL_LAYOUT_5_0_D
:
1032 reorder_self_2(src
, samples
, samplesize
, 5, 0, 1);
1034 case AF_CHANNEL_LAYOUT_5_0_D
<< 16 | AF_CHANNEL_LAYOUT_5_0_A
:
1035 reorder_self_3(src
, samples
, samplesize
, 5, 0, 1, 2);
1037 case AF_CHANNEL_LAYOUT_5_0_D
<< 16 | AF_CHANNEL_LAYOUT_5_0_B
:
1038 reorder_self_5_step_1(src
, samples
, samplesize
, 5, 0, 1, 2, 3, 4);
1040 case AF_CHANNEL_LAYOUT_5_0_D
<< 16 | AF_CHANNEL_LAYOUT_5_0_C
:
1041 reorder_self_2(src
, samples
, samplesize
, 5, 0, 1);
1043 // AF_CHANNEL_LAYOUT_5_1_A L R C LFE Ls Rs
1044 // AF_CHANNEL_LAYOUT_5_1_B L R Ls Rs C LFE
1045 // AF_CHANNEL_LAYOUT_5_1_C L C R Ls Rs LFE
1046 // AF_CHANNEL_LAYOUT_5_1_D C L R Ls Rs LFE
1047 // AF_CHANNEL_LAYOUT_5_1_E LFE L C R Ls Rs
1048 case AF_CHANNEL_LAYOUT_5_1_A
<< 16 | AF_CHANNEL_LAYOUT_5_1_B
:
1049 if (samplesize
!= 3)
1050 reorder_self_2(src
, samples
/2, samplesize
*2, 3, 1, 2);
1052 reorder_self_4_step_2(src
, samples
, samplesize
, 6, 2, 3, 4, 5);
1054 case AF_CHANNEL_LAYOUT_5_1_A
<< 16 | AF_CHANNEL_LAYOUT_5_1_C
:
1055 reorder_self_2_3(src
, samples
, samplesize
, 1, 2, 3, 4, 5);
1057 case AF_CHANNEL_LAYOUT_5_1_A
<< 16 | AF_CHANNEL_LAYOUT_5_1_D
:
1058 reorder_self_3_3(src
, samples
, samplesize
, 2, 1, 0, 3, 4, 5);
1060 case AF_CHANNEL_LAYOUT_5_1_B
<< 16 | AF_CHANNEL_LAYOUT_5_1_A
:
1061 if (samplesize
!= 3)
1062 reorder_self_2(src
, samples
/2, samplesize
*2, 3, 1, 2);
1064 reorder_self_4_step_2(src
, samples
, samplesize
, 6, 2, 3, 4, 5);
1066 case AF_CHANNEL_LAYOUT_5_1_B
<< 16 | AF_CHANNEL_LAYOUT_5_1_C
:
1067 reorder_self_4_step_1(src
, samples
, samplesize
, 6, 4, 3, 2, 1);
1069 case AF_CHANNEL_LAYOUT_5_1_B
<< 16 | AF_CHANNEL_LAYOUT_5_1_D
:
1070 reorder_self_5_step_1(src
, samples
, samplesize
, 6, 4, 3, 2, 1, 0);
1072 case AF_CHANNEL_LAYOUT_5_1_B
<< 16 | AF_CHANNEL_LAYOUT_5_1_E
:
1073 reorder_self_2_4(src
, samples
, samplesize
, 2, 4, 5, 3, 1, 0);
1075 case AF_CHANNEL_LAYOUT_5_1_C
<< 16 | AF_CHANNEL_LAYOUT_5_1_A
:
1076 reorder_self_2_3(src
, samples
, samplesize
, 1, 2, 5, 4, 3);
1078 case AF_CHANNEL_LAYOUT_5_1_C
<< 16 | AF_CHANNEL_LAYOUT_5_1_B
:
1079 reorder_self_4_step_1(src
, samples
, samplesize
, 6, 1, 2, 3, 4);
1081 case AF_CHANNEL_LAYOUT_5_1_C
<< 16 | AF_CHANNEL_LAYOUT_5_1_D
:
1082 reorder_self_2(src
, samples
, samplesize
, 6, 0, 1);
1084 case AF_CHANNEL_LAYOUT_5_1_D
<< 16 | AF_CHANNEL_LAYOUT_5_1_A
:
1085 reorder_self_3_3(src
, samples
, samplesize
, 0, 1, 2, 5, 4, 3);
1087 case AF_CHANNEL_LAYOUT_5_1_D
<< 16 | AF_CHANNEL_LAYOUT_5_1_B
:
1088 reorder_self_5_step_1(src
, samples
, samplesize
, 6, 0, 1, 2, 3, 4);
1090 case AF_CHANNEL_LAYOUT_5_1_D
<< 16 | AF_CHANNEL_LAYOUT_5_1_C
:
1091 reorder_self_2(src
, samples
, samplesize
, 6, 0, 1);
1093 case AF_CHANNEL_LAYOUT_5_1_E
<< 16 | AF_CHANNEL_LAYOUT_5_1_B
:
1094 reorder_self_2_4(src
, samples
, samplesize
, 2, 4, 0, 1, 3, 5);
1097 mp_msg(MSGT_GLOBAL
, MSGL_WARN
,
1098 "[reorder_channel] unsupported from %x to %x, %d * %d\n",
1099 src_layout
, dest_layout
, samples
, samplesize
);
1104 static int channel_layout_mapping_5ch
[AF_CHANNEL_LAYOUT_SOURCE_NUM
] = {
1105 AF_CHANNEL_LAYOUT_ALSA_5CH_DEFAULT
,
1106 AF_CHANNEL_LAYOUT_AAC_5CH_DEFAULT
,
1107 AF_CHANNEL_LAYOUT_WAVEEX_5CH_DEFAULT
,
1108 AF_CHANNEL_LAYOUT_LAVC_AC3_5CH_DEFAULT
,
1109 AF_CHANNEL_LAYOUT_LAVC_LIBA52_5CH_DEFAULT
,
1110 AF_CHANNEL_LAYOUT_LAVC_DCA_5CH_DEFAULT
,
1111 AF_CHANNEL_LAYOUT_VORBIS_5CH_DEFAULT
,
1112 AF_CHANNEL_LAYOUT_FLAC_5CH_DEFAULT
,
1115 static int channel_layout_mapping_6ch
[AF_CHANNEL_LAYOUT_SOURCE_NUM
] = {
1116 AF_CHANNEL_LAYOUT_ALSA_6CH_DEFAULT
,
1117 AF_CHANNEL_LAYOUT_AAC_6CH_DEFAULT
,
1118 AF_CHANNEL_LAYOUT_WAVEEX_6CH_DEFAULT
,
1119 AF_CHANNEL_LAYOUT_LAVC_AC3_6CH_DEFAULT
,
1120 AF_CHANNEL_LAYOUT_LAVC_LIBA52_6CH_DEFAULT
,
1121 AF_CHANNEL_LAYOUT_LAVC_DCA_6CH_DEFAULT
,
1122 AF_CHANNEL_LAYOUT_VORBIS_6CH_DEFAULT
,
1123 AF_CHANNEL_LAYOUT_FLAC_6CH_DEFAULT
,
1126 void reorder_channel_copy_nch(void *src
,
1134 if (chnum
< 5 || chnum
> 6 || src_layout
< 0 || dest_layout
< 0 ||
1135 src_layout
>= AF_CHANNEL_LAYOUT_SOURCE_NUM
||
1136 dest_layout
>= AF_CHANNEL_LAYOUT_SOURCE_NUM
)
1137 fast_memcpy(dest
, src
, samples
*samplesize
);
1138 else if (chnum
== 6)
1139 reorder_channel_copy(src
, channel_layout_mapping_6ch
[src_layout
],
1140 dest
, channel_layout_mapping_6ch
[dest_layout
],
1141 samples
, samplesize
);
1143 reorder_channel_copy(src
, channel_layout_mapping_5ch
[src_layout
],
1144 dest
, channel_layout_mapping_5ch
[dest_layout
],
1145 samples
, samplesize
);
1148 void reorder_channel_nch(void *buf
,
1155 if (src_layout
== dest_layout
|| chnum
< 5 || chnum
> 6 ||
1156 src_layout
< 0 || dest_layout
< 0 ||
1157 src_layout
>= AF_CHANNEL_LAYOUT_SOURCE_NUM
||
1158 dest_layout
>= AF_CHANNEL_LAYOUT_SOURCE_NUM
||
1159 src_layout
== dest_layout
)
1162 reorder_channel(buf
, channel_layout_mapping_6ch
[src_layout
],
1163 channel_layout_mapping_6ch
[dest_layout
],
1164 samples
, samplesize
);
1166 reorder_channel(buf
, channel_layout_mapping_5ch
[src_layout
],
1167 channel_layout_mapping_5ch
[dest_layout
],
1168 samples
, samplesize
);
1174 static void test_copy(int channels
) {
1175 int samples
= 12*1024*1024;
1178 unsigned char *bufin
= malloc((samples
+100)*samplesize
);
1179 unsigned char *bufout
= malloc((samples
+100)*samplesize
);
1180 memset(bufin
, 0xFF, samples
*samplesize
);
1181 for (i
= 0;i
< 100; ++i
)
1182 reorder_channel_copy(bufin
, AF_CHANNEL_LAYOUT_5_1_A
,
1183 bufout
, AF_CHANNEL_LAYOUT_5_1_B
,
1184 samples
, samplesize
);
1185 // reorder_channel(bufin, AF_CHANNEL_LAYOUT_5_1_B,
1186 // AF_CHANNEL_LAYOUT_5_1_D,
1187 // samples, samplesize);
1192 int main(int argc
, char *argv
[]) {
1195 channels
= atoi(argv
[1]);
1196 test_copy(channels
);