annotate libaf/reorder_ch.c @ 29812:54aafbe45eb4

Add a comment that the PIC handling in mangle.h is duplicate also in configure and libavutil and fixes to one should be applied to the others, too.
author reimar
date Sun, 08 Nov 2009 15:39:54 +0000
parents 816c1f02ebfe
children 9cf56cc1bbb2
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;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
71 for (i = 0; i < samples; i += 15) {
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;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
147 for (i = 0; i < samples; i += 18) {
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
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
192 void reorder_channel_copy(void *src,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
193 int src_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
194 void *dest,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
195 int dest_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
196 int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
197 int samplesize)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
198 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
199 if (dest_layout==src_layout) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
200 fast_memcpy(dest, src, samples*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
201 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
202 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
203 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
204 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
205 "between src and dest: %x, %x\n",
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
206 AF_GET_CH_NUM_WITH_LFE(src_layout),
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
207 AF_GET_CH_NUM_WITH_LFE(dest_layout));
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
208 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
209 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
210 switch ((src_layout<<16)|dest_layout) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
211 // 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
212 // 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
213 // 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
214 // 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
215 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
216 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
217 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
218 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
219 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
220 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
221 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
222 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
223 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
224 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
225 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
226 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
227 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
228 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
229 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
230 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
231 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
232 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
233 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
234 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
235 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
236 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
237 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
238 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
239 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
240 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
241 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
242 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
243 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
244 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
245 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
246 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
247 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
248 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
249 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
250 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
251 // 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
252 // 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
253 // 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
254 // 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
255 // 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
256 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
257 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
258 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
259 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
260 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
261 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
262 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
263 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
264 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
265 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
266 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
267 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
268 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
269 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
270 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
271 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
272 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
273 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
274 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
275 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
276 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
277 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
278 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
279 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
280 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
281 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
282 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
283 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
284 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
285 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
286 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
287 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
288 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
289 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
290 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
291 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
292 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
293 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
294 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
295 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
296 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
297 break;
29491
99eda963d27a Fix incorrect channel ordering for lavc audio codecs (specifically ffac3,
tack
parents: 29385
diff changeset
298 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
299 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
300 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
301 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
302 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
303 "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
304 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
305 fast_memcpy(dest, src, samples*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
306 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
307 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
308
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
309
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
310 #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
311 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
312 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
313 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
314 SRC[i+S1] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
315 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
316
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
317 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
318 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
319 int s0, int s1)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
320 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
321 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
322 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
323 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
324 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
325 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
326 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
327 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
328 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
329 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
330 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
331 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
332 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
333 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
334 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
335 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
336 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
337 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
338 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
339 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
340 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
341 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
342 else if (chnum==3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
343 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
344 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
345 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
346 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
347 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
348 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
349 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
350 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
351 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
352 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
353 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
354 for (i = 0; i < samples; i += chnum*3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
355 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
356 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
357 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
358 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
359 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
360 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
361 src_8[i+s1*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
362 src_8[i+s1*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
363 src_8[i+s1*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
364 }
29499
e8072b90858e Fix channel reordering when using 24-bit samples by adding breaks to cases
tack
parents: 29491
diff changeset
365 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
366 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
367 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
368 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
369 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
370 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
371 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
372 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
373 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
374 else if (chnum==3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
375 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
376 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
377 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
378 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
379 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
380 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
381 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
382 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
383 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
384 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
385 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
386 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
387 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
388 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
389 else if (chnum==3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
390 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
391 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
392 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
393 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
394 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
395 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
396 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
397 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
398 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
399 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
400 "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
401 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
402 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
403 return 1;
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 #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
407 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
408 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
409 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
410 SRC[i+S1] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
411 SRC[i+S2] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
412 }
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 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
415 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
416 int s0, int s1, int s2)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
417 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
418 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
419 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
420 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
421 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
422 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
423 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
424 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
425 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
426 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
427 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
428 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
429 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
430 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
431 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
432 case 2:
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 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
435 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
436 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
437 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
438 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
439 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
440 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
441 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
442 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
443 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
444 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
445 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
446 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
447 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
448 for (i = 0; i < samples; i += chnum*3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
449 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
450 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
451 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
452 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
453 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
454 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
455 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
456 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
457 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
458 src_8[i+s2*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
459 src_8[i+s2*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
460 src_8[i+s2*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
461 }
29385
f9ae25067fe0 Fix 24bit audio playback.
iive
parents: 27700
diff changeset
462 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
463 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
464 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
465 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
466 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
467 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
468 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
469 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
470 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
471 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
472 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
473 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
474 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
475 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
476 case 8:
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 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
479 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
480 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
481 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
482 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
483 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
484 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
485 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
486 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
487 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
488 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
489 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
490 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
491 "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
492 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
493 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
494 return 1;
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
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
497 #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
498 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
499 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
500 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
501 SRC[i+S1] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
502 SRC[i+S2] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
503 SRC[i+S3] = TMP;\
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
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
506 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
507 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
508 int s0, int s1, int s2, int s3)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
509 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
510 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
511 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
512 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
513 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
514 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
515 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
516 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
517 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
518 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
519 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
520 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
521 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
522 break;
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 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
525 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
526 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
527 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
528 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
529 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
530 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
531 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
532 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
533 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
534 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
535 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
536 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
537 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
538 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
539 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
540 for (i = 0; i < samples; i += chnum*3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
541 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
542 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
543 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
544 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
545 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
546 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
547 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
548 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
549 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
550 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
551 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
552 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
553 src_8[i+s3*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
554 src_8[i+s3*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
555 src_8[i+s3*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
556 }
29385
f9ae25067fe0 Fix 24bit audio playback.
iive
parents: 27700
diff changeset
557 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
558 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
559 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
560 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
561 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
562 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
563 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
564 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
565 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
566 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
567 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
568 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
569 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
570 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
571 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
572 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
573 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
574 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
575 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
576 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
577 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
578 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
579 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
580 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
581 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
582 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
583 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
584 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
585 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
586 "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
587 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
588 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
589 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
590 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
591
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
592 #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
593 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
594 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
595 SRC[i+S0] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
596 SRC[i+S2] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
597 TMP = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
598 SRC[i+S1] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
599 SRC[i+S3] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
600 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
601
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
602 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
603 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
604 int s0, int s1, int s2, int s3)
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 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
607 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
608 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
609 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
610 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
611 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
612 for (i = 0; i < samples; i += chnum*3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
613 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
614 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
615 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
616 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
617 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
618 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
619 src_8[i+s2*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
620 src_8[i+s2*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
621 src_8[i+s2*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
622 tmp0 = src_8[i+s1*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
623 tmp1 = src_8[i+s1*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
624 tmp2 = src_8[i+s1*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
625 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
626 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
627 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
628 src_8[i+s3*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
629 src_8[i+s3*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
630 src_8[i+s3*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
631 }
29499
e8072b90858e Fix channel reordering when using 24-bit samples by adding breaks to cases
tack
parents: 29491
diff changeset
632 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
633 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
634 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
635 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
636 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
637 "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
638 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
639 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
640 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
641 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
642
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
643 #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
644 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
645 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
646 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
647 SRC[i+S1] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
648 SRC[i+S2] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
649 SRC[i+S3] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
650 SRC[i+S4] = TMP;\
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
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
653 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
654 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
655 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
656 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
657 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
658 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
659 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
660 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
661 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
662 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
663 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
664 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
665 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
666 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
667 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
668 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
669 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
670 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
671 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
672 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
673 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
674 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
675 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
676 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
677 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
678 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
679 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
680 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
681 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
682 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
683 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
684 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
685 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
686 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
687 for (i = 0; i < samples; i += chnum*3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
688 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
689 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
690 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
691 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
692 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
693 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
694 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
695 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
696 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
697 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
698 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
699 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
700 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
701 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
702 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
703 src_8[i+s4*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
704 src_8[i+s4*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
705 src_8[i+s4*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
706 }
29385
f9ae25067fe0 Fix 24bit audio playback.
iive
parents: 27700
diff changeset
707 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
708 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
709 case 4:
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 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
712 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
713 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
714 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
715 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
716 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
717 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
718 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
719 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
720 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
721 case 8:
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 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
724 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
725 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
726 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
727 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
728 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
729 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
730 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
731 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
732 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
733 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
734 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
735 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
736 "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
737 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
738 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
739 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
740 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
741
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
742 #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
743 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
744 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
745 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
746 SRC[i+S1] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
747 TMP = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
748 SRC[i+S2] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
749 SRC[i+S3] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
750 SRC[i+S4] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
751 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
752
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
753 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
754 unsigned int samplesize,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
755 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
756 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
757 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
758 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
759 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
760 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
761 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
762 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
763 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
764 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
765 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
766 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
767 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
768 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
769 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
770 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
771 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
772 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
773 case 3:
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 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
776 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
777 for (i = 0; i < samples; i += 18) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
778 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
779 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
780 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
781 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
782 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
783 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
784 src_8[i+s1*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
785 src_8[i+s1*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
786 src_8[i+s1*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
787 tmp0 = src_8[i+s2*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
788 tmp1 = src_8[i+s2*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
789 tmp2 = src_8[i+s2*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
790 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
791 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
792 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
793 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
794 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
795 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
796 src_8[i+s4*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
797 src_8[i+s4*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
798 src_8[i+s4*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
799 }
29385
f9ae25067fe0 Fix 24bit audio playback.
iive
parents: 27700
diff changeset
800 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
801 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
802 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
803 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
804 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
805 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
806 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
807 break;
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 case 8:
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 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
812 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
813 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
814 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
815 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
816 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
817 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
818 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
819 "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
820 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
821 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
822 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
823 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
824
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
825 #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
826 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
827 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
828 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
829 SRC[i+S1] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
830 SRC[i+S2] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
831 TMP = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
832 SRC[i+S3] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
833 SRC[i+S4] = SRC[i+S5];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
834 SRC[i+S5] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
835 }
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 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
838 unsigned int samplesize,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
839 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
840 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
841 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
842 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
843 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
844 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
845 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
846 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
847 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
848 break;
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 case 2:
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 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
853 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
854 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
855 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
856 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
857 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
858 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
859 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
860 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
861 for (i = 0; i < samples; i += 18) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
862 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
863 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
864 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
865 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
866 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
867 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
868 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
869 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
870 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
871 src_8[i+s2*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
872 src_8[i+s2*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
873 src_8[i+s2*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
874 tmp0 = src_8[i+s3*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
875 tmp1 = src_8[i+s3*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
876 tmp2 = src_8[i+s3*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
877 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
878 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
879 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
880 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
881 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
882 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
883 src_8[i+s5*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
884 src_8[i+s5*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
885 src_8[i+s5*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
886 }
29385
f9ae25067fe0 Fix 24bit audio playback.
iive
parents: 27700
diff changeset
887 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
888 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
889 case 4:
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 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
892 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
893 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
894 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
895 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
896 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
897 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
898 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
899 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
900 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
901 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
902 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
903 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
904 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
905 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
906 "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
907 return 0;
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 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
910 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
911
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
912 #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
913 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
914 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
915 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
916 SRC[i+S1] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
917 TMP = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
918 SRC[i+S2] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
919 SRC[i+S3] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
920 SRC[i+S4] = SRC[i+S5];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
921 SRC[i+S5] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
922 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
923
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
924 static int reorder_self_2_4(void *src, unsigned int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
925 unsigned int samplesize,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
926 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
927 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
928 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
929 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
930 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
931 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
932 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
933 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
934 REORDER_SELF_SWAP_2_4(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
935 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
936 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
937 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
938 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
939 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
940 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
941 REORDER_SELF_SWAP_2_4(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
942 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
943 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
944 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
945 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
946 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
947 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
948 for (i = 0; i < samples; i += 18) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
949 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
950 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
951 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
952 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
953 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
954 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
955 src_8[i+s1*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
956 src_8[i+s1*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
957 src_8[i+s1*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
958 tmp0 = src_8[i+s2*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
959 tmp1 = src_8[i+s2*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
960 tmp2 = src_8[i+s2*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
961 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
962 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
963 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
964 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
965 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
966 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
967 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
968 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
969 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
970 src_8[i+s5*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
971 src_8[i+s5*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
972 src_8[i+s5*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
973 }
29385
f9ae25067fe0 Fix 24bit audio playback.
iive
parents: 27700
diff changeset
974 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
975 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
976 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
977 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
978 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
979 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
980 REORDER_SELF_SWAP_2_4(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
981 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
982 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
983 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
984 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
985 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
986 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
987 REORDER_SELF_SWAP_2_4(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
988 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
989 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
990 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
991 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
992 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
993 "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
994 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
995 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
996 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
997 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
998
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
999 void reorder_channel(void *src,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1000 int src_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1001 int dest_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1002 int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1003 int samplesize)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1004 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1005 if (dest_layout==src_layout)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1006 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1007 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
1008 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1009 "[reorder_channel] different channel count "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1010 "between current and target: %x, %x\n",
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1011 AF_GET_CH_NUM_WITH_LFE(src_layout),
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1012 AF_GET_CH_NUM_WITH_LFE(dest_layout));
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1013 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1014 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1015 switch ((src_layout<<16)|dest_layout) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1016 // 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
1017 // 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
1018 // 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
1019 // 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
1020 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
1021 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
1022 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1023 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
1024 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
1025 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1026 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
1027 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
1028 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1029 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
1030 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
1031 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1032 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
1033 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
1034 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1035 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
1036 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
1037 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1038 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
1039 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
1040 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1041 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
1042 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
1043 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1044 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
1045 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
1046 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1047 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
1048 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
1049 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1050 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
1051 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
1052 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1053 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
1054 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
1055 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1056 // 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
1057 // 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
1058 // 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
1059 // 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
1060 // 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
1061 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
1062 if (samplesize != 3)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1063 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
1064 else
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1065 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
1066 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1067 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
1068 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
1069 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1070 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
1071 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
1072 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1073 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
1074 if (samplesize != 3)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1075 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
1076 else
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1077 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
1078 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1079 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
1080 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
1081 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1082 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
1083 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
1084 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1085 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
1086 reorder_self_2_4(src, samples, samplesize, 2, 4, 5, 3, 1, 0);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1087 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1088 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
1089 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
1090 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1091 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
1092 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
1093 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1094 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
1095 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
1096 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1097 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
1098 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
1099 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1100 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
1101 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
1102 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1103 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
1104 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
1105 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1106 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
1107 reorder_self_2_4(src, samples, samplesize, 2, 4, 0, 1, 3, 5);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1108 break;
29491
99eda963d27a Fix incorrect channel ordering for lavc audio codecs (specifically ffac3,
tack
parents: 29385
diff changeset
1109 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
1110 reorder_self_2_4(src, samples, samplesize, 3, 5, 0, 1, 2, 4);
99eda963d27a Fix incorrect channel ordering for lavc audio codecs (specifically ffac3,
tack
parents: 29385
diff changeset
1111 break;
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1112 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1113 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1114 "[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
1115 src_layout, dest_layout, samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1116 }
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
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 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
1121 AF_CHANNEL_LAYOUT_ALSA_5CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1122 AF_CHANNEL_LAYOUT_AAC_5CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1123 AF_CHANNEL_LAYOUT_WAVEEX_5CH_DEFAULT,
29491
99eda963d27a Fix incorrect channel ordering for lavc audio codecs (specifically ffac3,
tack
parents: 29385
diff changeset
1124 AF_CHANNEL_LAYOUT_LAVC_5CH_DEFAULT,
26987
d3a0f537dbe8 rename AF_CHANNEL_LAYOUT_LAVC_VORBIS* => AF_CHANNEL_LAYOUT_VORBIS*.
ulion
parents: 26740
diff changeset
1125 AF_CHANNEL_LAYOUT_VORBIS_5CH_DEFAULT,
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1126 };
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1127
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1128 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
1129 AF_CHANNEL_LAYOUT_ALSA_6CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1130 AF_CHANNEL_LAYOUT_AAC_6CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1131 AF_CHANNEL_LAYOUT_WAVEEX_6CH_DEFAULT,
29491
99eda963d27a Fix incorrect channel ordering for lavc audio codecs (specifically ffac3,
tack
parents: 29385
diff changeset
1132 AF_CHANNEL_LAYOUT_LAVC_6CH_DEFAULT,
26987
d3a0f537dbe8 rename AF_CHANNEL_LAYOUT_LAVC_VORBIS* => AF_CHANNEL_LAYOUT_VORBIS*.
ulion
parents: 26740
diff changeset
1133 AF_CHANNEL_LAYOUT_VORBIS_6CH_DEFAULT,
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1134 };
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1135
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1136 void reorder_channel_copy_nch(void *src,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1137 int src_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1138 void *dest,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1139 int dest_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1140 int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1141 int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1142 int samplesize)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1143 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1144 if (chnum < 5 || chnum > 6 || src_layout < 0 || dest_layout < 0 ||
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1145 src_layout >= AF_CHANNEL_LAYOUT_SOURCE_NUM ||
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1146 dest_layout >= AF_CHANNEL_LAYOUT_SOURCE_NUM)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1147 fast_memcpy(dest, src, samples*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1148 else if (chnum == 6)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1149 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
1150 dest, channel_layout_mapping_6ch[dest_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1151 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1152 else
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1153 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
1154 dest, channel_layout_mapping_5ch[dest_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1155 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1156 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1157
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1158 void reorder_channel_nch(void *buf,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1159 int src_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1160 int dest_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1161 int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1162 int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1163 int samplesize)
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 if (src_layout == dest_layout || chnum < 5 || chnum > 6 ||
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1166 src_layout < 0 || dest_layout < 0 ||
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1167 src_layout >= AF_CHANNEL_LAYOUT_SOURCE_NUM ||
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1168 dest_layout >= AF_CHANNEL_LAYOUT_SOURCE_NUM ||
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1169 src_layout == dest_layout)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1170 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1171 if (chnum == 6)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1172 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
1173 channel_layout_mapping_6ch[dest_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1174 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1175 else
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1176 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
1177 channel_layout_mapping_5ch[dest_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1178 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1179 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1180
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1181
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1182 #ifdef TEST
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1183
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1184 static void test_copy(int channels) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1185 int samples = 12*1024*1024;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1186 int samplesize = 2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1187 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1188 unsigned char *bufin = malloc((samples+100)*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1189 unsigned char *bufout = malloc((samples+100)*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1190 memset(bufin, 0xFF, samples*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1191 for (i = 0;i < 100; ++i)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1192 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
1193 bufout, AF_CHANNEL_LAYOUT_5_1_B,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1194 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1195 // 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
1196 // AF_CHANNEL_LAYOUT_5_1_D,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1197 // samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1198 free(bufin);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1199 free(bufout);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1200 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1201
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1202 int main(int argc, char *argv[]) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1203 int channels = 6;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1204 if (argc > 1)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1205 channels = atoi(argv[1]);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1206 test_copy(channels);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1207 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1208 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1209
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1210 #endif
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1211