X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fac3tab.c;h=951a1014ce10a3c7b03c434f68a054b0527f4515;hb=eb239a577fcf1f19cdaa7aeb6e6586a172ee59c1;hp=66afcd443752bca1ae236e792e89f976aa7ccaa0;hpb=0c79b1402a48a99f32435a0f5ad2364c58c6fcf3;p=ffmpeg diff --git a/libavcodec/ac3tab.c b/libavcodec/ac3tab.c index 66afcd44375..951a1014ce1 100644 --- a/libavcodec/ac3tab.c +++ b/libavcodec/ac3tab.c @@ -1,29 +1,31 @@ /* - * AC3 tables + * AC-3 tables * copyright (c) 2001 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 */ /** - * @file ac3tab.c - * tables taken directly from AC3 spec. + * @file + * tables taken directly from the AC-3 spec. */ +#include "libavutil/audioconvert.h" +#include "avcodec.h" #include "ac3tab.h" /** @@ -72,13 +74,55 @@ const uint16_t ff_ac3_frame_size_tab[38][3] = { }; /** - * Maps audio coding mode (acmod) to number of full-bandwidth channels. + * Map audio coding mode (acmod) to number of full-bandwidth channels. * from ATSC A/52 Table 5.8 Audio Coding Mode */ const uint8_t ff_ac3_channels_tab[8] = { 2, 1, 2, 3, 3, 4, 4, 5 }; +/** + * Map audio coding mode (acmod) to channel layout mask. + */ +const uint16_t avpriv_ac3_channel_layout_tab[8] = { + AV_CH_LAYOUT_STEREO, + AV_CH_LAYOUT_MONO, + AV_CH_LAYOUT_STEREO, + AV_CH_LAYOUT_SURROUND, + AV_CH_LAYOUT_2_1, + AV_CH_LAYOUT_4POINT0, + AV_CH_LAYOUT_2_2, + AV_CH_LAYOUT_5POINT0 +}; + +#define COMMON_CHANNEL_MAP \ + { { 0, 1, }, { 0, 1, 2, } },\ + { { 0, }, { 0, 1, } },\ + { { 0, 1, }, { 0, 1, 2, } },\ + { { 0, 2, 1, }, { 0, 2, 1, 3, } },\ + { { 0, 1, 2, }, { 0, 1, 3, 2, } },\ + { { 0, 2, 1, 3, }, { 0, 2, 1, 4, 3, } }, + +/** + * Table to remap channels from SMPTE order to AC-3 order. + * [channel_mode][lfe][ch] + */ +const uint8_t ff_ac3_enc_channel_map[8][2][6] = { + COMMON_CHANNEL_MAP + { { 0, 1, 2, 3, }, { 0, 1, 3, 4, 2, } }, + { { 0, 2, 1, 3, 4, }, { 0, 2, 1, 4, 5, 3 } }, +}; + +/** + * Table to remap channels from from AC-3 order to SMPTE order. + * [channel_mode][lfe][ch] + */ +const uint8_t ff_ac3_dec_channel_map[8][2][6] = { + COMMON_CHANNEL_MAP + { { 0, 1, 2, 3, }, { 0, 1, 4, 2, 3, } }, + { { 0, 2, 1, 3, 4, }, { 0, 2, 1, 5, 3, 4 } }, +}; + /* possible frequencies */ const uint16_t ff_ac3_sample_rate_tab[3] = { 48000, 44100, 32000 }; @@ -88,10 +132,23 @@ const uint16_t ff_ac3_bitrate_tab[19] = { 160, 192, 224, 256, 320, 384, 448, 512, 576, 640 }; -/* AC3 MDCT window */ +/** + * Table of bin locations for rematrixing bands + * reference: Section 7.5.2 Rematrixing : Frequency Band Definitions + */ +const uint8_t ff_ac3_rematrix_band_tab[5] = { 13, 25, 37, 61, 253 }; + +/** + * Table E2.16 Default Coupling Banding Structure + */ +const uint8_t ff_eac3_default_cpl_band_struct[18] = { + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1 +}; + +/* AC-3 MDCT window */ /* MDCT window */ -const int16_t ff_ac3_window[256] = { +DECLARE_ALIGNED(16, const int16_t, ff_ac3_window)[AC3_WINDOW_SIZE/2] = { 4, 7, 12, 16, 21, 28, 34, 42, 51, 61, 72, 84, 97, 111, 127, 145, 164, 184, 207, 231, 257, 285, 315, 347, @@ -155,7 +212,7 @@ const uint8_t ff_ac3_log_add_tab[260]= { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; -const uint16_t ff_ac3_hearing_threshold_tab[50][3]= { +const uint16_t ff_ac3_hearing_threshold_tab[AC3_CRITICAL_BANDS][3]= { { 0x04d0,0x04f0,0x0580 }, { 0x04d0,0x04f0,0x0580 }, { 0x0440,0x0460,0x04b0 }, @@ -242,11 +299,6 @@ const uint16_t ff_ac3_fast_gain_tab[8]= { 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400, }; -const uint8_t ff_ac3_critical_band_size_tab[50]={ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, - 3, 6, 6, 6, 6, 6, 6, 12, 12, 12, 12, 24, 24, 24, 24, 24 -}; /** * Default channel map for a dependent substream defined by acmod */