annotate atrac3data.h @ 5443:40c87c0f754b libavcodec

exchange for() and if() order in the MT_FRAME case safes 24 cpu cycles
author michael
date Wed, 01 Aug 2007 21:05:58 +0000
parents 3fd46e281bd8
children 1d83e9c34641
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4856
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
1 /*
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
2 * Atrac 3 compatible decoder data
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
3 * Copyright (c) 2006-2007 Maxim Poliakovski
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
4 * Copyright (c) 2006-2007 Benjamin Larsson
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
5 *
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
6 * This file is part of FFmpeg.
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
7 *
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
12 *
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
16 * Lesser General Public License for more details.
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
17 *
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
21 */
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
22
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
23 /**
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
24 * @file atrac3data.h
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
25 * Atrac 3 AKA RealAudio 8 compatible decoder data
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
26 */
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
27
5163
9ecbfc0c82bf add multiple inclusion guards to headers
mru
parents: 5162
diff changeset
28 #ifndef AVCODEC_ATRAC3DATA_H
9ecbfc0c82bf add multiple inclusion guards to headers
mru
parents: 5162
diff changeset
29 #define AVCODEC_ATRAC3DATA_H
9ecbfc0c82bf add multiple inclusion guards to headers
mru
parents: 5162
diff changeset
30
5162
4394344397d8 include all prerequisites in header files
mru
parents: 4856
diff changeset
31 #include <stdint.h>
4394344397d8 include all prerequisites in header files
mru
parents: 4856
diff changeset
32
4856
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
33 /* VLC tables */
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
34
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
35 static const uint8_t huffcode1[9] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
36 0x0,0x4,0x5,0xC,0xD,0x1C,0x1D,0x1E,0x1F,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
37 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
38
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
39 static const uint8_t huffbits1[9] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
40 1,3,3,4,4,5,5,5,5,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
41 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
42
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
43 static const uint8_t huffcode2[5] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
44 0x0,0x4,0x5,0x6,0x7,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
45 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
46
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
47 static const uint8_t huffbits2[5] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
48 1,3,3,3,3,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
49 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
50
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
51 static const uint8_t huffcode3[7] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
52 0x0,0x4,0x5,0xC,0xD,0xE,0xF,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
53 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
54
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
55 static const uint8_t huffbits3[7] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
56 1,3,3,4,4,4,4,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
57 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
58
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
59 static const uint8_t huffcode4[9] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
60 0x0,0x4,0x5,0xC,0xD,0x1C,0x1D,0x1E,0x1F,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
61 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
62
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
63 static const uint8_t huffbits4[9] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
64 1,3,3,4,4,5,5,5,5,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
65 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
66
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
67 static const uint8_t huffcode5[15] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
68 0x0,0x2,0x3,0x8,0x9,0xA,0xB,0x1C,0x1D,0x3C,0x3D,0x3E,0x3F,0xC,0xD,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
69 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
70
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
71 static const uint8_t huffbits5[15] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
72 2,3,3,4,4,4,4,5,5,6,6,6,6,4,4
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
73 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
74
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
75 static const uint8_t huffcode6[31] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
76 0x0,0x2,0x3,0x4,0x5,0x6,0x7,0x14,0x15,0x16,0x17,0x18,0x19,0x34,0x35,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
77 0x36,0x37,0x38,0x39,0x3A,0x3B,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,0x8,0x9,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
78 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
79
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
80 static const uint8_t huffbits6[31] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
81 3,4,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,4,4
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
82 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
83
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
84 static const uint8_t huffcode7[63] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
85 0x0,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,0x10,0x11,0x24,0x25,0x26,0x27,0x28,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
86 0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x68,0x69,0x6A,0x6B,0x6C,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
87 0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
88 0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,0x2,0x3,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
89 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
90
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
91 static const uint8_t huffbits7[63] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
92 3,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
93 7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,4,4
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
94 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
95
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
96 static const uint8_t huff_tab_sizes[7] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
97 9, 5, 7, 9, 15, 31, 63,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
98 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
99
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
100 static const uint8_t* huff_codes[7] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
101 huffcode1,huffcode2,huffcode3,huffcode4,huffcode5,huffcode6,huffcode7,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
102 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
103
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
104 static const uint8_t* huff_bits[7] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
105 huffbits1,huffbits2,huffbits3,huffbits4,huffbits5,huffbits6,huffbits7,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
106 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
107
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
108 /* selector tables */
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
109
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
110 static const uint8_t CLCLengthTab[8] = {0, 4, 3, 3, 4, 4, 5, 6};
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
111 static const int8_t seTab_0[4] = {0, 1, -2, -1};
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
112 static const int8_t decTable1[18] = {0,0, 0,1, 0,-1, 1,0, -1,0, 1,1, 1,-1, -1,1, -1,-1};
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
113
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
114
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
115 /* tables for the scalefactor decoding */
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
116
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
117 static const float iMaxQuant[8] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
118 0.0, 1.0/1.5, 1.0/2.5, 1.0/3.5, 1.0/4.5, 1.0/7.5, 1.0/15.5, 1.0/31.5
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
119 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
120
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
121 static const uint16_t subbandTab[33] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
122 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
123 256, 288, 320, 352, 384, 416, 448, 480, 512, 576, 640, 704, 768, 896, 1024
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
124 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
125
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
126 /* transform data */
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
127
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
128 static const float qmf_48tap_half[24] = {
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
129 -0.00001461907, -0.00009205479, -0.000056157569, 0.00030117269,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
130 0.0002422519,-0.00085293897, -0.0005205574, 0.0020340169,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
131 0.00078333891, -0.0042153862, -0.00075614988, 0.0078402944,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
132 -0.000061169922, -0.01344162, 0.0024626821, 0.021736089,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
133 -0.007801671, -0.034090221, 0.01880949, 0.054326009,
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
134 -0.043596379, -0.099384367, 0.13207909, 0.46424159
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
135 };
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
136
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
137 /* joint stereo related tables */
5af8895c2805 Atrac3 decoder.
banan
parents:
diff changeset
138 static const float matrixCoeffs[8] = {0.0, 2.0, 2.0, 2.0, 0.0, 0.0, 1.0, 1.0};
5163
9ecbfc0c82bf add multiple inclusion guards to headers
mru
parents: 5162
diff changeset
139
5169
3fd46e281bd8 add a comment to indicate which #endif belong to which #define
gpoirier
parents: 5163
diff changeset
140 #endif // AVCODEC_ATRAC3DATA_H