/* * ATRAC3+ compatible decoder * * Copyright (c) 2010-2013 Maxim Poliakovski * * This file is part of FFmpeg. * * FFmpeg 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, * 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 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_ATRAC3PLUS_DATA_H#define AVCODEC_ATRAC3PLUS_DATA_H #include <stddef.h>#include <stdint.h> /** VLC tables for wordlen */static const uint8_t atrac3p_wl_huff_code1[3] = { 0, 2, 3 }; static const uint8_t atrac3p_wl_huff_bits1[3] = { 1, 2, 2 }; static const uint8_t atrac3p_wl_huff_xlat1[3] = { 0, 1, 7 }; static const uint8_t atrac3p_wl_huff_code2[5] = { 0, 4, 5, 6, 7 }; static const uint8_t atrac3p_wl_huff_bits2[5] = { 1, 3, 3, 3, 3 }; static const uint8_t atrac3p_wl_huff_xlat2[5] = { 0, 1, 2, 6, 7 }; static const uint8_t atrac3p_wl_huff_code3[8] = { 0, 4, 0xC, 0x1E, 0x1F, 0xD, 0xE, 5}; static const uint8_t atrac3p_wl_huff_bits3[8] = { 1, 3, 4, 5, 5, 4, 4, 3 }; static const uint8_t atrac3p_wl_huff_code4[8] = { 0, 4, 0xC, 0xD, 0x1E, 0x1F, 0xE, 5}; static const uint8_t atrac3p_wl_huff_bits4[8] = { 1, 3, 4, 4, 5, 5, 4, 3 }; /** VLC tables for scale factor indexes */static const uint16_t atrac3p_sf_huff_code1[64] = { 0, 2, 3, 4, 5, 0xC, 0xD, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0x1CE, 0x1CF, 0x1D0, 0x1D1, 0x1D2, 0x1D3, 0x1D4, 0x1D5, 0x1D6, 0x1D7, 0x1D8, 0x1D9, 0x1DA, 0x1DB, 0x1DC, 0x1DD, 0x1DE, 0x1DF, 0x1E0, 0x1E1, 0x1E2, 0x1E3, 0x1E4, 0x1E5, 0x1E6, 0x1E7, 0x1E8, 0x1E9, 0x1EA, 0x1EB, 0x1EC, 0x1ED, 0x1EE, 0x1EF, 0x1F0, 0x1F1, 0x1F2, 0x1F3, 0x1F4, 0x1F5, 0x1F6, 0x1F7, 0x1F8, 0x1F9, 0x1FA, 0x1FB, 0x1FC, 0x1FD, 0x1FE, 0x1FF}; static const uint8_t atrac3p_sf_huff_bits1[64] = { 2, 3, 3, 3, 3, 4, 4, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9}; static const uint8_t atrac3p_sf_huff_xlat1[64] = { 0, 1, 61, 62, 63, 2, 60, 3, 4, 5, 6, 57, 58, 59, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56}; static const uint8_t atrac3p_sf_huff_xlat2[64] = { 0, 1, 2, 62, 63, 3, 61, 4, 5, 6, 57, 58, 59, 60, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56}; static const uint16_t atrac3p_sf_huff_code2[64] = { 0, 4, 0x18, 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FC, 0x1FD, 0x1FE, 0x1FF, 0x71, 0x72, 0x1A, 0x1B, 4, 5}; static const uint8_t atrac3p_sf_huff_bits3[64] = { 2, 3, 3, 5, 5, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 5, 5, 3, 3}; static const uint16_t atrac3p_sf_huff_code4[16] = { 0, 2, 3, 4, 5, 0xC, 0xD, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0, 0x3D, 0x3E, 0x3F}; static const uint8_t atrac3p_sf_huff_bits4[16] = { 2, 3, 3, 3, 3, 4, 4, 6, 6, 6, 6, 6, 0, 6, 6, 6}; static const uint8_t atrac3p_sf_huff_xlat4[16] = { 0, 1, 13, 14, 15, 2, 12, 3, 4, 5, 6, 7, 8, 9, 10, 11}; static const uint8_t atrac3p_sf_huff_xlat5[16] = { 0, 1, 2, 14, 15, 3, 13, 4, 5, 6, 7, 9, 8, 10, 11, 12}; static const uint16_t atrac3p_sf_huff_code5[16] = { 0, 4, 0xC, 0x1C, 0x78, 0x79, 0x7A, 0x7B, 0, 0x7C, 0x7D, 0x7E, 0x7F, 0x1D, 0xD, 5}; static const uint8_t atrac3p_sf_huff_bits5[16] = { 1, 3, 4, 5, 7, 7, 7, 7, 0, 7, 7, 7, 7, 5, 4, 3}; static const uint16_t atrac3p_sf_huff_code6[16] = { 0, 2, 3, 0xC, 0x1C, 0x3C, 0x7C, 0x7D, 0, 0x7E, 0x7F, 0x3D, 0x1D, 0xD, 4, 5}; static const uint8_t atrac3p_sf_huff_bits6[16] = { 2, 3, 3, 4, 5, 6, 7, 7, 0, 7, 7, 6, 5, 4, 3, 3}; /** VLC tables for code table indexes */static const uint8_t atrac3p_ct_huff_code1[4] = { 0, 2, 6, 7 }; static const uint8_t atrac3p_ct_huff_bits1[4] = { 1, 2, 3, 3 }; static const uint8_t atrac3p_ct_huff_code2[8] = { 0, 2, 3, 4, 5, 6, 0xE, 0xF }; static const uint8_t atrac3p_ct_huff_bits2[8] = { 2, 3, 3, 3, 3, 3, 4, 4 }; static const uint8_t atrac3p_ct_huff_xlat1[8] = { 0, 1, 2, 3, 6, 7, 4, 5 }; static const uint8_t atrac3p_ct_huff_code3[8] = { 0, 4, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF}; static const uint8_t atrac3p_ct_huff_bits3[8] = { 1, 3, 4, 4, 4, 4, 4, 4 }; /* weights for quantized word lengths */static const int8_t atrac3p_wl_weights[6][32] = { { 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }, { 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 6, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}; /* weights for quantized scale factors * sf_weights[i] = i / (tab_idx + 1) * where tab_idx = [1,2] */static const int8_t atrac3p_sf_weights[2][32] = { { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15 }, { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10 }}; /** Ungroup table for word length segments. * Numbers in this table tell which coeff belongs to which segment. */static const uint8_t atrac3p_qu_num_to_seg[32] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9}; /** Map quant unit number to subband number */static const uint8_t atrac3p_qu_to_subband[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; /** Map subband number to number of power compensation groups */static const int atrac3p_subband_to_num_powgrps[16] = { 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5}; /** 3D base shape tables. The values are grouped together as follows: * [num_start_values = 8][num_shape_tables = 16][num_seg_coeffs = 9] * For each of the 8 start values there are 16 different shapes each * 9 coefficients long. */static const int8_t atrac3p_wl_shapes[8][16][9] = { { { 0, 0, 0, 0, 0, 0, 0, -2, -1 }, { 0, 0, 0, 0, 0, 0, 0, -5, -1 }, { 0, 0, 0, -7, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, -7, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, -5, 0, 0 }, { 0, 0, 0, 0, -5, 0, 0, 0, 0 }, { -7, -7, 0, 0, 0, 0, 0, 0, 0 }, { 0, -7, 0, 0, 0, 0, 0, 0, 0 }, { -2, -2, -5, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, -2, -5, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, -2, -5, 0, 0 }, { 0, 0, 0, -5, 0, 0, 0, 0, 0 }, { 0, -2, -7, -2, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, -2, -5, 0, 0, 0 }, { 0, 0, 0, -5, -5, 0, 0, 0, 0 }, { 0, 0, 0, -5, -2, 0, 0, 0, 0 } }, { { -1, -5, -3, -2, -1, -1, 0, 0, 0 }, { -2, -5, -3, -3, -2, -1, -1, 0, 0 }, { 0, -1, -1, -1, 0, 0, 0, 0, 0 }, { -1, -3, 0, 0, 0, 0, 0, 0, 0 }, { -1, -2, 0, 0, 0, 0, 0, 0, 0 }, { -1, -3, -1, 0, 0, 0, 0, 1, 1 }, { -1, -5, -3, -3, -2, -1, 0, 0, 0 }, { -1, -1, -4, -2, -2, -1, -1, 0, 0 }, { -1, -1, -3, -2, -3, -1, -1, -1, 0 }, { -1, -4, -2, -3, -1, 0, 0, 0, 0 }, { 0, -1, -2, -2, -1, -1, 0, 0, 0 }, { 0, -2, -1, 0, 0, 0, 0, 0, 0 }, { -1, -1, 0, 0, 0, 0, 0, 0, 0 }, { -1, -1, -3, -2, -2, -1, -1, -1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, -1, -3, -2, -2, -1, -1, -1, 0 }, }, { { -1, -2, 0, 1, 1, 1, 1, 1, 1 }, { 0, -1, 1, 1, 1, 1, 1, 1, 1 }, { 0, -2, 1, 1, 1, 1, 1, 1, 1 }, { 0, -2, 0, 1, 1, 1, 1, 1, 1 }, { -1, -1, 0, 1, 1, 1, 1, 1, 1 }, { 0, 0, -1, 0, 1, 1, 1, 1, 1 }, { -1, -1, 1, 1, 1, 1, 1, 1, 1 }, { 0, 0, -1, 1, 1, 1, 1, 1, 1 }, { 0, -1, 0, 1, 1, 1, 1, 1, 1 }, { -1, -1, -1, 1, 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 1, 1, 1, 1, 1 }, { 0, 0, 0, 1, 1, 1, 1, 1, 1 }, { 0, -1, -1, 1, 1, 1, 1, 1,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, 5, 6, 6 }, { 1, 2, 3, 4, 5, 6, 6, 6, 6 }, { 2, 3, 4, 5, 6, 6, 6, 6, 6 }, { 1, 2, 3, 4, 6, 6, 6, 6, 6 }, { 2, 2, 3, 4, 5, 5, 5, 6, 6 }, { 1, 2, 3, 4, 5, 5, 6, 6, 6 }, { 2, 2, 3, 4, 6, 6, 6, 6, 6 }, { 2, 2, 3, 4, 5, 6, 6, 6, 6 }, { 2, 2, 4, 5, 6, 6, 6, 6, 6 }, { 2, 2, 3, 5, 6, 6, 6, 6, 6 }, { 1, 2, 3, 5, 6, 6, 6, 6, 6 }, { 2, 3, 3, 5, 6, 6, 6, 6, 6 }, { 1, 2, 4, 5, 6, 6, 6, 6, 6 }, { 2, 2, 3, 4, 5, 5, 6, 6, 6 }, { 2, 3, 3, 4, 6, 6, 6, 6, 6 }, { 1, 3, 4, 5, 6, 6, 6, 6, 6 } }}; /** 2D base shape tables for scale factor coding. * The values are grouped together as follows: * [num_shape_tables = 64][num_seg_coeffs = 9] */static const int8_t atrac3p_sf_shapes[64][9] = { { -3, -2, -1, 0, 3, 5, 6, 8, 40 }, { -3, -2, 0, 1, 7, 9, 11, 13, 20 }, { -1, 0, 0, 1, 6, 8, 10, 13, 41 }, { 0, 0, 0, 2, 5, 5, 6, 8, 14 }, { 0, 0, 0, 2, 6, 7, 8, 11, 47 }, { 0, 0, 1, 2, 5, 7, 8, 10, 32 }, { 0, 0, 1, 3, 8, 10, 12, 14, 47 }, { 0, 0, 2, 4, 9, 10, 12, 14, 40 }, { 0, 0, 3, 5, 9, 10, 12, 14, 22 }, { 0, 1, 3, 5, 10, 14, 18, 22, 31 }, { 0, 2, 5, 6, 10, 10, 10, 12, 46 }, { 0, 2, 5, 7, 12, 14, 15, 18, 44 }, { 1, 1, 4, 5, 7, 7, 8, 9, 15 }, { 1, 2, 2, 2, 4, 5, 7, 9, 26 }, { 1, 2, 2, 3, 6, 7, 7, 8, 47 }, { 1, 2, 2, 3, 6, 8, 10, 13, 22 }, { 1, 3, 4, 7, 13, 17, 21, 24, 41 }, { 1, 4, 0, 4, 10, 12, 13, 14, 17 }, { 2, 3, 3, 3, 6, 8, 10, 13, 48 }, { 2, 3, 3, 4, 9, 12, 14, 17, 47 }, { 2, 3, 3, 5, 10, 12, 14, 17, 25 }, { 2, 3, 5, 7, 8, 9, 9, 9, 13 }, { 2, 3, 5, 9, 16, 21, 25, 28, 33 }, { 2, 4, 5, 8, 12, 14, 17, 19, 26 }, { 2, 4, 6, 8, 12, 13, 13, 15, 20 }, { 2, 4, 7, 12, 20, 26, 30, 32, 35 }, { 3, 3, 5, 6, 12, 14, 16, 19, 34 }, { 3, 4, 4, 5, 7, 9, 10, 11, 48 }, { 3, 4, 5, 6, 8, 9, 10, 11, 16 }, { 3, 5, 5, 5, 7, 9, 10, 13, 35 }, { 3, 5, 5, 7, 10, 12, 13, 15, 49 }, { 3, 5, 7, 7, 8, 7, 9, 12, 21 }, { 3, 5, 7, 8, 12, 14, 15, 15, 24 }, { 3, 5, 7, 10, 16, 21, 24, 27, 44 }, { 3, 5, 8, 14, 21, 26, 28, 29, 42 }, { 3, 6, 10, 13, 18, 19, 20, 22, 27 }, { 3, 6, 11, 16, 24, 27, 28, 29, 31 }, { 4, 5, 4, 3, 4, 6, 8, 11, 18 }, { 4, 6, 5, 6, 9, 10, 12, 14, 20 }, { 4, 6, 7, 6, 6, 6, 7, 8, 46 }, { 4, 6, 7, 9, 13, 16, 18, 20, 48 }, { 4, 6, 7, 9, 14, 17, 20, 23, 31 }, { 4, 6, 9, 11, 14, 15, 15, 17, 21 }, { 4, 8, 13, 20, 27, 32, 35, 36, 38 }, { 5, 6, 6, 4, 5, 6, 7, 6, 6 }, { 5, 7, 7, 8, 9, 9, 10, 12, 49 }, { 5, 8, 9, 9, 10, 11, 12, 13, 42 }, { 5, 8, 10, 12, 15, 16, 17, 19, 42 }, { 5, 8, 12, 17, 26, 31, 32, 33, 44 }, { 5, 9, 13, 16, 20, 22, 23, 23, 35 }, { 6, 8, 8, 7, 6, 5, 6, 8, 15 }, { 6, 8, 8, 8, 9, 10, 12, 16, 24 }, { 6, 8, 8, 9, 10, 10, 11, 11, 13 }, { 6, 8, 10, 13, 19, 21, 24, 26, 32 }, { 6, 9, 10, 11, 13, 13, 14, 16, 49 }, { 7, 9, 9, 10, 13, 14, 16, 19, 27 }, { 7, 10, 12, 13, 16, 16, 17, 17, 27 }, { 7, 10, 12, 14, 17, 19, 20, 22, 48 }, { 8, 9, 10, 9, 10, 11, 11, 11, 19 }, { 8, 11, 12, 12, 13, 13, 13, 13, 17 }, { 8, 11, 13, 14, 16, 17, 19, 20, 27 }, { 8, 12, 17, 22, 26, 28, 29, 30, 33 }, { 10, 14, 16, 19, 21, 22, 22, 24, 28 }, { 10, 15, 17, 18, 21, 22, 23, 25, 43 }}; static const uint8_t atrac3p_ct_restricted_to_full[2][7][4] = { { { 0, 5, 4, 1 }, { 0, 1, 2, 3 }, { 3, 0, 4, 2 }, { 4, 0, 1, 2 }, { 1, 0, 4, 3 }, { 3, 0, 2, 1 }, { 0, 3, 1, 2 } }, { { 4, 0, 1, 2 }, { 0, 3, 2, 1 }, { 0, 1, 2, 3 }, { 0, 1, 2, 4 }, { 0, 1, 2, 3 }, { 1, 4, 2, 0 }, { 0, 1, 2, 3 } }}; /** Tables for spectrum coding */static const uint8_t huff_a01_cb[14] = { 1, 12, 1, 0, 0, 1, 7, 0, 19, 5, 13, 21, 6, 8}; static const uint8_t huff_a01_xlat[81] = { 0x00, 0x03, 0x40, 0xC0, 0x10, 0x30, 0x04, 0x0C, 0x01, 0x50, 0xD0, 0x70, 0xF0, 0xC4, 0x14, 0x34, 0x4C, 0x1C, 0x3C, 0x41, 0xC1, 0x31, 0x05, 0x0D, 0xC3, 0x13, 0x07, 0x0F, 0x44, 0xCC, 0x11, 0x43, 0x33, 0x54, 0x74, 0xDC, 0xFC, 0x71, 0x15, 0x4D, 0xCD, 0x1D, 0xD3, 0xC7, 0x37, 0x3F, 0xD4, 0xF4, 0x5C, 0x7C, 0x51, 0xD1, 0xF1, 0x45, 0xC5, 0x35, 0xDD, 0x3D, 0x53, 0x73, 0xF3, 0x47, 0x17, 0x77, 0x4F, 0xCF, 0x1F, 0x55, 0xF5, 0x7D, 0xD7, 0x5F, 0xFF, 0xD5, 0x75, 0x5D, 0xFD, 0x57, 0xF7, 0xDF, 0x7F}; static const uint8_t huff_a02_cb[13] = { 2, 12, 1, 0, 4, 11, 0, 1, 29, 6, 20, 7, 2}; static const uint8_t huff_a02_xlat[81] = { 0x00, 0x40, 0x10, 0x04, 0x01, 0x50, 0x44, 0x14, 0x54, 0x41, 0x11, 0x51, 0x05, 0x45, 0x15, 0x55, 0x90, 0x80, 0x20, 0x60, 0x84, 0x94, 0x24, 0x64, 0x08, 0x48, 0x18, 0x58, 0x81, 0x91, 0x21, 0x85, 0x95, 0x65, 0x09, 0x49, 0x19, 0x59, 0x02, 0x42, 0x12, 0x52, 0x06, 0x46, 0x16, 0x56, 0x88, 0x61, 0x25, 0x29, 0x69, 0x5A, 0xA0, 0xA4, 0x98, 0x28, 0x68, 0xA1, 0xA5, 0x89, 0x99, 0xA9, 0x82, 0x92, 0x22, 0x62, 0x96, 0x26, 0x66, 0x0A, 0x4A, 0x1A, 0xA8, 0x86, 0xA6, 0x8A, 0x9A, 0x2A, 0x6A, 0xA2, 0xAA}; static const uint8_t huff_a03_cb[9] = { 3, 9, 1, 8, 0, 13, 18, 7, 2 }; static const uint8_t huff_a03_xlat[49] = { 0x00, 0x08, 0x38, 0x01, 0x09, 0x39, 0x07, 0x0F, 0x3F, 0x10, 0x30, 0x11, 0x31, 0x02, 0x0A, 0x3A, 0x05, 0x06, 0x0E, 0x3E, 0x17, 0x37, 0x18, 0x28, 0x19, 0x29, 0x2A, 0x32, 0x03, 0x0B, 0x33, 0x3B, 0x0D, 0x15, 0x3D, 0x16, 0x1E, 0x36, 0x1F, 0x2F, 0x12, 0x1A, 0x13, 0x2B, 0x1D, 0x35, 0x2E, 0x1B, 0x2D}; static const uint8_t huff_a04_cb[4] = { 2, 3, 2, 4 };static const uint8_t huff_a04_xlat[6] = { 1, 2, 0, 3, 4, 5 }; static const uint8_t huff_a05_cb[12] = { 3, 12, 1, 3, 5, 8, 12, 23, 72, 68, 31, 2}; static const uint8_t huff_a05_xlat[225] = { 0x00, 0x10, 0xF0, 0x01, 0x11, 0xF1, 0x0F, 0x1F, 0xFF, 0x20, 0xE0, 0xE1, 0x02, 0xF2, 0x0E, 0x1E, 0x2F, 0x30, 0xD0, 0x21, 0x12, 0x22, 0xE2, 0x03, 0x0D, 0x2E, 0xEE, 0xFE, 0xEF, 0x40, 0xC0, 0x31, 0xC1, 0xD1, 0x32, 0xD2, 0x13, 0x23, 0xE3, 0xF3, 0x04, 0xF4, 0x0C, 0x1C, 0x1D, 0x2D, 0xED, 0xFD, 0x3E, 0xDE, 0x3F, 0xDF, 0x50, 0x60, 0x70, 0x90, 0xA0, 0xB0, 0x41, 0x51, 0x61, 0x71, 0x91, 0xA1, 0xB1, 0x42, 0x62, 0x92, 0xA2, 0xC2, 0x33, 0xC3, 0xD3, 0x14, 0x24, 0x34, 0xD4, 0xE4, 0x05, 0x15, 0xF5, 0x06, 0x16, 0x26, 0xE6, 0xF6, 0x07, 0x17, 0xE7, 0xF7, 0x09, 0x19, 0x29, 0xF9, 0x0A, 0x1A, 0x2A, 0xEA, 0xFA, 0x0B, 0x1B, 0xFB, 0x2C, 0x3C, 0xDC, 0xEC, 0xFC, 0x3D, 0x4D, 0xCD, 0xDD, 0x4E, 0x6E, 0x7E, 0xAE, 0xCE, 0x4F, 0x5F, 0x6F, 0x7F, 0x9F, 0xAF, 0xBF, 0xCF, 0x52, 0x72, 0xB2, 0x43, 0x53, 0x63, 0x73, 0x93, 0xA3, 0xB3, 0x44, 0x64, 0x74, 0x94, 0xA4, 0xB4, 0xC4, 0x25, 0x35, 0xA5, 0xC5, 0xD5, 0xE5, 0x36, 0x46, 0xB6, 0xC6, 0xD6, 0x27, 0x37, 0x47, 0xB7, 0xC7, 0xD7, 0x39, 0x49, 0x59, 0xC9, 0xD9, 0xE9, 0x3A, 0x4A, 0x5A, 0xCA, 0xDA, 0x2B, 0x3B, 0x4B, 0x6B, 0x7B, 0xDB, 0xEB, 0x4C, 0x5C, 0x6C, 0x7C,Lines 1–500 of 1914. Load more
/* * ATRAC3+ compatible decoder * * Copyright (c) 2010-2013 Maxim Poliakovski * * This file is part of FFmpeg. * * FFmpeg 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, * 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 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_ATRAC3PLUS_DATA_H #define AVCODEC_ATRAC3PLUS_DATA_H #include <stddef.h> #include <stdint.h> /** VLC tables for wordlen */ static const uint8_t atrac3p_wl_huff_code1[3] = { 0, 2, 3 }; static const uint8_t atrac3p_wl_huff_bits1[3] = { 1, 2, 2 }; static const uint8_t atrac3p_wl_huff_xlat1[3] = { 0, 1, 7 }; static const uint8_t atrac3p_wl_huff_code2[5] = { 0, 4, 5, 6, 7 }; static const uint8_t atrac3p_wl_huff_bits2[5] = { 1, 3, 3, 3, 3 }; static const uint8_t atrac3p_wl_huff_xlat2[5] = { 0, 1, 2, 6, 7 }; static const uint8_t atrac3p_wl_huff_code3[8] = { 0, 4, 0xC, 0x1E, 0x1F, 0xD, 0xE, 5 }; static const uint8_t atrac3p_wl_huff_bits3[8] = { 1, 3, 4, 5, 5, 4, 4, 3 }; static const uint8_t atrac3p_wl_huff_code4[8] = { 0, 4, 0xC, 0xD, 0x1E, 0x1F, 0xE, 5 }; static const uint8_t atrac3p_wl_huff_bits4[8] = { 1, 3, 4, 4, 5, 5, 4, 3 }; /** VLC tables for scale factor indexes */ static const uint16_t atrac3p_sf_huff_code1[64] = { 0, 2, 3, 4, 5, 0xC, 0xD, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0x1CE, 0x1CF, 0x1D0, 0x1D1, 0x1D2, 0x1D3, 0x1D4, 0x1D5, 0x1D6, 0x1D7, 0x1D8, 0x1D9, 0x1DA, 0x1DB, 0x1DC, 0x1DD, 0x1DE, 0x1DF, 0x1E0, 0x1E1, 0x1E2, 0x1E3, 0x1E4, 0x1E5, 0x1E6, 0x1E7, 0x1E8, 0x1E9, 0x1EA, 0x1EB, 0x1EC, 0x1ED, 0x1EE, 0x1EF, 0x1F0, 0x1F1, 0x1F2, 0x1F3, 0x1F4, 0x1F5, 0x1F6, 0x1F7, 0x1F8, 0x1F9, 0x1FA, 0x1FB, 0x1FC, 0x1FD, 0x1FE, 0x1FF }; static const uint8_t atrac3p_sf_huff_bits1[64] = { 2, 3, 3, 3, 3, 4, 4, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9 }; static const uint8_t atrac3p_sf_huff_xlat1[64] = { 0, 1, 61, 62, 63, 2, 60, 3, 4, 5, 6, 57, 58, 59, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56 }; static const uint8_t atrac3p_sf_huff_xlat2[64] = { 0, 1, 2, 62, 63, 3, 61, 4, 5, 6, 57, 58, 59, 60, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56 }; static const uint16_t atrac3p_sf_huff_code2[64] = { 0, 4, 0x18, 0x19, 0x70, 0x1CA, 0x1CB, 0x1CC, 0x1CD, 0x1CE, 0x1CF, 0x1D0, 0x1D1, 0x1D2, 0x1D3, 0x1D4, 0x1D5, 0x1D6, 0x1D7, 0x1D8, 0x1D9, 0x1DA, 0x1DB, 0x1DC, 0x1DD, 0x1DE, 0x1DF, 0x1E0, 0x1E1, 0x1E2, 0x1E3, 0x1E4, 0x1E5, 0x1E6, 0x1E7, 0x1E8, 0x1E9, 0x1EA, 0x1EB, 0x1EC, 0x1ED, 0x1EE, 0x1EF, 0x1F0, 0x1F1, 0x1F2, 0x1F3, 0x1F4, 0x1F5, 0x1F6, 0x1F7, 0x1F8, 0x1F9, 0x1FA, 0x1FB, 0x1FC, 0x1FD, 0x1FE, 0x1FF, 0xE4, 0x71, 0x1A, 0x1B, 5 }; static const uint8_t atrac3p_sf_huff_bits2[64] = { 1, 3, 5, 5, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 7, 5, 5, 3 }; static const uint16_t atrac3p_sf_huff_code3[64] = { 0, 2, 3, 0x18, 0x19, 0x70, 0x1CC, 0x1CD, 0x1CE, 0x1CF, 0x1D0, 0x1D1, 0x1D2, 0x1D3, 0x1D4, 0x1D5, 0x1D6, 0x1D7, 0x1D8, 0x1D9, 0x1DA, 0x1DB, 0x1DC, 0x1DD, 0x1DE, 0x1DF, 0x1E0, 0x1E1, 0x1E2, 0x1E3, 0x1E4, 0x1E5, 0x1E6, 0x1E7, 0x1E8, 0x1E9, 0x1EA, 0x1EB, 0x1EC, 0x1ED, 0x1EE, 0x1EF, 0x1F0, 0x1F1, 0x1F2, 0x1F3, 0x1F4, 0x1F5, 0x1F6, 0x1F7, 0x1F8, 0x1F9, 0x1FA, 0x1FB, 0x1FC, 0x1FD, 0x1FE, 0x1FF, 0x71, 0x72, 0x1A, 0x1B, 4, 5 }; static const uint8_t atrac3p_sf_huff_bits3[64] = { 2, 3, 3, 5, 5, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 5, 5, 3, 3 }; static const uint16_t atrac3p_sf_huff_code4[16] = { 0, 2, 3, 4, 5, 0xC, 0xD, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0, 0x3D, 0x3E, 0x3F }; static const uint8_t atrac3p_sf_huff_bits4[16] = { 2, 3, 3, 3, 3, 4, 4, 6, 6, 6, 6, 6, 0, 6, 6, 6 }; static const uint8_t atrac3p_sf_huff_xlat4[16] = { 0, 1, 13, 14, 15, 2, 12, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; static const uint8_t atrac3p_sf_huff_xlat5[16] = { 0, 1, 2, 14, 15, 3, 13, 4, 5, 6, 7, 9, 8, 10, 11, 12 }; static const uint16_t atrac3p_sf_huff_code5[16] = { 0, 4, 0xC, 0x1C, 0x78, 0x79, 0x7A, 0x7B, 0, 0x7C, 0x7D, 0x7E, 0x7F, 0x1D, 0xD, 5 }; static const uint8_t atrac3p_sf_huff_bits5[16] = { 1, 3, 4, 5, 7, 7, 7, 7, 0, 7, 7, 7, 7, 5, 4, 3 }; static const uint16_t atrac3p_sf_huff_code6[16] = { 0, 2, 3, 0xC, 0x1C, 0x3C, 0x7C, 0x7D, 0, 0x7E, 0x7F, 0x3D, 0x1D, 0xD, 4, 5 }; static const uint8_t atrac3p_sf_huff_bits6[16] = { 2, 3, 3, 4, 5, 6, 7, 7, 0, 7, 7, 6, 5, 4, 3, 3 }; /** VLC tables for code table indexes */ static const uint8_t atrac3p_ct_huff_code1[4] = { 0, 2, 6, 7 }; static const uint8_t atrac3p_ct_huff_bits1[4] = { 1, 2, 3, 3 }; static const uint8_t atrac3p_ct_huff_code2[8] = { 0, 2, 3, 4, 5, 6, 0xE, 0xF }; static const uint8_t atrac3p_ct_huff_bits2[8] = { 2, 3, 3, 3, 3, 3, 4, 4 }; static const uint8_t atrac3p_ct_huff_xlat1[8] = { 0, 1, 2, 3, 6, 7, 4, 5 }; static const uint8_t atrac3p_ct_huff_code3[8] = { 0, 4, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF }; static const uint8_t atrac3p_ct_huff_bits3[8] = { 1, 3, 4, 4, 4, 4, 4, 4 }; /* weights for quantized word lengths */ static const int8_t atrac3p_wl_weights[6][32] = { { 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }, { 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 6, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; /* weights for quantized scale factors * sf_weights[i] = i / (tab_idx + 1) * where tab_idx = [1,2] */ static const int8_t atrac3p_sf_weights[2][32] = { { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15 }, { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10 } }; /** Ungroup table for word length segments. * Numbers in this table tell which coeff belongs to which segment. */ static const uint8_t atrac3p_qu_num_to_seg[32] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9 }; /** Map quant unit number to subband number */ static const uint8_t atrac3p_qu_to_subband[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; /** Map subband number to number of power compensation groups */ static const int atrac3p_subband_to_num_powgrps[16] = { 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5 }; /** 3D base shape tables. The values are grouped together as follows: * [num_start_values = 8][num_shape_tables = 16][num_seg_coeffs = 9] * For each of the 8 start values there are 16 different shapes each * 9 coefficients long. */ static const int8_t atrac3p_wl_shapes[8][16][9] = { { { 0, 0, 0, 0, 0, 0, 0, -2, -1 }, { 0, 0, 0, 0, 0, 0, 0, -5, -1 }, { 0, 0, 0, -7, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, -7, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, -5, 0, 0 }, { 0, 0, 0, 0, -5, 0, 0, 0, 0 }, { -7, -7, 0, 0, 0, 0, 0, 0, 0 }, { 0, -7, 0, 0, 0, 0, 0, 0, 0 }, { -2, -2, -5, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, -2, -5, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, -2, -5, 0, 0 }, { 0, 0, 0, -5, 0, 0, 0, 0, 0 }, { 0, -2, -7, -2, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, -2, -5, 0, 0, 0 }, { 0, 0, 0, -5, -5, 0, 0, 0, 0 }, { 0, 0, 0, -5, -2, 0, 0, 0, 0 } }, { { -1, -5, -3, -2, -1, -1, 0, 0, 0 }, { -2, -5, -3, -3, -2, -1, -1, 0, 0 }, { 0, -1, -1, -1, 0, 0, 0, 0, 0 }, { -1, -3, 0, 0, 0, 0, 0, 0, 0 }, { -1, -2, 0, 0, 0, 0, 0, 0, 0 }, { -1, -3, -1, 0, 0, 0, 0, 1, 1 }, { -1, -5, -3, -3, -2, -1, 0, 0, 0 }, { -1, -1, -4, -2, -2, -1, -1, 0, 0 }, { -1, -1, -3, -2, -3, -1, -1, -1, 0 }, { -1, -4, -2, -3, -1, 0, 0, 0, 0 }, { 0, -1, -2, -2, -1, -1, 0, 0, 0 }, { 0, -2, -1, 0, 0, 0, 0, 0, 0 }, { -1, -1, 0, 0, 0, 0, 0, 0, 0 }, { -1, -1, -3, -2, -2, -1, -1, -1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, -1, -3, -2, -2, -1, -1, -1, 0 }, }, { { -1, -2, 0, 1, 1, 1, 1, 1, 1 }, { 0, -1, 1, 1, 1, 1, 1, 1, 1 }, { 0, -2, 1, 1, 1, 1, 1, 1, 1 }, { 0, -2, 0, 1, 1, 1, 1, 1, 1 }, { -1, -1, 0, 1, 1, 1, 1, 1, 1 }, { 0, 0, -1, 0, 1, 1, 1, 1, 1 }, { -1, -1, 1, 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 3, 5, 5, 5, 5, 5, 5 }, { 0, 1, 3, 4, 5, 5, 5, 5, 5 }, { 1, 2, 2, 3, 5, 5, 5, 5, 5 }, { 2, 3, 4, 5, 5, 5, 5, 5, 5 }, { 0, 2, 3, 4, 5, 5, 5, 5, 5 }, { 1, 1, 1, 3, 4, 5, 5, 5, 5 }, }, { { 1, 2, 3, 4, 5, 5, 5, 6, 6 }, { 1, 2, 3, 4, 5, 6, 6, 6, 6 }, { 2, 3, 4, 5, 6, 6, 6, 6, 6 }, { 1, 2, 3, 4, 6, 6, 6, 6, 6 }, { 2, 2, 3, 4, 5, 5, 5, 6, 6 }, { 1, 2, 3, 4, 5, 5, 6, 6, 6 }, { 2, 2, 3, 4, 6, 6, 6, 6, 6 }, { 2, 2, 3, 4, 5, 6, 6, 6, 6 }, { 2, 2, 4, 5, 6, 6, 6, 6, 6 }, { 2, 2, 3, 5, 6, 6, 6, 6, 6 }, { 1, 2, 3, 5, 6, 6, 6, 6, 6 }, { 2, 3, 3, 5, 6, 6, 6, 6, 6 }, { 1, 2, 4, 5, 6, 6, 6, 6, 6 }, { 2, 2, 3, 4, 5, 5, 6, 6, 6 }, { 2, 3, 3, 4, 6, 6, 6, 6, 6 }, { 1, 3, 4, 5, 6, 6, 6, 6, 6 } } }; /** 2D base shape tables for scale factor coding. * The values are grouped together as follows: * [num_shape_tables = 64][num_seg_coeffs = 9] */ static const int8_t atrac3p_sf_shapes[64][9] = { { -3, -2, -1, 0, 3, 5, 6, 8, 40 }, { -3, -2, 0, 1, 7, 9, 11, 13, 20 }, { -1, 0, 0, 1, 6, 8, 10, 13, 41 }, { 0, 0, 0, 2, 5, 5, 6, 8, 14 }, { 0, 0, 0, 2, 6, 7, 8, 11, 47 }, { 0, 0, 1, 2, 5, 7, 8, 10, 32 }, { 0, 0, 1, 3, 8, 10, 12, 14, 47 }, { 0, 0, 2, 4, 9, 10, 12, 14, 40 }, { 0, 0, 3, 5, 9, 10, 12, 14, 22 }, { 0, 1, 3, 5, 10, 14, 18, 22, 31 }, { 0, 2, 5, 6, 10, 10, 10, 12, 46 }, { 0, 2, 5, 7, 12, 14, 15, 18, 44 }, { 1, 1, 4, 5, 7, 7, 8, 9, 15 }, { 1, 2, 2, 2, 4, 5, 7, 9, 26 }, { 1, 2, 2, 3, 6, 7, 7, 8, 47 }, { 1, 2, 2, 3, 6, 8, 10, 13, 22 }, { 1, 3, 4, 7, 13, 17, 21, 24, 41 }, { 1, 4, 0, 4, 10, 12, 13, 14, 17 }, { 2, 3, 3, 3, 6, 8, 10, 13, 48 }, { 2, 3, 3, 4, 9, 12, 14, 17, 47 }, { 2, 3, 3, 5, 10, 12, 14, 17, 25 }, { 2, 3, 5, 7, 8, 9, 9, 9, 13 }, { 2, 3, 5, 9, 16, 21, 25, 28, 33 }, { 2, 4, 5, 8, 12, 14, 17, 19, 26 }, { 2, 4, 6, 8, 12, 13, 13, 15, 20 }, { 2, 4, 7, 12, 20, 26, 30, 32, 35 }, { 3, 3, 5, 6, 12, 14, 16, 19, 34 }, { 3, 4, 4, 5, 7, 9, 10, 11, 48 }, { 3, 4, 5, 6, 8, 9, 10, 11, 16 }, { 3, 5, 5, 5, 7, 9, 10, 13, 35 }, { 3, 5, 5, 7, 10, 12, 13, 15, 49 }, { 3, 5, 7, 7, 8, 7, 9, 12, 21 }, { 3, 5, 7, 8, 12, 14, 15, 15, 24 }, { 3, 5, 7, 10, 16, 21, 24, 27, 44 }, { 3, 5, 8, 14, 21, 26, 28, 29, 42 }, { 3, 6, 10, 13, 18, 19, 20, 22, 27 }, { 3, 6, 11, 16, 24, 27, 28, 29, 31 }, { 4, 5, 4, 3, 4, 6, 8, 11, 18 }, { 4, 6, 5, 6, 9, 10, 12, 14, 20 }, { 4, 6, 7, 6, 6, 6, 7, 8, 46 }, { 4, 6, 7, 9, 13, 16, 18, 20, 48 }, { 4, 6, 7, 9, 14, 17, 20, 23, 31 }, { 4, 6, 9, 11, 14, 15, 15, 17, 21 }, { 4, 8, 13, 20, 27, 32, 35, 36, 38 }, { 5, 6, 6, 4, 5, 6, 7, 6, 6 }, { 5, 7, 7, 8, 9, 9, 10, 12, 49 }, { 5, 8, 9, 9, 10, 11, 12, 13, 42 }, { 5, 8, 10, 12, 15, 16, 17, 19, 42 }, { 5, 8, 12, 17, 26, 31, 32, 33, 44 }, { 5, 9, 13, 16, 20, 22, 23, 23, 35 }, { 6, 8, 8, 7, 6, 5, 6, 8, 15 }, { 6, 8, 8, 8, 9, 10, 12, 16, 24 }, { 6, 8, 8, 9, 10, 10, 11, 11, 13 }, { 6, 8, 10, 13, 19, 21, 24, 26, 32 }, { 6, 9, 10, 11, 13, 13, 14, 16, 49 }, { 7, 9, 9, 10, 13, 14, 16, 19, 27 }, { 7, 10, 12, 13, 16, 16, 17, 17, 27 }, { 7, 10, 12, 14, 17, 19, 20, 22, 48 }, { 8, 9, 10, 9, 10, 11, 11, 11, 19 }, { 8, 11, 12, 12, 13, 13, 13, 13, 17 }, { 8, 11, 13, 14, 16, 17, 19, 20, 27 }, { 8, 12, 17, 22, 26, 28, 29, 30, 33 }, { 10, 14, 16, 19, 21, 22, 22, 24, 28 }, { 10, 15, 17, 18, 21, 22, 23, 25, 43 } }; static const uint8_t atrac3p_ct_restricted_to_full[2][7][4] = { { { 0, 5, 4, 1 }, { 0, 1, 2, 3 }, { 3, 0, 4, 2 }, { 4, 0, 1, 2 }, { 1, 0, 4, 3 }, { 3, 0, 2, 1 }, { 0, 3, 1, 2 } }, { { 4, 0, 1, 2 }, { 0, 3, 2, 1 }, { 0, 1, 2, 3 }, { 0, 1, 2, 4 }, { 0, 1, 2, 3 }, { 1, 4, 2, 0 }, { 0, 1, 2, 3 } } }; /** Tables for spectrum coding */ static const uint8_t huff_a01_cb[14] = { 1, 12, 1, 0, 0, 1, 7, 0, 19, 5, 13, 21, 6, 8 }; static const uint8_t huff_a01_xlat[81] = { 0x00, 0x03, 0x40, 0xC0, 0x10, 0x30, 0x04, 0x0C, 0x01, 0x50, 0xD0, 0x70, 0xF0, 0xC4, 0x14, 0x34, 0x4C, 0x1C, 0x3C, 0x41, 0xC1, 0x31, 0x05, 0x0D, 0xC3, 0x13, 0x07, 0x0F, 0x44, 0xCC, 0x11, 0x43, 0x33, 0x54, 0x74, 0xDC, 0xFC, 0x71, 0x15, 0x4D, 0xCD, 0x1D, 0xD3, 0xC7, 0x37, 0x3F, 0xD4, 0xF4, 0x5C, 0x7C, 0x51, 0xD1, 0xF1, 0x45, 0xC5, 0x35, 0xDD, 0x3D, 0x53, 0x73, 0xF3, 0x47, 0x17, 0x77, 0x4F, 0xCF, 0x1F, 0x55, 0xF5, 0x7D, 0xD7, 0x5F, 0xFF, 0xD5, 0x75, 0x5D, 0xFD, 0x57, 0xF7, 0xDF, 0x7F }; static const uint8_t huff_a02_cb[13] = { 2, 12, 1, 0, 4, 11, 0, 1, 29, 6, 20, 7, 2 }; static const uint8_t huff_a02_xlat[81] = { 0x00, 0x40, 0x10, 0x04, 0x01, 0x50, 0x44, 0x14, 0x54, 0x41, 0x11, 0x51, 0x05, 0x45, 0x15, 0x55, 0x90, 0x80, 0x20, 0x60, 0x84, 0x94, 0x24, 0x64, 0x08, 0x48, 0x18, 0x58, 0x81, 0x91, 0x21, 0x85, 0x95, 0x65, 0x09, 0x49, 0x19, 0x59, 0x02, 0x42, 0x12, 0x52, 0x06, 0x46, 0x16, 0x56, 0x88, 0x61, 0x25, 0x29, 0x69, 0x5A, 0xA0, 0xA4, 0x98, 0x28, 0x68, 0xA1, 0xA5, 0x89, 0x99, 0xA9, 0x82, 0x92, 0x22, 0x62, 0x96, 0x26, 0x66, 0x0A, 0x4A, 0x1A, 0xA8, 0x86, 0xA6, 0x8A, 0x9A, 0x2A, 0x6A, 0xA2, 0xAA }; static const uint8_t huff_a03_cb[9] = { 3, 9, 1, 8, 0, 13, 18, 7, 2 }; static const uint8_t huff_a03_xlat[49] = { 0x00, 0x08, 0x38, 0x01, 0x09, 0x39, 0x07, 0x0F, 0x3F, 0x10, 0x30, 0x11, 0x31, 0x02, 0x0A, 0x3A, 0x05, 0x06, 0x0E, 0x3E, 0x17, 0x37, 0x18, 0x28, 0x19, 0x29, 0x2A, 0x32, 0x03, 0x0B, 0x33, 0x3B, 0x0D, 0x15, 0x3D, 0x16, 0x1E, 0x36, 0x1F, 0x2F, 0x12, 0x1A, 0x13, 0x2B, 0x1D, 0x35, 0x2E, 0x1B, 0x2D }; static const uint8_t huff_a04_cb[4] = { 2, 3, 2, 4 }; static const uint8_t huff_a04_xlat[6] = { 1, 2, 0, 3, 4, 5 }; static const uint8_t huff_a05_cb[12] = { 3, 12, 1, 3, 5, 8, 12, 23, 72, 68, 31, 2 }; static const uint8_t huff_a05_xlat[225] = { 0x00, 0x10, 0xF0, 0x01, 0x11, 0xF1, 0x0F, 0x1F, 0xFF, 0x20, 0xE0, 0xE1, 0x02, 0xF2, 0x0E, 0x1E, 0x2F, 0x30, 0xD0, 0x21, 0x12, 0x22, 0xE2, 0x03, 0x0D, 0x2E, 0xEE, 0xFE, 0xEF, 0x40, 0xC0, 0x31, 0xC1, 0xD1, 0x32, 0xD2, 0x13, 0x23, 0xE3, 0xF3, 0x04, 0xF4, 0x0C, 0x1C, 0x1D, 0x2D, 0xED, 0xFD, 0x3E, 0xDE, 0x3F, 0xDF, 0x50, 0x60, 0x70, 0x90, 0xA0, 0xB0, 0x41, 0x51, 0x61, 0x71, 0x91, 0xA1, 0xB1, 0x42, 0x62, 0x92, 0xA2, 0xC2, 0x33, 0xC3, 0xD3, 0x14, 0x24, 0x34, 0xD4, 0xE4, 0x05, 0x15, 0xF5, 0x06, 0x16, 0x26, 0xE6, 0xF6, 0x07, 0x17, 0xE7, 0xF7, 0x09, 0x19, 0x29, 0xF9, 0x0A, 0x1A, 0x2A, 0xEA, 0xFA, 0x0B, 0x1B, 0xFB, 0x2C, 0x3C, 0xDC, 0xEC, 0xFC, 0x3D, 0x4D, 0xCD, 0xDD, 0x4E, 0x6E, 0x7E, 0xAE, 0xCE, 0x4F, 0x5F, 0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