Replace 5 with AOT_SBR when referring to the MPEG-4 audio object type.
[FFMpeg-mirror/lagarith.git] / libavcodec / acelp_vectors.c
blob54430067185580a3d7af62e5c44ab8781add6fec
1 /*
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
23 #include <inttypes.h>
24 #include "avcodec.h"
25 #include "acelp_vectors.h"
27 const uint8_t ff_fc_2pulses_9bits_track1[16] =
29 1, 3,
30 6, 8,
31 11, 13,
32 16, 18,
33 21, 23,
34 26, 28,
35 31, 33,
36 36, 38
38 const uint8_t ff_fc_2pulses_9bits_track1_gray[16] =
40 1, 3,
41 8, 6,
42 18, 16,
43 11, 13,
44 38, 36,
45 31, 33,
46 21, 23,
47 28, 26,
50 const uint8_t ff_fc_2pulses_9bits_track2_gray[32] =
52 0, 2,
53 5, 4,
54 12, 10,
55 7, 9,
56 25, 24,
57 20, 22,
58 14, 15,
59 19, 17,
60 36, 31,
61 21, 26,
62 1, 6,
63 16, 11,
64 27, 29,
65 32, 30,
66 39, 37,
67 34, 35,
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] =
77 3, 4,
78 8, 9,
79 13, 14,
80 18, 19,
81 23, 24,
82 28, 29,
83 33, 34,
84 38, 39,
85 43, 44,
86 48, 49,
87 53, 54,
88 58, 59,
89 63, 64,
90 68, 69,
91 73, 74,
92 78, 79,
95 #if 0
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
103 #endif
105 void ff_acelp_fc_pulse_per_track(
106 int16_t* fc_v,
107 const uint8_t *tab1,
108 const uint8_t *tab2,
109 int pulse_indexes,
110 int pulse_signs,
111 int pulse_count,
112 int bits)
114 int mask = (1 << bits) - 1;
115 int i;
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;
123 pulse_signs >>= 1;
126 fc_v[tab2[pulse_indexes]] += (pulse_signs & 1) ? 8191 : -8192;
129 void ff_acelp_weighted_vector_sum(
130 int16_t* out,
131 const int16_t *in_a,
132 const int16_t *in_b,
133 int16_t weight_coeff_a,
134 int16_t weight_coeff_b,
135 int16_t rounder,
136 int shift,
137 int length)
139 int i;
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 +
146 rounder) >> shift);
149 void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b,
150 float weight_coeff_a, float weight_coeff_b, int length)
152 int i;
154 for(i=0; i<length; i++)
155 out[i] = weight_coeff_a * in_a[i]
156 + weight_coeff_b * in_b[i];