Patch by Vladimir Voroshilov and myself. Originally committed as revision 21125 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -48,6 +48,7 @@ version <next>: · 47 unmodified lines | ||
| 48 | 48 | - R210 decoder |
| 49 | 49 | - Auravision Aura 1 and 2 decoders |
| 50 | 50 | - Deluxe Paint Animation playback system |
| 51 | +- SIPR decoding for modes 8k5, 6k5 and 5k0 | |
| 51 | 52 | |
| 52 | 53 | |
| 53 | 54 | |
| @@ -618,6 +618,8 @@ following image formats are supported: · 617 unmodified lines | ||
| 618 | 618 | @tab Real 28800 bit/s codec |
| 619 | 619 | @item RealAudio 3.0 (dnet) @tab IX @tab X |
| 620 | 620 | @tab Real low bitrate AC-3 codec |
| 621 | +@item RealAudio SIPR / ACELP.NET @tab @tab X | |
| 622 | + @tab 16 kbps mode not yet supported | |
| 621 | 623 | @item Shorten @tab @tab X |
| 622 | 624 | @item Sierra VMD audio @tab @tab X |
| 623 | 625 | @tab Used in Sierra VMD files. |
| @@ -260,6 +260,9 @@ OBJS-$(CONFIG_RV40_DECODER) += rv40.o rv34.o h264pred.o rv40dsp.o \ · 259 unmodified lines | ||
| 260 | 260 | OBJS-$(CONFIG_SGI_DECODER) += sgidec.o |
| 261 | 261 | OBJS-$(CONFIG_SGI_ENCODER) += sgienc.o rle.o |
| 262 | 262 | OBJS-$(CONFIG_SHORTEN_DECODER) += shorten.o |
| 263 | +OBJS-$(CONFIG_SIPR_DECODER) += sipr.o acelp_pitch_delay.o \ | |
| 264 | + celp_math.o acelp_vectors.o \ | |
| 265 | + acelp_filters.o celp_filters.o lsp.o | |
| 263 | 266 | OBJS-$(CONFIG_SMACKAUD_DECODER) += smacker.o |
| 264 | 267 | OBJS-$(CONFIG_SMACKER_DECODER) += smacker.o |
| 265 | 268 | OBJS-$(CONFIG_SMC_DECODER) += smc.o |
| @@ -232,6 +232,7 @@ void avcodec_register_all(void) · 231 unmodified lines | ||
| 232 | 232 | REGISTER_DECODER (RA_144, ra_144); |
| 233 | 233 | REGISTER_DECODER (RA_288, ra_288); |
| 234 | 234 | REGISTER_DECODER (SHORTEN, shorten); |
| 235 | + REGISTER_DECODER (SIPR, sipr); | |
| 235 | 236 | REGISTER_DECODER (SMACKAUD, smackaud); |
| 236 | 237 | REGISTER_ENCDEC (SONIC, sonic); |
| 237 | 238 | REGISTER_ENCODER (SONIC_LS, sonic_ls); |
| @@ -30,7 +30,7 @@ · 29 unmodified lines | ||
| 30 | 30 | #include "libavutil/avutil.h" |
| 31 | 31 | |
| 32 | 32 | #define LIBAVCODEC_VERSION_MAJOR 52 |
| 33 | −#define LIBAVCODEC_VERSION_MINOR 46 | |
| 33 | +#define LIBAVCODEC_VERSION_MINOR 47 | |
| 34 | 34 | #define LIBAVCODEC_VERSION_MICRO 0 |
| 35 | 35 | |
| 36 | 36 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| @@ -0,0 +1,608 @@ | ||
| 1 | +/* | |
| 2 | + * SIPR / ACELP.NET decoder | |
| 3 | + * | |
| 4 | + * Copyright (c) 2008 Vladimir Voroshilov | |
| 5 | + * Copyright (c) 2009 Vitor Sessak | |
| 6 | + * | |
| 7 | + * This file is part of FFmpeg. | |
| 8 | + * | |
| 9 | + * FFmpeg is free software; you can redistribute it and/or | |
| 10 | + * modify it under the terms of the GNU Lesser General Public | |
| 11 | + * License as published by the Free Software Foundation; either | |
| 12 | + * version 2.1 of the License, or (at your option) any later version. | |
| 13 | + * | |
| 14 | + * FFmpeg is distributed in the hope that it will be useful, | |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 17 | + * Lesser General Public License for more details. | |
| 18 | + * | |
| 19 | + * You should have received a copy of the GNU Lesser General Public | |
| 20 | + * License along with FFmpeg; if not, write to the Free Software | |
| 21 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 22 | + */ | |
| 23 | + | |
| 24 | +#include <math.h> | |
| 25 | +#include <stdint.h> | |
| 26 | + | |
| 27 | +#include "avcodec.h" | |
| 28 | +#define ALT_BITSTREAM_READER_LE | |
| 29 | +#include "get_bits.h" | |
| 30 | +#include "dsputil.h" | |
| 31 | + | |
| 32 | +#include "lsp.h" | |
| 33 | +#include "celp_math.h" | |
| 34 | +#include "acelp_vectors.h" | |
| 35 | +#include "acelp_pitch_delay.h" | |
| 36 | +#include "acelp_filters.h" | |
| 37 | +#include "celp_filters.h" | |
| 38 | + | |
| 39 | +#define LSFQ_DIFF_MIN (0.0125 * M_PI) | |
| 40 | + | |
| 41 | +#define LP_FILTER_ORDER 10 | |
| 42 | + | |
| 43 | +/** Number of past samples needed for excitation interpolation */ | |
| 44 | +#define L_INTERPOL (LP_FILTER_ORDER + 1) | |
| 45 | + | |
| 46 | +/** Subframe size for all modes except 16k */ | |
| 47 | +#define SUBFR_SIZE 48 | |
| 48 | + | |
| 49 | +#include "siprdata.h" | |
| 50 | + | |
| 51 | +typedef enum { | |
| 52 | + MODE_16k, | |
| 53 | + MODE_8k5, | |
| 54 | + MODE_6k5, | |
| 55 | + MODE_5k0, | |
| 56 | + MODE_COUNT | |
| 57 | +} SiprMode; | |
| 58 | + | |
| 59 | +typedef struct { | |
| 60 | + const char *mode_name; | |
| 61 | + uint16_t bits_per_frame; | |
| 62 | + uint8_t subframe_count; | |
| 63 | + uint8_t frames_per_packet; | |
| 64 | + float pitch_sharp_factor; | |
| 65 | + | |
| 66 | + /* bitstream parameters */ | |
| 67 | + uint8_t number_of_fc_indexes; | |
| 68 | + | |
| 69 | + /** size in bits of the i-th stage vector of quantizer */ | |
| 70 | + uint8_t vq_indexes_bits[5]; | |
| 71 | + | |
| 72 | + /** size in bits of the adaptive-codebook index for every subframe */ | |
| 73 | + uint8_t pitch_delay_bits[5]; | |
| 74 | + | |
| 75 | + uint8_t gp_index_bits; | |
| 76 | + uint8_t fc_index_bits[10]; ///< size in bits of the fixed codebook indexes | |
| 77 | + uint8_t gc_index_bits; ///< size in bits of the gain codebook indexes | |
| 78 | +} SiprModeParam; | |
| 79 | + | |
| 80 | +static const SiprModeParam modes[MODE_COUNT] = { | |
| 81 | + [MODE_8k5] = { | |
| 82 | + .mode_name = "8k5", | |
| 83 | + .bits_per_frame = 152, | |
| 84 | + .subframe_count = 3, | |
| 85 | + .frames_per_packet = 1, | |
| 86 | + .pitch_sharp_factor = 0.8, | |
| 87 | + | |
| 88 | + .number_of_fc_indexes = 3, | |
| 89 | + .vq_indexes_bits = {6, 7, 7, 7, 5}, | |
| 90 | + .pitch_delay_bits = {8, 5, 5}, | |
| 91 | + .gp_index_bits = 0, | |
| 92 | + .fc_index_bits = {9, 9, 9}, | |
| 93 | + .gc_index_bits = 7 | |
| 94 | + }, | |
| 95 | + | |
| 96 | + [MODE_6k5] = { | |
| 97 | + .mode_name = "6k5", | |
| 98 | + .bits_per_frame = 232, | |
| 99 | + .subframe_count = 3, | |
| 100 | + .frames_per_packet = 2, | |
| 101 | + .pitch_sharp_factor = 0.8, | |
| 102 | + | |
| 103 | + .number_of_fc_indexes = 3, | |
| 104 | + .vq_indexes_bits = {6, 7, 7, 7, 5}, | |
| 105 | + .pitch_delay_bits = {8, 5, 5}, | |
| 106 | + .gp_index_bits = 0, | |
| 107 | + .fc_index_bits = {5, 5, 5}, | |
| 108 | + .gc_index_bits = 7 | |
| 109 | + }, | |
| 110 | + | |
| 111 | + [MODE_5k0] = { | |
| 112 | + .mode_name = "5k0", | |
| 113 | + .bits_per_frame = 296, | |
| 114 | + .subframe_count = 5, | |
| 115 | + .frames_per_packet = 2, | |
| 116 | + .pitch_sharp_factor = 0.85, | |
| 117 | + | |
| 118 | + .number_of_fc_indexes = 1, | |
| 119 | + .vq_indexes_bits = {6, 7, 7, 7, 5}, | |
| 120 | + .pitch_delay_bits = {8, 5, 8, 5, 5}, | |
| 121 | + .gp_index_bits = 0, | |
| 122 | + .fc_index_bits = {10}, | |
| 123 | + .gc_index_bits = 7 | |
| 124 | + } | |
| 125 | +}; | |
| 126 | + | |
| 127 | +typedef struct { | |
| 128 | + AVCodecContext *avctx; | |
| 129 | + DSPContext dsp; | |
| 130 | + | |
| 131 | + SiprModeParam m; | |
| 132 | + SiprMode mode; | |
| 133 | + | |
| 134 | + float past_pitch_gain; | |
| 135 | + float lsf_history[LP_FILTER_ORDER]; | |
| 136 | + | |
| 137 | + float excitation[L_INTERPOL + PITCH_DELAY_MAX + 5*SUBFR_SIZE]; | |
| 138 | + | |
| 139 | + DECLARE_ALIGNED_16(float, synth_buf[LP_FILTER_ORDER + 5*SUBFR_SIZE + 6]); | |
| 140 | + | |
| 141 | + float lsp_history[LP_FILTER_ORDER]; | |
| 142 | + float gain_mem; | |
| 143 | + float energy_history[4]; | |
| 144 | + float highpass_filt_mem[2]; | |
| 145 | + float postfilter_mem[PITCH_DELAY_MAX + LP_FILTER_ORDER]; | |
| 146 | + | |
| 147 | + /* 5k0 */ | |
| 148 | + float tilt_mem; | |
| 149 | + float postfilter_agc; | |
| 150 | + float postfilter_mem5k0[PITCH_DELAY_MAX + LP_FILTER_ORDER]; | |
| 151 | + float postfilter_syn5k0[LP_FILTER_ORDER + SUBFR_SIZE*5]; | |
| 152 | +} SiprContext; | |
| 153 | + | |
| 154 | +typedef struct { | |
| 155 | + int vq_indexes[5]; | |
| 156 | + int pitch_delay[5]; ///< pitch delay | |
| 157 | + int gp_index[5]; ///< adaptive-codebook gain indexes | |
| 158 | + int16_t fc_indexes[5][10]; ///< fixed-codebook indexes | |
| 159 | + int gc_index[5]; ///< fixed-codebook gain indexes | |
| 160 | +} SiprParameters; | |
| 161 | + | |
| 162 | + | |
| 163 | +static void dequant(float *out, const int *idx, const float *cbs[]) | |
| 164 | +{ | |
| 165 | + int i; | |
| 166 | + int stride = 2; | |
| 167 | + int num_vec = 5; | |
| 168 | + | |
| 169 | + for (i = 0; i < num_vec; i++) | |
| 170 | + memcpy(out + stride*i, cbs[i] + stride*idx[i], stride*sizeof(float)); | |
| 171 | + | |
| 172 | +} | |
| 173 | + | |
| 174 | +static void lsf_decode_fp(float *lsfnew, float *lsf_history, | |
| 175 | + const SiprParameters *parm) | |
| 176 | +{ | |
| 177 | + int i; | |
| 178 | + float lsf_tmp[LP_FILTER_ORDER]; | |
| 179 | + | |
| 180 | + dequant(lsf_tmp, parm->vq_indexes, lsf_codebooks); | |
| 181 | + | |
| 182 | + for (i = 0; i < LP_FILTER_ORDER; i++) | |
| 183 | + lsfnew[i] = lsf_history[i] * 0.33 + lsf_tmp[i] + mean_lsf[i]; | |
| 184 | + | |
| 185 | + ff_sort_nearly_sorted_floats(lsfnew, LP_FILTER_ORDER - 1); | |
| 186 | + | |
| 187 | + /* Note that a minimum distance is not enforced between the last value and | |
| 188 | + the previous one, contrary to what is done in ff_acelp_reorder_lsf() */ | |
| 189 | + ff_set_min_dist_lsf(lsfnew, LSFQ_DIFF_MIN, LP_FILTER_ORDER - 1); | |
| 190 | + lsfnew[9] = FFMIN(lsfnew[LP_FILTER_ORDER - 1], 1.3 * M_PI); | |
| 191 | + | |
| 192 | + memcpy(lsf_history, lsf_tmp, LP_FILTER_ORDER * sizeof(*lsf_history)); | |
| 193 | + | |
| 194 | + for (i = 0; i < LP_FILTER_ORDER - 1; i++) | |
| 195 | + lsfnew[i] = cos(lsfnew[i]); | |
| 196 | + lsfnew[LP_FILTER_ORDER - 1] *= 6.153848 / M_PI; | |
| 197 | +} | |
| 198 | + | |
| 199 | +/** Apply pitch lag to the fixed vector (AMR section 6.1.2). */ | |
| 200 | +static void pitch_sharpening(int pitch_lag_int, float beta, | |
| 201 | + float *fixed_vector) | |
| 202 | +{ | |
| 203 | + int i; | |
| 204 | + | |
| 205 | + for (i = pitch_lag_int; i < SUBFR_SIZE; i++) | |
| 206 | + fixed_vector[i] += beta * fixed_vector[i - pitch_lag_int]; | |
| 207 | +} | |
| 208 | + | |
| 209 | +/** | |
| 210 | + * Extracts decoding parameters from the input bitstream. | |
| 211 | + * @param parms parameters structure | |
| 212 | + * @param pgb pointer to initialized GetBitContext structure | |
| 213 | + */ | |
| 214 | +static void decode_parameters(SiprParameters* parms, GetBitContext *pgb, | |
| 215 | + const SiprModeParam *p) | |
| 216 | +{ | |
| 217 | + int i, j; | |
| 218 | + | |
| 219 | + for (i = 0; i < 5; i++) | |
| 220 | + parms->vq_indexes[i] = get_bits(pgb, p->vq_indexes_bits[i]); | |
| 221 | + | |
| 222 | + for (i = 0; i < p->subframe_count; i++) { | |
| 223 | + parms->pitch_delay[i] = get_bits(pgb, p->pitch_delay_bits[i]); | |
| 224 | + parms->gp_index[i] = get_bits(pgb, p->gp_index_bits); | |
| 225 | + | |
| 226 | + for (j = 0; j < p->number_of_fc_indexes; j++) | |
| 227 | + parms->fc_indexes[i][j] = get_bits(pgb, p->fc_index_bits[j]); | |
| 228 | + | |
| 229 | + parms->gc_index[i] = get_bits(pgb, p->gc_index_bits); | |
| 230 | + } | |
| 231 | +} | |
| 232 | + | |
| 233 | +static void lsp2lpc_sipr(const double *lsp, float *Az) | |
| 234 | +{ | |
| 235 | + int lp_half_order = LP_FILTER_ORDER >> 1; | |
| 236 | + double buf[lp_half_order + 1]; | |
| 237 | + double pa[lp_half_order + 1]; | |
| 238 | + double *qa = buf + 1; | |
| 239 | + int i,j; | |
| 240 | + | |
| 241 | + qa[-1] = 0.0; | |
| 242 | + | |
| 243 | + ff_lsp2polyf(lsp , pa, lp_half_order ); | |
| 244 | + ff_lsp2polyf(lsp + 1, qa, lp_half_order - 1); | |
| 245 | + | |
| 246 | + for (i = 1, j = LP_FILTER_ORDER - 1; i < lp_half_order; i++, j--) { | |
| 247 | + double paf = pa[i] * (1 + lsp[LP_FILTER_ORDER - 1]); | |
| 248 | + double qaf = (qa[i] - qa[i-2]) * (1 - lsp[LP_FILTER_ORDER - 1]); | |
| 249 | + Az[i-1] = (paf + qaf) * 0.5; | |
| 250 | + Az[j-1] = (paf - qaf) * 0.5; | |
| 251 | + } | |
| 252 | + | |
| 253 | + Az[lp_half_order - 1] = (1.0 + lsp[LP_FILTER_ORDER - 1]) * | |
| 254 | + pa[lp_half_order] * 0.5; | |
| 255 | + | |
| 256 | + Az[LP_FILTER_ORDER - 1] = lsp[LP_FILTER_ORDER - 1]; | |
| 257 | +} | |
| 258 | + | |
| 259 | +static void sipr_decode_lp(float *lsfnew, const float *lsfold, float *Az, | |
| 260 | + int num_subfr) | |
| 261 | +{ | |
| 262 | + double lsfint[LP_FILTER_ORDER]; | |
| 263 | + int i,j; | |
| 264 | + float t, t0 = 1.0 / num_subfr; | |
| 265 | + | |
| 266 | + t = t0 * 0.5; | |
| 267 | + for (i = 0; i < num_subfr; i++) { | |
| 268 | + for (j = 0; j < LP_FILTER_ORDER; j++) | |
| 269 | + lsfint[j] = lsfold[j] * (1 - t) + t * lsfnew[j]; | |
| 270 | + | |
| 271 | + lsp2lpc_sipr(lsfint, Az); | |
| 272 | + Az += LP_FILTER_ORDER; | |
| 273 | + t += t0; | |
| 274 | + } | |
| 275 | +} | |
| 276 | + | |
| 277 | +/** | |
| 278 | + * Evaluates the adaptative impulse response. | |
| 279 | + */ | |
| 280 | +static void eval_ir(const float *Az, int pitch_lag, float *freq, | |
| 281 | + float pitch_sharp_factor) | |
| 282 | +{ | |
| 283 | + float tmp1[SUBFR_SIZE+1], tmp2[LP_FILTER_ORDER+1]; | |
| 284 | + int i; | |
| 285 | + | |
| 286 | + tmp1[0] = 1.; | |
| 287 | + for (i = 0; i < LP_FILTER_ORDER; i++) { | |
| 288 | + tmp1[i+1] = Az[i] * ff_pow_0_55[i]; | |
| 289 | + tmp2[i ] = Az[i] * ff_pow_0_7 [i]; | |
| 290 | + } | |
| 291 | + memset(tmp1 + 11, 0, 37 * sizeof(float)); | |
| 292 | + | |
| 293 | + ff_celp_lp_synthesis_filterf(freq, tmp2, tmp1, SUBFR_SIZE, | |
| 294 | + LP_FILTER_ORDER); | |
| 295 | + | |
| 296 | + pitch_sharpening(pitch_lag, pitch_sharp_factor, freq); | |
| 297 | +} | |
| 298 | + | |
| 299 | +/** | |
| 300 | + * Evaluates the convolution of a vector with a sparse vector. | |
| 301 | + */ | |
| 302 | +static void convolute_with_sparse(float *out, const AMRFixed *pulses, | |
| 303 | + const float *shape, int length) | |
| 304 | +{ | |
| 305 | + int i, j; | |
| 306 | + | |
| 307 | + memset(out, 0, length*sizeof(float)); | |
| 308 | + for (i = 0; i < pulses->n; i++) | |
| 309 | + for (j = pulses->x[i]; j < length; j++) | |
| 310 | + out[j] += pulses->y[i] * shape[j - pulses->x[i]]; | |
| 311 | +} | |
| 312 | + | |
| 313 | +/** | |
| 314 | + * Apply postfilter, very similar to AMR one. | |
| 315 | + */ | |
| 316 | +static void postfilter_5k0(SiprContext *ctx, const float *lpc, float *samples) | |
| 317 | +{ | |
| 318 | + float buf[SUBFR_SIZE + LP_FILTER_ORDER]; | |
| 319 | + float *pole_out = buf + LP_FILTER_ORDER; | |
| 320 | + float lpc_n[LP_FILTER_ORDER]; | |
| 321 | + float lpc_d[LP_FILTER_ORDER]; | |
| 322 | + int i; | |
| 323 | + | |
| 324 | + for (i = 0; i < LP_FILTER_ORDER; i++) { | |
| 325 | + lpc_d[i] = lpc[i] * ff_pow_0_75[i]; | |
| 326 | + lpc_n[i] = lpc[i] * pow_0_5 [i]; | |
| 327 | + }; | |
| 328 | + | |
| 329 | + memcpy(pole_out - LP_FILTER_ORDER, ctx->postfilter_mem, | |
| 330 | + LP_FILTER_ORDER*sizeof(float)); | |
| 331 | + | |
| 332 | + ff_celp_lp_synthesis_filterf(pole_out, lpc_d, samples, SUBFR_SIZE, | |
| 333 | + LP_FILTER_ORDER); | |
| 334 | + | |
| 335 | + memcpy(ctx->postfilter_mem, pole_out + SUBFR_SIZE - LP_FILTER_ORDER, | |
| 336 | + LP_FILTER_ORDER*sizeof(float)); | |
| 337 | + | |
| 338 | + ff_tilt_compensation(&ctx->tilt_mem, 0.4, pole_out, SUBFR_SIZE); | |
| 339 | + | |
| 340 | + memcpy(pole_out - LP_FILTER_ORDER, ctx->postfilter_mem5k0, | |
| 341 | + LP_FILTER_ORDER*sizeof(*pole_out)); | |
| 342 | + | |
| 343 | + memcpy(ctx->postfilter_mem5k0, pole_out + SUBFR_SIZE - LP_FILTER_ORDER, | |
| 344 | + LP_FILTER_ORDER*sizeof(*pole_out)); | |
| 345 | + | |
| 346 | + ff_celp_lp_zero_synthesis_filterf(samples, lpc_n, pole_out, SUBFR_SIZE, | |
| 347 | + LP_FILTER_ORDER); | |
| 348 | + | |
| 349 | +} | |
| 350 | + | |
| 351 | +static void decode_fixed_sparse(AMRFixed *fixed_sparse, const int16_t *pulses, | |
| 352 | + SiprMode mode, int low_gain) | |
| 353 | +{ | |
| 354 | + int i; | |
| 355 | + | |
| 356 | + switch (mode) { | |
| 357 | + case MODE_6k5: | |
| 358 | + for (i = 0; i < 3; i++) { | |
| 359 | + fixed_sparse->x[i] = 3 * (pulses[i] & 0xf) + i; | |
| 360 | + fixed_sparse->y[i] = pulses[i] & 0x10 ? -1 : 1; | |
| 361 | + } | |
| 362 | + fixed_sparse->n = 3; | |
| 363 | + break; | |
| 364 | + case MODE_8k5: | |
| 365 | + for (i = 0; i < 3; i++) { | |
| 366 | + fixed_sparse->x[2*i ] = 3 * ((pulses[i] >> 4) & 0xf) + i; | |
| 367 | + fixed_sparse->x[2*i + 1] = 3 * ( pulses[i] & 0xf) + i; | |
| 368 | + | |
| 369 | + fixed_sparse->y[2*i ] = (pulses[i] & 0x100) ? -1.0: 1.0; | |
| 370 | + | |
| 371 | + fixed_sparse->y[2*i + 1] = | |
| 372 | + (fixed_sparse->x[2*i + 1] < fixed_sparse->x[2*i]) ? | |
| 373 | + -fixed_sparse->y[2*i ] : fixed_sparse->y[2*i]; | |
| 374 | + } | |
| 375 | + | |
| 376 | + fixed_sparse->n = 6; | |
| 377 | + break; | |
| 378 | + case MODE_5k0: | |
| 379 | + default: | |
| 380 | + if (low_gain) { | |
| 381 | + int offset = (pulses[0] & 0x200) ? 2 : 0; | |
| 382 | + int val = pulses[0]; | |
| 383 | + | |
| 384 | + for (i = 0; i < 3; i++) { | |
| 385 | + int index = (val & 0x7) * 6 + 4 - i*2; | |
| 386 | + | |
| 387 | + fixed_sparse->y[i] = (offset + index) & 0x3 ? -1 : 1; | |
| 388 | + fixed_sparse->x[i] = index; | |
| 389 | + | |
| 390 | + val >>= 3; | |
| 391 | + } | |
| 392 | + fixed_sparse->n = 3; | |
| 393 | + } else { | |
| 394 | + int pulse_subset = (pulses[0] >> 8) & 1; | |
| 395 | + | |
| 396 | + fixed_sparse->x[0] = ((pulses[0] >> 4) & 15) * 3 + pulse_subset; | |
| 397 | + fixed_sparse->x[1] = ( pulses[0] & 15) * 3 + pulse_subset + 1; | |
| 398 | + | |
| 399 | + fixed_sparse->y[0] = pulses[0] & 0x200 ? -1 : 1; | |
| 400 | + fixed_sparse->y[1] = -fixed_sparse->y[0]; | |
| 401 | + fixed_sparse->n = 2; | |
| 402 | + } | |
| 403 | + break; | |
| 404 | + } | |
| 405 | +} | |
| 406 | + | |
| 407 | +static void decode_frame(SiprContext *ctx, SiprParameters *params, | |
| 408 | + float *out_data) | |
| 409 | +{ | |
| 410 | + int i, j; | |
| 411 | + int frame_size = ctx->m.subframe_count * SUBFR_SIZE; | |
| 412 | + float Az[LP_FILTER_ORDER * ctx->m.subframe_count]; | |
| 413 | + float *excitation; | |
| 414 | + float ir_buf[SUBFR_SIZE + LP_FILTER_ORDER]; | |
| 415 | + float lsf_new[LP_FILTER_ORDER]; | |
| 416 | + float *impulse_response = ir_buf + LP_FILTER_ORDER; | |
| 417 | + float *synth = ctx->synth_buf + 16; // 16 instead of LP_FILTER_ORDER for | |
| 418 | + // memory alignment | |
| 419 | + int t0_first = 0; | |
| 420 | + AMRFixed fixed_cb; | |
| 421 | + | |
| 422 | + memset(ir_buf, 0, LP_FILTER_ORDER * sizeof(float)); | |
| 423 | + lsf_decode_fp(lsf_new, ctx->lsf_history, params); | |
| 424 | + | |
| 425 | + sipr_decode_lp(lsf_new, ctx->lsp_history, Az, ctx->m.subframe_count); | |
| 426 | + | |
| 427 | + memcpy(ctx->lsp_history, lsf_new, LP_FILTER_ORDER * sizeof(float)); | |
| 428 | + | |
| 429 | + excitation = ctx->excitation + PITCH_DELAY_MAX + L_INTERPOL; | |
| 430 | + | |
| 431 | + for (i = 0; i < ctx->m.subframe_count; i++) { | |
| 432 | + float *pAz = Az + i*LP_FILTER_ORDER; | |
| 433 | + float fixed_vector[SUBFR_SIZE]; | |
| 434 | + int T0,T0_frac; | |
| 435 | + float pitch_gain, gain_code, avg_energy; | |
| 436 | + | |
| 437 | + ff_decode_pitch_lag(&T0, &T0_frac, params->pitch_delay[i], t0_first, i, | |
| 438 | + ctx->mode == MODE_5k0, 6); | |
| 439 | + | |
| 440 | + if (i == 0 || (i == 2 && ctx->mode == MODE_5k0)) | |
| 441 | + t0_first = T0; | |
| 442 | + | |
| 443 | + ff_acelp_interpolatef(excitation, excitation - T0 + (T0_frac <= 0), | |
| 444 | + ff_b60_sinc, 6, | |
| 445 | + 2 * ((2 + T0_frac)%3 + 1), LP_FILTER_ORDER, | |
| 446 | + SUBFR_SIZE); | |
| 447 | + | |
| 448 | + decode_fixed_sparse(&fixed_cb, params->fc_indexes[i], ctx->mode, | |
| 449 | + ctx->past_pitch_gain < 0.8); | |
| 450 | + | |
| 451 | + eval_ir(pAz, T0, impulse_response, ctx->m.pitch_sharp_factor); | |
| 452 | + | |
| 453 | + convolute_with_sparse(fixed_vector, &fixed_cb, impulse_response, | |
| 454 | + SUBFR_SIZE); | |
| 455 | + | |
| 456 | + avg_energy = | |
| 457 | + (0.01 + ff_dot_productf(fixed_vector, fixed_vector, SUBFR_SIZE))/ | |
| 458 | + SUBFR_SIZE; | |
| 459 | + | |
| 460 | + ctx->past_pitch_gain = pitch_gain = gain_cb[params->gc_index[i]][0]; | |
| 461 | + | |
| 462 | + gain_code = ff_amr_set_fixed_gain(gain_cb[params->gc_index[i]][1], | |
| 463 | + avg_energy, ctx->energy_history, | |
| 464 | + 34 - 15.0/(log2f(10.0) * 0.05), | |
| 465 | + pred); | |
| 466 | + | |
| 467 | + ff_weighted_vector_sumf(excitation, excitation, fixed_vector, | |
| 468 | + pitch_gain, gain_code, SUBFR_SIZE); | |
| 469 | + | |
| 470 | + pitch_gain *= 0.5 * pitch_gain; | |
| 471 | + pitch_gain = FFMIN(pitch_gain, 0.4); | |
| 472 | + | |
| 473 | + ctx->gain_mem = 0.7 * ctx->gain_mem + 0.3 * pitch_gain; | |
| 474 | + ctx->gain_mem = FFMIN(ctx->gain_mem, pitch_gain); | |
| 475 | + gain_code *= ctx->gain_mem; | |
| 476 | + | |
| 477 | + for (j = 0; j < SUBFR_SIZE; j++) | |
| 478 | + fixed_vector[j] = excitation[j] - gain_code * fixed_vector[j]; | |
| 479 | + | |
| 480 | + if (ctx->mode == MODE_5k0) { | |
| 481 | + postfilter_5k0(ctx, pAz, fixed_vector); | |
| 482 | + | |
| 483 | + ff_celp_lp_synthesis_filterf(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE, | |
| 484 | + pAz, excitation, SUBFR_SIZE, | |
| 485 | + LP_FILTER_ORDER); | |
| 486 | + } | |
| 487 | + | |
| 488 | + ff_celp_lp_synthesis_filterf(synth + i*SUBFR_SIZE, pAz, fixed_vector, | |
| 489 | + SUBFR_SIZE, LP_FILTER_ORDER); | |
| 490 | + | |
| 491 | + excitation += SUBFR_SIZE; | |
| 492 | + } | |
| 493 | + | |
| 494 | + memcpy(synth - LP_FILTER_ORDER, synth + frame_size - LP_FILTER_ORDER, | |
| 495 | + LP_FILTER_ORDER * sizeof(float)); | |
| 496 | + | |
| 497 | + if (ctx->mode == MODE_5k0) { | |
| 498 | + for (i = 0; i < ctx->m.subframe_count; i++) { | |
| 499 | + float energy = ff_dot_productf(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE, | |
| 500 | + ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE, | |
| 501 | + SUBFR_SIZE); | |
| 502 | + ff_adaptative_gain_control(&synth[i * SUBFR_SIZE], energy, | |
| 503 | + SUBFR_SIZE, 0.9, &ctx->postfilter_agc); | |
| 504 | + } | |
| 505 | + | |
| 506 | + memcpy(ctx->postfilter_syn5k0, ctx->postfilter_syn5k0 + frame_size, | |
| 507 | + LP_FILTER_ORDER*sizeof(float)); | |
| 508 | + } | |
| 509 | + memcpy(ctx->excitation, excitation - PITCH_DELAY_MAX - L_INTERPOL, | |
| 510 | + (PITCH_DELAY_MAX + L_INTERPOL) * sizeof(float)); | |
| 511 | + | |
| 512 | + ff_acelp_apply_order_2_transfer_function(synth, | |
| 513 | + (const float[2]) {-1.99997 , 1.000000000}, | |
| 514 | + (const float[2]) {-1.93307352, 0.935891986}, | |
| 515 | + 0.939805806, | |
| 516 | + ctx->highpass_filt_mem, | |
| 517 | + frame_size); | |
| 518 | + | |
| 519 | + ctx->dsp.vector_clipf(out_data, synth, -1, 32767./(1<<15), frame_size); | |
| 520 | + | |
| 521 | +} | |
| 522 | + | |
| 523 | +static av_cold int sipr_decoder_init(AVCodecContext * avctx) | |
| 524 | +{ | |
| 525 | + SiprContext *ctx = avctx->priv_data; | |
| 526 | + int i; | |
| 527 | + | |
| 528 | + if (avctx->bit_rate > 12200) ctx->mode = MODE_16k; | |
| 529 | + else if (avctx->bit_rate > 7500 ) ctx->mode = MODE_8k5; | |
| 530 | + else if (avctx->bit_rate > 5750 ) ctx->mode = MODE_6k5; | |
| 531 | + else ctx->mode = MODE_5k0; | |
| 532 | + | |
| 533 | + ctx->m = modes[ctx->mode]; | |
| 534 | + av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", ctx->m.mode_name); | |
| 535 | + | |
| 536 | + for (i = 0; i < LP_FILTER_ORDER; i++) | |
| 537 | + ctx->lsp_history[i] = cos((i+1) * M_PI / (LP_FILTER_ORDER + 1)); | |
| 538 | + | |
| 539 | + for (i = 0; i < 4; i++) | |
| 540 | + ctx->energy_history[i] = -14; | |
| 541 | + | |
| 542 | + avctx->sample_fmt = SAMPLE_FMT_FLT; | |
| 543 | + | |
| 544 | + if (ctx->mode == MODE_16k) { | |
| 545 | + av_log(avctx, AV_LOG_ERROR, "decoding 16kbps SIPR files is not " | |
| 546 | + "supported yet.\n"); | |
| 547 | + return -1; | |
| 548 | + } | |
| 549 | + | |
| 550 | + dsputil_init(&ctx->dsp, avctx); | |
| 551 | + | |
| 552 | + return 0; | |
| 553 | +} | |
| 554 | + | |
| 555 | +static int sipr_decode_frame(AVCodecContext *avctx, void *datap, | |
| 556 | + int *data_size, AVPacket *avpkt) | |
| 557 | +{ | |
| 558 | + SiprContext *ctx = avctx->priv_data; | |
| 559 | + const uint8_t *buf=avpkt->data; | |
| 560 | + SiprParameters parm; | |
| 561 | + GetBitContext gb; | |
| 562 | + float *data = datap; | |
| 563 | + int i; | |
| 564 | + | |
| 565 | + ctx->avctx = avctx; | |
| 566 | + if (avpkt->size < (ctx->m.bits_per_frame >> 3)) { | |
| 567 | + av_log(avctx, AV_LOG_ERROR, | |
| 568 | + "Error processing packet: packet size (%d) too small\n", | |
| 569 | + avpkt->size); | |
| 570 | + | |
| 571 | + *data_size = 0; | |
| 572 | + return -1; | |
| 573 | + } | |
| 574 | + if (*data_size < SUBFR_SIZE * ctx->m.subframe_count * sizeof(float)) { | |
| 575 | + av_log(avctx, AV_LOG_ERROR, | |
| 576 | + "Error processing packet: output buffer (%d) too small\n", | |
| 577 | + *data_size); | |
| 578 | + | |
| 579 | + *data_size = 0; | |
| 580 | + return -1; | |
| 581 | + } | |
| 582 | + | |
| 583 | + init_get_bits(&gb, buf, ctx->m.bits_per_frame); | |
| 584 | + | |
| 585 | + for (i = 0; i < ctx->m.frames_per_packet; i++) { | |
| 586 | + decode_parameters(&parm, &gb, &ctx->m); | |
| 587 | + decode_frame(ctx, &parm, data); | |
| 588 | + | |
| 589 | + data += SUBFR_SIZE * ctx->m.subframe_count; | |
| 590 | + } | |
| 591 | + | |
| 592 | + *data_size = ctx->m.frames_per_packet * SUBFR_SIZE * | |
| 593 | + ctx->m.subframe_count * sizeof(float); | |
| 594 | + | |
| 595 | + return ctx->m.bits_per_frame >> 3; | |
| 596 | +}; | |
| 597 | + | |
| 598 | +AVCodec sipr_decoder = { | |
| 599 | + "sipr", | |
| 600 | + CODEC_TYPE_AUDIO, | |
| 601 | + CODEC_ID_SIPR, | |
| 602 | + sizeof(SiprContext), | |
| 603 | + sipr_decoder_init, | |
| 604 | + NULL, | |
| 605 | + NULL, | |
| 606 | + sipr_decode_frame, | |
| 607 | + .long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"), | |
| 608 | +}; | |
| @@ -0,0 +1,270 @@ | ||
| 1 | +/* | |
| 2 | + * SIPR / ACELP.NET decoder | |
| 3 | + * | |
| 4 | + * Copyright (c) 2008 Vladimir Voroshilov | |
| 5 | + * Copyright (c) 2009 Vitor Sessak | |
| 6 | + * | |
| 7 | + * This file is part of FFmpeg. | |
| 8 | + * | |
| 9 | + * FFmpeg is free software; you can redistribute it and/or | |
| 10 | + * modify it under the terms of the GNU Lesser General Public | |
| 11 | + * License as published by the Free Software Foundation; either | |
| 12 | + * version 2.1 of the License, or (at your option) any later version. | |
| 13 | + * | |
| 14 | + * FFmpeg is distributed in the hope that it will be useful, | |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 17 | + * Lesser General Public License for more details. | |
| 18 | + * | |
| 19 | + * You should have received a copy of the GNU Lesser General Public | |
| 20 | + * License along with FFmpeg; if not, write to the Free Software | |
| 21 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 22 | + */ | |
| 23 | + | |
| 24 | +#ifndef AVCODEC_SIPRDATA_H | |
| 25 | +#define AVCODEC_SIPRDATA_H | |
| 26 | + | |
| 27 | +static const float pow_0_5[] = { | |
| 28 | + 1.0/(1 << 1), 1.0/(1 << 2), 1.0/(1 << 3), 1.0/(1 << 4), | |
| 29 | + 1.0/(1 << 5), 1.0/(1 << 6), 1.0/(1 << 7), 1.0/(1 << 8), | |
| 30 | + 1.0/(1 << 9), 1.0/(1 << 10), 1.0/(1 << 11), 1.0/(1 << 12), | |
| 31 | + 1.0/(1 << 13), 1.0/(1 << 14), 1.0/(1 << 15), 1.0/(1 << 16) | |
| 32 | +}; | |
| 33 | + | |
| 34 | +static const float mean_lsf[10] = { | |
| 35 | + 0.297151, 0.452308, 0.765443, 1.134803, 1.421125, | |
| 36 | + 1.773822, 2.049173, 2.375914, 2.585097, 0.075756 | |
| 37 | +}; | |
| 38 | + | |
| 39 | +static const float lsf_cb1[64][2] = { | |
| 40 | + { 0.007587, -0.005843}, { 0.042163, -0.028048}, {-0.017147, -0.060705}, | |
| 41 | + { 0.013773, -0.038108}, {-0.041563, -0.078571}, {-0.076928, -0.119343}, | |
| 42 | + { 0.012654, 0.176005}, { 0.059737, 0.156869}, { 0.171767, 0.231837}, | |
| 43 | + { 0.114030, 0.242047}, { 0.168977, 0.283101}, { 0.146210, 0.397961}, | |
| 44 | + { 0.249446, 0.268421}, { 0.137074, 0.186724}, {-0.057736, -0.135638}, | |
| 45 | + {-0.109664, -0.124611}, {-0.021234, -0.031174}, {-0.013990, -0.091819}, | |
| 46 | + {-0.040046, -0.111426}, {-0.016830, 0.055361}, { 0.057815, 0.071606}, | |
| 47 | + { 0.060670, 0.114436}, { 0.106695, 0.140838}, { 0.093601, 0.092793}, | |
| 48 | + { 0.039593, 0.006142}, {-0.066589, -0.092463}, {-0.102589, -0.171380}, | |
| 49 | + {-0.059621, -0.050671}, { 0.166131, 0.139773}, { 0.213069, 0.190761}, | |
| 50 | + { 0.061820, 0.037661}, { 0.136471, 0.090823}, {-0.019789, 0.013515}, | |
| 51 | + { 0.022280, 0.079473}, { 0.215281, 0.461959}, { 0.206497, 0.340077}, | |
| 52 | + { 0.012249, -0.065596}, { 0.091345, 0.190871}, { 0.019506, 0.037266}, | |
| 53 | + {-0.050702, -0.013223}, {-0.057334, 0.028943}, { 0.291512, 0.371415}, | |
| 54 | + {-0.053467, 0.084160}, { 0.025372, 0.375310}, { 0.269995, 0.566520}, | |
| 55 | + {-0.095259, -0.012353}, { 0.050479, 0.212893}, { 0.101219, 0.049320}, | |
| 56 | + { 0.072426, 0.283362}, {-0.084116, -0.150542}, {-0.031485, 0.144922}, | |
| 57 | + { 0.012714, 0.256910}, {-0.009528, 0.102768}, {-0.039572, 0.204967}, | |
| 58 | + {-0.098800, 0.055038}, { 0.020719, 0.128387}, {-0.045559, -0.178373}, | |
| 59 | + {-0.082338, 0.136933}, {-0.058270, 0.292806}, { 0.084242, 0.505112}, | |
| 60 | + { 0.121825, 0.326386}, {-0.102658, -0.069341}, { 0.071675, 0.004744}, | |
| 61 | + {-0.117763, -0.202608} | |
| 62 | +}; | |
| 63 | + | |
| 64 | +static const float lsf_cb2[128][2] = { | |
| 65 | + { 0.025412, 0.006095}, {-0.069803, 0.010650}, {-0.175957, -0.185800}, | |
| 66 | + {-0.139298, -0.048013}, {-0.156150, -0.129688}, {-0.160523, 0.068022}, | |
| 67 | + { 0.199683, 0.259982}, { 0.258038, 0.236147}, { 0.367089, 0.304716}, | |
| 68 | + { 0.251764, 0.305853}, { 0.394314, 0.382153}, { 0.448579, 0.337438}, | |
| 69 | + { 0.323286, 0.425563}, { 0.015369, 0.123820}, {-0.026770, 0.083881}, | |
| 70 | + {-0.112161, -0.097993}, {-0.221847, -0.161311}, {-0.050014, -0.092862}, | |
| 71 | + {-0.214960, -0.398498}, {-0.114062, -0.241381}, { 0.137950, 0.138852}, | |
| 72 | + { 0.031529, 0.065719}, { 0.208734, 0.084760}, { 0.157862, 0.057535}, | |
| 73 | + { 0.124750, 0.011922}, {-0.035227, -0.154397}, {-0.105523, -0.291427}, | |
| 74 | + {-0.073488, -0.201948}, {-0.224184, -0.273290}, {-0.168019, -0.240297}, | |
| 75 | + {-0.271591, -0.384682}, {-0.124784, 0.014253}, { 0.004210, -0.110418}, | |
| 76 | + { 0.074270, -0.014272}, { 0.053058, -0.068672}, {-0.090098, -0.145019}, | |
| 77 | + { 0.303214, 0.210323}, { 0.413443, 0.272002}, { 0.356904, 0.230646}, | |
| 78 | + {-0.035186, -0.028579}, {-0.117558, 0.115105}, {-0.159225, 0.218385}, | |
| 79 | + {-0.230178, 0.172901}, {-0.216148, -0.110195}, { 0.309444, 0.101508}, | |
| 80 | + { 0.250489, 0.118338}, { 0.293324, 0.151205}, {-0.023634, 0.033084}, | |
| 81 | + { 0.076708, 0.114024}, { 0.123119, 0.087704}, {-0.060265, 0.126543}, | |
| 82 | + {-0.223766, -0.021903}, {-0.241987, -0.328089}, { 0.205598, 0.147925}, | |
| 83 | + {-0.087010, 0.064601}, {-0.287892, -0.286099}, {-0.179451, -0.350781}, | |
| 84 | + {-0.219572, 0.043816}, {-0.217263, 0.245550}, {-0.286743, -0.180981}, | |
| 85 | + { 0.172659, 0.112620}, {-0.105422, 0.176856}, { 0.006176, -0.051491}, | |
| 86 | + { 0.099802, 0.176322}, {-0.186620, -0.068980}, { 0.164689, 0.185018}, | |
| 87 | + { 0.519877, 0.376111}, { 0.521941, 0.533731}, { 0.473375, 0.439534}, | |
| 88 | + { 0.214235, 0.202476}, { 0.579215, 0.466969}, { 0.310414, 0.271057}, | |
| 89 | + { 0.257450, 0.058939}, { 0.023936, -0.169464}, {-0.268817, -0.064531}, | |
| 90 | + {-0.174182, -0.000198}, {-0.268405, -0.234529}, {-0.296522, 0.247140}, | |
| 91 | + { 0.115950, -0.072194}, {-0.303666, 0.149084}, {-0.347762, -0.011002}, | |
| 92 | + {-0.223829, -0.214137}, {-0.278958, -0.457975}, { 0.135500, 0.238466}, | |
| 93 | + { 0.312730, 0.342760}, { 0.071754, -0.125912}, { 0.485938, 0.260429}, | |
| 94 | + { 0.037536, 0.179771}, { 0.391493, 0.156938}, { 0.397320, 0.484446}, | |
| 95 | + {-0.308630, -0.342418}, {-0.269599, -0.128453}, {-0.086683, -0.043863}, | |
| 96 | + { 0.421115, 0.213521}, { 0.082417, 0.049006}, {-0.087873, 0.238126}, | |
| 97 | + { 0.338899, 0.166131}, {-0.166988, 0.147105}, {-0.167214, -0.294075}, | |
| 98 | + { 0.588706, 0.328303}, { 0.207270, 0.017671}, {-0.141658, 0.291147}, | |
| 99 | + {-0.140850, 0.374321}, { 0.028180, 0.322510}, {-0.229858, 0.328036}, | |
| 100 | + {-0.060743, -0.260916}, {-0.011131, 0.246442}, {-0.058151, 0.310760}, | |
| 101 | + {-0.127536, -0.186432}, {-0.128523, -0.334884}, {-0.283899, 0.077729}, | |
| 102 | + {-0.031595, 0.181015}, {-0.329330, -0.108630}, {-0.215739, 0.107458}, | |
| 103 | + { 0.175734, 0.327134}, { 0.255801, 0.176077}, { 0.228265, 0.396859}, | |
| 104 | + {-0.370909, -0.185081}, {-0.355138, -0.300405}, { 0.061669, 0.242616}, | |
| 105 | + { 0.104489, 0.307995}, {-0.320021, -0.234002}, { 0.077349, 0.416286}, | |
| 106 | + {-0.339471, -0.407609}, {-0.019384, -0.215111}, { 0.168229, -0.032453}, | |
| 107 | + {-0.040140, 0.399658}, {-0.275141, 0.008218} | |
| 108 | +}; | |
| 109 | + | |
| 110 | +static const float lsf_cb3[128][2] = { | |
| 111 | + { 0.024608, 0.006198}, {-0.216616, -0.398169}, {-0.089601, -0.201370}, | |
| 112 | + {-0.121878, -0.305281}, { 0.037913, 0.059320}, { 0.245126, 0.244089}, | |
| 113 | + { 0.266853, 0.182476}, { 0.319362, 0.203481}, { 0.349945, 0.252644}, | |
| 114 | + { 0.393849, 0.279272}, { 0.445707, 0.258063}, { 0.387321, 0.200855}, | |
| 115 | + {-0.038818, 0.129603}, {-0.009510, 0.076441}, {-0.023892, -0.028199}, | |
| 116 | + {-0.117134, -0.145990}, {-0.186585, -0.052886}, {-0.034250, -0.084547}, | |
| 117 | + {-0.087443, -0.095426}, {-0.453322, -0.174493}, {-0.363975, -0.148186}, | |
| 118 | + {-0.334413, -0.202479}, {-0.221313, -0.181320}, {-0.131146, -0.050611}, | |
| 119 | + {-0.104706, 0.115139}, { 0.192765, 0.275417}, { 0.014184, 0.194251}, | |
| 120 | + { 0.154215, 0.226949}, { 0.084031, 0.221759}, { 0.189438, 0.164566}, | |
| 121 | + { 0.130737, 0.170962}, {-0.066815, 0.062954}, {-0.177176, -0.145167}, | |
| 122 | + {-0.247608, -0.129767}, {-0.187886, -0.293720}, {-0.244036, -0.344655}, | |
| 123 | + {-0.203063, -0.234947}, {-0.292715, -0.158421}, { 0.064990, -0.028164}, | |
| 124 | + { 0.147664, 0.085995}, { 0.107977, 0.002253}, { 0.071286, 0.027533}, | |
| 125 | + { 0.021017, -0.049807}, {-0.272056, -0.217857}, {-0.065596, 0.008375}, | |
| 126 | + {-0.150818, -0.195514}, {-0.012767, -0.150787}, { 0.238541, 0.136606}, | |
| 127 | + { 0.291741, 0.114024}, { 0.202677, 0.103701}, { 0.140985, 0.037759}, | |
| 128 | + {-0.257347, -0.442383}, {-0.320666, -0.319742}, {-0.488725, -0.603660}, | |
| 129 | + {-0.319170, -0.469806}, { 0.014970, -0.101074}, { 0.102209, 0.066790}, | |
| 130 | + {-0.076202, -0.044884}, { 0.073868, 0.152565}, { 0.070755, -0.091358}, | |
| 131 | + {-0.016751, 0.027216}, { 0.071201, 0.096981}, {-0.060975, -0.145638}, | |
| 132 | + { 0.114156, 0.117587}, {-0.284757, -0.029101}, {-0.253005, -0.073645}, | |
| 133 | + {-0.204028, -0.098492}, {-0.114508, 0.001219}, {-0.225284, -0.011998}, | |
| 134 | + {-0.235670, 0.084330}, { 0.161921, 0.128334}, { 0.025717, 0.119456}, | |
| 135 | + {-0.255292, -0.281471}, {-0.392803, -0.095809}, { 0.039229, -0.152110}, | |
| 136 | + {-0.310905, -0.099233}, {-0.268773, 0.032308}, {-0.340150, 0.013129}, | |
| 137 | + {-0.344890, -0.045157}, {-0.188423, 0.265603}, {-0.168235, -0.000936}, | |
| 138 | + { 0.000462, 0.297000}, { 0.263674, 0.371214}, {-0.146797, -0.098225}, | |
| 139 | + {-0.386557, -0.282426}, {-0.070940, -0.255550}, { 0.293258, 0.252785}, | |
| 140 | + { 0.408332, 0.387751}, {-0.381914, -0.358918}, {-0.463621, -0.315560}, | |
| 141 | + {-0.323681, -0.258465}, { 0.250055, 0.071195}, {-0.405256, -0.429754}, | |
| 142 | + {-0.135748, -0.251274}, { 0.186827, 0.060177}, { 0.116742, -0.053526}, | |
| 143 | + {-0.403321, -0.220339}, {-0.414144, -0.021108}, {-0.416877, 0.050184}, | |
| 144 | + {-0.470083, -0.079564}, {-0.315554, 0.219217}, {-0.273183, 0.138437}, | |
| 145 | + { 0.253231, 0.306374}, { 0.177802, 0.346298}, { 0.210358, 0.207697}, | |
| 146 | + {-0.323480, 0.077519}, {-0.193136, 0.048170}, { 0.114492, 0.292778}, | |
| 147 | + {-0.130766, 0.056677}, {-0.171572, -0.349267}, {-0.370076, -0.536392}, | |
| 148 | + {-0.311109, -0.389953}, { 0.334928, 0.367664}, { 0.351246, 0.438664}, | |
| 149 | + { 0.518803, 0.331253}, { 0.437061, 0.327257}, { 0.318906, 0.307389}, | |
| 150 | + {-0.025972, -0.206758}, { 0.373278, 0.325438}, { 0.473488, 0.389441}, | |
| 151 | + { 0.478553, 0.477990}, { 0.332783, 0.153825}, { 0.212098, 0.452336}, | |
| 152 | + { 0.161522, -0.011212}, { 0.209368, 0.020687}, {-0.086262, 0.204493}, | |
| 153 | + {-0.388643, 0.133640}, {-0.177016, 0.134404} | |
| 154 | +}; | |
| 155 | + | |
| 156 | +static const float lsf_cb4[128][2] = { | |
| 157 | + {-0.003594, -0.022447}, { 0.070651, 0.028334}, {-0.290374, -0.018347}, | |
| 158 | + {-0.224495, -0.370312}, {-0.269555, -0.131227}, {-0.122714, -0.267733}, | |
| 159 | + { 0.173325, 0.138698}, { 0.161946, 0.020687}, { 0.111706, 0.022510}, | |
| 160 | + { 0.097638, 0.056049}, { 0.139754, 0.059920}, { 0.056549, -0.050586}, | |
| 161 | + { 0.036301, 0.021501}, {-0.066347, 0.012324}, {-0.066972, 0.096136}, | |
| 162 | + {-0.120062, -0.084201}, { 0.011225, 0.047425}, {-0.012846, -0.067390}, | |
| 163 | + {-0.116201, 0.122874}, {-0.027819, 0.035453}, {-0.024743, 0.072835}, | |
| 164 | + {-0.034061, -0.001310}, { 0.077469, 0.081609}, { 0.128347, 0.139584}, | |
| 165 | + { 0.183416, 0.086563}, {-0.155839, -0.053775}, {-0.190403, -0.018639}, | |
| 166 | + {-0.202548, -0.062841}, {-0.373733, -0.275094}, {-0.394260, -0.186513}, | |
| 167 | + {-0.465700, -0.220031}, { 0.064400, -0.095825}, {-0.262053, -0.199837}, | |
| 168 | + {-0.167233, -0.094402}, { 0.048600, 0.057567}, {-0.007122, 0.168506}, | |
| 169 | + { 0.050938, 0.156451}, {-0.060828, 0.147083}, {-0.171889, 0.195822}, | |
| 170 | + {-0.218934, 0.138431}, {-0.270532, 0.195775}, {-0.405818, 0.075643}, | |
| 171 | + {-0.440187, 0.193387}, {-0.484968, 0.157607}, {-0.480560, 0.067230}, | |
| 172 | + {-0.436757, -0.111847}, {-0.040731, -0.040363}, {-0.202319, -0.170457}, | |
| 173 | + {-0.158515, -0.134551}, {-0.356709, -0.378549}, {-0.268820, -0.289831}, | |
| 174 | + {-0.188486, -0.289306}, {-0.148139, -0.177616}, {-0.071591, -0.191128}, | |
| 175 | + {-0.052270, -0.150589}, {-0.020543, -0.116220}, { 0.039584, -0.012592}, | |
| 176 | + {-0.268226, 0.042704}, {-0.209755, 0.069423}, {-0.168964, 0.124504}, | |
| 177 | + {-0.363240, 0.188266}, {-0.524935, -0.025010}, {-0.105894, -0.002699}, | |
| 178 | + {-0.251830, -0.062018}, {-0.310480, -0.082325}, { 0.014652, 0.083127}, | |
| 179 | + {-0.136512, 0.033116}, {-0.073755, -0.025236}, { 0.110766, 0.095954}, | |
| 180 | + { 0.002878, 0.011838}, {-0.074977, -0.244586}, {-0.047023, -0.081339}, | |
| 181 | + {-0.183249, 0.029525}, { 0.263435, 0.206934}, {-0.156721, -0.229993}, | |
| 182 | + {-0.112224, -0.208941}, {-0.116534, -0.123191}, {-0.073988, -0.111668}, | |
| 183 | + { 0.029484, -0.137573}, {-0.009802, -0.161685}, {-0.023273, 0.114043}, | |
| 184 | + {-0.332651, 0.049072}, {-0.394009, 0.018608}, {-0.433543, -0.035318}, | |
| 185 | + {-0.368459, -0.108024}, {-0.350215, -0.037617}, {-0.321140, -0.178537}, | |
| 186 | + { 0.020307, -0.048487}, {-0.210512, -0.232274}, {-0.082140, -0.065443}, | |
| 187 | + { 0.081961, -0.009340}, { 0.146794, 0.101973}, { 0.213999, 0.124687}, | |
| 188 | + { 0.100217, -0.054095}, {-0.114411, -0.041403}, {-0.097631, 0.037061}, | |
| 189 | + {-0.099651, -0.157978}, {-0.215790, -0.116550}, {-0.107100, 0.076300}, | |
| 190 | + { 0.084653, 0.126088}, { 0.246439, 0.091442}, { 0.160077, 0.188536}, | |
| 191 | + { 0.273900, 0.279190}, { 0.320417, 0.232550}, { 0.132710, -0.018988}, | |
| 192 | + { 0.018950, -0.091681}, {-0.032073, -0.202906}, { 0.212789, 0.178188}, | |
| 193 | + { 0.208580, 0.239726}, { 0.049420, 0.099840}, {-0.145695, -0.010619}, | |
| 194 | + {-0.132525, -0.322660}, { 0.019666, 0.126603}, { 0.260809, 0.147727}, | |
| 195 | + {-0.232795, -0.001090}, {-0.049826, 0.225987}, {-0.154774, 0.076614}, | |
| 196 | + { 0.045032, 0.221397}, { 0.321014, 0.161632}, {-0.062379, 0.053586}, | |
| 197 | + { 0.132252, 0.246675}, { 0.392627, 0.271905}, {-0.264585, 0.102344}, | |
| 198 | + {-0.327200, 0.121624}, {-0.399642, 0.124445}, {-0.108335, 0.179171}, | |
| 199 | + { 0.100374, 0.182731}, { 0.203852, 0.049505} | |
| 200 | +}; | |
| 201 | + | |
| 202 | +static const float lsf_cb5[32][2] = { | |
| 203 | + {-0.047705, 0.008002}, { 0.011332, 0.065028}, {-0.021796, -0.034777}, | |
| 204 | + {-0.147394, -0.001241}, {-0.001577, 0.020599}, {-0.083827, -0.028975}, | |
| 205 | + {-0.177707, 0.066046}, {-0.043241, -0.165144}, { 0.053322, 0.096519}, | |
| 206 | + {-0.097688, 0.106484}, {-0.023392, 0.111234}, {-0.146747, -0.159360}, | |
| 207 | + { 0.027241, -0.011806}, {-0.043156, 0.057667}, { 0.019516, -0.062116}, | |
| 208 | + { 0.025990, 0.162533}, { 0.091888, 0.009720}, {-0.098511, 0.036414}, | |
| 209 | + { 0.013722, -0.116512}, { 0.054833, -0.180975}, { 0.119497, 0.128774}, | |
| 210 | + { 0.118378, -0.125997}, { 0.065882, -0.030932}, { 0.120581, -0.039964}, | |
| 211 | + {-0.050561, -0.088577}, { 0.050134, 0.033194}, {-0.129654, -0.075112}, | |
| 212 | + {-0.225334, -0.040234}, { 0.070629, -0.084455}, { 0.095508, 0.063548}, | |
| 213 | + { 0.150514, 0.034366}, { 0.186092, -0.069272} | |
| 214 | +}; | |
| 215 | + | |
| 216 | +static const float *lsf_codebooks[] = { | |
| 217 | + lsf_cb1[0], lsf_cb2[0], lsf_cb3[0], lsf_cb4[0], lsf_cb5[0] | |
| 218 | +}; | |
| 219 | + | |
| 220 | +static const float gain_cb[128][2] = { | |
| 221 | + {0.035230, 0.161540}, {0.049223, 0.448359}, {0.057443, 0.809043}, | |
| 222 | + {0.072434, 1.760306}, {0.111491, 0.566418}, {0.112820, 1.098524}, | |
| 223 | + {0.143493, 0.726856}, {0.144840, 0.347800}, {0.180341, 1.050010}, | |
| 224 | + {0.188171, 2.197256}, {0.189771, 0.256947}, {0.198260, 0.484678}, | |
| 225 | + {0.210622, 0.755825}, {0.220694, 0.590788}, {0.237062, 1.322214}, | |
| 226 | + {0.255175, 0.338710}, {0.298980, 0.919051}, {0.314627, 0.520961}, | |
| 227 | + {0.337106, 1.469863}, {0.341422, 2.804546}, {0.363257, 0.736222}, | |
| 228 | + {0.363881, 0.367640}, {0.369850, 1.937934}, {0.370136, 1.075201}, | |
| 229 | + {0.397152, 0.549410}, {0.426557, 0.876015}, {0.450686, 0.215588}, | |
| 230 | + {0.468116, 0.671848}, {0.470495, 1.242034}, {0.474180, 1.739845}, | |
| 231 | + {0.484875, 0.490564}, {0.498917, 0.971238}, {0.530996, 0.785765}, | |
| 232 | + {0.539768, 2.130689}, {0.546021, 0.589544}, {0.546632, 3.050846}, | |
| 233 | + {0.552336, 0.389775}, {0.556302, 1.400103}, {0.559688, 1.105421}, | |
| 234 | + {0.574140, 0.667513}, {0.595547, 0.828943}, {0.597771, 0.496929}, | |
| 235 | + {0.617079, 1.863075}, {0.619657, 1.221713}, {0.621172, 0.950275}, | |
| 236 | + {0.628426, 0.630766}, {0.628689, 4.242164}, {0.640899, 1.529846}, | |
| 237 | + {0.645813, 0.331127}, {0.653056, 0.748168}, {0.662909, 1.077438}, | |
| 238 | + {0.669505, 2.631114}, {0.681570, 1.839298}, {0.687844, 0.903400}, | |
| 239 | + {0.688660, 1.270830}, {0.695070, 0.578227}, {0.697926, 0.428440}, | |
| 240 | + {0.715454, 0.812355}, {0.729981, 1.539357}, {0.737434, 1.106765}, | |
| 241 | + {0.740241, 2.033374}, {0.740871, 0.568460}, {0.752689, 0.698461}, | |
| 242 | + {0.756587, 0.893078}, {0.767797, 0.499246}, {0.768516, 3.712434}, | |
| 243 | + {0.773153, 1.332360}, {0.786125, 1.042996}, {0.788792, 0.238388}, | |
| 244 | + {0.790861, 2.273229}, {0.795338, 1.582767}, {0.809621, 0.595501}, | |
| 245 | + {0.821032, 0.756460}, {0.824590, 0.922925}, {0.826019, 1.186793}, | |
| 246 | + {0.827426, 1.885076}, {0.830080, 6.088666}, {0.837028, 2.819993}, | |
| 247 | + {0.845561, 1.490623}, {0.848323, 0.410436}, {0.856522, 0.729725}, | |
| 248 | + {0.862636, 0.966880}, {0.874561, 1.681660}, {0.874751, 1.177630}, | |
| 249 | + {0.879289, 2.301300}, {0.886671, 0.613068}, {0.896729, 0.781097}, | |
| 250 | + {0.904777, 3.484111}, {0.906098, 1.330892}, {0.919182, 1.877203}, | |
| 251 | + {0.919901, 0.569511}, {0.921772, 1.034126}, {0.922439, 0.376000}, | |
| 252 | + {0.934221, 1.485214}, {0.938842, 0.869135}, {0.939166, 2.378294}, | |
| 253 | + {0.958933, 1.122722}, {0.959042, 0.694098}, {0.960995, 1.743430}, | |
| 254 | + {0.970763, 2.884897}, {0.982881, 0.814506}, {0.990141, 1.330022}, | |
| 255 | + {0.996447, 1.823381}, {1.000013, 0.967498}, {1.000743, 0.480597}, | |
| 256 | + {1.008020, 5.095226}, {1.013883, 2.105435}, {1.026438, 0.691312}, | |
| 257 | + {1.027361, 1.558169}, {1.030123, 3.586526}, {1.033916, 1.118036}, | |
| 258 | + {1.039315, 2.543360}, {1.068596, 0.836380}, {1.081023, 1.318768}, | |
| 259 | + {1.093150, 2.267843}, {1.095607, 1.712383}, {1.102816, 1.037334}, | |
| 260 | + {1.103231, 3.536292}, {1.107320, 0.508615}, {1.150000, 7.999000}, | |
| 261 | + {1.156731, 1.236772}, {1.168428, 2.268084}, {1.184130, 0.775839}, | |
| 262 | + {1.210609, 1.511840}, {1.220663, 4.365683}, {1.224016, 0.983179}, | |
| 263 | + {1.252236, 2.778535}, {1.301176, 1.923126} | |
| 264 | +}; | |
| 265 | + | |
| 266 | +static const float pred[4] = { | |
| 267 | + 0.200, 0.334, 0.504, 0.691 | |
| 268 | +}; | |
| 269 | + | |
| 270 | +#endif /* AVCODEC_SIPRDATA_H */ | |