Browse code

Add no_repeat_mask option, so that single-pulse vectors can also be expressed in a AMRFixed structure and handled by ff_set_fixed_vector().

Originally committed as revision 21528 to svn://svn.ffmpeg.org/ffmpeg/trunk

Ronald S. Bultje authored on 2010/01/30 01:49:06
Showing 2 changed files
... ...
@@ -164,6 +164,7 @@ void ff_decode_10_pulses_35bits(const int16_t *fixed_index,
164 164
     int i;
165 165
     int mask = (1 << bits) - 1;
166 166
 
167
+    fixed_sparse->no_repeat_mask = 0;
167 168
     fixed_sparse->n = 2 * half_pulse_count;
168 169
     for (i = 0; i < half_pulse_count; i++) {
169 170
         const int pos1   = gray_decode[fixed_index[2*i+1] & mask] + i;
... ...
@@ -243,14 +244,14 @@ void ff_set_fixed_vector(float *out, const AMRFixed *in, float scale, int size)
243 243
     int i;
244 244
 
245 245
     for (i=0; i < in->n; i++) {
246
-        int x   = in->x[i];
246
+        int x   = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1);
247 247
         float y = in->y[i] * scale;
248 248
 
249 249
         do {
250 250
             out[x] += y;
251 251
             y *= in->pitch_fac;
252 252
             x += in->pitch_lag;
253
-        } while (x < size);
253
+        } while (x < size && repeats);
254 254
     }
255 255
 }
256 256
 
... ...
@@ -259,11 +260,11 @@ void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size)
259 259
     int i;
260 260
 
261 261
     for (i=0; i < in->n; i++) {
262
-        int x  = in->x[i];
262
+        int x  = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1);
263 263
 
264 264
         do {
265 265
             out[x] = 0.0;
266 266
             x += in->pitch_lag;
267
-        } while (x < size);
267
+        } while (x < size && repeats);
268 268
     }
269 269
 }
... ...
@@ -30,6 +30,7 @@ typedef struct {
30 30
     int      n;
31 31
     int      x[10];
32 32
     float    y[10];
33
+    int      no_repeat_mask;
33 34
     int      pitch_lag;
34 35
     float    pitch_fac;
35 36
 } AMRFixed;