1 /*
2 * VC-1 and WMV3 decoder
3 * copyright (c) 2011 Mashiat Sarker Shakkhar
4 * copyright (c) 2006 Konstantin Shishkov
5 * (c) 2005 anonymous, Alex Beregszaszi, Michael Niedermayer
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 /**
25 * @file
26 * VC-1 tables.
27 */
28
32
33 /** Table for conversion between TTBLK and TTMB */
38 };
39
41
42 /** MV P mode - the 5th element is only used for mode 1 */
46 };
50 };
51
52 /* MBMODE table for interlaced frame P-picture */
54 { /* 1: 4-MV, 0: non-4-MV */
55 /* Type, FIELDTX, 1-MV Differential present, Residuals (CBP) present */
56 /* Table 164 - Table 167 */
66 },
67 {
68 /* Table 160 - Table 163 */
84 }
85 };
86
90 /* Implicit quantizer */
91 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 11, 12,
92 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 29, 31 },
93 /* Explicit quantizer, pquantizer uniform */
94 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
95 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 },
96 /* Explicit quantizer, pquantizer non-uniform */
97 { 0, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
98 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 31 }
99 };
100
101 /** @name VC-1 VLC tables
102 * @todo TODO move this into the context
103 */
104 //@{
108 /* Could be optimized, one table only needs 8 bits */
123
125
126 //@}
127
128
129 #if B_FRACTION_DEN == 840 // original bfraction from vc9data.h, not conforming to standard
130 /* bfraction is fractional, we scale to the GCD 3*5*7*8 = 840 */
132 420 /*1/2*/, 280 /*1/3*/, 560 /*2/3*/, 210 /*1/4*/,
133 630 /*3/4*/, 168 /*1/5*/, 336 /*2/5*/,
134 504 /*3/5*/, 672 /*4/5*/, 140 /*1/6*/, 700 /*5/6*/,
135 120 /*1/7*/, 240 /*2/7*/, 360 /*3/7*/, 480 /*4/7*/,
136 600 /*5/7*/, 720 /*6/7*/, 105 /*1/8*/, 315 /*3/8*/,
137 525 /*5/8*/, 735 /*7/8*/,
138 -1 /*inv.*/, 0 /*BI fm*/
139 };
140 #else
141 /* pre-computed scales for all bfractions and base=256 */
143 128 /*1/2*/, 85 /*1/3*/, 170 /*2/3*/, 64 /*1/4*/,
144 192 /*3/4*/, 51 /*1/5*/, 102 /*2/5*/,
145 153 /*3/5*/, 204 /*4/5*/, 43 /*1/6*/, 215 /*5/6*/,
146 37 /*1/7*/, 74 /*2/7*/, 111 /*3/7*/, 148 /*4/7*/,
147 185 /*5/7*/, 222 /*6/7*/, 32 /*1/8*/, 96 /*3/8*/,
148 160 /*5/8*/, 224 /*7/8*/,
149 -1 /*inv.*/, 0 /*BI fm*/
150 };
151 #endif
152
153 //Same as H.264
155 { 0, 1 },
156 { 1, 1 },
157 { 12, 11 },
158 { 10, 11 },
159 { 16, 11 },
160 { 40, 33 },
161 { 24, 11 },
162 { 20, 11 },
163 { 32, 11 },
164 { 80, 33 },
165 { 18, 11 },
166 { 15, 11 },
167 { 64, 33 },
168 { 160, 99 },
169 { 0, 1 },
170 { 0, 1 }
171 };
172
174 0, 2, 4, 8, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13,
175 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21
176 };
177
178
179 /* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */
180
181 /* Table 232 */
183 0, 8, 16, 1,
184 9, 24, 17, 2,
185 10, 18, 25, 3,
186 11, 26, 19, 27
187 };
188
190 0, 8, 1, 16, 2, 9, 10, 3,
191 24, 17, 4, 11, 18, 12, 5, 19,
192 25, 13, 20, 26, 27, 6, 21, 28,
193 14, 22, 29, 7, 30, 15, 23, 31
194 };
195
197 0, 1, 8, 2,
198 9, 16, 17, 24,
199 10, 32, 25, 18,
200 40, 3, 33, 26,
201 48, 11, 56, 41,
202 34, 49, 57, 42,
203 19, 50, 27, 58,
204 35, 43, 51, 59
205 };
206
208 0, 8, 1, 16, 24, 9, 2, 32,
209 40, 48, 56, 17, 10, 3, 25, 18,
210 11, 4, 33, 41, 49, 57, 26, 34,
211 42, 50, 58, 19, 12, 5, 27, 20,
212 13, 6, 35, 28, 21, 14, 7, 15,
213 22, 29, 36, 43, 51, 59, 60, 52,
214 44, 37, 30, 23, 31, 38, 45, 53,
215 61, 62, 54, 46, 39, 47, 55, 63
216 };
217
219 0, 8, 16, 24, 1, 9, 2, 17,
220 25, 10, 3, 18, 26, 4, 11, 19,
221 12, 5, 13, 20, 27, 6, 21, 28,
222 14, 22, 29, 7, 30, 15, 23, 31
223 };
224
226 0, 1, 2, 8,
227 16, 9, 24, 17,
228 10, 3, 32, 40,
229 48, 56, 25, 18,
230 33, 26, 41, 34,
231 49, 57, 11, 42,
232 19, 50, 27, 58,
233 35, 43, 51, 59
234 };
235
237 0, 8, 16, 24,
238 1, 9, 17, 2,
239 25, 10, 18, 3,
240 26, 11, 19, 27
241 };
242
243
244 /* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */
246 0x40000, 0x20000, 0x15555, 0x10000, 0xCCCD, 0xAAAB, 0x9249, 0x8000,
247 0x71C7, 0x6666, 0x5D17, 0x5555, 0x4EC5, 0x4925, 0x4444, 0x4000,
248 0x3C3C, 0x38E4, 0x35E5, 0x3333, 0x30C3, 0x2E8C, 0x2C86, 0x2AAB,
249 0x28F6, 0x2762, 0x25ED, 0x2492, 0x234F, 0x2222, 0x2108, 0x2000,
250 0x1F08, 0x1E1E, 0x1D42, 0x1C72, 0x1BAD, 0x1AF3, 0x1A42, 0x199A,
251 0x18FA, 0x1862, 0x17D0, 0x1746, 0x16C1, 0x1643, 0x15CA, 0x1555,
252 0x14E6, 0x147B, 0x1414, 0x13B1, 0x1352, 0x12F7, 0x129E, 0x1249,
253 0x11F7, 0x11A8, 0x115B, 0x1111, 0x10C9, 0x1084, 0x1041
254 };
255
256 /* P Interlaced field picture MV predictor scaling values (Table 114) */
258 // Refdist:
259 // 0 1 2 3 or greater
260 { // current field is first
261 { 128, 192, 213, 224 }, // SCALEOPP
262 { 512, 341, 307, 293 }, // SCALESAME1
263 { 219, 236, 242, 245 }, // SCALESAME2
264 { 32, 48, 53, 56 }, // SCALEZONE1_X
265 { 8, 12, 13, 14 }, // SCALEZONE1_Y
266 { 37, 20, 14, 11 }, // ZONE1OFFSET_X
267 { 10, 5, 4, 3 } // ZONE1OFFSET_Y
268 },
269 { // current field is second
270 { 128, 64, 43, 32 }, // SCALEOPP
271 { 512, 1024, 1536, 2048 }, // SCALESAME1
272 { 219, 204, 200, 198 }, // SCALESAME2
273 { 32, 16, 11, 8 }, // SCALEZONE1_X
274 { 8, 4, 3, 2 }, // SCALEZONE1_Y
275 { 37, 52, 56, 58 }, // ZONE1OFFSET_X
276 { 10, 13, 14, 15 } // ZONE1OFFSET_Y
277 }
278 };
279
280 /* B Interlaced field picture backward MV predictor scaling values for first field (Table 115) */
282 // BRFD:
283 // 0 1 2 3 or greater
284 { 171, 205, 219, 228 }, // SCALESAME
285 { 384, 320, 299, 288 }, // SCALEOPP1
286 { 230, 239, 244, 246 }, // SCALEOPP2
287 { 43, 51, 55, 57 }, // SCALEZONE1_X
288 { 11, 13, 14, 14 }, // SCALEZONE1_Y
289 { 26, 17, 12, 10 }, // ZONE1OFFSET_X
290 { 7, 4, 3, 3 } // ZONE1OFFSET_Y
291 };