00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027 #include "avcodec.h"
00028 #include "ac3tab.h"
00029
00034 const uint16_t ff_ac3_frame_size_tab[38][3] = {
00035 { 64, 69, 96 },
00036 { 64, 70, 96 },
00037 { 80, 87, 120 },
00038 { 80, 88, 120 },
00039 { 96, 104, 144 },
00040 { 96, 105, 144 },
00041 { 112, 121, 168 },
00042 { 112, 122, 168 },
00043 { 128, 139, 192 },
00044 { 128, 140, 192 },
00045 { 160, 174, 240 },
00046 { 160, 175, 240 },
00047 { 192, 208, 288 },
00048 { 192, 209, 288 },
00049 { 224, 243, 336 },
00050 { 224, 244, 336 },
00051 { 256, 278, 384 },
00052 { 256, 279, 384 },
00053 { 320, 348, 480 },
00054 { 320, 349, 480 },
00055 { 384, 417, 576 },
00056 { 384, 418, 576 },
00057 { 448, 487, 672 },
00058 { 448, 488, 672 },
00059 { 512, 557, 768 },
00060 { 512, 558, 768 },
00061 { 640, 696, 960 },
00062 { 640, 697, 960 },
00063 { 768, 835, 1152 },
00064 { 768, 836, 1152 },
00065 { 896, 975, 1344 },
00066 { 896, 976, 1344 },
00067 { 1024, 1114, 1536 },
00068 { 1024, 1115, 1536 },
00069 { 1152, 1253, 1728 },
00070 { 1152, 1254, 1728 },
00071 { 1280, 1393, 1920 },
00072 { 1280, 1394, 1920 },
00073 };
00074
00079 const uint8_t ff_ac3_channels_tab[8] = {
00080 2, 1, 2, 3, 3, 4, 4, 5
00081 };
00082
00086 const uint16_t ff_ac3_channel_layout_tab[8] = {
00087 CH_LAYOUT_STEREO,
00088 CH_LAYOUT_MONO,
00089 CH_LAYOUT_STEREO,
00090 CH_LAYOUT_SURROUND,
00091 CH_LAYOUT_2_1,
00092 CH_LAYOUT_4POINT0,
00093 CH_LAYOUT_2_2,
00094 CH_LAYOUT_5POINT0
00095 };
00096
00097 #define COMMON_CHANNEL_MAP \
00098 { { 0, 1, }, { 0, 1, 2, } },\
00099 { { 0, }, { 0, 1, } },\
00100 { { 0, 1, }, { 0, 1, 2, } },\
00101 { { 0, 2, 1, }, { 0, 2, 1, 3, } },\
00102 { { 0, 1, 2, }, { 0, 1, 3, 2, } },\
00103 { { 0, 2, 1, 3, }, { 0, 2, 1, 4, 3, } },
00104
00109 const uint8_t ff_ac3_enc_channel_map[8][2][6] = {
00110 COMMON_CHANNEL_MAP
00111 { { 0, 1, 2, 3, }, { 0, 1, 3, 4, 2, } },
00112 { { 0, 2, 1, 3, 4, }, { 0, 2, 1, 4, 5, 3 } },
00113 };
00114
00119 const uint8_t ff_ac3_dec_channel_map[8][2][6] = {
00120 COMMON_CHANNEL_MAP
00121 { { 0, 1, 2, 3, }, { 0, 1, 4, 2, 3, } },
00122 { { 0, 2, 1, 3, 4, }, { 0, 2, 1, 5, 3, 4 } },
00123 };
00124
00125
00126 const uint16_t ff_ac3_sample_rate_tab[3] = { 48000, 44100, 32000 };
00127
00128
00129 const uint16_t ff_ac3_bitrate_tab[19] = {
00130 32, 40, 48, 56, 64, 80, 96, 112, 128,
00131 160, 192, 224, 256, 320, 384, 448, 512, 576, 640
00132 };
00133
00134
00135
00136
00137 const int16_t ff_ac3_window[256] = {
00138 4, 7, 12, 16, 21, 28, 34, 42,
00139 51, 61, 72, 84, 97, 111, 127, 145,
00140 164, 184, 207, 231, 257, 285, 315, 347,
00141 382, 419, 458, 500, 544, 591, 641, 694,
00142 750, 810, 872, 937, 1007, 1079, 1155, 1235,
00143 1318, 1406, 1497, 1593, 1692, 1796, 1903, 2016,
00144 2132, 2253, 2379, 2509, 2644, 2783, 2927, 3076,
00145 3230, 3389, 3552, 3721, 3894, 4072, 4255, 4444,
00146 4637, 4835, 5038, 5246, 5459, 5677, 5899, 6127,
00147 6359, 6596, 6837, 7083, 7334, 7589, 7848, 8112,
00148 8380, 8652, 8927, 9207, 9491, 9778,10069,10363,
00149 10660,10960,11264,11570,11879,12190,12504,12820,
00150 13138,13458,13780,14103,14427,14753,15079,15407,
00151 15735,16063,16392,16720,17049,17377,17705,18032,
00152 18358,18683,19007,19330,19651,19970,20287,20602,
00153 20914,21225,21532,21837,22139,22438,22733,23025,
00154 23314,23599,23880,24157,24430,24699,24964,25225,
00155 25481,25732,25979,26221,26459,26691,26919,27142,
00156 27359,27572,27780,27983,28180,28373,28560,28742,
00157 28919,29091,29258,29420,29577,29729,29876,30018,
00158 30155,30288,30415,30538,30657,30771,30880,30985,
00159 31086,31182,31274,31363,31447,31528,31605,31678,
00160 31747,31814,31877,31936,31993,32046,32097,32145,
00161 32190,32232,32272,32310,32345,32378,32409,32438,
00162 32465,32490,32513,32535,32556,32574,32592,32608,
00163 32623,32636,32649,32661,32671,32681,32690,32698,
00164 32705,32712,32718,32724,32729,32733,32737,32741,
00165 32744,32747,32750,32752,32754,32756,32757,32759,
00166 32760,32761,32762,32763,32764,32764,32765,32765,
00167 32766,32766,32766,32766,32767,32767,32767,32767,
00168 32767,32767,32767,32767,32767,32767,32767,32767,
00169 32767,32767,32767,32767,32767,32767,32767,32767,
00170 };
00171
00172 const uint8_t ff_ac3_log_add_tab[260]= {
00173 0x40,0x3f,0x3e,0x3d,0x3c,0x3b,0x3a,0x39,0x38,0x37,
00174 0x36,0x35,0x34,0x34,0x33,0x32,0x31,0x30,0x2f,0x2f,
00175 0x2e,0x2d,0x2c,0x2c,0x2b,0x2a,0x29,0x29,0x28,0x27,
00176 0x26,0x26,0x25,0x24,0x24,0x23,0x23,0x22,0x21,0x21,
00177 0x20,0x20,0x1f,0x1e,0x1e,0x1d,0x1d,0x1c,0x1c,0x1b,
00178 0x1b,0x1a,0x1a,0x19,0x19,0x18,0x18,0x17,0x17,0x16,
00179 0x16,0x15,0x15,0x15,0x14,0x14,0x13,0x13,0x13,0x12,
00180 0x12,0x12,0x11,0x11,0x11,0x10,0x10,0x10,0x0f,0x0f,
00181 0x0f,0x0e,0x0e,0x0e,0x0d,0x0d,0x0d,0x0d,0x0c,0x0c,
00182 0x0c,0x0c,0x0b,0x0b,0x0b,0x0b,0x0a,0x0a,0x0a,0x0a,
00183 0x0a,0x09,0x09,0x09,0x09,0x09,0x08,0x08,0x08,0x08,
00184 0x08,0x08,0x07,0x07,0x07,0x07,0x07,0x07,0x06,0x06,
00185 0x06,0x06,0x06,0x06,0x06,0x06,0x05,0x05,0x05,0x05,
00186 0x05,0x05,0x05,0x05,0x04,0x04,0x04,0x04,0x04,0x04,
00187 0x04,0x04,0x04,0x04,0x04,0x03,0x03,0x03,0x03,0x03,
00188 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x02,
00189 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
00190 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,
00191 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
00192 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
00193 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
00194 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00195 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00196 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00197 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00198 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
00199 };
00200
00201 const uint16_t ff_ac3_hearing_threshold_tab[50][3]= {
00202 { 0x04d0,0x04f0,0x0580 },
00203 { 0x04d0,0x04f0,0x0580 },
00204 { 0x0440,0x0460,0x04b0 },
00205 { 0x0400,0x0410,0x0450 },
00206 { 0x03e0,0x03e0,0x0420 },
00207 { 0x03c0,0x03d0,0x03f0 },
00208 { 0x03b0,0x03c0,0x03e0 },
00209 { 0x03b0,0x03b0,0x03d0 },
00210 { 0x03a0,0x03b0,0x03c0 },
00211 { 0x03a0,0x03a0,0x03b0 },
00212 { 0x03a0,0x03a0,0x03b0 },
00213 { 0x03a0,0x03a0,0x03b0 },
00214 { 0x03a0,0x03a0,0x03a0 },
00215 { 0x0390,0x03a0,0x03a0 },
00216 { 0x0390,0x0390,0x03a0 },
00217 { 0x0390,0x0390,0x03a0 },
00218 { 0x0380,0x0390,0x03a0 },
00219 { 0x0380,0x0380,0x03a0 },
00220 { 0x0370,0x0380,0x03a0 },
00221 { 0x0370,0x0380,0x03a0 },
00222 { 0x0360,0x0370,0x0390 },
00223 { 0x0360,0x0370,0x0390 },
00224 { 0x0350,0x0360,0x0390 },
00225 { 0x0350,0x0360,0x0390 },
00226 { 0x0340,0x0350,0x0380 },
00227 { 0x0340,0x0350,0x0380 },
00228 { 0x0330,0x0340,0x0380 },
00229 { 0x0320,0x0340,0x0370 },
00230 { 0x0310,0x0320,0x0360 },
00231 { 0x0300,0x0310,0x0350 },
00232 { 0x02f0,0x0300,0x0340 },
00233 { 0x02f0,0x02f0,0x0330 },
00234 { 0x02f0,0x02f0,0x0320 },
00235 { 0x02f0,0x02f0,0x0310 },
00236 { 0x0300,0x02f0,0x0300 },
00237 { 0x0310,0x0300,0x02f0 },
00238 { 0x0340,0x0320,0x02f0 },
00239 { 0x0390,0x0350,0x02f0 },
00240 { 0x03e0,0x0390,0x0300 },
00241 { 0x0420,0x03e0,0x0310 },
00242 { 0x0460,0x0420,0x0330 },
00243 { 0x0490,0x0450,0x0350 },
00244 { 0x04a0,0x04a0,0x03c0 },
00245 { 0x0460,0x0490,0x0410 },
00246 { 0x0440,0x0460,0x0470 },
00247 { 0x0440,0x0440,0x04a0 },
00248 { 0x0520,0x0480,0x0460 },
00249 { 0x0800,0x0630,0x0440 },
00250 { 0x0840,0x0840,0x0450 },
00251 { 0x0840,0x0840,0x04e0 },
00252 };
00253
00254 const uint8_t ff_ac3_bap_tab[64]= {
00255 0, 1, 1, 1, 1, 1, 2, 2, 3, 3,
00256 3, 4, 4, 5, 5, 6, 6, 6, 6, 7,
00257 7, 7, 7, 8, 8, 8, 8, 9, 9, 9,
00258 9, 10, 10, 10, 10, 11, 11, 11, 11, 12,
00259 12, 12, 12, 13, 13, 13, 13, 14, 14, 14,
00260 14, 14, 14, 14, 14, 15, 15, 15, 15, 15,
00261 15, 15, 15, 15,
00262 };
00263
00264 const uint8_t ff_ac3_slow_decay_tab[4]={
00265 0x0f, 0x11, 0x13, 0x15,
00266 };
00267
00268 const uint8_t ff_ac3_fast_decay_tab[4]={
00269 0x3f, 0x53, 0x67, 0x7b,
00270 };
00271
00272 const uint16_t ff_ac3_slow_gain_tab[4]= {
00273 0x540, 0x4d8, 0x478, 0x410,
00274 };
00275
00276 const uint16_t ff_ac3_db_per_bit_tab[4]= {
00277 0x000, 0x700, 0x900, 0xb00,
00278 };
00279
00280 const int16_t ff_ac3_floor_tab[8]= {
00281 0x2f0, 0x2b0, 0x270, 0x230, 0x1f0, 0x170, 0x0f0, 0xf800,
00282 };
00283
00284 const uint16_t ff_ac3_fast_gain_tab[8]= {
00285 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400,
00286 };
00287
00288 const uint8_t ff_ac3_critical_band_size_tab[50]={
00289 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
00290 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
00291 3, 6, 6, 6, 6, 6, 6, 12, 12, 12, 12, 24, 24, 24, 24, 24
00292 };
00296 const uint16_t ff_eac3_default_chmap[8] = {
00297 AC3_CHMAP_L | AC3_CHMAP_R,
00298 AC3_CHMAP_C,
00299 AC3_CHMAP_L | AC3_CHMAP_R,
00300 AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R,
00301 AC3_CHMAP_L | AC3_CHMAP_R | AC3_CHMAP_C_SUR,
00302 AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R | AC3_CHMAP_C_SUR,
00303 AC3_CHMAP_L | AC3_CHMAP_R | AC3_CHMAP_L_SUR | AC3_CHMAP_R_SUR,
00304 AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R | AC3_CHMAP_L_SUR | AC3_CHMAP_R_SUR
00305 };