Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: third_party/opus/src/celt/celt.c

Issue 2962373002: [Opus] Update to v1.2.1 (Closed)
Patch Set: Pre-increment instead of post-increment Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/opus/src/celt/celt.h ('k') | third_party/opus/src/celt/celt_decoder.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2007-2008 CSIRO 1 /* Copyright (c) 2007-2008 CSIRO
2 Copyright (c) 2007-2010 Xiph.Org Foundation 2 Copyright (c) 2007-2010 Xiph.Org Foundation
3 Copyright (c) 2008 Gregory Maxwell 3 Copyright (c) 2008 Gregory Maxwell
4 Written by Jean-Marc Valin and Gregory Maxwell */ 4 Written by Jean-Marc Valin and Gregory Maxwell */
5 /* 5 /*
6 Redistribution and use in source and binary forms, with or without 6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions 7 modification, are permitted provided that the following conditions
8 are met: 8 are met:
9 9
10 - Redistributions of source code must retain the above copyright 10 - Redistributions of source code must retain the above copyright
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 x3 = SHL32(x[-T-1], 1); 104 x3 = SHL32(x[-T-1], 1);
105 x2 = SHL32(x[-T], 1); 105 x2 = SHL32(x[-T], 1);
106 x1 = SHL32(x[-T+1], 1); 106 x1 = SHL32(x[-T+1], 1);
107 for (i=0;i<N-4;i+=5) 107 for (i=0;i<N-4;i+=5)
108 { 108 {
109 opus_val32 t; 109 opus_val32 t;
110 x0=SHL32(x[i-T+2],1); 110 x0=SHL32(x[i-T+2],1);
111 t = MAC16_32_Q16(x[i], g10, x2); 111 t = MAC16_32_Q16(x[i], g10, x2);
112 t = MAC16_32_Q16(t, g11, ADD32(x1,x3)); 112 t = MAC16_32_Q16(t, g11, ADD32(x1,x3));
113 t = MAC16_32_Q16(t, g12, ADD32(x0,x4)); 113 t = MAC16_32_Q16(t, g12, ADD32(x0,x4));
114 t = SATURATE(t, SIG_SAT);
114 y[i] = t; 115 y[i] = t;
115 x4=SHL32(x[i-T+3],1); 116 x4=SHL32(x[i-T+3],1);
116 t = MAC16_32_Q16(x[i+1], g10, x1); 117 t = MAC16_32_Q16(x[i+1], g10, x1);
117 t = MAC16_32_Q16(t, g11, ADD32(x0,x2)); 118 t = MAC16_32_Q16(t, g11, ADD32(x0,x2));
118 t = MAC16_32_Q16(t, g12, ADD32(x4,x3)); 119 t = MAC16_32_Q16(t, g12, ADD32(x4,x3));
120 t = SATURATE(t, SIG_SAT);
119 y[i+1] = t; 121 y[i+1] = t;
120 x3=SHL32(x[i-T+4],1); 122 x3=SHL32(x[i-T+4],1);
121 t = MAC16_32_Q16(x[i+2], g10, x0); 123 t = MAC16_32_Q16(x[i+2], g10, x0);
122 t = MAC16_32_Q16(t, g11, ADD32(x4,x1)); 124 t = MAC16_32_Q16(t, g11, ADD32(x4,x1));
123 t = MAC16_32_Q16(t, g12, ADD32(x3,x2)); 125 t = MAC16_32_Q16(t, g12, ADD32(x3,x2));
126 t = SATURATE(t, SIG_SAT);
124 y[i+2] = t; 127 y[i+2] = t;
125 x2=SHL32(x[i-T+5],1); 128 x2=SHL32(x[i-T+5],1);
126 t = MAC16_32_Q16(x[i+3], g10, x4); 129 t = MAC16_32_Q16(x[i+3], g10, x4);
127 t = MAC16_32_Q16(t, g11, ADD32(x3,x0)); 130 t = MAC16_32_Q16(t, g11, ADD32(x3,x0));
128 t = MAC16_32_Q16(t, g12, ADD32(x2,x1)); 131 t = MAC16_32_Q16(t, g12, ADD32(x2,x1));
132 t = SATURATE(t, SIG_SAT);
129 y[i+3] = t; 133 y[i+3] = t;
130 x1=SHL32(x[i-T+6],1); 134 x1=SHL32(x[i-T+6],1);
131 t = MAC16_32_Q16(x[i+4], g10, x3); 135 t = MAC16_32_Q16(x[i+4], g10, x3);
132 t = MAC16_32_Q16(t, g11, ADD32(x2,x4)); 136 t = MAC16_32_Q16(t, g11, ADD32(x2,x4));
133 t = MAC16_32_Q16(t, g12, ADD32(x1,x0)); 137 t = MAC16_32_Q16(t, g12, ADD32(x1,x0));
138 t = SATURATE(t, SIG_SAT);
134 y[i+4] = t; 139 y[i+4] = t;
135 } 140 }
136 #ifdef CUSTOM_MODES 141 #ifdef CUSTOM_MODES
137 for (;i<N;i++) 142 for (;i<N;i++)
138 { 143 {
139 opus_val32 t; 144 opus_val32 t;
140 x0=SHL32(x[i-T+2],1); 145 x0=SHL32(x[i-T+2],1);
141 t = MAC16_32_Q16(x[i], g10, x2); 146 t = MAC16_32_Q16(x[i], g10, x2);
142 t = MAC16_32_Q16(t, g11, ADD32(x1,x3)); 147 t = MAC16_32_Q16(t, g11, ADD32(x1,x3));
143 t = MAC16_32_Q16(t, g12, ADD32(x0,x4)); 148 t = MAC16_32_Q16(t, g12, ADD32(x0,x4));
149 t = SATURATE(t, SIG_SAT);
144 y[i] = t; 150 y[i] = t;
145 x4=x3; 151 x4=x3;
146 x3=x2; 152 x3=x2;
147 x2=x1; 153 x2=x1;
148 x1=x0; 154 x1=x0;
149 } 155 }
150 #endif 156 #endif
151 } 157 }
152 #else 158 #else
153 #ifndef NON_STATIC_COMB_FILTER_CONST_C 159 #ifndef NON_STATIC_COMB_FILTER_CONST_C
154 static 160 static
155 #endif 161 #endif
156 void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N, 162 void comb_filter_const_c(opus_val32 *y, opus_val32 *x, int T, int N,
157 opus_val16 g10, opus_val16 g11, opus_val16 g12) 163 opus_val16 g10, opus_val16 g11, opus_val16 g12)
158 { 164 {
159 opus_val32 x0, x1, x2, x3, x4; 165 opus_val32 x0, x1, x2, x3, x4;
160 int i; 166 int i;
161 x4 = x[-T-2]; 167 x4 = x[-T-2];
162 x3 = x[-T-1]; 168 x3 = x[-T-1];
163 x2 = x[-T]; 169 x2 = x[-T];
164 x1 = x[-T+1]; 170 x1 = x[-T+1];
165 for (i=0;i<N;i++) 171 for (i=0;i<N;i++)
166 { 172 {
167 x0=x[i-T+2]; 173 x0=x[i-T+2];
168 y[i] = x[i] 174 y[i] = x[i]
169 + MULT16_32_Q15(g10,x2) 175 + MULT16_32_Q15(g10,x2)
170 + MULT16_32_Q15(g11,ADD32(x1,x3)) 176 + MULT16_32_Q15(g11,ADD32(x1,x3))
171 + MULT16_32_Q15(g12,ADD32(x0,x4)); 177 + MULT16_32_Q15(g12,ADD32(x0,x4));
178 y[i] = SATURATE(y[i], SIG_SAT);
172 x4=x3; 179 x4=x3;
173 x3=x2; 180 x3=x2;
174 x2=x1; 181 x2=x1;
175 x1=x0; 182 x1=x0;
176 } 183 }
177 184
178 } 185 }
179 #endif 186 #endif
180 #endif 187 #endif
181 188
(...skipping 11 matching lines...) Expand all
193 {QCONST16(0.4638671875f, 15), QCONST16(0.2680664062f, 15), QCONST16(0.f , 15)}, 200 {QCONST16(0.4638671875f, 15), QCONST16(0.2680664062f, 15), QCONST16(0.f , 15)},
194 {QCONST16(0.7998046875f, 15), QCONST16(0.1000976562f, 15), QCONST16(0.f , 15)}}; 201 {QCONST16(0.7998046875f, 15), QCONST16(0.1000976562f, 15), QCONST16(0.f , 15)}};
195 202
196 if (g0==0 && g1==0) 203 if (g0==0 && g1==0)
197 { 204 {
198 /* OPT: Happens to work without the OPUS_MOVE(), but only because the curr ent encoder already copies x to y */ 205 /* OPT: Happens to work without the OPUS_MOVE(), but only because the curr ent encoder already copies x to y */
199 if (x!=y) 206 if (x!=y)
200 OPUS_MOVE(y, x, N); 207 OPUS_MOVE(y, x, N);
201 return; 208 return;
202 } 209 }
210 /* When the gain is zero, T0 and/or T1 is set to zero. We need
211 to have then be at least 2 to avoid processing garbage data. */
212 T0 = IMAX(T0, COMBFILTER_MINPERIOD);
213 T1 = IMAX(T1, COMBFILTER_MINPERIOD);
203 g00 = MULT16_16_P15(g0, gains[tapset0][0]); 214 g00 = MULT16_16_P15(g0, gains[tapset0][0]);
204 g01 = MULT16_16_P15(g0, gains[tapset0][1]); 215 g01 = MULT16_16_P15(g0, gains[tapset0][1]);
205 g02 = MULT16_16_P15(g0, gains[tapset0][2]); 216 g02 = MULT16_16_P15(g0, gains[tapset0][2]);
206 g10 = MULT16_16_P15(g1, gains[tapset1][0]); 217 g10 = MULT16_16_P15(g1, gains[tapset1][0]);
207 g11 = MULT16_16_P15(g1, gains[tapset1][1]); 218 g11 = MULT16_16_P15(g1, gains[tapset1][1]);
208 g12 = MULT16_16_P15(g1, gains[tapset1][2]); 219 g12 = MULT16_16_P15(g1, gains[tapset1][2]);
209 x1 = x[-T1+1]; 220 x1 = x[-T1+1];
210 x2 = x[-T1 ]; 221 x2 = x[-T1 ];
211 x3 = x[-T1-1]; 222 x3 = x[-T1-1];
212 x4 = x[-T1-2]; 223 x4 = x[-T1-2];
213 /* If the filter didn't change, we don't need the overlap */ 224 /* If the filter didn't change, we don't need the overlap */
214 if (g0==g1 && T0==T1 && tapset0==tapset1) 225 if (g0==g1 && T0==T1 && tapset0==tapset1)
215 overlap=0; 226 overlap=0;
216 for (i=0;i<overlap;i++) 227 for (i=0;i<overlap;i++)
217 { 228 {
218 opus_val16 f; 229 opus_val16 f;
219 x0=x[i-T1+2]; 230 x0=x[i-T1+2];
220 f = MULT16_16_Q15(window[i],window[i]); 231 f = MULT16_16_Q15(window[i],window[i]);
221 y[i] = x[i] 232 y[i] = x[i]
222 + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g00),x[i-T0]) 233 + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g00),x[i-T0])
223 + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g01),ADD32(x[i-T0+1],x[i -T0-1])) 234 + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g01),ADD32(x[i-T0+1],x[i -T0-1]))
224 + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g02),ADD32(x[i-T0+2],x[i -T0-2])) 235 + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g02),ADD32(x[i-T0+2],x[i -T0-2]))
225 + MULT16_32_Q15(MULT16_16_Q15(f,g10),x2) 236 + MULT16_32_Q15(MULT16_16_Q15(f,g10),x2)
226 + MULT16_32_Q15(MULT16_16_Q15(f,g11),ADD32(x1,x3)) 237 + MULT16_32_Q15(MULT16_16_Q15(f,g11),ADD32(x1,x3))
227 + MULT16_32_Q15(MULT16_16_Q15(f,g12),ADD32(x0,x4)); 238 + MULT16_32_Q15(MULT16_16_Q15(f,g12),ADD32(x0,x4));
239 y[i] = SATURATE(y[i], SIG_SAT);
228 x4=x3; 240 x4=x3;
229 x3=x2; 241 x3=x2;
230 x2=x1; 242 x2=x1;
231 x1=x0; 243 x1=x0;
232 244
233 } 245 }
234 if (g1==0) 246 if (g1==0)
235 { 247 {
236 /* OPT: Happens to work without the OPUS_MOVE(), but only because the curr ent encoder already copies x to y */ 248 /* OPT: Happens to work without the OPUS_MOVE(), but only because the curr ent encoder already copies x to y */
237 if (x!=y) 249 if (x!=y)
238 OPUS_MOVE(y+overlap, x+overlap, N-overlap); 250 OPUS_MOVE(y+overlap, x+overlap, N-overlap);
239 return; 251 return;
240 } 252 }
241 253
242 /* Compute the part with the constant filter. */ 254 /* Compute the part with the constant filter. */
243 comb_filter_const(y+i, x+i, T1, N-i, g10, g11, g12, arch); 255 comb_filter_const(y+i, x+i, T1, N-i, g10, g11, g12, arch);
244 } 256 }
245 #endif /* OVERRIDE_comb_filter */ 257 #endif /* OVERRIDE_comb_filter */
246 258
259 /* TF change table. Positive values mean better frequency resolution (longer
260 effective window), whereas negative values mean better time resolution
261 (shorter effective window). The second index is computed as:
262 4*isTransient + 2*tf_select + per_band_flag */
247 const signed char tf_select_table[4][8] = { 263 const signed char tf_select_table[4][8] = {
248 {0, -1, 0, -1, 0,-1, 0,-1}, 264 /*isTransient=0 isTransient=1 */
249 {0, -1, 0, -2, 1, 0, 1,-1}, 265 {0, -1, 0, -1, 0,-1, 0,-1}, /* 2.5 ms */
250 {0, -2, 0, -3, 2, 0, 1,-1}, 266 {0, -1, 0, -2, 1, 0, 1,-1}, /* 5 ms */
251 {0, -2, 0, -3, 3, 0, 1,-1}, 267 {0, -2, 0, -3, 2, 0, 1,-1}, /* 10 ms */
268 {0, -2, 0, -3, 3, 0, 1,-1}, /* 20 ms */
252 }; 269 };
253 270
254 271
255 void init_caps(const CELTMode *m,int *cap,int LM,int C) 272 void init_caps(const CELTMode *m,int *cap,int LM,int C)
256 { 273 {
257 int i; 274 int i;
258 for (i=0;i<m->nbEBands;i++) 275 for (i=0;i<m->nbEBands;i++)
259 { 276 {
260 int N; 277 int N;
261 N=(m->eBands[i+1]-m->eBands[i])<<LM; 278 N=(m->eBands[i+1]-m->eBands[i])<<LM;
(...skipping 28 matching lines...) Expand all
290 string to determine if they have a fixed-point or floating-point build 307 string to determine if they have a fixed-point or floating-point build
291 at runtime. */ 308 at runtime. */
292 #ifdef FIXED_POINT 309 #ifdef FIXED_POINT
293 "-fixed" 310 "-fixed"
294 #endif 311 #endif
295 #ifdef FUZZING 312 #ifdef FUZZING
296 "-fuzzing" 313 "-fuzzing"
297 #endif 314 #endif
298 ; 315 ;
299 } 316 }
OLDNEW
« no previous file with comments | « third_party/opus/src/celt/celt.h ('k') | third_party/opus/src/celt/celt_decoder.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698