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