15
15
* You should have received a copy of the GNU Lesser General Public
16
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
21
* @file mpegaudiodec.c
22
22
* MPEG Audio decoder.
26
26
#include "avcodec.h"
66
66
typedef struct MPADecodeContext {
67
uint8_t inbuf1[2][MPA_MAX_CODED_FRAME_SIZE + BACKSTEP_SIZE]; /* input buffer */
67
uint8_t inbuf1[2][MPA_MAX_CODED_FRAME_SIZE + BACKSTEP_SIZE]; /* input buffer */
69
69
uint8_t *inbuf_ptr, *inbuf;
71
71
int free_format_frame_size; /* frame size in case of free format
72
72
(zero if currently unknown) */
73
73
/* next header (used in free format parsing) */
74
uint32_t free_format_next_header;
74
uint32_t free_format_next_header;
75
75
int error_protection;
140
140
static void compute_antialias_float(MPADecodeContext *s, GranuleDef *g);
142
142
/* vlc structure for decoding layer 3 huffman tables */
143
static VLC huff_vlc[16];
143
static VLC huff_vlc[16];
144
144
static uint8_t *huff_code_table[16];
145
145
static VLC huff_quad_vlc[2];
146
146
/* computed from band_size_long */
174
174
void ff_mpa_synth_init(MPA_INT *window);
175
175
static MPA_INT window[512] __attribute__((aligned(16)));
177
177
/* layer 1 unscaling */
178
178
/* n = number of bits of the mantissa minus 1 */
179
179
static inline int l1_unscale(int n, int mant, int scale_factor)
334
334
scale_factor_mult[i][1] = MULL(FIXR(0.7937005259 * 2.0), norm);
335
335
scale_factor_mult[i][2] = MULL(FIXR(0.6299605249 * 2.0), norm);
336
336
dprintf("%d: norm=%x s=%x %x %x\n",
338
338
scale_factor_mult[i][0],
339
339
scale_factor_mult[i][1],
340
340
scale_factor_mult[i][2]);
343
ff_mpa_synth_init(window);
343
ff_mpa_synth_init(window);
345
345
/* huffman decode tables */
346
346
huff_code_table[0] = NULL;
347
347
for(i=1;i<16;i++) {
348
348
const HuffTable *h = &mpa_huff_tables[i];
351
351
uint8_t *code_table;
353
353
xsize = h->xsize;
354
354
n = xsize * xsize;
355
355
/* XXX: fail test */
356
init_vlc(&huff_vlc[i], 8, n,
356
init_vlc(&huff_vlc[i], 8, n,
357
357
h->bits, 1, 1, h->codes, 2, 2, 1);
359
359
code_table = av_mallocz(n);
361
361
for(x=0;x<xsize;x++) {
365
365
huff_code_table[i] = code_table;
367
367
for(i=0;i<2;i++) {
368
init_vlc(&huff_quad_vlc[i], i == 0 ? 7 : 4, 16,
368
init_vlc(&huff_quad_vlc[i], i == 0 ? 7 : 4, 16,
369
369
mpa_quad_bits[i], 1, 1, mpa_quad_codes[i], 1, 1, 1);
378
378
band_index_long[i][22] = k;
381
/* compute n ^ (4/3) and store it in mantissa/exp format */
382
table_4_3_exp= av_mallocz_static(TABLE_4_3_SIZE * sizeof(table_4_3_exp[0]));
381
/* compute n ^ (4/3) and store it in mantissa/exp format */
382
table_4_3_exp= av_mallocz_static(TABLE_4_3_SIZE * sizeof(table_4_3_exp[0]));
383
383
if(!table_4_3_exp)
385
table_4_3_value= av_mallocz_static(TABLE_4_3_SIZE * sizeof(table_4_3_value[0]));
385
table_4_3_value= av_mallocz_static(TABLE_4_3_SIZE * sizeof(table_4_3_value[0]));
386
386
if(!table_4_3_value)
390
390
for(i=1;i<TABLE_4_3_SIZE;i++) {
428
428
is_table_lsf[j][k ^ 1][i] = FIXR(f);
429
429
is_table_lsf[j][k][i] = FIXR(1.0);
430
dprintf("is_table_lsf %d %d: %x %x\n",
430
dprintf("is_table_lsf %d %d: %x %x\n",
431
431
i, j, is_table_lsf[j][0][i], is_table_lsf[j][1][i]);
440
440
csa_table[i][0] = FIXHR(cs/4);
441
441
csa_table[i][1] = FIXHR(ca/4);
442
442
csa_table[i][2] = FIXHR(ca/4) + FIXHR(cs/4);
443
csa_table[i][3] = FIXHR(ca/4) - FIXHR(cs/4);
443
csa_table[i][3] = FIXHR(ca/4) - FIXHR(cs/4);
444
444
csa_table_float[i][0] = cs;
445
445
csa_table_float[i][1] = ca;
446
446
csa_table_float[i][2] = ca + cs;
447
csa_table_float[i][3] = ca - cs;
447
csa_table_float[i][3] = ca - cs;
448
448
// printf("%d %d %d %d\n", FIX(cs), FIX(cs-1), FIX(ca), FIX(cs)-FIX(ca));
449
449
// av_log(NULL, AV_LOG_DEBUG,"%f %f %f %f\n", cs, ca, ca+cs, ca-cs);
839
839
window[512 - i] = v;
843
843
/* 32 sub band synthesis filter. Input: 32 sub band samples, Output:
845
845
/* XXX: optimize by avoiding ring buffer usage */
846
846
void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
847
MPA_INT *window, int *dither_state,
848
OUT_INT *samples, int incr,
847
MPA_INT *window, int *dither_state,
848
OUT_INT *samples, int incr,
849
849
int32_t sb_samples[SBLIMIT])
1015
1015
t0 = MUL64(2*(in1[2*2] + in1[2*4]), C2);
1016
1016
t1 = MUL64( in1[2*4] - in1[2*8] , -2*C8);
1017
1017
t2 = MUL64(2*(in1[2*2] + in1[2*8]), -C4);
1019
1019
tmp1[10] = (t3 - t0 - t2) >> 32;
1020
1020
tmp1[ 2] = (t3 + t0 + t1) >> 32;
1021
1021
tmp1[14] = (t3 + t2 - t1) >> 32;
1023
1023
tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3);
1024
1024
t2 = MUL64(2*(in1[2*1] + in1[2*5]), C1);
1025
1025
t3 = MUL64( in1[2*5] - in1[2*7] , -2*C7);
1041
1041
t0 = MULH(2*(in1[2*2] + in1[2*4]), C2);
1042
1042
t1 = MULH( in1[2*4] - in1[2*8] , -2*C8);
1043
1043
t2 = MULH(2*(in1[2*2] + in1[2*8]), -C4);
1045
1045
tmp1[10] = t3 - t0 - t2;
1046
1046
tmp1[ 2] = t3 + t0 + t1;
1047
1047
tmp1[14] = t3 + t2 - t1;
1049
1049
tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3);
1050
1050
t2 = MULH(2*(in1[2*1] + in1[2*5]), C1);
1051
1051
t3 = MULH( in1[2*5] - in1[2*7] , -2*C7);
1070
1070
t3 = tmp[i + 3];
1071
1071
s1 = MULL(t3 + t2, icos36[j]);
1072
1072
s3 = MULL(t3 - t2, icos36[8 - j]);
1076
1076
out[(9 + j)*SBLIMIT] = MULH(t1, win[9 + j]) + buf[9 + j];
1077
1077
out[(8 - j)*SBLIMIT] = MULH(t1, win[8 - j]) + buf[8 - j];
1078
1078
buf[9 + j] = MULH(t0, win[18 + 9 + j]);
1079
1079
buf[8 - j] = MULH(t0, win[18 + 8 - j]);
1083
1083
out[(9 + 8 - j)*SBLIMIT] = MULH(t1, win[9 + 8 - j]) + buf[9 + 8 - j];
1181
1181
#if defined(DEBUG)
1182
1182
printf("layer%d, %d Hz, %d kbits/s, ",
1183
1183
s->layer, s->sample_rate, s->bit_rate);
1241
1241
uint8_t allocation[MPA_MAX_CHANNELS][SBLIMIT];
1242
1242
uint8_t scale_factors[MPA_MAX_CHANNELS][SBLIMIT];
1244
if (s->mode == MPA_JSTEREO)
1244
if (s->mode == MPA_JSTEREO)
1245
1245
bound = (s->mode_ext + 1) * 4;
1247
1247
bound = SBLIMIT;
1305
1305
int l2_select_table(int bitrate, int nb_channels, int freq, int lsf)
1307
1307
int ch_bitrate, table;
1309
1309
ch_bitrate = bitrate / nb_channels;
1311
1311
if ((freq == 48000 && ch_bitrate >= 56) ||
1312
(ch_bitrate >= 56 && ch_bitrate <= 80))
1312
(ch_bitrate >= 56 && ch_bitrate <= 80))
1314
else if (freq != 48000 && ch_bitrate >= 96)
1314
else if (freq != 48000 && ch_bitrate >= 96)
1316
else if (freq != 32000 && ch_bitrate <= 48)
1316
else if (freq != 32000 && ch_bitrate <= 48)
1334
1334
int scale, qindex, bits, steps, k, l, m, b;
1336
1336
/* select decoding table */
1337
table = l2_select_table(s->bit_rate / 1000, s->nb_channels,
1337
table = l2_select_table(s->bit_rate / 1000, s->nb_channels,
1338
1338
s->sample_rate, s->lsf);
1339
1339
sblimit = sblimit_table[table];
1340
1340
alloc_table = alloc_tables[table];
1342
if (s->mode == MPA_JSTEREO)
1342
if (s->mode == MPA_JSTEREO)
1343
1343
bound = (s->mode_ext + 1) * 4;
1345
1345
bound = sblimit;
1446
1446
/* 3 values at the same time */
1447
1447
v = get_bits(&s->gb, -bits);
1448
1448
steps = quant_steps[qindex];
1449
s->sb_samples[ch][k * 12 + l + 0][i] =
1450
l2_unscale_group(steps, v % steps, scale);
1452
s->sb_samples[ch][k * 12 + l + 1][i] =
1453
l2_unscale_group(steps, v % steps, scale);
1455
s->sb_samples[ch][k * 12 + l + 2][i] =
1449
s->sb_samples[ch][k * 12 + l + 0][i] =
1450
l2_unscale_group(steps, v % steps, scale);
1452
s->sb_samples[ch][k * 12 + l + 1][i] =
1453
l2_unscale_group(steps, v % steps, scale);
1455
s->sb_samples[ch][k * 12 + l + 2][i] =
1456
1456
l2_unscale_group(steps, v, scale);
1458
1458
for(m=0;m<3;m++) {
1470
1470
/* next subband in alloc table */
1471
j += 1 << bit_alloc_bits;
1471
j += 1 << bit_alloc_bits;
1473
1473
/* XXX: find a way to avoid this duplication of code */
1474
1474
for(i=bound;i<sblimit;i++) {
1486
1486
steps = quant_steps[qindex];
1487
1487
mant = v % steps;
1489
s->sb_samples[0][k * 12 + l + 0][i] =
1489
s->sb_samples[0][k * 12 + l + 0][i] =
1490
1490
l2_unscale_group(steps, mant, scale0);
1491
s->sb_samples[1][k * 12 + l + 0][i] =
1491
s->sb_samples[1][k * 12 + l + 0][i] =
1492
1492
l2_unscale_group(steps, mant, scale1);
1493
1493
mant = v % steps;
1495
s->sb_samples[0][k * 12 + l + 1][i] =
1495
s->sb_samples[0][k * 12 + l + 1][i] =
1496
1496
l2_unscale_group(steps, mant, scale0);
1497
s->sb_samples[1][k * 12 + l + 1][i] =
1497
s->sb_samples[1][k * 12 + l + 1][i] =
1498
1498
l2_unscale_group(steps, mant, scale1);
1499
s->sb_samples[0][k * 12 + l + 2][i] =
1499
s->sb_samples[0][k * 12 + l + 2][i] =
1500
1500
l2_unscale_group(steps, v, scale0);
1501
s->sb_samples[1][k * 12 + l + 2][i] =
1501
s->sb_samples[1][k * 12 + l + 2][i] =
1502
1502
l2_unscale_group(steps, v, scale1);
1504
1504
for(m=0;m<3;m++) {
1505
1505
mant = get_bits(&s->gb, bits);
1506
s->sb_samples[0][k * 12 + l + m][i] =
1506
s->sb_samples[0][k * 12 + l + m][i] =
1507
1507
l1_unscale(bits - 1, mant, scale0);
1508
s->sb_samples[1][k * 12 + l + m][i] =
1508
s->sb_samples[1][k * 12 + l + m][i] =
1509
1509
l1_unscale(bits - 1, mant, scale1);
1518
1518
s->sb_samples[1][k * 12 + l + 2][i] = 0;
1520
1520
/* next subband in alloc table */
1521
j += 1 << bit_alloc_bits;
1521
j += 1 << bit_alloc_bits;
1523
1523
/* fill remaining samples to zero */
1524
1524
for(i=sblimit;i<SBLIMIT;i++) {
1546
1546
/* copy old data before current one */
1547
1547
ptr -= backstep;
1548
memcpy(ptr, s->inbuf1[s->inbuf_index ^ 1] +
1548
memcpy(ptr, s->inbuf1[s->inbuf_index ^ 1] +
1549
1549
BACKSTEP_SIZE + s->old_frame_size - backstep, backstep);
1550
1550
/* init get bits again */
1551
1551
init_get_bits(&s->gb, ptr, (s->frame_size + backstep)*8);
1650
1650
if (get_bits_count(&s->gb) >= end_pos)
1652
1652
if (code_table) {
1653
code = get_vlc(&s->gb, vlc);
1653
code = get_vlc2(&s->gb, vlc->table, 8, 2);
1656
1656
y = code_table[code];
1663
dprintf("region=%d n=%d x=%d y=%d exp=%d\n",
1663
dprintf("region=%d n=%d x=%d y=%d exp=%d\n",
1664
1664
i, g->region_size[i] - j, x, y, exponents[s_index]);
1702
1702
last_gb= s->gb;
1704
code = get_vlc(&s->gb, vlc);
1704
code = get_vlc2(&s->gb, vlc->table, vlc->bits, 2);
1705
1705
dprintf("t=%d code=%d\n", g->count1table_select, code);
1834
non_zero_found = non_zero_found_short[0] |
1835
non_zero_found_short[1] |
1834
non_zero_found = non_zero_found_short[0] |
1835
non_zero_found_short[1] |
1836
1836
non_zero_found_short[2];
1838
1838
for(i = g1->long_end - 1;i >= 0;i--) {
2068
2068
f = files[fnum];
2070
snprintf(buf, sizeof(buf), "/tmp/out%d.%s.pcm",
2070
snprintf(buf, sizeof(buf), "/tmp/out%d.%s.pcm",
2072
2072
#ifdef USE_HIGHPRECISION
2128
2128
granules[ch][1].scfsi = get_bits(&s->gb, 4);
2132
2132
for(gr=0;gr<nb_granules;gr++) {
2133
2133
for(ch=0;ch<s->nb_channels;ch++) {
2134
2134
dprintf("gr=%d ch=%d: side_info\n", gr, ch);
2138
2138
g->global_gain = get_bits(&s->gb, 8);
2139
2139
/* if MS stereo only is selected, we precompute the
2140
2140
1/sqrt(2) renormalization factor */
2141
if ((s->mode_ext & (MODE_EXT_MS_STEREO | MODE_EXT_I_STEREO)) ==
2141
if ((s->mode_ext & (MODE_EXT_MS_STEREO | MODE_EXT_I_STEREO)) ==
2142
2142
MODE_EXT_MS_STEREO)
2143
2143
g->global_gain -= 2;
2153
2153
g->switch_point = get_bits(&s->gb, 1);
2154
2154
for(i=0;i<2;i++)
2155
2155
g->table_select[i] = get_bits(&s->gb, 5);
2157
2157
g->subblock_gain[i] = get_bits(&s->gb, 3);
2158
2158
/* compute huffman coded region sizes */
2159
2159
if (g->block_type == 2)
2160
2160
g->region_size[0] = (36 / 2);
2162
if (s->sample_rate_index <= 2)
2162
if (s->sample_rate_index <= 2)
2163
2163
g->region_size[0] = (36 / 2);
2164
else if (s->sample_rate_index != 8)
2164
else if (s->sample_rate_index != 8)
2165
2165
g->region_size[0] = (54 / 2);
2167
2167
g->region_size[0] = (108 / 2);
2176
2176
/* compute huffman coded region sizes */
2177
2177
region_address1 = get_bits(&s->gb, 4);
2178
2178
region_address2 = get_bits(&s->gb, 3);
2179
dprintf("region1=%d region2=%d\n",
2179
dprintf("region1=%d region2=%d\n",
2180
2180
region_address1, region_address2);
2182
2182
band_index_long[s->sample_rate_index][region_address1 + 1] >> 1;
2183
2183
l = region_address1 + region_address2 + 2;
2184
2184
/* should not overflow */
2188
2188
band_index_long[s->sample_rate_index][l] >> 1;
2190
2190
/* convert region offsets to region sizes and truncate
2286
2286
#if defined(DEBUG)
2288
printf("scfsi=%x gr=%d ch=%d scale_factors:\n",
2288
printf("scfsi=%x gr=%d ch=%d scale_factors:\n",
2289
2289
g->scfsi, gr, ch);
2290
2290
for(i=0;i<j;i++)
2291
2291
printf(" %d", g->scale_factors[i]);
2342
2342
g->scale_factors[j] = 0;
2343
2343
#if defined(DEBUG)
2345
printf("gr=%d ch=%d scale_factors:\n",
2345
printf("gr=%d ch=%d scale_factors:\n",
2347
2347
for(i=0;i<40;i++)
2348
2348
printf(" %d", g->scale_factors[i]);
2389
2389
#if defined(DEBUG)
2390
2390
sample_dump(1, g->sb_hybrid, 576);
2392
compute_imdct(s, g, &s->sb_samples[ch][18 * gr][0], s->mdct_buf[ch]);
2392
compute_imdct(s, g, &s->sb_samples[ch][18 * gr][0], s->mdct_buf[ch]);
2393
2393
#if defined(DEBUG)
2394
2394
sample_dump(2, &s->sb_samples[ch][18 * gr][0], 576);
2398
2398
return nb_granules * 18;
2401
static int mp_decode_frame(MPADecodeContext *s,
2401
static int mp_decode_frame(MPADecodeContext *s,
2402
2402
OUT_INT *samples)
2404
2404
int i, nb_frames, ch;
2405
2405
OUT_INT *samples_ptr;
2407
init_get_bits(&s->gb, s->inbuf + HEADER_SIZE,
2407
init_get_bits(&s->gb, s->inbuf + HEADER_SIZE,
2408
2408
(s->inbuf_ptr - s->inbuf - HEADER_SIZE)*8);
2410
2410
/* skip error protection field */
2411
2411
if (s->error_protection)
2412
2412
get_bits(&s->gb, 16);
2440
2440
samples_ptr = samples + ch;
2441
2441
for(i=0;i<nb_frames;i++) {
2442
2442
ff_mpa_synth_filter(s->synth_buf[ch], &(s->synth_buf_offset[ch]),
2443
window, &s->dither_state,
2444
samples_ptr, s->nb_channels,
2443
window, &s->dither_state,
2444
samples_ptr, s->nb_channels,
2445
2445
s->sb_samples[ch][i]);
2446
2446
samples_ptr += 32 * s->nb_channels;
2452
2452
return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels;
2455
2455
static int decode_frame(AVCodecContext * avctx,
2456
void *data, int *data_size,
2457
uint8_t * buf, int buf_size)
2456
void *data, int *data_size,
2457
uint8_t * buf, int buf_size)
2459
2459
MPADecodeContext *s = avctx->priv_data;
2460
2460
uint32_t header;
2466
2466
while (buf_size > 0) {
2467
len = s->inbuf_ptr - s->inbuf;
2468
if (s->frame_size == 0) {
2467
len = s->inbuf_ptr - s->inbuf;
2468
if (s->frame_size == 0) {
2469
2469
/* special case for next header for first frame in free
2470
2470
format case (XXX: find a simpler method) */
2471
2471
if (s->free_format_next_header != 0) {
2477
2477
s->free_format_next_header = 0;
2478
2478
goto got_header;
2480
/* no header seen : find one. We need at least HEADER_SIZE
2480
/* no header seen : find one. We need at least HEADER_SIZE
2481
2481
bytes to parse it */
2482
len = HEADER_SIZE - len;
2486
memcpy(s->inbuf_ptr, buf_ptr, len);
2489
s->inbuf_ptr += len;
2491
if ((s->inbuf_ptr - s->inbuf) >= HEADER_SIZE) {
2482
len = HEADER_SIZE - len;
2486
memcpy(s->inbuf_ptr, buf_ptr, len);
2489
s->inbuf_ptr += len;
2491
if ((s->inbuf_ptr - s->inbuf) >= HEADER_SIZE) {
2493
header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
2494
(s->inbuf[2] << 8) | s->inbuf[3];
2493
header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) |
2494
(s->inbuf[2] << 8) | s->inbuf[3];
2496
if (ff_mpa_check_header(header) < 0) {
2497
/* no sync found : move by one byte (inefficient, but simple!) */
2498
memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
2496
if (ff_mpa_check_header(header) < 0) {
2497
/* no sync found : move by one byte (inefficient, but simple!) */
2498
memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
2500
2500
dprintf("skip %x\n", header);
2501
2501
/* reset free format frame size to give a chance
2502
2502
to get a new bitrate */
2503
2503
s->free_format_frame_size = 0;
2505
if (decode_header(s, header) == 1) {
2505
if (decode_header(s, header) == 1) {
2506
2506
/* free format: prepare to compute frame size */
2509
2509
/* update codec info */
2510
2510
avctx->sample_rate = s->sample_rate;
2525
2525
avctx->frame_size = 1152;
2530
2530
} else if (s->frame_size == -1) {
2531
2531
/* free format : find next sync to compute frame size */
2532
len = MPA_MAX_CODED_FRAME_SIZE - len;
2532
len = MPA_MAX_CODED_FRAME_SIZE - len;
2535
2535
if (len == 0) {
2536
/* frame too long: resync */
2536
/* frame too long: resync */
2537
2537
s->frame_size = 0;
2538
memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
2538
memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
2541
2541
uint8_t *p, *pend;
2542
2542
uint32_t header1;
2568
2568
s->free_format_frame_size -= padding * 4;
2570
2570
s->free_format_frame_size -= padding;
2571
dprintf("free frame size=%d padding=%d\n",
2571
dprintf("free frame size=%d padding=%d\n",
2572
2572
s->free_format_frame_size, padding);
2573
2573
decode_header(s, header1);
2574
2574
goto next_data;
2580
2580
s->inbuf_ptr += len;
2581
2581
buf_size -= len;
2583
} else if (len < s->frame_size) {
2583
} else if (len < s->frame_size) {
2584
2584
if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)
2585
2585
s->frame_size = MPA_MAX_CODED_FRAME_SIZE;
2586
len = s->frame_size - len;
2589
memcpy(s->inbuf_ptr, buf_ptr, len);
2591
s->inbuf_ptr += len;
2586
len = s->frame_size - len;
2589
memcpy(s->inbuf_ptr, buf_ptr, len);
2591
s->inbuf_ptr += len;
2595
if (s->frame_size > 0 &&
2595
if (s->frame_size > 0 &&
2596
2596
(s->inbuf_ptr - s->inbuf) >= s->frame_size) {
2597
2597
if (avctx->parse_only) {
2598
2598
/* simply return the frame data */
2602
2602
out_size = mp_decode_frame(s, out_samples);
2604
s->inbuf_ptr = s->inbuf;
2604
s->inbuf_ptr = s->inbuf;
2606
2606
if(out_size>=0)
2607
*data_size = out_size;
2607
*data_size = out_size;
2609
2609
av_log(avctx, AV_LOG_DEBUG, "Error while decoding mpeg audio frame\n"); //FIXME return -1 / but also return the number of bytes consumed
2613
2613
return buf_ptr - buf;
2617
2617
static int decode_frame_adu(AVCodecContext * avctx,
2618
void *data, int *data_size,
2619
uint8_t * buf, int buf_size)
2618
void *data, int *data_size,
2619
uint8_t * buf, int buf_size)
2621
2621
MPADecodeContext *s = avctx->priv_data;
2622
2622
uint32_t header;
2749
2749
static int decode_frame_mp3on4(AVCodecContext * avctx,
2750
void *data, int *data_size,
2751
uint8_t * buf, int buf_size)
2750
void *data, int *data_size,
2751
uint8_t * buf, int buf_size)
2753
2753
MP3On4DecodeContext *s = avctx->priv_data;
2754
2754
MPADecodeContext *m;