2 * adaptive and fixed codebook vector operations for ACELP-based codecs
4 * Copyright (c) 2008 Vladimir Voroshilov
6 * This file is part of FFmpeg.
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "acelp_vectors.h"
27 const uint8_t ff_fc_2pulses_9bits_track1[16] =
38 const uint8_t ff_fc_2pulses_9bits_track1_gray[16] =
50 const uint8_t ff_fc_2pulses_9bits_track2_gray[32] =
70 const uint8_t ff_fc_4pulses_8bits_tracks_13[16] =
72 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75,
75 const uint8_t ff_fc_4pulses_8bits_track_4[32] =
96 static uint8_t gray_decode[32] =
98 0, 1, 3, 2, 7, 6, 4, 5,
99 15, 14, 12, 13, 8, 9, 11, 10,
100 31, 30, 28, 29, 24, 25, 27, 26,
101 16, 17, 19, 18, 23, 22, 20, 21
105 void ff_acelp_fc_pulse_per_track(
114 int mask = (1 << bits) - 1;
117 for(i=0; i<pulse_count; i++)
119 fc_v[i + tab1[pulse_indexes & mask]] +=
120 (pulse_signs & 1) ? 8191 : -8192; // +/-1 in (2.13)
122 pulse_indexes >>= bits;
126 fc_v[tab2[pulse_indexes]] += (pulse_signs & 1) ? 8191 : -8192;
129 void ff_acelp_weighted_vector_sum(
133 int16_t weight_coeff_a,
134 int16_t weight_coeff_b,
141 // Clipping required here; breaks OVERFLOW test.
142 for(i=0; i<length; i++)
143 out[i] = av_clip_int16((
144 in_a[i] * weight_coeff_a +
145 in_b[i] * weight_coeff_b +