Mercurial > libavcodec.hg
comparison mpegaudiodec.c @ 6702:a9a28c8b40fb libavcodec
simplify: merge loops
author | bcoudurier |
---|---|
date | Sat, 26 Apr 2008 14:33:09 +0000 |
parents | ef18192d8474 |
children | 656a92752424 |
comparison
equal
deleted
inserted
replaced
6701:ef18192d8474 | 6702:a9a28c8b40fb |
---|---|
2570 uint32_t header; | 2570 uint32_t header; |
2571 OUT_INT *out_samples = data; | 2571 OUT_INT *out_samples = data; |
2572 OUT_INT decoded_buf[MPA_FRAME_SIZE * MPA_MAX_CHANNELS]; | 2572 OUT_INT decoded_buf[MPA_FRAME_SIZE * MPA_MAX_CHANNELS]; |
2573 OUT_INT *outptr, *bp; | 2573 OUT_INT *outptr, *bp; |
2574 int fsize; | 2574 int fsize; |
2575 int fr, i, j, n; | 2575 int fr, j, n; |
2576 | 2576 |
2577 len = buf_size; | 2577 len = buf_size; |
2578 | 2578 |
2579 *data_size = 0; | 2579 *data_size = 0; |
2580 // Discard too short frames | 2580 // Discard too short frames |
2581 if (buf_size < HEADER_SIZE) | 2581 if (buf_size < HEADER_SIZE) |
2582 return -1; | 2582 return -1; |
2583 | 2583 |
2584 // If only one decoder interleave is not needed | 2584 // If only one decoder interleave is not needed |
2585 outptr = s->frames == 1 ? out_samples : decoded_buf; | 2585 outptr = s->frames == 1 ? out_samples : decoded_buf; |
2586 | |
2587 avctx->bit_rate = 0; | |
2586 | 2588 |
2587 for (fr = 0; fr < s->frames; fr++) { | 2589 for (fr = 0; fr < s->frames; fr++) { |
2588 fsize = AV_RB16(buf) >> 4; | 2590 fsize = AV_RB16(buf) >> 4; |
2589 fsize = FFMIN3(fsize, len, MPA_MAX_CODED_FRAME_SIZE); | 2591 fsize = FFMIN3(fsize, len, MPA_MAX_CODED_FRAME_SIZE); |
2590 m = s->mp3decctx[fr]; | 2592 m = s->mp3decctx[fr]; |
2617 bp[1] = decoded_buf[j]; | 2619 bp[1] = decoded_buf[j]; |
2618 bp += avctx->channels; | 2620 bp += avctx->channels; |
2619 } | 2621 } |
2620 } | 2622 } |
2621 } | 2623 } |
2624 avctx->bit_rate += m->bit_rate; | |
2622 } | 2625 } |
2623 | 2626 |
2624 /* update codec info */ | 2627 /* update codec info */ |
2625 avctx->sample_rate = s->mp3decctx[0]->sample_rate; | 2628 avctx->sample_rate = s->mp3decctx[0]->sample_rate; |
2626 avctx->bit_rate = 0; | |
2627 for (i = 0; i < s->frames; i++) | |
2628 avctx->bit_rate += s->mp3decctx[i]->bit_rate; | |
2629 | 2629 |
2630 *data_size = out_size; | 2630 *data_size = out_size; |
2631 return buf_size; | 2631 return buf_size; |
2632 } | 2632 } |
2633 #endif /* CONFIG_MP3ON4_DECODER */ | 2633 #endif /* CONFIG_MP3ON4_DECODER */ |