diff options
author | Vitor Sessak <vitor1001@gmail.com> | 2009-12-12 13:58:07 +0000 |
---|---|---|
committer | Vitor Sessak <vitor1001@gmail.com> | 2009-12-12 13:58:07 +0000 |
commit | 92f99a33b8886798015a87923bddda817cc5ca41 (patch) | |
tree | cd7001b672822c22f87862571d446de0e422be5e /libavcodec/acelp_vectors.c | |
parent | dae658d764377f26ed6844ab4fbc6fb32dddb732 (diff) | |
download | ffmpeg-92f99a33b8886798015a87923bddda817cc5ca41.tar.gz |
Commit functions used by both AMRNB and SIPR
Originally committed as revision 20805 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/acelp_vectors.c')
-rw-r--r-- | libavcodec/acelp_vectors.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c index b193d08865..b83c270190 100644 --- a/libavcodec/acelp_vectors.c +++ b/libavcodec/acelp_vectors.c @@ -127,6 +127,26 @@ void ff_acelp_fc_pulse_per_track( fc_v[tab2[pulse_indexes]] += (pulse_signs & 1) ? 8191 : -8192; } +void ff_decode_10_pulses_35bits(const int16_t *fixed_index, + AMRFixed *fixed_sparse, + const uint8_t *gray_decode, + int half_pulse_count, int bits) +{ + int i; + int mask = (1 << bits) - 1; + + fixed_sparse->n = 2 * half_pulse_count; + for (i = 0; i < half_pulse_count; i++) { + const int pos1 = gray_decode[fixed_index[2*i+1] & mask] + i; + const int pos2 = gray_decode[fixed_index[2*i ] & mask] + i; + const float sign = (fixed_index[2*i+1] & (1 << bits)) ? -1.0 : 1.0; + fixed_sparse->x[2*i+1] = pos1; + fixed_sparse->x[2*i ] = pos2; + fixed_sparse->y[2*i+1] = sign; + fixed_sparse->y[2*i ] = pos2 < pos1 ? -sign : sign; + } +} + void ff_acelp_weighted_vector_sum( int16_t* out, const int16_t *in_a, @@ -188,3 +208,37 @@ void ff_scale_vector_to_given_sum_of_squares(float *out, const float *in, for (i = 0; i < n; i++) out[i] = in[i] * scalefactor; } + +void ff_set_fixed_vector(float *out, const AMRFixed *in, float scale, int size) +{ + int i; + + for (i=0; i < in->n; i++) { + int x = in->x[i]; + float y = in->y[i] * scale; + out[x] += y; + + x += in->pitch_lag; + while (x < size) { + y *= in->pitch_fac; + out[x] += y; + x += in->pitch_lag; + } + } +} + +void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size) +{ + int i; + + for (i=0; i < in->n; i++) { + int x = in->x[i]; + out[x] = 0.0; + + x += in->pitch_lag; + while (x < size) { + out[x] = 0.0; + x += in->pitch_lag; + } + } +} |