2 * Quant and Weight for DV codec
3 * Copyright (c) 2002 Fabrice Bellard
5 * This file is part of Libav.
7 * Libav is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * Libav is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with Libav; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 * Constants for DV codec.
27 #ifndef AVCODEC_DVQUANT_H
28 #define AVCODEC_DVQUANT_H
32 /* unquant tables (not used directly) */
33 static const uint8_t dv_quant_shifts[22][4] = {
58 static const uint8_t dv_quant_offset[4] = { 6, 3, 0, 1 };
59 static const uint8_t dv_quant_areas[4] = { 6, 21, 43, 64 };
61 /* quantization quanta by QNO for DV100 */
62 static const uint8_t dv100_qstep[16] = {
63 1, /* QNO = 0 and 1 both have no quantization */
65 2, 3, 4, 5, 6, 7, 8, 16, 18, 20, 22, 24, 28, 52
68 /* DV25/50 DCT coefficient weights and inverse weights */
69 /* created by dvtables.py */
70 static const int dv_weight_bits = 18;
71 static const int dv_weight_88[64] = {
72 131072, 257107, 257107, 242189, 252167, 242189, 235923, 237536,
73 237536, 235923, 229376, 231390, 223754, 231390, 229376, 222935,
74 224969, 217965, 217965, 224969, 222935, 200636, 218652, 211916,
75 212325, 211916, 218652, 200636, 188995, 196781, 205965, 206433,
76 206433, 205965, 196781, 188995, 185364, 185364, 200636, 200704,
77 200636, 185364, 185364, 174609, 180568, 195068, 195068, 180568,
78 174609, 170091, 175557, 189591, 175557, 170091, 165371, 170627,
79 170627, 165371, 160727, 153560, 160727, 144651, 144651, 136258,
81 static const int dv_weight_248[64] = {
82 131072, 242189, 257107, 237536, 229376, 200636, 242189, 223754,
83 224969, 196781, 262144, 242189, 229376, 200636, 257107, 237536,
84 211916, 185364, 235923, 217965, 229376, 211916, 206433, 180568,
85 242189, 223754, 224969, 196781, 211916, 185364, 235923, 217965,
86 200704, 175557, 222935, 205965, 200636, 185364, 195068, 170627,
87 229376, 211916, 206433, 180568, 200704, 175557, 222935, 205965,
88 175557, 153560, 188995, 174609, 165371, 144651, 200636, 185364,
89 195068, 170627, 175557, 153560, 188995, 174609, 165371, 144651,
91 static const int dv_iweight_bits = 14;
92 static const int dv_iweight_88[64] = {
93 32768, 16710, 16710, 17735, 17015, 17735, 18197, 18079,
94 18079, 18197, 18725, 18559, 19196, 18559, 18725, 19284,
95 19108, 19692, 19692, 19108, 19284, 21400, 19645, 20262,
96 20214, 20262, 19645, 21400, 22733, 21845, 20867, 20815,
97 20815, 20867, 21845, 22733, 23173, 23173, 21400, 21400,
98 21400, 23173, 23173, 24600, 23764, 22017, 22017, 23764,
99 24600, 25267, 24457, 22672, 24457, 25267, 25971, 25191,
100 25191, 25971, 26715, 27962, 26715, 29642, 29642, 31536,
102 static const int dv_iweight_248[64] = {
103 32768, 17735, 16710, 18079, 18725, 21400, 17735, 19196,
104 19108, 21845, 16384, 17735, 18725, 21400, 16710, 18079,
105 20262, 23173, 18197, 19692, 18725, 20262, 20815, 23764,
106 17735, 19196, 19108, 21845, 20262, 23173, 18197, 19692,
107 21400, 24457, 19284, 20867, 21400, 23173, 22017, 25191,
108 18725, 20262, 20815, 23764, 21400, 24457, 19284, 20867,
109 24457, 27962, 22733, 24600, 25971, 29642, 21400, 23173,
110 22017, 25191, 24457, 27962, 22733, 24600, 25971, 29642,
114 * The "inverse" DV100 weights are actually just the spec weights (zig-zagged).
116 static const int dv_iweight_1080_y[64] = {
117 128, 16, 16, 17, 17, 17, 18, 18,
118 18, 18, 18, 18, 19, 18, 18, 19,
119 19, 19, 19, 19, 19, 42, 38, 40,
120 40, 40, 38, 42, 44, 43, 41, 41,
121 41, 41, 43, 44, 45, 45, 42, 42,
122 42, 45, 45, 48, 46, 43, 43, 46,
123 48, 49, 48, 44, 48, 49, 101, 98,
124 98, 101, 104, 109, 104, 116, 116, 123,
126 static const int dv_iweight_1080_c[64] = {
127 128, 16, 16, 17, 17, 17, 25, 25,
128 25, 25, 26, 25, 26, 25, 26, 26,
129 26, 27, 27, 26, 26, 42, 38, 40,
130 40, 40, 38, 42, 44, 43, 41, 41,
131 41, 41, 43, 44, 91, 91, 84, 84,
132 84, 91, 91, 96, 93, 86, 86, 93,
133 96, 197, 191, 177, 191, 197, 203, 197,
134 197, 203, 209, 219, 209, 232, 232, 246,
136 static const int dv_iweight_720_y[64] = {
137 128, 16, 16, 17, 17, 17, 18, 18,
138 18, 18, 18, 18, 19, 18, 18, 19,
139 19, 19, 19, 19, 19, 42, 38, 40,
140 40, 40, 38, 42, 44, 43, 41, 41,
141 41, 41, 43, 44, 68, 68, 63, 63,
142 63, 68, 68, 96, 92, 86, 86, 92,
143 96, 98, 96, 88, 96, 98, 202, 196,
144 196, 202, 208, 218, 208, 232, 232, 246,
146 static const int dv_iweight_720_c[64] = {
147 128, 24, 24, 26, 26, 26, 36, 36,
148 36, 36, 36, 36, 38, 36, 36, 38,
149 38, 38, 38, 38, 38, 84, 76, 80,
150 80, 80, 76, 84, 88, 86, 82, 82,
151 82, 82, 86, 88, 182, 182, 168, 168,
152 168, 182, 182, 192, 186, 192, 172, 186,
153 192, 394, 382, 354, 382, 394, 406, 394,
154 394, 406, 418, 438, 418, 464, 464, 492,
157 #endif /* AVCODEC_DVQUANT_H */