1
/*************************************************************************
3
This software module was originally developed by
5
Ming-Chieh Lee (mingcl@microsoft.com), Microsoft Corporation
6
Wei-ge Chen (wchen@microsoft.com), Microsoft Corporation
7
Bruce Lin (blin@microsoft.com), Microsoft Corporation
8
Chuang Gu (chuanggu@microsoft.com), Microsoft Corporation
12
Yoshihiro Kikuchi (TOSHIBA CORPORATION)
13
Takeshi Nagai (TOSHIBA CORPORATION)
14
Toshiaki Watanabe (TOSHIBA CORPORATION)
15
Noboru Yamaguchi (TOSHIBA CORPORATION)
18
Mathias Wien (wien@ient.rwth-aachen.de) RWTH Aachen / Robert BOSCH GmbH
24
Fujitsu Laboratories Ltd. (contact: Eishi Morimatsu)
25
Sehoon Son (shson@unitel.co.kr) Samsung AIT
27
in the course of development of the MPEG-4 Video (ISO/IEC 14496-2).
28
This software module is an implementation of a part of one or more MPEG-4 Video tools
29
as specified by the MPEG-4 Video.
30
ISO/IEC gives users of the MPEG-4 Video free license to this software module or modifications
31
thereof for use in hardware or software products claiming conformance to the MPEG-4 Video.
32
Those intending to use this software module in hardware or software products are advised that its use may infringe existing patents.
33
The original developer of this software module and his/her company,
34
the subsequent editors and their companies,
35
and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation.
36
Copyright is not released for non MPEG-4 Video conforming products.
37
Microsoft retains full right to use the code for his/her own purpose,
38
assign or donate the code to a third party and to inhibit third parties from using the code for non <MPEG standard> conforming products.
39
This copyright notice must be included in all copies or derivative works.
41
Copyright (c) 1996, 1997.
44
Aug.24, 1999 : NEWPRED added by Hideaki Kimata (NTT)
45
Sep.06 1999 : RRV added by Eishi Morimatsu (Fujitsu Laboratories Ltd.)
46
*************************************************************************/
54
// global tables for overlap motion comp.
60
class CNewPredEncoder;
61
class CNewPredDecoder;
62
CNewPredEncoder* g_pNewPredEnc;
63
CNewPredDecoder* g_pNewPredDec;
110
UInt gWghtL[8][8] = {
122
UInt gWghtC_RRV[16][16] = {
123
{4,4,5,5,5,5,5,5,5,5,5,5,5,5,4,4},
124
{4,4,5,5,5,5,5,5,5,5,5,5,5,5,4,4},
125
{5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5},
126
{5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5},
127
{5,5,5,5,6,6,6,6,6,6,6,6,5,5,5,5},
128
{5,5,5,5,6,6,6,6,6,6,6,6,5,5,5,5},
129
{5,5,5,5,6,6,6,6,6,6,6,6,5,5,5,5},
130
{5,5,5,5,6,6,6,6,6,6,6,6,5,5,5,5},
131
{5,5,5,5,6,6,6,6,6,6,6,6,5,5,5,5},
132
{5,5,5,5,6,6,6,6,6,6,6,6,5,5,5,5},
133
{5,5,5,5,6,6,6,6,6,6,6,6,5,5,5,5},
134
{5,5,5,5,6,6,6,6,6,6,6,6,5,5,5,5},
135
{5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5},
136
{5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5},
137
{4,4,5,5,5,5,5,5,5,5,5,5,5,5,4,4},
138
{4,4,5,5,5,5,5,5,5,5,5,5,5,5,4,4},
141
UInt gWghtT_RRV[16][16] = {
142
{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
143
{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
144
{1,1,1,1,2,2,2,2,2,2,2,2,1,1,1,1},
145
{1,1,1,1,2,2,2,2,2,2,2,2,1,1,1,1},
146
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
147
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
148
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
149
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
150
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
151
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
152
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
153
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
154
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
155
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
156
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
157
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
160
UInt gWghtB_RRV[16][16] = {
161
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
162
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
163
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
164
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
165
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
166
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
167
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
168
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
169
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
170
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
171
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
172
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
173
{1,1,1,1,2,2,2,2,2,2,2,2,1,1,1,1},
174
{1,1,1,1,2,2,2,2,2,2,2,2,1,1,1,1},
175
{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
176
{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2},
179
UInt gWghtR_RRV[16][16] = {
180
{0,0,0,0,0,0,0,0,1,1,1,1,1,1,2,2},
181
{0,0,0,0,0,0,0,0,1,1,1,1,1,1,2,2},
182
{0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2},
183
{0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2},
184
{0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2},
185
{0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2},
186
{0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2},
187
{0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2},
188
{0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2},
189
{0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2},
190
{0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2},
191
{0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2},
192
{0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2},
193
{0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2},
194
{0,0,0,0,0,0,0,0,1,1,1,1,1,1,2,2},
195
{0,0,0,0,0,0,0,0,1,1,1,1,1,1,2,2},
198
UInt gWghtL_RRV[16][16] = {
199
{2,2,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
200
{2,2,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
201
{2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0},
202
{2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0},
203
{2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0},
204
{2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0},
205
{2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0},
206
{2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0},
207
{2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0},
208
{2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0},
209
{2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0},
210
{2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0},
211
{2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0},
212
{2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0},
213
{2,2,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
214
{2,2,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
218
// rounding table for Chrominace mv; see VM1.1/Table ?
219
Int grgiMvRound16 [16] = {
220
0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
222
Int grgiMvRound12 [12] = {
223
0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2,
225
Int grgiMvRound8 [8] = {
226
0, 0, 1, 1, 1, 1, 1, 2,
228
Int grgiMvRound4 [4] ={
233
//index of candidate blocks for diffrential mv coding
234
BlockNum gIndexOfCandBlk[5][3] = {
235
{Y_BLOCK2, Y_BLOCK3, Y_BLOCK3},
236
{Y_BLOCK2, Y_BLOCK3, Y_BLOCK3},
237
{Y_BLOCK1, Y_BLOCK4, Y_BLOCK3},
238
{Y_BLOCK4, Y_BLOCK1, Y_BLOCK2},
239
{Y_BLOCK3, Y_BLOCK1, Y_BLOCK2}};
241
//MPEG quantizer matrix
242
Int rgiDefaultIntraQMatrix [BLOCK_SQUARE_SIZE] = {
243
8, 17, 18, 19, 21, 23, 25, 27,
244
17, 18, 19, 21, 23, 25, 27, 28,
245
20, 21, 22, 23, 24, 26, 28, 30,
246
21, 22, 23, 24, 26, 28, 30, 32,
247
22, 23, 24, 26, 28, 30, 32, 35,
248
23, 24, 26, 28, 30, 32, 35, 38,
249
25, 26, 28, 30, 32, 35, 38, 41,
250
27, 28, 30, 32, 35, 38, 41, 45
253
Int rgiDefaultInterQMatrix [BLOCK_SQUARE_SIZE] = {
254
16, 17, 18, 19, 20, 21, 22, 23,
255
17, 18, 19, 20, 21, 22, 23, 24,
256
18, 19, 20, 21, 22, 23, 24, 25,
257
19, 20, 21, 22, 23, 24, 26, 27,
258
20, 21, 22, 23, 25, 26, 27, 28,
259
21, 22, 23, 24, 26, 27, 28, 30,
260
22, 23, 24, 26, 27, 28, 30, 31,
261
23, 24, 25, 27, 28, 30, 31, 33
264
Int rgiDefaultIntraQMatrixAlpha [BLOCK_SQUARE_SIZE] = {
265
8, 17, 18, 19, 21, 23, 25, 27,
266
17, 18, 19, 21, 23, 25, 27, 28,
267
20, 21, 22, 23, 24, 26, 28, 30,
268
21, 22, 23, 24, 26, 28, 30, 32,
269
22, 23, 24, 26, 28, 30, 32, 35,
270
23, 24, 26, 28, 30, 32, 35, 38,
271
25, 26, 28, 30, 32, 35, 38, 41,
272
27, 28, 30, 32, 35, 38, 41, 45
275
Int rgiDefaultInterQMatrixAlpha [BLOCK_SQUARE_SIZE] = {
276
16, 17, 18, 19, 20, 21, 22, 23,
277
17, 18, 19, 20, 21, 22, 23, 24,
278
18, 19, 20, 21, 22, 23, 24, 25,
279
19, 20, 21, 22, 23, 24, 26, 27,
280
20, 21, 22, 23, 25, 26, 27, 28,
281
21, 22, 23, 24, 26, 27, 28, 30,
282
22, 23, 24, 26, 27, 28, 30, 31,
283
23, 24, 25, 27, 28, 30, 31, 33
288
Int rgiDefaultIntraQMatrix [BLOCK_SQUARE_SIZE] = {
289
16, 16, 16, 16, 16, 16, 16, 16,
290
16, 16, 16, 16, 16, 16, 16, 16,
291
16, 16, 16, 16, 16, 16, 16, 16,
292
16, 16, 16, 16, 16, 16, 16, 16,
293
16, 16, 16, 16, 16, 16, 16, 16,
294
16, 16, 16, 16, 16, 16, 16, 16,
295
16, 16, 16, 16, 16, 16, 16, 16,
296
16, 16, 16, 16, 16, 16, 16, 16
299
Int rgiDefaultInterQMatrix [BLOCK_SQUARE_SIZE] = {
300
16, 16, 16, 16, 16, 16, 16, 16,
301
16, 16, 16, 16, 16, 16, 16, 16,
302
16, 16, 16, 16, 16, 16, 16, 16,
303
16, 16, 16, 16, 16, 16, 16, 16,
304
16, 16, 16, 16, 16, 16, 16, 16,
305
16, 16, 16, 16, 16, 16, 16, 16,
306
16, 16, 16, 16, 16, 16, 16, 16,
307
16, 16, 16, 16, 16, 16, 16, 16
310
Int grgiStandardZigzag [BLOCK_SQUARE_SIZE] = {
311
0, 1, 8, 16, 9, 2, 3, 10,
312
17, 24, 32, 25, 18, 11, 4, 5,
313
12, 19, 26, 33, 40, 48, 41, 34,
314
27, 20, 13, 6, 7, 14, 21, 28,
315
35, 42, 49, 56, 57, 50, 43, 36,
316
29, 22, 15, 23, 30, 37, 44, 51,
317
58, 59, 52, 45, 38, 31, 39, 46,
318
53, 60, 61, 54, 47, 55, 62, 63
321
Int grgiHorizontalZigzag [BLOCK_SQUARE_SIZE] = {
322
0, 1, 2, 3, 8, 9, 16, 17,
323
10, 11, 4, 5, 6, 7, 15, 14,
324
13, 12, 19, 18, 24, 25, 32, 33,
325
26, 27, 20, 21, 22, 23, 28, 29,
326
30, 31, 34, 35, 40, 41, 48, 49,
327
42, 43, 36, 37, 38, 39, 44, 45,
328
46, 47, 50, 51, 56, 57, 58, 59,
329
52, 53, 54, 55, 60, 61, 62, 63
332
Int grgiVerticalZigzag [BLOCK_SQUARE_SIZE] = {
333
0, 8, 16, 24, 1, 9, 2, 10,
334
17, 25, 32, 40, 48, 56, 57, 49,
335
41, 33, 26, 18, 3, 11, 4, 12,
336
19, 27, 34, 42, 50, 58, 35, 43,
337
51, 59, 20, 28, 5, 13, 6, 14,
338
21, 29, 36, 44, 52, 60, 37, 45,
339
53, 61, 22, 30, 7, 15, 23, 31,
340
38, 46, 54, 62, 39, 47, 55, 63
343
UInt grgIfNotLastNumOfLevelAtRun [27] = {
344
12, 6, 4, 3, 3, 3, 3, 2, 2, 2, 2,
345
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
349
UInt grgIfLastNumOfLevelAtRun [41] = {
350
3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
351
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
352
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
353
1, 1, 1, 1, 1, 1, 1, 1
356
UInt grgiIntraYAVCLHashingTable [102] = {
357
1, 3, 6, 9, 10, 13, 14, 17, 18, 21,
358
22, 23, 2, 34, 11, 19, 24, 25, 33, 12,
359
20, 26, 4, 15, 39, 5, 130, 27, 65, 68,
360
41, 7, 100, 195, 8, 131, 97, 258, 129,
361
163, 35, 42, 66, 225, 36, 98, 16, 37,
362
38, 67, 99, 162, 194, 226, 40, 290, 69,
363
227, 1025, 353, 1030, 1057, 1031, 1089, 161,
364
1026, 1185, 193, 1121, 1153, 1313, 257, 289,
365
321, 1027, 1217, 1249, 1281, 385, 1028, 1058,
366
1345, 1377, 1409, 1441, 1473, 417, 1029, 1059,
367
1090, 1122, 1154, 1505, 1537, 449, 1032, 1186,
368
1218, 1569, 1601, 1633, 1665};
370
Int g_rgiLMAXintra [128] ={27, 10, 5, 4, 3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 1, 0,
371
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
372
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
373
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
374
8, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
375
1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
376
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
377
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
379
Int g_rgiRMAXintra [64] = {0, 15,10, 8, 4, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1,
380
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
381
0, 21, 7, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
382
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
384
Int g_rgiLMAXinter [128] = {12, 6, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1,
385
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
386
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
387
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
388
3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
389
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
390
1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
391
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
393
Int g_rgiRMAXinter [64] = {0, 27, 11, 7, 3, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0,
394
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
395
0, 41, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
396
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,};
398
U16 gCAEintraProb [1024] = {
399
65267,16468,65003,17912,64573,8556,64252,5653,
400
40174,3932,29789,277,45152,1140,32768,2043,
401
4499,80,6554,1144,21065,465,32768,799,
402
5482,183,7282,264,5336,99,6554,563,
403
54784,30201,58254,9879,54613,3069,32768,58495,
404
32768,32768,32768,2849,58982,54613,32768,12892,
405
31006,1332,49152,3287,60075,350,32768,712,
406
39322,760,32768,354,52659,432,61854,150,
407
64999,28362,65323,42521,63572,32768,63677,18319,
408
4910,32768,64238,434,53248,32768,61865,13590,
409
16384,32768,13107,333,32768,32768,32768,32768,
410
32768,32768,1074,780,25058,5461,6697,233,
411
62949,30247,63702,24638,59578,32768,32768,42257,
412
32768,32768,49152,546,62557,32768,54613,19258,
413
62405,32569,64600,865,60495,10923,32768,898,
414
34193,24576,64111,341,47492,5231,55474,591,
415
65114,60075,64080,5334,65448,61882,64543,13209,
416
54906,16384,35289,4933,48645,9614,55351,7318,
417
49807,54613,32768,32768,50972,32768,32768,32768,
418
15159,1928,2048,171,3093,8,6096,74,
419
32768,60855,32768,32768,32768,32768,32768,32768,
420
32768,32768,32768,32768,32768,55454,32768,57672,
421
32768,16384,32768,21845,32768,32768,32768,32768,
422
32768,32768,32768,5041,28440,91,32768,45,
423
65124,10923,64874,5041,65429,57344,63435,48060,
424
61440,32768,63488,24887,59688,3277,63918,14021,
425
32768,32768,32768,32768,32768,32768,32768,32768,
426
690,32768,32768,1456,32768,32768,8192,728,
427
32768,32768,58982,17944,65237,54613,32768,2242,
428
32768,32768,32768,42130,49152,57344,58254,16740,
429
32768,10923,54613,182,32768,32768,32768,7282,
430
49152,32768,32768,5041,63295,1394,55188,77,
431
63672,6554,54613,49152,64558,32768,32768,5461,
432
64142,32768,32768,32768,62415,32768,32768,16384,
433
1481,438,19661,840,33654,3121,64425,6554,
434
4178,2048,32768,2260,5226,1680,32768,565,
435
60075,32768,32768,32768,32768,32768,32768,32768,
436
32768,32768,32768,32768,32768,32768,32768,32768,
437
16384,261,32768,412,16384,636,32768,4369,
438
23406,4328,32768,524,15604,560,32768,676,
439
49152,32768,49152,32768,32768,32768,64572,32768,
440
32768,32768,54613,32768,32768,32768,32768,32768,
441
4681,32768,5617,851,32768,32768,59578,32768,
442
32768,32768,3121,3121,49152,32768,6554,10923,
443
32768,32768,54613,14043,32768,32768,32768,3449,
444
32768,32768,32768,32768,32768,32768,32768,32768,
445
57344,32768,57344,3449,32768,32768,32768,3855,
446
58982,10923,32768,239,62259,32768,49152,85,
447
58778,23831,62888,20922,64311,8192,60075,575,
448
59714,32768,57344,40960,62107,4096,61943,3921,
449
39862,15338,32768,1524,45123,5958,32768,58982,
450
6669,930,1170,1043,7385,44,8813,5011,
451
59578,29789,54613,32768,32768,32768,32768,32768,
452
32768,32768,32768,32768,58254,56174,32768,32768,
453
64080,25891,49152,22528,32768,2731,32768,10923,
454
10923,3283,32768,1748,17827,77,32768,108,
455
62805,32768,62013,42612,32768,32768,61681,16384,
456
58982,60075,62313,58982,65279,58982,62694,62174,
457
32768,32768,10923,950,32768,32768,32768,32768,
458
5958,32768,38551,1092,11012,39322,13705,2072,
459
54613,32768,32768,11398,32768,32768,32768,145,
460
32768,32768,32768,29789,60855,32768,61681,54792,
461
32768,32768,32768,17348,32768,32768,32768,8192,
462
57344,16384,32768,3582,52581,580,24030,303,
463
62673,37266,65374,6197,62017,32768,49152,299,
464
54613,32768,32768,32768,35234,119,32768,3855,
465
31949,32768,32768,49152,16384,32768,32768,32768,
466
24576,32768,49152,32768,17476,32768,32768,57445,
467
51200,50864,54613,27949,60075,20480,32768,57344,
468
32768,32768,32768,32768,32768,45875,32768,32768,
469
11498,3244,24576,482,16384,1150,32768,16384,
470
7992,215,32768,1150,23593,927,32768,993,
471
65353,32768,65465,46741,41870,32768,64596,59578,
472
62087,32768,12619,23406,11833,32768,47720,17476,
473
32768,32768,2621,6554,32768,32768,32768,32768,
474
32768,32768,5041,32768,16384,32768,4096,2731,
475
63212,43526,65442,47124,65410,35747,60304,55858,
476
60855,58982,60075,19859,35747,63015,64470,25432,
477
58689,1118,64717,1339,24576,32768,32768,1257,
478
53297,1928,32768,33,52067,3511,62861,453,
479
64613,32768,32768,32768,64558,32768,32768,2731,
480
49152,32768,32768,32768,61534,32768,32768,35747,
481
32768,32768,32768,32768,13107,32768,32768,32768,
482
32768,32768,32768,32768,20480,32768,32768,32768,
483
32768,32768,32768,54613,40960,5041,32768,32768,
484
32768,32768,32768,3277,64263,57592,32768,3121,
485
32768,32768,32768,32768,32768,10923,32768,32768,
486
32768,8192,32768,32768,5461,6899,32768,1725,
487
63351,3855,63608,29127,62415,7282,64626,60855,
488
32768,32768,60075,5958,44961,32768,61866,53718,
489
32768,32768,32768,32768,32768,32768,6554,32768,
490
32768,32768,32768,32768,2521,978,32768,1489,
491
58254,32768,58982,61745,21845,32768,54613,58655,
492
60075,32768,49152,16274,50412,64344,61643,43987,
493
32768,32768,32768,1638,32768,32768,32768,24966,
494
54613,32768,32768,2427,46951,32768,17970,654,
495
65385,27307,60075,26472,64479,32768,32768,4681,
496
61895,32768,32768,16384,58254,32768,32768,6554,
497
37630,3277,54613,6554,4965,5958,4681,32768,
498
42765,16384,32768,21845,22827,16384,32768,6554,
499
65297,64769,60855,12743,63195,16384,32768,37942,
500
32768,32768,32768,32768,60075,32768,62087,54613,
501
41764,2161,21845,1836,17284,5424,10923,1680,
502
11019,555,32768,431,39819,907,32768,171,
503
65480,32768,64435,33803,2595,32768,57041,32768,
504
61167,32768,32768,32768,32768,32768,32768,1796,
505
60855,32768,17246,978,32768,32768,8192,32768,
506
32768,32768,14043,2849,32768,2979,6554,6554,
507
65507,62415,65384,61891,65273,58982,65461,55097,
508
32768,32768,32768,55606,32768,2979,3745,16913,
509
61885,13827,60893,12196,60855,53248,51493,11243,
510
56656,783,55563,143,63432,7106,52429,445,
511
65485,1031,65020,1380,65180,57344,65162,36536,
512
61154,6554,26569,2341,63593,3449,65102,533,
513
47827,2913,57344,3449,35688,1337,32768,22938,
514
25012,910,7944,1008,29319,607,64466,4202,
515
64549,57301,49152,20025,63351,61167,32768,45542,
516
58982,14564,32768,9362,61895,44840,32768,26385,
517
59664,17135,60855,13291,40050,12252,32768,7816,
518
25798,1850,60495,2662,18707,122,52538,231,
519
65332,32768,65210,21693,65113,6554,65141,39667,
520
62259,32768,22258,1337,63636,32768,64255,52429,
521
60362,32768,6780,819,16384,32768,16384,4681,
522
49152,32768,8985,2521,24410,683,21535,16585,
523
65416,46091,65292,58328,64626,32768,65016,39897,
524
62687,47332,62805,28948,64284,53620,52870,49567,
525
65032,31174,63022,28312,64299,46811,48009,31453,
526
61207,7077,50299,1514,60047,2634,46488,235
529
U16 gCAEinterProb [512] = {
530
65532,62970,65148,54613,62470,8192,62577,8937,
531
65480,64335,65195,53248,65322,62518,62891,38312,
532
65075,53405,63980,58982,32768,32768,54613,32768,
533
65238,60009,60075,32768,59294,19661,61203,13107,
534
63000,9830,62566,58982,11565,32768,25215,3277,
535
53620,50972,63109,43691,54613,32768,39671,17129,
536
59788,6068,43336,27913,6554,32768,12178,1771,
537
56174,49152,60075,43691,58254,16384,49152,9930,
538
23130,7282,40960,32768,10923,32768,32768,32768,
539
27307,32768,32768,32768,32768,32768,32768,32768,
540
36285,12511,10923,32768,45875,16384,32768,32768,
541
16384,23831,4369,32768,8192,10923,32768,32768,
542
10175,2979,18978,10923,54613,32768,6242,6554,
543
1820,10923,32768,32768,32768,32768,32768,5461,
544
28459,593,11886,2030,3121,4681,1292,112,
545
42130,23831,49152,29127,32768,6554,5461,2048,
546
65331,64600,63811,63314,42130,19661,49152,32768,
547
65417,64609,62415,64617,64276,44256,61068,36713,
548
64887,57525,53620,61375,32768,8192,57344,6554,
549
63608,49809,49152,62623,32768,15851,58982,34162,
550
55454,51739,64406,64047,32768,32768,7282,32768,
551
49152,58756,62805,64990,32768,14895,16384,19418,
552
57929,24966,58689,31832,32768,16384,10923,6554,
553
54613,42882,57344,64238,58982,10082,20165,20339,
554
62687,15061,32768,10923,32768,10923,32768,16384,
555
59578,34427,32768,16384,32768,7825,32768,7282,
556
58052,23400,32768,5041,32768,2849,32768,32768,
557
47663,15073,57344,4096,32768,1176,32768,1320,
558
24858,410,24576,923,32768,16384,16384,5461,
559
16384,1365,32768,5461,32768,5699,8192,13107,
560
46884,2361,23559,424,19661,712,655,182,
561
58637,2094,49152,9362,8192,85,32768,1228,
562
65486,49152,65186,49152,61320,32768,57088,25206,
563
65352,63047,62623,49152,64641,62165,58986,18304,
564
64171,16384,60855,54613,42130,32768,61335,32768,
565
58254,58982,49152,32768,60985,35289,64520,31554,
566
51067,32768,64074,32768,40330,32768,34526,4096,
567
60855,32768,63109,58254,57672,16384,31009,2567,
568
23406,32768,44620,10923,32768,32768,32099,10923,
569
49152,49152,54613,60075,63422,54613,46388,39719,
570
58982,32768,54613,32768,14247,32768,22938,5041,
571
32768,49152,32768,32768,25321,6144,29127,10999,
572
41263,32768,46811,32768,267,4096,426,16384,
573
32768,19275,49152,32768,1008,1437,5767,11275,
574
5595,5461,37493,6554,4681,32768,6147,1560,
575
38229,10923,32768,40960,35747,2521,5999,312,
576
17052,2521,18808,3641,213,2427,574,32,
577
51493,42130,42130,53053,11155,312,2069,106,
578
64406,45197,58982,32768,32768,16384,40960,36864,
579
65336,64244,60075,61681,65269,50748,60340,20515,
580
58982,23406,57344,32768,6554,16384,19661,61564,
581
60855,47480,32768,54613,46811,21701,54909,37826,
582
32768,58982,60855,60855,32768,32768,39322,49152,
583
57344,45875,60855,55706,32768,24576,62313,25038,
584
54613,8192,49152,10923,32768,32768,32768,32768,
585
32768,19661,16384,51493,32768,14043,40050,44651,
586
59578,5174,32768,6554,32768,5461,23593,5461,
587
63608,51825,32768,23831,58887,24032,57170,3298,
588
39322,12971,16384,49152,1872,618,13107,2114,
589
58982,25705,32768,60075,28913,949,18312,1815,
590
48188,114,51493,1542,5461,3855,11360,1163,
591
58982,7215,54613,21487,49152,4590,48430,1421,
592
28944,1319,6868,324,1456,232,820,7,
593
61681,1864,60855,9922,4369,315,6589,14
597
U16 enh_intra_v_prob [128] = {
598
65476, 64428, 62211, 63560, 52253, 58271, 38098, 31981, 50087, 41042,
599
54620, 31532, 8382, 10754, 3844, 6917, 63834, 50444, 50140, 63043,
600
58093, 45146, 36768, 13351, 17594, 28777, 39830, 38719, 9768, 21447,
601
12340, 9786, 60461, 41489, 27433, 53893, 47246, 11415, 13754, 24965,
602
51620, 28011, 11973, 29709, 13878, 22794, 24385, 1558, 57065, 41918,
603
25259, 55117, 48064, 12960, 19929, 5937, 25730, 22366, 5204, 32865,
604
3415, 14814, 6634, 1155, 64444, 62907, 56337, 63144, 38112, 56527,
605
40247, 37088, 60326, 45675, 51248, 15151, 18868, 43723, 14757, 11721,
606
62436, 50971, 51738, 59767, 49927, 50675, 38182, 24724, 48447, 47316,
607
56628, 36336, 12264, 25893, 24243, 5358, 58717, 56646, 48302, 60515,
608
36497, 26959, 43579, 40280, 54092, 20741, 10891, 7504, 8109, 30840,
609
6772, 4090, 59810, 61410, 53216, 64127, 32344, 12462, 23132, 19270,
610
32232, 24774, 9615, 17750, 1714, 6539, 3237, 152
613
U16 enh_intra_h_prob [128] = {
614
65510, 63321, 63851, 62223, 64959, 62202, 63637, 48019, 57072, 33553,
615
37041, 9527, 53190, 50479, 54232, 12855, 62779, 63980, 49604, 31847,
616
57591, 64385, 40657, 8402, 33878, 54743, 17873, 8707, 34470, 54322,
617
16702, 2192, 58325, 48447, 7345, 31317, 45687, 44236, 16685, 24144,
618
34327, 18724, 10591, 24965, 9247, 7281, 3144, 5921, 59349, 33539,
619
11447, 5543, 58082, 48995, 35630, 10653, 7123, 15893, 23830, 800,
620
3491, 15792, 8930, 905, 65209, 63939, 52634, 62194, 64937, 53948,
621
60081, 46851, 56157, 50930, 35498, 24655, 56331, 59318, 32209, 6872,
622
59172, 64273, 46724, 41200, 53619, 59022, 37941, 20529, 55026, 52858,
623
26402, 45073, 57740, 55485, 20533, 6288, 64286, 55438, 16454, 55656,
624
61175, 45874, 28536, 53762, 58056, 21895, 5482, 39352, 32635, 21633,
625
2137, 4016, 58490, 14100, 18724, 10461, 53459, 15490, 57992, 15128,
626
12034, 4340, 6761, 1859, 5794, 6785, 2412, 35
629
U16 SI_bab_type_prob[1] = { 59808 };
632
U8 grgchFirstShpCd [243] = {
633
0, 3, 2, 3, 2, 0, 2, 3, 0, 0, 3, 2, 0, 2, 3, 0, 2, 3,
634
0, 3, 2, 0, 2, 3, 2, 3, 0, 3, 2, 0, 0, 2, 3, 0, 2, 3,
635
3, 2, 0, 0, 2, 3, 2, 0, 3, 3, 2, 0, 0, 2, 3, 0, 2, 3,
636
2, 3, 0, 0, 2, 3, 3, 2, 0, 2, 3, 0, 0, 2, 3, 3, 2, 0,
637
2, 3, 0, 3, 2, 0, 3, 2, 0, 0, 2, 3, 0, 2, 3, 0, 2, 3,
638
0, 2, 3, 0, 2, 3, 0, 2, 3, 0, 2, 3, 0, 2, 3, 3, 2, 0,
639
0, 2, 3, 3, 2, 0, 3, 2, 0, 0, 2, 3, 3, 0, 2, 3, 2, 0,
640
0, 2, 3, 3, 0, 2, 3, 2, 0, 0, 2, 3, 3, 2, 0, 2, 3, 0,
641
0, 2, 3, 3, 2, 0, 2, 3, 0, 0, 3, 2, 3, 0, 2, 2, 3, 0,
642
0, 3, 2, 2, 3, 0, 2, 3, 0, 0, 2, 3, 0, 2, 3, 0, 2, 3,
643
0, 2, 3, 0, 2, 3, 2, 3, 0, 0, 2, 3, 3, 2, 0, 3, 2, 0,
644
2, 3, 0, 3, 0, 2, 3, 0, 2, 2, 3, 0, 3, 0, 2, 3, 2, 0,
645
0, 3, 2, 3, 2, 0, 2, 3, 0, 2, 3, 0, 3, 0, 2, 3, 2, 0,
646
0, 3, 2, 3, 0, 2, 3, 2, 0
649
// 10/11/97 Threshold for shape upsampling filter : added by dscho@dspsun.sait.samsung.co.kr
650
U8 grgchInterpolationFilterTh [256] = {
651
3, 6, 6, 7, 4, 7, 7, 8, 6, 7, 5, 8, 7, 8, 8, 9,
652
6, 5, 5, 8, 5, 6, 8, 9, 7, 6, 8, 9, 8, 7, 9,10,
653
6, 7, 7, 8, 7, 8, 8, 9, 7,10, 8, 9, 8, 9, 9,10,
654
7, 8, 6, 9, 6, 9, 9,10, 8, 9, 9,10, 11,10,10,11,
655
6, 9, 5, 8, 5, 6, 8, 9, 7,10,10, 9, 8, 7, 9,10,
656
7, 6, 8, 9, 8, 7, 7,10, 8, 9, 9,10, 9, 8,10, 9,
657
7, 8, 8, 9, 6, 9, 9,10, 8, 9, 9,10, 9,10,10, 9,
658
8, 9,11,10, 7,10,10,11, 9,12,10,11, 10,11,11,12,
659
6, 7, 5, 8, 5, 6, 8, 9, 5, 6, 6, 9, 8, 9, 9,10,
660
5, 8, 8, 9, 6, 7, 9,10, 6, 7, 9,10, 9,10,10,11,
661
7, 8, 6, 9, 8, 9, 9,10, 8, 7, 9,10, 9,10,10,11,
662
8, 9, 7,10, 9,10, 8,11, 9,10,10,11, 10,11, 9,12,
663
7, 8, 6, 9, 8, 9, 9,10, 10, 9, 7,10, 9,10,10,11,
664
8, 7, 7,10, 7, 8, 8, 9, 9,10,10,11, 10,11,11,12,
665
8, 9, 9,10, 9,10,10, 9, 9,10,10,11, 10,11,11,12,
666
9,10,10,11, 10,11,11,12, 10,11,11,12, 11,12,12,13
668
// Added for error resilient mode by Toshiba(1997-11-14)
672
// End Toshiba(1997-11-14)
674
// Added for error resilience mode By Toshiba(1998-1-16:DP+RVLC)
675
UInt grgiInterRVLCYAVCLHashingTable [169] = {
676
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
677
11, 12, 13, 14, 15, 16, 17, 18, 19, 33,
678
34, 35, 36, 37, 38, 39, 40, 41, 42, 65,
679
66, 67, 68, 69, 70, 71, 97, 98, 99, 100,
680
101, 102, 103, 129, 130, 131, 132, 133, 161, 162,
681
163, 164, 193, 194, 195, 196, 225, 226, 227, 228,
682
257, 258, 259, 289, 290, 291, 321, 322, 353, 354,
683
385, 386, 417, 418, 449, 450, 481, 482, 513, 514,
684
545, 546, 577, 609, 641, 673, 705, 737, 769, 801,
685
833, 865, 897, 929, 961, 993,1025,1057,1089,1121,
686
1153,1185,1217,2049,2050,2051,2052,2053,2081,2082,
687
2083,2084,2085,2113,2114,2115,2145,2146,2177,2178,
688
2209,2210,2241,2242,2273,2274,2305,2306,2337,2338,
689
2369,2370,2401,2402,2433,2434,2465,2466,2497,2529,
690
2561,2593,2625,2657,2689,2721,2753,2785,2817,2849,
691
2881,2913,2945,2977,3009,3041,3073,3105,3137,3169,
692
3201,3233,3265,3297,3329,3361,3393,3425,3457
695
UInt grgiIntraRVLCYAVCLHashingTable [169] = {
696
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
697
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
698
21, 22, 23, 24, 25, 26, 27, 33, 34, 35,
699
36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
700
65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
701
75, 97, 98, 99, 100, 101, 102, 103, 104, 105,
702
129, 130, 131, 132, 133, 134, 161, 162, 163, 164,
703
165, 166, 193, 194, 195, 196, 197, 225, 226, 227,
704
228, 229, 257, 258, 259, 260, 289, 290, 291, 292,
705
321, 322, 353, 354, 385, 386, 417, 449, 481, 513,
706
545, 577, 609,2049,2050,2051,2052,2053,2081,2082,
707
2083,2084,2085,2113,2114,2115,2145,2146,2177,2178,
708
2209,2210,2241,2242,2273,2274,2305,2306,2337,2338,
709
2369,2370,2401,2402,2433,2434,2465,2466,2497,2529,
710
2561,2593,2625,2657,2689,2721,2753,2785,2817,2849,
711
2881,2913,2945,2977,3009,3041,3073,3105,3137,3169,
712
3201,3233,3265,3297,3329,3361,3393,3425,3457
715
UInt grgIfNotLastNumOfLevelAtRunInterRVLC [39] = {
716
19, 10, 7, 7, 5, 4, 4, 4, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2,
717
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
720
UInt grgIfLastNumOfLevelAtRunInterRVLC [45] = {
721
5, 5, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
722
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
723
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
726
UInt grgIfNotLastNumOfLevelAtRunIntraRVLC [20] = {
727
27, 13, 11, 9, 6, 6, 5, 5, 4, 4, 2, 2, 2,
731
UInt grgIfLastNumOfLevelAtRunIntraRVLC [45] = {
732
5, 5, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
733
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
734
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
736
// End Toshiba(1998-1-16:DP+RVLC)
741
class CNewPredEncoder;
742
class CNewPredDecoder;
743
extern CNewPredEncoder* g_pNewPredEnc;
744
extern CNewPredDecoder* g_pNewPredDec;
747
extern UInt gWghtC[8][8];
748
extern UInt gWghtT[8][8];
749
extern UInt gWghtB[8][8];
750
extern UInt gWghtR[8][8];
751
extern UInt gWghtL[8][8];
753
extern UInt gWghtC_RRV[16][16];
754
extern UInt gWghtT_RRV[16][16];
755
extern UInt gWghtB_RRV[16][16];
756
extern UInt gWghtR_RRV[16][16];
757
extern UInt gWghtL_RRV[16][16];
759
extern Int grgiMvRound16 [16];
760
extern Int grgiMvRound12 [12];
761
extern Int grgiMvRound8 [8];
762
extern Int grgiMvRound4 [4];
763
extern BlockNum gIndexOfCandBlk[5][3];
764
extern Int rgiDefaultIntraQMatrix [BLOCK_SQUARE_SIZE];
765
extern Int rgiDefaultInterQMatrix [BLOCK_SQUARE_SIZE];
766
extern Int rgiDefaultIntraQMatrixAlpha [BLOCK_SQUARE_SIZE]; // added by mwi
767
extern Int rgiDefaultInterQMatrixAlpha [BLOCK_SQUARE_SIZE]; // added by mwi
768
extern Int grgiStandardZigzag [BLOCK_SQUARE_SIZE];
769
extern Int grgiHorizontalZigzag [BLOCK_SQUARE_SIZE];
770
extern Int grgiVerticalZigzag [BLOCK_SQUARE_SIZE];
771
extern UInt grgIfNotLastNumOfLevelAtRun [27];
772
extern UInt grgIfLastNumOfLevelAtRun [41];
773
extern UInt grgiIntraYAVCLHashingTable [102];
774
extern Int g_rgiLMAXintra [128];
775
extern Int g_rgiRMAXintra [32];
776
extern Int g_rgiLMAXinter [128];
777
extern Int g_rgiRMAXinter [32];
778
extern U16 gCAEintraProb [1024];
779
extern U16 gCAEinterProb [512];
781
extern U16 enh_intra_v_prob [128];
782
extern U16 enh_intra_h_prob [128];
783
extern U16 SI_bab_type_prob [1];
785
extern U8 grgchFirstShpCd [243];
786
extern U8 grgchInterpolationFilterTh [256];
787
// Added for error resilient mode by Toshiba(1997-11-14)
788
extern Int g_iMaxHeading;
789
extern Int g_iMaxMiddle;
790
extern Int g_iMaxTrailing;
791
// End Toshiba(1997-11-14)
792
// Added for error resilience mode By Toshiba(1998-1-16:DP+RVLC)
793
extern UInt grgiIntraRVLCYAVCLHashingTable [169];
794
extern UInt grgiInterRVLCYAVCLHashingTable [169];
795
extern UInt grgIfNotLastNumOfLevelAtRunInterRVLC [39];
796
extern UInt grgIfLastNumOfLevelAtRunInterRVLC [45];
797
extern UInt grgIfNotLastNumOfLevelAtRunIntraRVLC [20];
798
extern UInt grgIfLastNumOfLevelAtRunIntraRVLC [45];
799
// End Toshiba(1998-1-16:DP+RVLC)