X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=libavcodec%2Fmpegaudiodec.c;h=024d618502af49fab1da7274220db3fdedfa90bc;hb=9181976348cac563977a0450c90f27ad72018f1d;hp=0ae21e03fb3ca56994e559173fb0779ede6c384d;hpb=06d01188e94321113684a271f62f6b0f2b818e53;p=ffmpeg diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index 0ae21e03fb3..024d618502a 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -2,20 +2,20 @@ * MPEG Audio decoder * Copyright (c) 2001, 2002 Fabrice Bellard * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * FFmpeg is distributed in the hope that it will be useful, + * Libav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -24,6 +24,7 @@ * MPEG Audio decoder. */ +#include "libavutil/audioconvert.h" #include "avcodec.h" #include "get_bits.h" #include "dsputil.h" @@ -73,8 +74,7 @@ # include "dct32.c" #endif -static void compute_antialias_integer(MPADecodeContext *s, GranuleDef *g); -static void compute_antialias_float(MPADecodeContext *s, GranuleDef *g); +static void compute_antialias(MPADecodeContext *s, GranuleDef *g); static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window, int *dither_state, OUT_INT *samples, int incr); @@ -322,9 +322,14 @@ static av_cold int decode_init(AVCodecContext * avctx) s->avctx = avctx; s->apply_window_mp3 = apply_window_mp3_c; -#if HAVE_MMX +#if HAVE_MMX && CONFIG_FLOAT ff_mpegaudiodec_init_mmx(s); #endif +#if CONFIG_FLOAT + ff_dct_init(&s->dct, 5, DCT_II); +#endif + if (HAVE_ALTIVEC && CONFIG_FLOAT) ff_mpegaudiodec_init_altivec(s); + avctx->sample_fmt= OUT_FMT; s->error_recognition= avctx->error_recognition; @@ -348,16 +353,13 @@ static av_cold int decode_init(AVCodecContext * avctx) scale_factor_mult[i][0] = MULLx(norm, FIXR(1.0 * 2.0), FRAC_BITS); scale_factor_mult[i][1] = MULLx(norm, FIXR(0.7937005259 * 2.0), FRAC_BITS); scale_factor_mult[i][2] = MULLx(norm, FIXR(0.6299605249 * 2.0), FRAC_BITS); - dprintf(avctx, "%d: norm=%x s=%x %x %x\n", + av_dlog(avctx, "%d: norm=%x s=%x %x %x\n", i, norm, scale_factor_mult[i][0], scale_factor_mult[i][1], scale_factor_mult[i][2]); } -#if CONFIG_FLOAT - ff_dct_init(&s->dct, 5, DCT_II); -#endif RENAME(ff_mpa_synth_init)(RENAME(ff_mpa_synth_window)); /* huffman decode tables */ @@ -456,7 +458,7 @@ static av_cold int decode_init(AVCodecContext * avctx) k = i & 1; is_table_lsf[j][k ^ 1][i] = FIXR(f); is_table_lsf[j][k][i] = FIXR(1.0); - dprintf(avctx, "is_table_lsf %d %d: %x %x\n", + av_dlog(avctx, "is_table_lsf %d %d: %x %x\n", i, j, is_table_lsf[j][0][i], is_table_lsf[j][1][i]); } } @@ -985,7 +987,7 @@ static int mp_decode_layer2(MPADecodeContext *s) else bound = sblimit; - dprintf(s->avctx, "bound=%d sblimit=%d\n", bound, sblimit); + av_dlog(s->avctx, "bound=%d sblimit=%d\n", bound, sblimit); /* sanity check */ if( bound > sblimit ) bound = sblimit; @@ -1308,7 +1310,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g, exponent= exponents[s_index]; - dprintf(s->avctx, "region=%d n=%d x=%d y=%d exp=%d\n", + av_dlog(s->avctx, "region=%d n=%d x=%d y=%d exp=%d\n", i, g->region_size[i] - j, x, y, exponent); if(y&16){ x = y >> 5; @@ -1376,7 +1378,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g, last_pos= pos; code = get_vlc2(&s->gb, vlc->table, vlc->bits, 1); - dprintf(s->avctx, "t=%d code=%d\n", g->count1table_select, code); + av_dlog(s->avctx, "t=%d code=%d\n", g->count1table_select, code); g->sb_hybrid[s_index+0]= g->sb_hybrid[s_index+1]= g->sb_hybrid[s_index+2]= @@ -1573,6 +1575,7 @@ static void compute_stereo(MPADecodeContext *s, } } +#if !CONFIG_FLOAT static void compute_antialias_integer(MPADecodeContext *s, GranuleDef *g) { @@ -1612,45 +1615,7 @@ static void compute_antialias_integer(MPADecodeContext *s, ptr += 18; } } - -static void compute_antialias_float(MPADecodeContext *s, - GranuleDef *g) -{ - float *ptr; - int n, i; - - /* we antialias only "long" bands */ - if (g->block_type == 2) { - if (!g->switch_point) - return; - /* XXX: check this for 8000Hz case */ - n = 1; - } else { - n = SBLIMIT - 1; - } - - ptr = g->sb_hybrid + 18; - for(i = n;i > 0;i--) { - float tmp0, tmp1; - float *csa = &csa_table_float[0][0]; -#define FLOAT_AA(j)\ - tmp0= ptr[-1-j];\ - tmp1= ptr[ j];\ - ptr[-1-j] = tmp0 * csa[0+4*j] - tmp1 * csa[1+4*j];\ - ptr[ j] = tmp0 * csa[1+4*j] + tmp1 * csa[0+4*j]; - - FLOAT_AA(0) - FLOAT_AA(1) - FLOAT_AA(2) - FLOAT_AA(3) - FLOAT_AA(4) - FLOAT_AA(5) - FLOAT_AA(6) - FLOAT_AA(7) - - ptr += 18; - } -} +#endif static void compute_imdct(MPADecodeContext *s, GranuleDef *g, @@ -1771,7 +1736,7 @@ static int mp_decode_layer3(MPADecodeContext *s) for(gr=0;grnb_channels;ch++) { - dprintf(s->avctx, "gr=%d ch=%d: side_info\n", gr, ch); + av_dlog(s->avctx, "gr=%d ch=%d: side_info\n", gr, ch); g = &s->granules[ch][gr]; g->part2_3_length = get_bits(&s->gb, 12); g->big_values = get_bits(&s->gb, 9); @@ -1812,7 +1777,7 @@ static int mp_decode_layer3(MPADecodeContext *s) /* compute huffman coded region sizes */ region_address1 = get_bits(&s->gb, 4); region_address2 = get_bits(&s->gb, 3); - dprintf(s->avctx, "region1=%d region2=%d\n", + av_dlog(s->avctx, "region1=%d region2=%d\n", region_address1, region_address2); ff_init_long_region(s, g, region_address1, region_address2); } @@ -1824,7 +1789,7 @@ static int mp_decode_layer3(MPADecodeContext *s) g->preflag = get_bits1(&s->gb); g->scalefac_scale = get_bits1(&s->gb); g->count1table_select = get_bits1(&s->gb); - dprintf(s->avctx, "block_type=%d switch_point=%d\n", + av_dlog(s->avctx, "block_type=%d switch_point=%d\n", g->block_type, g->switch_point); } } @@ -1833,7 +1798,7 @@ static int mp_decode_layer3(MPADecodeContext *s) const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3); assert((get_bits_count(&s->gb) & 7) == 0); /* now we get bits from the main_data_begin offset */ - dprintf(s->avctx, "seekback: %d\n", main_data_begin); + av_dlog(s->avctx, "seekback: %d\n", main_data_begin); //av_log(NULL, AV_LOG_ERROR, "backstep:%d, lastbuf:%d\n", main_data_begin, s->last_buf_size); memcpy(s->last_buf + s->last_buf_size, ptr, EXTRABYTES); @@ -1867,7 +1832,7 @@ static int mp_decode_layer3(MPADecodeContext *s) /* MPEG1 scale factors */ slen1 = slen_table[0][g->scalefac_compress]; slen2 = slen_table[1][g->scalefac_compress]; - dprintf(s->avctx, "slen1=%d slen2=%d\n", slen1, slen2); + av_dlog(s->avctx, "slen1=%d slen2=%d\n", slen1, slen2); if (g->block_type == 2) { n = g->switch_point ? 17 : 18; j = 0; @@ -2000,7 +1965,7 @@ static int mp_decode_frame(MPADecodeContext *s, if (s->error_protection) skip_bits(&s->gb, 16); - dprintf(s->avctx, "frame %d:\n", s->frame_count); + av_dlog(s->avctx, "frame %d:\n", s->frame_count); switch(s->layer) { case 1: s->avctx->frame_size = 384; @@ -2090,7 +2055,9 @@ static int decode_frame(AVCodecContext * avctx, } /* update codec info */ avctx->channels = s->nb_channels; - avctx->bit_rate = s->bit_rate; + avctx->channel_layout = s->nb_channels == 1 ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO; + if (!avctx->bit_rate) + avctx->bit_rate = s->bit_rate; avctx->sub_id = s->layer; if(*data_size < 1152*avctx->channels*sizeof(OUT_INT)) @@ -2122,7 +2089,7 @@ static void flush(AVCodecContext *avctx){ s->last_buf_size= 0; } -#if CONFIG_MP3ADU_DECODER +#if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER static int decode_frame_adu(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt) @@ -2158,7 +2125,8 @@ static int decode_frame_adu(AVCodecContext * avctx, /* update codec info */ avctx->sample_rate = s->sample_rate; avctx->channels = s->nb_channels; - avctx->bit_rate = s->bit_rate; + if (!avctx->bit_rate) + avctx->bit_rate = s->bit_rate; avctx->sub_id = s->layer; s->frame_size = len; @@ -2172,9 +2140,9 @@ static int decode_frame_adu(AVCodecContext * avctx, *data_size = out_size; return buf_size; } -#endif /* CONFIG_MP3ADU_DECODER */ +#endif /* CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER */ -#if CONFIG_MP3ON4_DECODER +#if CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER /** * Context for MP3On4 decoder @@ -2261,8 +2229,7 @@ static av_cold int decode_close_mp3on4(AVCodecContext * avctx) int i; for (i = 0; i < s->frames; i++) - if (s->mp3decctx[i]) - av_free(s->mp3decctx[i]); + av_free(s->mp3decctx[i]); return 0; } @@ -2338,11 +2305,11 @@ static int decode_frame_mp3on4(AVCodecContext * avctx, *data_size = out_size; return buf_size; } -#endif /* CONFIG_MP3ON4_DECODER */ +#endif /* CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER */ #if !CONFIG_FLOAT #if CONFIG_MP1_DECODER -AVCodec mp1_decoder = +AVCodec ff_mp1_decoder = { "mp1", AVMEDIA_TYPE_AUDIO, @@ -2358,7 +2325,7 @@ AVCodec mp1_decoder = }; #endif #if CONFIG_MP2_DECODER -AVCodec mp2_decoder = +AVCodec ff_mp2_decoder = { "mp2", AVMEDIA_TYPE_AUDIO, @@ -2374,7 +2341,7 @@ AVCodec mp2_decoder = }; #endif #if CONFIG_MP3_DECODER -AVCodec mp3_decoder = +AVCodec ff_mp3_decoder = { "mp3", AVMEDIA_TYPE_AUDIO, @@ -2390,7 +2357,7 @@ AVCodec mp3_decoder = }; #endif #if CONFIG_MP3ADU_DECODER -AVCodec mp3adu_decoder = +AVCodec ff_mp3adu_decoder = { "mp3adu", AVMEDIA_TYPE_AUDIO, @@ -2406,7 +2373,7 @@ AVCodec mp3adu_decoder = }; #endif #if CONFIG_MP3ON4_DECODER -AVCodec mp3on4_decoder = +AVCodec ff_mp3on4_decoder = { "mp3on4", AVMEDIA_TYPE_AUDIO,