You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

609 lines
19KB

  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. #include <math.h>
  24. #include <stdint.h>
  25. #include "avcodec.h"
  26. #define ALT_BITSTREAM_READER_LE
  27. #include "get_bits.h"
  28. #include "dsputil.h"
  29. #include "lsp.h"
  30. #include "celp_math.h"
  31. #include "acelp_vectors.h"
  32. #include "acelp_pitch_delay.h"
  33. #include "acelp_filters.h"
  34. #include "celp_filters.h"
  35. #define LSFQ_DIFF_MIN (0.0125 * M_PI)
  36. #define LP_FILTER_ORDER 10
  37. /** Number of past samples needed for excitation interpolation */
  38. #define L_INTERPOL (LP_FILTER_ORDER + 1)
  39. /** Subframe size for all modes except 16k */
  40. #define SUBFR_SIZE 48
  41. #include "siprdata.h"
  42. typedef enum {
  43. MODE_16k,
  44. MODE_8k5,
  45. MODE_6k5,
  46. MODE_5k0,
  47. MODE_COUNT
  48. } SiprMode;
  49. typedef struct {
  50. const char *mode_name;
  51. uint16_t bits_per_frame;
  52. uint8_t subframe_count;
  53. uint8_t frames_per_packet;
  54. float pitch_sharp_factor;
  55. /* bitstream parameters */
  56. uint8_t number_of_fc_indexes;
  57. /** size in bits of the i-th stage vector of quantizer */
  58. uint8_t vq_indexes_bits[5];
  59. /** size in bits of the adaptive-codebook index for every subframe */
  60. uint8_t pitch_delay_bits[5];
  61. uint8_t gp_index_bits;
  62. uint8_t fc_index_bits[10]; ///< size in bits of the fixed codebook indexes
  63. uint8_t gc_index_bits; ///< size in bits of the gain codebook indexes
  64. } SiprModeParam;
  65. static const SiprModeParam modes[MODE_COUNT] = {
  66. [MODE_8k5] = {
  67. .mode_name = "8k5",
  68. .bits_per_frame = 152,
  69. .subframe_count = 3,
  70. .frames_per_packet = 1,
  71. .pitch_sharp_factor = 0.8,
  72. .number_of_fc_indexes = 3,
  73. .vq_indexes_bits = {6, 7, 7, 7, 5},
  74. .pitch_delay_bits = {8, 5, 5},
  75. .gp_index_bits = 0,
  76. .fc_index_bits = {9, 9, 9},
  77. .gc_index_bits = 7
  78. },
  79. [MODE_6k5] = {
  80. .mode_name = "6k5",
  81. .bits_per_frame = 232,
  82. .subframe_count = 3,
  83. .frames_per_packet = 2,
  84. .pitch_sharp_factor = 0.8,
  85. .number_of_fc_indexes = 3,
  86. .vq_indexes_bits = {6, 7, 7, 7, 5},
  87. .pitch_delay_bits = {8, 5, 5},
  88. .gp_index_bits = 0,
  89. .fc_index_bits = {5, 5, 5},
  90. .gc_index_bits = 7
  91. },
  92. [MODE_5k0] = {
  93. .mode_name = "5k0",
  94. .bits_per_frame = 296,
  95. .subframe_count = 5,
  96. .frames_per_packet = 2,
  97. .pitch_sharp_factor = 0.85,
  98. .number_of_fc_indexes = 1,
  99. .vq_indexes_bits = {6, 7, 7, 7, 5},
  100. .pitch_delay_bits = {8, 5, 8, 5, 5},
  101. .gp_index_bits = 0,
  102. .fc_index_bits = {10},
  103. .gc_index_bits = 7
  104. }
  105. };
  106. typedef struct {
  107. AVCodecContext *avctx;
  108. DSPContext dsp;
  109. SiprModeParam m;
  110. SiprMode mode;
  111. float past_pitch_gain;
  112. float lsf_history[LP_FILTER_ORDER];
  113. float excitation[L_INTERPOL + PITCH_DELAY_MAX + 5*SUBFR_SIZE];
  114. DECLARE_ALIGNED_16(float, synth_buf[LP_FILTER_ORDER + 5*SUBFR_SIZE + 6]);
  115. float lsp_history[LP_FILTER_ORDER];
  116. float gain_mem;
  117. float energy_history[4];
  118. float highpass_filt_mem[2];
  119. float postfilter_mem[PITCH_DELAY_MAX + LP_FILTER_ORDER];
  120. /* 5k0 */
  121. float tilt_mem;
  122. float postfilter_agc;
  123. float postfilter_mem5k0[PITCH_DELAY_MAX + LP_FILTER_ORDER];
  124. float postfilter_syn5k0[LP_FILTER_ORDER + SUBFR_SIZE*5];
  125. } SiprContext;
  126. typedef struct {
  127. int vq_indexes[5];
  128. int pitch_delay[5]; ///< pitch delay
  129. int gp_index[5]; ///< adaptive-codebook gain indexes
  130. int16_t fc_indexes[5][10]; ///< fixed-codebook indexes
  131. int gc_index[5]; ///< fixed-codebook gain indexes
  132. } SiprParameters;
  133. static void dequant(float *out, const int *idx, const float *cbs[])
  134. {
  135. int i;
  136. int stride = 2;
  137. int num_vec = 5;
  138. for (i = 0; i < num_vec; i++)
  139. memcpy(out + stride*i, cbs[i] + stride*idx[i], stride*sizeof(float));
  140. }
  141. static void lsf_decode_fp(float *lsfnew, float *lsf_history,
  142. const SiprParameters *parm)
  143. {
  144. int i;
  145. float lsf_tmp[LP_FILTER_ORDER];
  146. dequant(lsf_tmp, parm->vq_indexes, lsf_codebooks);
  147. for (i = 0; i < LP_FILTER_ORDER; i++)
  148. lsfnew[i] = lsf_history[i] * 0.33 + lsf_tmp[i] + mean_lsf[i];
  149. ff_sort_nearly_sorted_floats(lsfnew, LP_FILTER_ORDER - 1);
  150. /* Note that a minimum distance is not enforced between the last value and
  151. the previous one, contrary to what is done in ff_acelp_reorder_lsf() */
  152. ff_set_min_dist_lsf(lsfnew, LSFQ_DIFF_MIN, LP_FILTER_ORDER - 1);
  153. lsfnew[9] = FFMIN(lsfnew[LP_FILTER_ORDER - 1], 1.3 * M_PI);
  154. memcpy(lsf_history, lsf_tmp, LP_FILTER_ORDER * sizeof(*lsf_history));
  155. for (i = 0; i < LP_FILTER_ORDER - 1; i++)
  156. lsfnew[i] = cos(lsfnew[i]);
  157. lsfnew[LP_FILTER_ORDER - 1] *= 6.153848 / M_PI;
  158. }
  159. /** Apply pitch lag to the fixed vector (AMR section 6.1.2). */
  160. static void pitch_sharpening(int pitch_lag_int, float beta,
  161. float *fixed_vector)
  162. {
  163. int i;
  164. for (i = pitch_lag_int; i < SUBFR_SIZE; i++)
  165. fixed_vector[i] += beta * fixed_vector[i - pitch_lag_int];
  166. }
  167. /**
  168. * Extracts decoding parameters from the input bitstream.
  169. * @param parms parameters structure
  170. * @param pgb pointer to initialized GetBitContext structure
  171. */
  172. static void decode_parameters(SiprParameters* parms, GetBitContext *pgb,
  173. const SiprModeParam *p)
  174. {
  175. int i, j;
  176. for (i = 0; i < 5; i++)
  177. parms->vq_indexes[i] = get_bits(pgb, p->vq_indexes_bits[i]);
  178. for (i = 0; i < p->subframe_count; i++) {
  179. parms->pitch_delay[i] = get_bits(pgb, p->pitch_delay_bits[i]);
  180. parms->gp_index[i] = get_bits(pgb, p->gp_index_bits);
  181. for (j = 0; j < p->number_of_fc_indexes; j++)
  182. parms->fc_indexes[i][j] = get_bits(pgb, p->fc_index_bits[j]);
  183. parms->gc_index[i] = get_bits(pgb, p->gc_index_bits);
  184. }
  185. }
  186. static void lsp2lpc_sipr(const double *lsp, float *Az)
  187. {
  188. int lp_half_order = LP_FILTER_ORDER >> 1;
  189. double buf[lp_half_order + 1];
  190. double pa[lp_half_order + 1];
  191. double *qa = buf + 1;
  192. int i,j;
  193. qa[-1] = 0.0;
  194. ff_lsp2polyf(lsp , pa, lp_half_order );
  195. ff_lsp2polyf(lsp + 1, qa, lp_half_order - 1);
  196. for (i = 1, j = LP_FILTER_ORDER - 1; i < lp_half_order; i++, j--) {
  197. double paf = pa[i] * (1 + lsp[LP_FILTER_ORDER - 1]);
  198. double qaf = (qa[i] - qa[i-2]) * (1 - lsp[LP_FILTER_ORDER - 1]);
  199. Az[i-1] = (paf + qaf) * 0.5;
  200. Az[j-1] = (paf - qaf) * 0.5;
  201. }
  202. Az[lp_half_order - 1] = (1.0 + lsp[LP_FILTER_ORDER - 1]) *
  203. pa[lp_half_order] * 0.5;
  204. Az[LP_FILTER_ORDER - 1] = lsp[LP_FILTER_ORDER - 1];
  205. }
  206. static void sipr_decode_lp(float *lsfnew, const float *lsfold, float *Az,
  207. int num_subfr)
  208. {
  209. double lsfint[LP_FILTER_ORDER];
  210. int i,j;
  211. float t, t0 = 1.0 / num_subfr;
  212. t = t0 * 0.5;
  213. for (i = 0; i < num_subfr; i++) {
  214. for (j = 0; j < LP_FILTER_ORDER; j++)
  215. lsfint[j] = lsfold[j] * (1 - t) + t * lsfnew[j];
  216. lsp2lpc_sipr(lsfint, Az);
  217. Az += LP_FILTER_ORDER;
  218. t += t0;
  219. }
  220. }
  221. /**
  222. * Evaluates the adaptative impulse response.
  223. */
  224. static void eval_ir(const float *Az, int pitch_lag, float *freq,
  225. float pitch_sharp_factor)
  226. {
  227. float tmp1[SUBFR_SIZE+1], tmp2[LP_FILTER_ORDER+1];
  228. int i;
  229. tmp1[0] = 1.;
  230. for (i = 0; i < LP_FILTER_ORDER; i++) {
  231. tmp1[i+1] = Az[i] * ff_pow_0_55[i];
  232. tmp2[i ] = Az[i] * ff_pow_0_7 [i];
  233. }
  234. memset(tmp1 + 11, 0, 37 * sizeof(float));
  235. ff_celp_lp_synthesis_filterf(freq, tmp2, tmp1, SUBFR_SIZE,
  236. LP_FILTER_ORDER);
  237. pitch_sharpening(pitch_lag, pitch_sharp_factor, freq);
  238. }
  239. /**
  240. * Evaluates the convolution of a vector with a sparse vector.
  241. */
  242. static void convolute_with_sparse(float *out, const AMRFixed *pulses,
  243. const float *shape, int length)
  244. {
  245. int i, j;
  246. memset(out, 0, length*sizeof(float));
  247. for (i = 0; i < pulses->n; i++)
  248. for (j = pulses->x[i]; j < length; j++)
  249. out[j] += pulses->y[i] * shape[j - pulses->x[i]];
  250. }
  251. /**
  252. * Apply postfilter, very similar to AMR one.
  253. */
  254. static void postfilter_5k0(SiprContext *ctx, const float *lpc, float *samples)
  255. {
  256. float buf[SUBFR_SIZE + LP_FILTER_ORDER];
  257. float *pole_out = buf + LP_FILTER_ORDER;
  258. float lpc_n[LP_FILTER_ORDER];
  259. float lpc_d[LP_FILTER_ORDER];
  260. int i;
  261. for (i = 0; i < LP_FILTER_ORDER; i++) {
  262. lpc_d[i] = lpc[i] * ff_pow_0_75[i];
  263. lpc_n[i] = lpc[i] * pow_0_5 [i];
  264. };
  265. memcpy(pole_out - LP_FILTER_ORDER, ctx->postfilter_mem,
  266. LP_FILTER_ORDER*sizeof(float));
  267. ff_celp_lp_synthesis_filterf(pole_out, lpc_d, samples, SUBFR_SIZE,
  268. LP_FILTER_ORDER);
  269. memcpy(ctx->postfilter_mem, pole_out + SUBFR_SIZE - LP_FILTER_ORDER,
  270. LP_FILTER_ORDER*sizeof(float));
  271. ff_tilt_compensation(&ctx->tilt_mem, 0.4, pole_out, SUBFR_SIZE);
  272. memcpy(pole_out - LP_FILTER_ORDER, ctx->postfilter_mem5k0,
  273. LP_FILTER_ORDER*sizeof(*pole_out));
  274. memcpy(ctx->postfilter_mem5k0, pole_out + SUBFR_SIZE - LP_FILTER_ORDER,
  275. LP_FILTER_ORDER*sizeof(*pole_out));
  276. ff_celp_lp_zero_synthesis_filterf(samples, lpc_n, pole_out, SUBFR_SIZE,
  277. LP_FILTER_ORDER);
  278. }
  279. static void decode_fixed_sparse(AMRFixed *fixed_sparse, const int16_t *pulses,
  280. SiprMode mode, int low_gain)
  281. {
  282. int i;
  283. switch (mode) {
  284. case MODE_6k5:
  285. for (i = 0; i < 3; i++) {
  286. fixed_sparse->x[i] = 3 * (pulses[i] & 0xf) + i;
  287. fixed_sparse->y[i] = pulses[i] & 0x10 ? -1 : 1;
  288. }
  289. fixed_sparse->n = 3;
  290. break;
  291. case MODE_8k5:
  292. for (i = 0; i < 3; i++) {
  293. fixed_sparse->x[2*i ] = 3 * ((pulses[i] >> 4) & 0xf) + i;
  294. fixed_sparse->x[2*i + 1] = 3 * ( pulses[i] & 0xf) + i;
  295. fixed_sparse->y[2*i ] = (pulses[i] & 0x100) ? -1.0: 1.0;
  296. fixed_sparse->y[2*i + 1] =
  297. (fixed_sparse->x[2*i + 1] < fixed_sparse->x[2*i]) ?
  298. -fixed_sparse->y[2*i ] : fixed_sparse->y[2*i];
  299. }
  300. fixed_sparse->n = 6;
  301. break;
  302. case MODE_5k0:
  303. default:
  304. if (low_gain) {
  305. int offset = (pulses[0] & 0x200) ? 2 : 0;
  306. int val = pulses[0];
  307. for (i = 0; i < 3; i++) {
  308. int index = (val & 0x7) * 6 + 4 - i*2;
  309. fixed_sparse->y[i] = (offset + index) & 0x3 ? -1 : 1;
  310. fixed_sparse->x[i] = index;
  311. val >>= 3;
  312. }
  313. fixed_sparse->n = 3;
  314. } else {
  315. int pulse_subset = (pulses[0] >> 8) & 1;
  316. fixed_sparse->x[0] = ((pulses[0] >> 4) & 15) * 3 + pulse_subset;
  317. fixed_sparse->x[1] = ( pulses[0] & 15) * 3 + pulse_subset + 1;
  318. fixed_sparse->y[0] = pulses[0] & 0x200 ? -1 : 1;
  319. fixed_sparse->y[1] = -fixed_sparse->y[0];
  320. fixed_sparse->n = 2;
  321. }
  322. break;
  323. }
  324. }
  325. static void decode_frame(SiprContext *ctx, SiprParameters *params,
  326. float *out_data)
  327. {
  328. int i, j;
  329. int frame_size = ctx->m.subframe_count * SUBFR_SIZE;
  330. float Az[LP_FILTER_ORDER * ctx->m.subframe_count];
  331. float *excitation;
  332. float ir_buf[SUBFR_SIZE + LP_FILTER_ORDER];
  333. float lsf_new[LP_FILTER_ORDER];
  334. float *impulse_response = ir_buf + LP_FILTER_ORDER;
  335. float *synth = ctx->synth_buf + 16; // 16 instead of LP_FILTER_ORDER for
  336. // memory alignment
  337. int t0_first = 0;
  338. AMRFixed fixed_cb;
  339. memset(ir_buf, 0, LP_FILTER_ORDER * sizeof(float));
  340. lsf_decode_fp(lsf_new, ctx->lsf_history, params);
  341. sipr_decode_lp(lsf_new, ctx->lsp_history, Az, ctx->m.subframe_count);
  342. memcpy(ctx->lsp_history, lsf_new, LP_FILTER_ORDER * sizeof(float));
  343. excitation = ctx->excitation + PITCH_DELAY_MAX + L_INTERPOL;
  344. for (i = 0; i < ctx->m.subframe_count; i++) {
  345. float *pAz = Az + i*LP_FILTER_ORDER;
  346. float fixed_vector[SUBFR_SIZE];
  347. int T0,T0_frac;
  348. float pitch_gain, gain_code, avg_energy;
  349. ff_decode_pitch_lag(&T0, &T0_frac, params->pitch_delay[i], t0_first, i,
  350. ctx->mode == MODE_5k0, 6);
  351. if (i == 0 || (i == 2 && ctx->mode == MODE_5k0))
  352. t0_first = T0;
  353. ff_acelp_interpolatef(excitation, excitation - T0 + (T0_frac <= 0),
  354. ff_b60_sinc, 6,
  355. 2 * ((2 + T0_frac)%3 + 1), LP_FILTER_ORDER,
  356. SUBFR_SIZE);
  357. decode_fixed_sparse(&fixed_cb, params->fc_indexes[i], ctx->mode,
  358. ctx->past_pitch_gain < 0.8);
  359. eval_ir(pAz, T0, impulse_response, ctx->m.pitch_sharp_factor);
  360. convolute_with_sparse(fixed_vector, &fixed_cb, impulse_response,
  361. SUBFR_SIZE);
  362. avg_energy =
  363. (0.01 + ff_dot_productf(fixed_vector, fixed_vector, SUBFR_SIZE))/
  364. SUBFR_SIZE;
  365. ctx->past_pitch_gain = pitch_gain = gain_cb[params->gc_index[i]][0];
  366. gain_code = ff_amr_set_fixed_gain(gain_cb[params->gc_index[i]][1],
  367. avg_energy, ctx->energy_history,
  368. 34 - 15.0/(log2f(10.0) * 0.05),
  369. pred);
  370. ff_weighted_vector_sumf(excitation, excitation, fixed_vector,
  371. pitch_gain, gain_code, SUBFR_SIZE);
  372. pitch_gain *= 0.5 * pitch_gain;
  373. pitch_gain = FFMIN(pitch_gain, 0.4);
  374. ctx->gain_mem = 0.7 * ctx->gain_mem + 0.3 * pitch_gain;
  375. ctx->gain_mem = FFMIN(ctx->gain_mem, pitch_gain);
  376. gain_code *= ctx->gain_mem;
  377. for (j = 0; j < SUBFR_SIZE; j++)
  378. fixed_vector[j] = excitation[j] - gain_code * fixed_vector[j];
  379. if (ctx->mode == MODE_5k0) {
  380. postfilter_5k0(ctx, pAz, fixed_vector);
  381. ff_celp_lp_synthesis_filterf(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,
  382. pAz, excitation, SUBFR_SIZE,
  383. LP_FILTER_ORDER);
  384. }
  385. ff_celp_lp_synthesis_filterf(synth + i*SUBFR_SIZE, pAz, fixed_vector,
  386. SUBFR_SIZE, LP_FILTER_ORDER);
  387. excitation += SUBFR_SIZE;
  388. }
  389. memcpy(synth - LP_FILTER_ORDER, synth + frame_size - LP_FILTER_ORDER,
  390. LP_FILTER_ORDER * sizeof(float));
  391. if (ctx->mode == MODE_5k0) {
  392. for (i = 0; i < ctx->m.subframe_count; i++) {
  393. float energy = ff_dot_productf(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,
  394. ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,
  395. SUBFR_SIZE);
  396. ff_adaptative_gain_control(&synth[i * SUBFR_SIZE], energy,
  397. SUBFR_SIZE, 0.9, &ctx->postfilter_agc);
  398. }
  399. memcpy(ctx->postfilter_syn5k0, ctx->postfilter_syn5k0 + frame_size,
  400. LP_FILTER_ORDER*sizeof(float));
  401. }
  402. memcpy(ctx->excitation, excitation - PITCH_DELAY_MAX - L_INTERPOL,
  403. (PITCH_DELAY_MAX + L_INTERPOL) * sizeof(float));
  404. ff_acelp_apply_order_2_transfer_function(synth,
  405. (const float[2]) {-1.99997 , 1.000000000},
  406. (const float[2]) {-1.93307352, 0.935891986},
  407. 0.939805806,
  408. ctx->highpass_filt_mem,
  409. frame_size);
  410. ctx->dsp.vector_clipf(out_data, synth, -1, 32767./(1<<15), frame_size);
  411. }
  412. static av_cold int sipr_decoder_init(AVCodecContext * avctx)
  413. {
  414. SiprContext *ctx = avctx->priv_data;
  415. int i;
  416. if (avctx->bit_rate > 12200) ctx->mode = MODE_16k;
  417. else if (avctx->bit_rate > 7500 ) ctx->mode = MODE_8k5;
  418. else if (avctx->bit_rate > 5750 ) ctx->mode = MODE_6k5;
  419. else ctx->mode = MODE_5k0;
  420. ctx->m = modes[ctx->mode];
  421. av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", ctx->m.mode_name);
  422. for (i = 0; i < LP_FILTER_ORDER; i++)
  423. ctx->lsp_history[i] = cos((i+1) * M_PI / (LP_FILTER_ORDER + 1));
  424. for (i = 0; i < 4; i++)
  425. ctx->energy_history[i] = -14;
  426. avctx->sample_fmt = SAMPLE_FMT_FLT;
  427. if (ctx->mode == MODE_16k) {
  428. av_log(avctx, AV_LOG_ERROR, "decoding 16kbps SIPR files is not "
  429. "supported yet.\n");
  430. return -1;
  431. }
  432. dsputil_init(&ctx->dsp, avctx);
  433. return 0;
  434. }
  435. static int sipr_decode_frame(AVCodecContext *avctx, void *datap,
  436. int *data_size, AVPacket *avpkt)
  437. {
  438. SiprContext *ctx = avctx->priv_data;
  439. const uint8_t *buf=avpkt->data;
  440. SiprParameters parm;
  441. GetBitContext gb;
  442. float *data = datap;
  443. int i;
  444. ctx->avctx = avctx;
  445. if (avpkt->size < (ctx->m.bits_per_frame >> 3)) {
  446. av_log(avctx, AV_LOG_ERROR,
  447. "Error processing packet: packet size (%d) too small\n",
  448. avpkt->size);
  449. *data_size = 0;
  450. return -1;
  451. }
  452. if (*data_size < SUBFR_SIZE * ctx->m.subframe_count * sizeof(float)) {
  453. av_log(avctx, AV_LOG_ERROR,
  454. "Error processing packet: output buffer (%d) too small\n",
  455. *data_size);
  456. *data_size = 0;
  457. return -1;
  458. }
  459. init_get_bits(&gb, buf, ctx->m.bits_per_frame);
  460. for (i = 0; i < ctx->m.frames_per_packet; i++) {
  461. decode_parameters(&parm, &gb, &ctx->m);
  462. decode_frame(ctx, &parm, data);
  463. data += SUBFR_SIZE * ctx->m.subframe_count;
  464. }
  465. *data_size = ctx->m.frames_per_packet * SUBFR_SIZE *
  466. ctx->m.subframe_count * sizeof(float);
  467. return ctx->m.bits_per_frame >> 3;
  468. };
  469. AVCodec sipr_decoder = {
  470. "sipr",
  471. CODEC_TYPE_AUDIO,
  472. CODEC_ID_SIPR,
  473. sizeof(SiprContext),
  474. sipr_decoder_init,
  475. NULL,
  476. NULL,
  477. sipr_decode_frame,
  478. .long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"),
  479. };