ffmpeg / libavcodec / sipr.c @ d79c06b2
History  View  Annotate  Download (17.9 KB)
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 021101301 USA

22 
*/

23  
24 
#include <math.h> 
25 
#include <stdint.h> 
26  
27 
#include "libavutil/mathematics.h" 
28 
#include "avcodec.h" 
29 
#define ALT_BITSTREAM_READER_LE

30 
#include "get_bits.h" 
31 
#include "dsputil.h" 
32  
33 
#include "lsp.h" 
34 
#include "celp_math.h" 
35 
#include "acelp_vectors.h" 
36 
#include "acelp_pitch_delay.h" 
37 
#include "acelp_filters.h" 
38 
#include "celp_filters.h" 
39  
40 
#define MAX_SUBFRAME_COUNT 5 
41  
42 
#include "sipr.h" 
43 
#include "siprdata.h" 
44  
45 
typedef struct { 
46 
const char *mode_name; 
47 
uint16_t bits_per_frame; 
48 
uint8_t subframe_count; 
49 
uint8_t frames_per_packet; 
50 
float pitch_sharp_factor;

51  
52 
/* bitstream parameters */

53 
uint8_t number_of_fc_indexes; 
54  
55 
/** size in bits of the ith stage vector of quantizer */

56 
uint8_t vq_indexes_bits[5];

57  
58 
/** size in bits of the adaptivecodebook index for every subframe */

59 
uint8_t pitch_delay_bits[5];

60  
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  
66 
static const SiprModeParam modes[MODE_COUNT] = { 
67 
[MODE_8k5] = { 
68 
.mode_name = "8k5",

69 
.bits_per_frame = 152,

70 
.subframe_count = 3,

71 
.frames_per_packet = 1,

72 
.pitch_sharp_factor = 0.8, 
73  
74 
.number_of_fc_indexes = 3,

75 
.vq_indexes_bits = {6, 7, 7, 7, 5}, 
76 
.pitch_delay_bits = {8, 5, 5}, 
77 
.gp_index_bits = 0,

78 
.fc_index_bits = {9, 9, 9}, 
79 
.gc_index_bits = 7

80 
}, 
81  
82 
[MODE_6k5] = { 
83 
.mode_name = "6k5",

84 
.bits_per_frame = 232,

85 
.subframe_count = 3,

86 
.frames_per_packet = 2,

87 
.pitch_sharp_factor = 0.8, 
88  
89 
.number_of_fc_indexes = 3,

90 
.vq_indexes_bits = {6, 7, 7, 7, 5}, 
91 
.pitch_delay_bits = {8, 5, 5}, 
92 
.gp_index_bits = 0,

93 
.fc_index_bits = {5, 5, 5}, 
94 
.gc_index_bits = 7

95 
}, 
96  
97 
[MODE_5k0] = { 
98 
.mode_name = "5k0",

99 
.bits_per_frame = 296,

100 
.subframe_count = 5,

101 
.frames_per_packet = 2,

102 
.pitch_sharp_factor = 0.85, 
103  
104 
.number_of_fc_indexes = 1,

105 
.vq_indexes_bits = {6, 7, 7, 7, 5}, 
106 
.pitch_delay_bits = {8, 5, 8, 5, 5}, 
107 
.gp_index_bits = 0,

108 
.fc_index_bits = {10},

109 
.gc_index_bits = 7

110 
} 
111 
}; 
112  
113 
const float ff_pow_0_5[] = { 
114 
1.0/(1 << 1), 1.0/(1 << 2), 1.0/(1 << 3), 1.0/(1 << 4), 
115 
1.0/(1 << 5), 1.0/(1 << 6), 1.0/(1 << 7), 1.0/(1 << 8), 
116 
1.0/(1 << 9), 1.0/(1 << 10), 1.0/(1 << 11), 1.0/(1 << 12), 
117 
1.0/(1 << 13), 1.0/(1 << 14), 1.0/(1 << 15), 1.0/(1 << 16) 
118 
}; 
119  
120 
static void dequant(float *out, const int *idx, const float *cbs[]) 
121 
{ 
122 
int i;

123 
int stride = 2; 
124 
int num_vec = 5; 
125  
126 
for (i = 0; i < num_vec; i++) 
127 
memcpy(out + stride*i, cbs[i] + stride*idx[i], stride*sizeof(float)); 
128  
129 
} 
130  
131 
static void lsf_decode_fp(float *lsfnew, float *lsf_history, 
132 
const SiprParameters *parm)

133 
{ 
134 
int i;

135 
float lsf_tmp[LP_FILTER_ORDER];

136  
137 
dequant(lsf_tmp, parm>vq_indexes, lsf_codebooks); 
138  
139 
for (i = 0; i < LP_FILTER_ORDER; i++) 
140 
lsfnew[i] = lsf_history[i] * 0.33 + lsf_tmp[i] + mean_lsf[i]; 
141  
142 
ff_sort_nearly_sorted_floats(lsfnew, LP_FILTER_ORDER  1);

143  
144 
/* Note that a minimum distance is not enforced between the last value and

145 
the previous one, contrary to what is done in ff_acelp_reorder_lsf() */

146 
ff_set_min_dist_lsf(lsfnew, LSFQ_DIFF_MIN, LP_FILTER_ORDER  1);

147 
lsfnew[9] = FFMIN(lsfnew[LP_FILTER_ORDER  1], 1.3 * M_PI); 
148  
149 
memcpy(lsf_history, lsf_tmp, LP_FILTER_ORDER * sizeof(*lsf_history));

150  
151 
for (i = 0; i < LP_FILTER_ORDER  1; i++) 
152 
lsfnew[i] = cos(lsfnew[i]); 
153 
lsfnew[LP_FILTER_ORDER  1] *= 6.153848 / M_PI; 
154 
} 
155  
156 
/** Apply pitch lag to the fixed vector (AMR section 6.1.2). */

157 
static void pitch_sharpening(int pitch_lag_int, float beta, 
158 
float *fixed_vector)

159 
{ 
160 
int i;

161  
162 
for (i = pitch_lag_int; i < SUBFR_SIZE; i++)

163 
fixed_vector[i] += beta * fixed_vector[i  pitch_lag_int]; 
164 
} 
165  
166 
/**

167 
* Extracts decoding parameters from the input bitstream.

168 
* @param parms parameters structure

169 
* @param pgb pointer to initialized GetBitContext structure

170 
*/

171 
static void decode_parameters(SiprParameters* parms, GetBitContext *pgb, 
172 
const SiprModeParam *p)

173 
{ 
174 
int i, j;

175  
176 
for (i = 0; i < 5; i++) 
177 
parms>vq_indexes[i] = get_bits(pgb, p>vq_indexes_bits[i]); 
178  
179 
for (i = 0; i < p>subframe_count; i++) { 
180 
parms>pitch_delay[i] = get_bits(pgb, p>pitch_delay_bits[i]); 
181 
parms>gp_index[i] = get_bits(pgb, p>gp_index_bits); 
182  
183 
for (j = 0; j < p>number_of_fc_indexes; j++) 
184 
parms>fc_indexes[i][j] = get_bits(pgb, p>fc_index_bits[j]); 
185  
186 
parms>gc_index[i] = get_bits(pgb, p>gc_index_bits); 
187 
} 
188 
} 
189  
190 
static void lsp2lpc_sipr(const double *lsp, float *Az) 
191 
{ 
192 
int lp_half_order = LP_FILTER_ORDER >> 1; 
193 
double buf[(LP_FILTER_ORDER >> 1) + 1]; 
194 
double pa[(LP_FILTER_ORDER >> 1) + 1]; 
195 
double *qa = buf + 1; 
196 
int i,j;

197  
198 
qa[1] = 0.0; 
199  
200 
ff_lsp2polyf(lsp , pa, lp_half_order ); 
201 
ff_lsp2polyf(lsp + 1, qa, lp_half_order  1); 
202  
203 
for (i = 1, j = LP_FILTER_ORDER  1; i < lp_half_order; i++, j) { 
204 
double paf = pa[i] * (1 + lsp[LP_FILTER_ORDER  1]); 
205 
double qaf = (qa[i]  qa[i2]) * (1  lsp[LP_FILTER_ORDER  1]); 
206 
Az[i1] = (paf + qaf) * 0.5; 
207 
Az[j1] = (paf  qaf) * 0.5; 
208 
} 
209  
210 
Az[lp_half_order  1] = (1.0 + lsp[LP_FILTER_ORDER  1]) * 
211 
pa[lp_half_order] * 0.5; 
212  
213 
Az[LP_FILTER_ORDER  1] = lsp[LP_FILTER_ORDER  1]; 
214 
} 
215  
216 
static void sipr_decode_lp(float *lsfnew, const float *lsfold, float *Az, 
217 
int num_subfr)

218 
{ 
219 
double lsfint[LP_FILTER_ORDER];

220 
int i,j;

221 
float t, t0 = 1.0 / num_subfr; 
222  
223 
t = t0 * 0.5; 
224 
for (i = 0; i < num_subfr; i++) { 
225 
for (j = 0; j < LP_FILTER_ORDER; j++) 
226 
lsfint[j] = lsfold[j] * (1  t) + t * lsfnew[j];

227  
228 
lsp2lpc_sipr(lsfint, Az); 
229 
Az += LP_FILTER_ORDER; 
230 
t += t0; 
231 
} 
232 
} 
233  
234 
/**

235 
* Evaluates the adaptative impulse response.

236 
*/

237 
static void eval_ir(const float *Az, int pitch_lag, float *freq, 
238 
float pitch_sharp_factor)

239 
{ 
240 
float tmp1[SUBFR_SIZE+1], tmp2[LP_FILTER_ORDER+1]; 
241 
int i;

242  
243 
tmp1[0] = 1.; 
244 
for (i = 0; i < LP_FILTER_ORDER; i++) { 
245 
tmp1[i+1] = Az[i] * ff_pow_0_55[i];

246 
tmp2[i ] = Az[i] * ff_pow_0_7 [i]; 
247 
} 
248 
memset(tmp1 + 11, 0, 37 * sizeof(float)); 
249  
250 
ff_celp_lp_synthesis_filterf(freq, tmp2, tmp1, SUBFR_SIZE, 
251 
LP_FILTER_ORDER); 
252  
253 
pitch_sharpening(pitch_lag, pitch_sharp_factor, freq); 
254 
} 
255  
256 
/**

257 
* Evaluates the convolution of a vector with a sparse vector.

258 
*/

259 
static void convolute_with_sparse(float *out, const AMRFixed *pulses, 
260 
const float *shape, int length) 
261 
{ 
262 
int i, j;

263  
264 
memset(out, 0, length*sizeof(float)); 
265 
for (i = 0; i < pulses>n; i++) 
266 
for (j = pulses>x[i]; j < length; j++)

267 
out[j] += pulses>y[i] * shape[j  pulses>x[i]]; 
268 
} 
269  
270 
/**

271 
* Apply postfilter, very similar to AMR one.

272 
*/

273 
static void postfilter_5k0(SiprContext *ctx, const float *lpc, float *samples) 
274 
{ 
275 
float buf[SUBFR_SIZE + LP_FILTER_ORDER];

276 
float *pole_out = buf + LP_FILTER_ORDER;

277 
float lpc_n[LP_FILTER_ORDER];

278 
float lpc_d[LP_FILTER_ORDER];

279 
int i;

280  
281 
for (i = 0; i < LP_FILTER_ORDER; i++) { 
282 
lpc_d[i] = lpc[i] * ff_pow_0_75[i]; 
283 
lpc_n[i] = lpc[i] * ff_pow_0_5 [i]; 
284 
}; 
285  
286 
memcpy(pole_out  LP_FILTER_ORDER, ctx>postfilter_mem, 
287 
LP_FILTER_ORDER*sizeof(float)); 
288  
289 
ff_celp_lp_synthesis_filterf(pole_out, lpc_d, samples, SUBFR_SIZE, 
290 
LP_FILTER_ORDER); 
291  
292 
memcpy(ctx>postfilter_mem, pole_out + SUBFR_SIZE  LP_FILTER_ORDER, 
293 
LP_FILTER_ORDER*sizeof(float)); 
294  
295 
ff_tilt_compensation(&ctx>tilt_mem, 0.4, pole_out, SUBFR_SIZE); 
296  
297 
memcpy(pole_out  LP_FILTER_ORDER, ctx>postfilter_mem5k0, 
298 
LP_FILTER_ORDER*sizeof(*pole_out));

299  
300 
memcpy(ctx>postfilter_mem5k0, pole_out + SUBFR_SIZE  LP_FILTER_ORDER, 
301 
LP_FILTER_ORDER*sizeof(*pole_out));

302  
303 
ff_celp_lp_zero_synthesis_filterf(samples, lpc_n, pole_out, SUBFR_SIZE, 
304 
LP_FILTER_ORDER); 
305  
306 
} 
307  
308 
static void decode_fixed_sparse(AMRFixed *fixed_sparse, const int16_t *pulses, 
309 
SiprMode mode, int low_gain)

310 
{ 
311 
int i;

312  
313 
switch (mode) {

314 
case MODE_6k5:

315 
for (i = 0; i < 3; i++) { 
316 
fixed_sparse>x[i] = 3 * (pulses[i] & 0xf) + i; 
317 
fixed_sparse>y[i] = pulses[i] & 0x10 ? 1 : 1; 
318 
} 
319 
fixed_sparse>n = 3;

320 
break;

321 
case MODE_8k5:

322 
for (i = 0; i < 3; i++) { 
323 
fixed_sparse>x[2*i ] = 3 * ((pulses[i] >> 4) & 0xf) + i; 
324 
fixed_sparse>x[2*i + 1] = 3 * ( pulses[i] & 0xf) + i; 
325  
326 
fixed_sparse>y[2*i ] = (pulses[i] & 0x100) ? 1.0: 1.0; 
327  
328 
fixed_sparse>y[2*i + 1] = 
329 
(fixed_sparse>x[2*i + 1] < fixed_sparse>x[2*i]) ? 
330 
fixed_sparse>y[2*i ] : fixed_sparse>y[2*i]; 
331 
} 
332  
333 
fixed_sparse>n = 6;

334 
break;

335 
case MODE_5k0:

336 
default:

337 
if (low_gain) {

338 
int offset = (pulses[0] & 0x200) ? 2 : 0; 
339 
int val = pulses[0]; 
340  
341 
for (i = 0; i < 3; i++) { 
342 
int index = (val & 0x7) * 6 + 4  i*2; 
343  
344 
fixed_sparse>y[i] = (offset + index) & 0x3 ? 1 : 1; 
345 
fixed_sparse>x[i] = index; 
346  
347 
val >>= 3;

348 
} 
349 
fixed_sparse>n = 3;

350 
} else {

351 
int pulse_subset = (pulses[0] >> 8) & 1; 
352  
353 
fixed_sparse>x[0] = ((pulses[0] >> 4) & 15) * 3 + pulse_subset; 
354 
fixed_sparse>x[1] = ( pulses[0] & 15) * 3 + pulse_subset + 1; 
355  
356 
fixed_sparse>y[0] = pulses[0] & 0x200 ? 1 : 1; 
357 
fixed_sparse>y[1] = fixed_sparse>y[0]; 
358 
fixed_sparse>n = 2;

359 
} 
360 
break;

361 
} 
362 
} 
363  
364 
static void decode_frame(SiprContext *ctx, SiprParameters *params, 
365 
float *out_data)

366 
{ 
367 
int i, j;

368 
int subframe_count = modes[ctx>mode].subframe_count;

369 
int frame_size = subframe_count * SUBFR_SIZE;

370 
float Az[LP_FILTER_ORDER * MAX_SUBFRAME_COUNT];

371 
float *excitation;

372 
float ir_buf[SUBFR_SIZE + LP_FILTER_ORDER];

373 
float lsf_new[LP_FILTER_ORDER];

374 
float *impulse_response = ir_buf + LP_FILTER_ORDER;

375 
float *synth = ctx>synth_buf + 16; // 16 instead of LP_FILTER_ORDER for 
376 
// memory alignment

377 
int t0_first = 0; 
378 
AMRFixed fixed_cb; 
379  
380 
memset(ir_buf, 0, LP_FILTER_ORDER * sizeof(float)); 
381 
lsf_decode_fp(lsf_new, ctx>lsf_history, params); 
382  
383 
sipr_decode_lp(lsf_new, ctx>lsp_history, Az, subframe_count); 
384  
385 
memcpy(ctx>lsp_history, lsf_new, LP_FILTER_ORDER * sizeof(float)); 
386  
387 
excitation = ctx>excitation + PITCH_DELAY_MAX + L_INTERPOL; 
388  
389 
for (i = 0; i < subframe_count; i++) { 
390 
float *pAz = Az + i*LP_FILTER_ORDER;

391 
float fixed_vector[SUBFR_SIZE];

392 
int T0,T0_frac;

393 
float pitch_gain, gain_code, avg_energy;

394  
395 
ff_decode_pitch_lag(&T0, &T0_frac, params>pitch_delay[i], t0_first, i, 
396 
ctx>mode == MODE_5k0, 6);

397  
398 
if (i == 0  (i == 2 && ctx>mode == MODE_5k0)) 
399 
t0_first = T0; 
400  
401 
ff_acelp_interpolatef(excitation, excitation  T0 + (T0_frac <= 0),

402 
ff_b60_sinc, 6,

403 
2 * ((2 + T0_frac)%3 + 1), LP_FILTER_ORDER, 
404 
SUBFR_SIZE); 
405  
406 
decode_fixed_sparse(&fixed_cb, params>fc_indexes[i], ctx>mode, 
407 
ctx>past_pitch_gain < 0.8); 
408  
409 
eval_ir(pAz, T0, impulse_response, modes[ctx>mode].pitch_sharp_factor); 
410  
411 
convolute_with_sparse(fixed_vector, &fixed_cb, impulse_response, 
412 
SUBFR_SIZE); 
413  
414 
avg_energy = 
415 
(0.01 + ff_dot_productf(fixed_vector, fixed_vector, SUBFR_SIZE))/ 
416 
SUBFR_SIZE; 
417  
418 
ctx>past_pitch_gain = pitch_gain = gain_cb[params>gc_index[i]][0];

419  
420 
gain_code = ff_amr_set_fixed_gain(gain_cb[params>gc_index[i]][1],

421 
avg_energy, ctx>energy_history, 
422 
34  15.0/(0.05*M_LN10/M_LN2), 
423 
pred); 
424  
425 
ff_weighted_vector_sumf(excitation, excitation, fixed_vector, 
426 
pitch_gain, gain_code, SUBFR_SIZE); 
427  
428 
pitch_gain *= 0.5 * pitch_gain; 
429 
pitch_gain = FFMIN(pitch_gain, 0.4); 
430  
431 
ctx>gain_mem = 0.7 * ctx>gain_mem + 0.3 * pitch_gain; 
432 
ctx>gain_mem = FFMIN(ctx>gain_mem, pitch_gain); 
433 
gain_code *= ctx>gain_mem; 
434  
435 
for (j = 0; j < SUBFR_SIZE; j++) 
436 
fixed_vector[j] = excitation[j]  gain_code * fixed_vector[j]; 
437  
438 
if (ctx>mode == MODE_5k0) {

439 
postfilter_5k0(ctx, pAz, fixed_vector); 
440  
441 
ff_celp_lp_synthesis_filterf(ctx>postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE, 
442 
pAz, excitation, SUBFR_SIZE, 
443 
LP_FILTER_ORDER); 
444 
} 
445  
446 
ff_celp_lp_synthesis_filterf(synth + i*SUBFR_SIZE, pAz, fixed_vector, 
447 
SUBFR_SIZE, LP_FILTER_ORDER); 
448  
449 
excitation += SUBFR_SIZE; 
450 
} 
451  
452 
memcpy(synth  LP_FILTER_ORDER, synth + frame_size  LP_FILTER_ORDER, 
453 
LP_FILTER_ORDER * sizeof(float)); 
454  
455 
if (ctx>mode == MODE_5k0) {

456 
for (i = 0; i < subframe_count; i++) { 
457 
float energy = ff_dot_productf(ctx>postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,

458 
ctx>postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE, 
459 
SUBFR_SIZE); 
460 
ff_adaptative_gain_control(&synth[i * SUBFR_SIZE], energy, 
461 
SUBFR_SIZE, 0.9, &ctx>postfilter_agc); 
462 
} 
463  
464 
memcpy(ctx>postfilter_syn5k0, ctx>postfilter_syn5k0 + frame_size, 
465 
LP_FILTER_ORDER*sizeof(float)); 
466 
} 
467 
memcpy(ctx>excitation, excitation  PITCH_DELAY_MAX  L_INTERPOL, 
468 
(PITCH_DELAY_MAX + L_INTERPOL) * sizeof(float)); 
469  
470 
ff_acelp_apply_order_2_transfer_function(synth, 
471 
(const float[2]) {1.99997 , 1.000000000}, 
472 
(const float[2]) {1.93307352, 0.935891986}, 
473 
0.939805806, 
474 
ctx>highpass_filt_mem, 
475 
frame_size); 
476  
477 
ctx>dsp.vector_clipf(out_data, synth, 1, 32767./(1<<15), frame_size); 
478  
479 
} 
480  
481 
static av_cold int sipr_decoder_init(AVCodecContext * avctx) 
482 
{ 
483 
SiprContext *ctx = avctx>priv_data; 
484 
int i;

485  
486 
if (avctx>bit_rate > 12200) ctx>mode = MODE_16k; 
487 
else if (avctx>bit_rate > 7500 ) ctx>mode = MODE_8k5; 
488 
else if (avctx>bit_rate > 5750 ) ctx>mode = MODE_6k5; 
489 
else ctx>mode = MODE_5k0;

490  
491 
av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", modes[ctx>mode].mode_name);

492  
493 
for (i = 0; i < LP_FILTER_ORDER; i++) 
494 
ctx>lsp_history[i] = cos((i+1) * M_PI / (LP_FILTER_ORDER + 1)); 
495  
496 
for (i = 0; i < 4; i++) 
497 
ctx>energy_history[i] = 14;

498  
499 
avctx>sample_fmt = SAMPLE_FMT_FLT; 
500  
501 
if (ctx>mode == MODE_16k) {

502 
av_log(avctx, AV_LOG_ERROR, "decoding 16kbps SIPR files is not "

503 
"supported yet.\n");

504 
return 1; 
505 
} 
506  
507 
dsputil_init(&ctx>dsp, avctx); 
508  
509 
return 0; 
510 
} 
511  
512 
static int sipr_decode_frame(AVCodecContext *avctx, void *datap, 
513 
int *data_size, AVPacket *avpkt)

514 
{ 
515 
SiprContext *ctx = avctx>priv_data; 
516 
const uint8_t *buf=avpkt>data;

517 
SiprParameters parm; 
518 
const SiprModeParam *mode_par = &modes[ctx>mode];

519 
GetBitContext gb; 
520 
float *data = datap;

521 
int i;

522  
523 
ctx>avctx = avctx; 
524 
if (avpkt>size < (mode_par>bits_per_frame >> 3)) { 
525 
av_log(avctx, AV_LOG_ERROR, 
526 
"Error processing packet: packet size (%d) too small\n",

527 
avpkt>size); 
528  
529 
*data_size = 0;

530 
return 1; 
531 
} 
532 
if (*data_size < SUBFR_SIZE * mode_par>subframe_count * sizeof(float)) { 
533 
av_log(avctx, AV_LOG_ERROR, 
534 
"Error processing packet: output buffer (%d) too small\n",

535 
*data_size); 
536  
537 
*data_size = 0;

538 
return 1; 
539 
} 
540  
541 
init_get_bits(&gb, buf, mode_par>bits_per_frame); 
542  
543 
for (i = 0; i < mode_par>frames_per_packet; i++) { 
544 
decode_parameters(&parm, &gb, mode_par); 
545 
decode_frame(ctx, &parm, data); 
546  
547 
data += SUBFR_SIZE * mode_par>subframe_count; 
548 
} 
549  
550 
*data_size = mode_par>frames_per_packet * SUBFR_SIZE * 
551 
mode_par>subframe_count * sizeof(float); 
552  
553 
return mode_par>bits_per_frame >> 3; 
554 
}; 
555  
556 
AVCodec sipr_decoder = { 
557 
"sipr",

558 
CODEC_TYPE_AUDIO, 
559 
CODEC_ID_SIPR, 
560 
sizeof(SiprContext),

561 
sipr_decoder_init, 
562 
NULL,

563 
NULL,

564 
sipr_decode_frame, 
565 
.long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"),

566 
}; 