annotate libaf/reorder_ch.c @ 26026:a1e19c442cab

Create standard multiple inclusion guards.
author diego
date Thu, 21 Feb 2008 22:57:10 +0000
parents dfa8a510c81c
children b6280829f7f8
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 *
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
19 * along with MPlayer; if not, write to the Free Software
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
88 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
89 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
90 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
91 int32_t *dest_32 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
92 const int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
93 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
94 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
95 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
96 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
97 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
98 int64_t *dest_64 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
99 const int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
100 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
101 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
102 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
103 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
104 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
105 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
106 "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
107 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
108 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
109 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
110 }
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 #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
113 for (i = 0; i < SAMPLES; i += 6) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
114 DEST[i] = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
115 DEST[i+1] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
116 DEST[i+2] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
117 DEST[i+3] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
118 DEST[i+4] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
119 DEST[i+5] = SRC[i+S5];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
120 }
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 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
123 unsigned int samples, uint8_t samplesize,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
124 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
125 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
126 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
127 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
128 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
129 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
130 int8_t *dest_8 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
131 const int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
132 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
133 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
134 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
135 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
136 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
137 int16_t *dest_16 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
138 const int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
139 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
140 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
141 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
142 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
143 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
144 int8_t *dest_8 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
145 const int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
146 for (i = 0; i < samples; i += 18) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
147 dest_8[i] = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
148 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
149 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
150 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 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
164 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
165 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
166 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
167 case 4:
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 int32_t *dest_32 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
170 const int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
171 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
172 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
173 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
174 case 8:
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 int64_t *dest_64 = dest;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
177 const int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
178 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
179 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
180 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
181 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
182 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
183 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
184 "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
185 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
186 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
187 return 1;
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
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
190 void reorder_channel_copy(void *src,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
191 int src_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
192 void *dest,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
193 int dest_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
194 int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
195 int samplesize)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
196 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
197 if (dest_layout==src_layout) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
198 fast_memcpy(dest, src, samples*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
199 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
200 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
201 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
202 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
203 "between src and dest: %x, %x\n",
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
204 AF_GET_CH_NUM_WITH_LFE(src_layout),
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
205 AF_GET_CH_NUM_WITH_LFE(dest_layout));
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
206 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
207 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
208 switch ((src_layout<<16)|dest_layout) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
209 // 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
210 // 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
211 // 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
212 // 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
213 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
214 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
215 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
216 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
217 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
218 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
219 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
220 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
221 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
222 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
223 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
224 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
225 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
226 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
227 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
228 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
229 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
230 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
231 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
232 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
233 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
234 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
235 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
236 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
237 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
238 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
239 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
240 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
241 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
242 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
243 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
244 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
245 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
246 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
247 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
248 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
249 // 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
250 // 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
251 // 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
252 // 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
253 // 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
254 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
255 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
256 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
257 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
258 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
259 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
260 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
261 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
262 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
263 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
264 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
265 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
266 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
267 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
268 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
269 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
270 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
271 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
272 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
273 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
274 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
275 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
276 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
277 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
278 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
279 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
280 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
281 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
282 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
283 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
284 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
285 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
286 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
287 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
288 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
289 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
290 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
291 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
292 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
293 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
294 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
295 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
296 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
297 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
298 "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
299 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
300 fast_memcpy(dest, src, samples*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
301 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
302 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
303
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
304
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
305 #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
306 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
307 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
308 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
309 SRC[i+S1] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
310 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
311
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
312 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
313 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
314 int s0, int s1)
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 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
317 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
318 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
319 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
320 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
321 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
322 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
323 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
324 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
325 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
326 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
327 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
328 break;
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 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
331 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
332 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
333 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
334 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
335 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
336 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
337 else if (chnum==3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
338 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
339 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
340 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
341 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
342 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
343 break;
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 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
346 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
347 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
348 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
349 for (i = 0; i < samples; i += chnum*3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
350 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
351 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
352 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
353 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
354 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
355 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
356 src_8[i+s1*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
357 src_8[i+s1*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
358 src_8[i+s1*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
359 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
360 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
361 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
362 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
363 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
364 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
365 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
366 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
367 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
368 else if (chnum==3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
369 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
370 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
371 else {
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,5,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 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
375 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
376 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
377 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
378 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
379 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
380 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
381 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
382 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
383 else if (chnum==3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
384 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
385 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
386 else {
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,5,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 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
390 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
391 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
392 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
393 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
394 "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
395 return 0;
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 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
398 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
399
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
400 #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
401 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
402 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
403 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
404 SRC[i+S1] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
405 SRC[i+S2] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
406 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
407
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
408 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
409 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
410 int s0, int s1, int s2)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
411 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
412 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
413 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
414 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
415 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
416 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
417 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
418 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
419 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
420 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
421 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
422 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
423 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
424 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
425 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
426 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
427 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
428 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
429 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
430 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
431 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
432 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
433 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
434 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
435 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
436 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
437 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
438 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
439 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
440 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
441 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
442 for (i = 0; i < samples; i += chnum*3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
443 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
444 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
445 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
446 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
447 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
448 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
449 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
450 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
451 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
452 src_8[i+s2*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
453 src_8[i+s2*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
454 src_8[i+s2*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
455 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
456 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
457 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
458 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
459 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
460 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
461 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
462 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
463 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
464 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
465 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
466 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
467 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
468 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
469 case 8:
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 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
472 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
473 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
474 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
475 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
476 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
477 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
478 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
479 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
480 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
481 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
482 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
483 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
484 "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
485 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
486 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
487 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
488 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
489
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
490 #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
491 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
492 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
493 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
494 SRC[i+S1] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
495 SRC[i+S2] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
496 SRC[i+S3] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
497 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
498
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
499 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
500 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
501 int s0, int s1, int s2, int s3)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
502 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
503 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
504 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
505 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
506 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
507 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
508 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
509 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
510 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
511 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
512 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
513 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
514 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
515 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
516 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
517 case 2:
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 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
520 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
521 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
522 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
523 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
524 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
525 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
526 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
527 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
528 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
529 case 3:
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 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
532 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
533 for (i = 0; i < samples; i += chnum*3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
534 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
535 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
536 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
537 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
538 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
539 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
540 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
541 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
542 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
543 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
544 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
545 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
546 src_8[i+s3*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
547 src_8[i+s3*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
548 src_8[i+s3*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
549 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
550 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
551 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
552 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
553 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
554 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
555 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
556 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
557 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
558 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
559 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
560 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
561 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
562 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
563 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
564 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
565 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
566 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
567 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
568 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
569 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
570 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
571 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
572 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
573 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
574 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
575 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
576 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
577 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
578 "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
579 return 0;
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 return 1;
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
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
584 #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
585 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
586 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
587 SRC[i+S0] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
588 SRC[i+S2] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
589 TMP = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
590 SRC[i+S1] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
591 SRC[i+S3] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
592 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
593
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
594 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
595 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
596 int s0, int s1, int s2, int s3)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
597 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
598 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
599 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
600 case 3:
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 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
603 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
604 for (i = 0; i < samples; i += chnum*3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
605 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
606 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
607 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
608 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
609 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
610 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
611 src_8[i+s2*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
612 src_8[i+s2*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
613 src_8[i+s2*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
614 tmp0 = src_8[i+s1*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
615 tmp1 = src_8[i+s1*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
616 tmp2 = src_8[i+s1*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
617 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
618 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
619 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
620 src_8[i+s3*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
621 src_8[i+s3*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
622 src_8[i+s3*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
623 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
624 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
625 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
626 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
627 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
628 "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
629 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
630 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
631 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
632 }
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 #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
635 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
636 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
637 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
638 SRC[i+S1] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
639 SRC[i+S2] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
640 SRC[i+S3] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
641 SRC[i+S4] = TMP;\
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
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
644 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
645 unsigned int samplesize, unsigned int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
646 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
647 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
648 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
649 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
650 case 1:
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 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
653 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
654 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
655 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
656 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
657 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
658 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
659 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
660 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
661 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
662 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
663 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
664 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
665 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
666 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
667 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
668 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
669 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
670 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
671 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
672 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
673 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
674 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
675 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
676 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
677 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
678 for (i = 0; i < samples; i += chnum*3) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
679 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
680 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
681 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
682 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
683 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
684 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
685 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
686 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
687 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
688 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
689 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
690 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
691 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
692 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
693 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
694 src_8[i+s4*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
695 src_8[i+s4*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
696 src_8[i+s4*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
697 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
698 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
699 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
700 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
701 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
702 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
703 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
704 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
705 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
706 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
707 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
708 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
709 break;
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 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
712 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
713 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
714 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
715 if (chnum==6) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
716 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
717 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
718 else {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
719 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
720 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
721 break;
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 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
724 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
725 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
726 "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
727 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
728 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
729 return 1;
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
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
732 #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
733 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
734 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
735 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
736 SRC[i+S1] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
737 TMP = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
738 SRC[i+S2] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
739 SRC[i+S3] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
740 SRC[i+S4] = TMP;\
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
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
743 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
744 unsigned int samplesize,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
745 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
746 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
747 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
748 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
749 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
750 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
751 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
752 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
753 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
754 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
755 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
756 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
757 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
758 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
759 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
760 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
761 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
762 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
763 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
764 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
765 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
766 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
767 for (i = 0; i < samples; i += 18) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
768 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
769 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
770 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
771 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
772 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
773 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
774 src_8[i+s1*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
775 src_8[i+s1*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
776 src_8[i+s1*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
777 tmp0 = src_8[i+s2*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
778 tmp1 = src_8[i+s2*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
779 tmp2 = src_8[i+s2*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
780 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
781 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
782 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
783 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
784 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
785 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
786 src_8[i+s4*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
787 src_8[i+s4*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
788 src_8[i+s4*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
789 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
790 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
791 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
792 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
793 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
794 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
795 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
796 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
797 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
798 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
799 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
800 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
801 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
802 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
803 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
804 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
805 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
806 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
807 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
808 "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
809 return 0;
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 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
812 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
813
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
814 #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
815 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
816 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
817 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
818 SRC[i+S1] = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
819 SRC[i+S2] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
820 TMP = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
821 SRC[i+S3] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
822 SRC[i+S4] = SRC[i+S5];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
823 SRC[i+S5] = TMP;\
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
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
826 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
827 unsigned int samplesize,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
828 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
829 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
830 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
831 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
832 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
833 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
834 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
835 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
836 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
837 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
838 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
839 case 2:
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 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
842 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
843 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
844 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
845 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
846 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
847 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
848 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
849 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
850 for (i = 0; i < samples; i += 18) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
851 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
852 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
853 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
854 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
855 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
856 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
857 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
858 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
859 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
860 src_8[i+s2*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
861 src_8[i+s2*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
862 src_8[i+s2*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
863 tmp0 = src_8[i+s3*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
864 tmp1 = src_8[i+s3*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
865 tmp2 = src_8[i+s3*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
866 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
867 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
868 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
869 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
870 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
871 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
872 src_8[i+s5*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
873 src_8[i+s5*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
874 src_8[i+s5*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
875 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
876 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
877 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
878 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
879 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
880 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
881 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
882 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
883 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
884 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
885 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
886 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
887 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
888 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
889 break;
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 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
892 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
893 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
894 "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
895 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
896 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
897 return 1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
898 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
899
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
900 #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
901 for (i = 0; i < SAMPLES; i += CHNUM) {\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
902 TMP = SRC[i+S0];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
903 SRC[i+S0] = SRC[i+S1];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
904 SRC[i+S1] = TMP;\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
905 TMP = SRC[i+S2];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
906 SRC[i+S2] = SRC[i+S3];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
907 SRC[i+S3] = SRC[i+S4];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
908 SRC[i+S4] = SRC[i+S5];\
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
909 SRC[i+S5] = TMP;\
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 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
913 unsigned int samplesize,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
914 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
915 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
916 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
917 switch (samplesize) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
918 case 1:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
919 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
920 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
921 int8_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
922 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
923 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
924 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
925 case 2:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
926 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
927 int16_t *src_16 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
928 int16_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
929 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
930 break;
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 case 3:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
933 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
934 int8_t *src_8 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
935 int8_t tmp0, tmp1, tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
936 for (i = 0; i < samples; i += 18) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
937 tmp0 = src_8[i+s0*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
938 tmp1 = src_8[i+s0*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
939 tmp2 = src_8[i+s0*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
940 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
941 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
942 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
943 src_8[i+s1*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
944 src_8[i+s1*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
945 src_8[i+s1*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
946 tmp0 = src_8[i+s2*3];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
947 tmp1 = src_8[i+s2*3+1];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
948 tmp2 = src_8[i+s2*3+2];
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
949 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
950 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
951 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
952 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
953 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
954 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
955 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
956 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
957 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
958 src_8[i+s5*3] = tmp0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
959 src_8[i+s5*3+1] = tmp1;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
960 src_8[i+s5*3+2] = tmp2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
961 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
962 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
963 case 4:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
964 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
965 int32_t *src_32 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
966 int32_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
967 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
968 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
969 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
970 case 8:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
971 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
972 int64_t *src_64 = src;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
973 int64_t tmp;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
974 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
975 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
976 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
977 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
978 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
979 "[reorder_ch] Unsupported sample size: %d, please "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
980 "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
981 return 0;
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 return 1;
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
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
986 void reorder_channel(void *src,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
987 int src_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
988 int dest_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
989 int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
990 int samplesize)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
991 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
992 if (dest_layout==src_layout)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
993 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
994 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
995 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
996 "[reorder_channel] different channel count "
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
997 "between current and target: %x, %x\n",
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
998 AF_GET_CH_NUM_WITH_LFE(src_layout),
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
999 AF_GET_CH_NUM_WITH_LFE(dest_layout));
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1000 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1001 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1002 switch ((src_layout<<16)|dest_layout) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1003 // 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
1004 // 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
1005 // 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
1006 // 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
1007 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
1008 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
1009 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1010 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
1011 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
1012 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1013 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
1014 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
1015 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1016 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
1017 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
1018 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1019 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
1020 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
1021 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1022 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
1023 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
1024 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1025 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
1026 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
1027 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1028 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
1029 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
1030 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1031 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
1032 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
1033 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1034 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
1035 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
1036 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1037 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
1038 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
1039 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1040 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
1041 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
1042 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1043 // 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
1044 // 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
1045 // 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
1046 // 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
1047 // 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
1048 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
1049 if (samplesize != 3)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1050 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
1051 else
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1052 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
1053 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1054 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
1055 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
1056 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1057 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
1058 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
1059 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1060 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
1061 if (samplesize != 3)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1062 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
1063 else
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1064 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
1065 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1066 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
1067 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
1068 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1069 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
1070 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
1071 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1072 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
1073 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
1074 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1075 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
1076 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
1077 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1078 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
1079 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
1080 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1081 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
1082 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
1083 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1084 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
1085 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
1086 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1087 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
1088 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
1089 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1090 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
1091 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
1092 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1093 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
1094 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
1095 break;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1096 default:
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1097 mp_msg(MSGT_GLOBAL, MSGL_WARN,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1098 "[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
1099 src_layout, dest_layout, samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1100 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1101 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1102
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1103
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1104 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
1105 AF_CHANNEL_LAYOUT_ALSA_5CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1106 AF_CHANNEL_LAYOUT_AAC_5CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1107 AF_CHANNEL_LAYOUT_WAVEEX_5CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1108 AF_CHANNEL_LAYOUT_LAVC_AC3_5CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1109 AF_CHANNEL_LAYOUT_LAVC_LIBA52_5CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1110 AF_CHANNEL_LAYOUT_LAVC_DCA_5CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1111 };
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1112
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1113 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
1114 AF_CHANNEL_LAYOUT_ALSA_6CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1115 AF_CHANNEL_LAYOUT_AAC_6CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1116 AF_CHANNEL_LAYOUT_WAVEEX_6CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1117 AF_CHANNEL_LAYOUT_LAVC_AC3_6CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1118 AF_CHANNEL_LAYOUT_LAVC_LIBA52_6CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1119 AF_CHANNEL_LAYOUT_LAVC_DCA_6CH_DEFAULT,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1120 };
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1121
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1122 void reorder_channel_copy_nch(void *src,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1123 int src_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1124 void *dest,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1125 int dest_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1126 int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1127 int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1128 int samplesize)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1129 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1130 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
1131 src_layout >= AF_CHANNEL_LAYOUT_SOURCE_NUM ||
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1132 dest_layout >= AF_CHANNEL_LAYOUT_SOURCE_NUM)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1133 fast_memcpy(dest, src, samples*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1134 else if (chnum == 6)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1135 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
1136 dest, channel_layout_mapping_6ch[dest_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1137 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1138 else
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1139 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
1140 dest, channel_layout_mapping_5ch[dest_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1141 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1142 }
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 void reorder_channel_nch(void *buf,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1145 int src_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1146 int dest_layout,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1147 int chnum,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1148 int samples,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1149 int samplesize)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1150 {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1151 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
1152 src_layout < 0 || dest_layout < 0 ||
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1153 src_layout >= AF_CHANNEL_LAYOUT_SOURCE_NUM ||
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1154 dest_layout >= AF_CHANNEL_LAYOUT_SOURCE_NUM ||
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1155 src_layout == dest_layout)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1156 return;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1157 if (chnum == 6)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1158 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
1159 channel_layout_mapping_6ch[dest_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1160 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1161 else
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1162 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
1163 channel_layout_mapping_5ch[dest_layout],
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1164 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1165 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1166
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1167
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1168 #ifdef TEST
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1169
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1170 static void test_copy(int channels) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1171 int samples = 12*1024*1024;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1172 int samplesize = 2;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1173 int i;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1174 unsigned char *bufin = malloc((samples+100)*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1175 unsigned char *bufout = malloc((samples+100)*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1176 memset(bufin, 0xFF, samples*samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1177 for (i = 0;i < 100; ++i)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1178 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
1179 bufout, AF_CHANNEL_LAYOUT_5_1_B,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1180 samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1181 // 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
1182 // AF_CHANNEL_LAYOUT_5_1_D,
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1183 // samples, samplesize);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1184 free(bufin);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1185 free(bufout);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1186 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1187
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1188 int main(int argc, char *argv[]) {
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1189 int channels = 6;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1190 if (argc > 1)
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1191 channels = atoi(argv[1]);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1192 test_copy(channels);
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1193 return 0;
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1194 }
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1195
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1196 #endif
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents:
diff changeset
1197