1 |
/****************************************************************************** |
/***************************************************************************** |
2 |
* * |
* |
3 |
* This file is part of XviD, a free MPEG-4 video encoder/decoder * |
* XVID MPEG-4 VIDEO CODEC |
4 |
* * |
* - MB coding - |
5 |
* XviD is an implementation of a part of one or more MPEG-4 Video tools * |
* |
6 |
* as specified in ISO/IEC 14496-2 standard. Those intending to use this * |
* Copyright (C) 2002 Michael Militzer <isibaar@xvid.org> |
7 |
* software module in hardware or software products are advised that its * |
* |
8 |
* use may infringe existing patents or copyrights, and any such use * |
* This program is free software ; you can redistribute it and/or modify |
9 |
* would be at such party's own risk. The original developer of this * |
* it under the terms of the GNU General Public License as published by |
10 |
* software module and his/her company, and subsequent editors and their * |
* the Free Software Foundation ; either version 2 of the License, or |
11 |
* companies, will have no liability for use of this software or * |
* (at your option) any later version. |
12 |
* modifications or derivatives thereof. * |
* |
13 |
* * |
* This program is distributed in the hope that it will be useful, |
14 |
* XviD is free software; you can redistribute it and/or modify it * |
* but WITHOUT ANY WARRANTY ; without even the implied warranty of |
15 |
* under the terms of the GNU General Public License as published by * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
* the Free Software Foundation; either version 2 of the License, or * |
* GNU General Public License for more details. |
17 |
* (at your option) any later version. * |
* |
18 |
* * |
* You should have received a copy of the GNU General Public License |
19 |
* XviD is distributed in the hope that it will be useful, but * |
* along with this program ; if not, write to the Free Software |
20 |
* WITHOUT ANY WARRANTY; without even the implied warranty of * |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* |
22 |
* GNU General Public License for more details. * |
* $Id$ |
23 |
* * |
* |
24 |
* You should have received a copy of the GNU General Public License * |
****************************************************************************/ |
|
* along with this program; if not, write to the Free Software * |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
|
|
* * |
|
|
******************************************************************************/ |
|
|
|
|
|
/****************************************************************************** |
|
|
* * |
|
|
* mbcoding.c * |
|
|
* * |
|
|
* Copyright (C) 2002 - Michael Militzer <isibaar@xvid.org> * |
|
|
* * |
|
|
* For more information visit the XviD homepage: http://www.xvid.org * |
|
|
* * |
|
|
******************************************************************************/ |
|
|
|
|
|
/****************************************************************************** |
|
|
* * |
|
|
* Revision history: * |
|
|
* * |
|
|
* 28.10.2002 GMC support - gruel * |
|
|
* 28.06.2002 added check_resync_marker() * |
|
|
* 14.04.2002 bframe encoding * |
|
|
* 08.03.2002 initial version; isibaar * |
|
|
* * |
|
|
******************************************************************************/ |
|
|
|
|
25 |
|
|
26 |
#include <stdio.h> |
#include <stdio.h> |
27 |
#include <stdlib.h> |
#include <stdlib.h> |
28 |
|
#include <string.h> |
29 |
|
|
30 |
#include "../portab.h" |
#include "../portab.h" |
31 |
#include "../global.h" |
#include "../global.h" |
32 |
#include "bitstream.h" |
#include "bitstream.h" |
36 |
|
|
37 |
#include "../utils/mbfunctions.h" |
#include "../utils/mbfunctions.h" |
38 |
|
|
|
/* #define BIGLUT */ |
|
|
|
|
|
#ifdef BIGLUT |
|
|
#define LEVELOFFSET 2048 |
|
|
#else |
|
39 |
#define LEVELOFFSET 32 |
#define LEVELOFFSET 32 |
|
#endif |
|
40 |
|
|
41 |
|
/* Initialized once during xvid_global call |
42 |
|
* RO access is thread safe */ |
43 |
static REVERSE_EVENT DCT3D[2][4096]; |
static REVERSE_EVENT DCT3D[2][4096]; |
|
|
|
|
#ifdef BIGLUT |
|
|
static VLC coeff_VLC[2][2][4096][64]; |
|
|
static VLC *intra_table, *inter_table; |
|
|
#else |
|
44 |
static VLC coeff_VLC[2][2][64][64]; |
static VLC coeff_VLC[2][2][64][64]; |
|
#endif |
|
45 |
|
|
46 |
/* not really MB related, but VLCs are only available here */ |
/* not really MB related, but VLCs are only available here */ |
47 |
void bs_put_spritetrajectory(Bitstream * bs, const int val) |
void bs_put_spritetrajectory(Bitstream * bs, const int val) |
51 |
const int code2 = sprite_trajectory_len[len].code; |
const int code2 = sprite_trajectory_len[len].code; |
52 |
const int len2 = sprite_trajectory_len[len].len; |
const int len2 = sprite_trajectory_len[len].len; |
53 |
|
|
54 |
// printf("GMC=%d Code/Len = %d / %d ",val, code,len); |
#if 0 |
55 |
// printf("Code2 / Len2 = %d / %d \n",code2,len2); |
printf("GMC=%d Code/Len = %d / %d ",val, code,len); |
56 |
|
printf("Code2 / Len2 = %d / %d \n",code2,len2); |
57 |
|
#endif |
58 |
|
|
59 |
BitstreamPutBits(bs, code2, len2); |
BitstreamPutBits(bs, code2, len2); |
60 |
if (len) BitstreamPutBits(bs, code, len); |
if (len) BitstreamPutBits(bs, code, len); |
77 |
void |
void |
78 |
init_vlc_tables(void) |
init_vlc_tables(void) |
79 |
{ |
{ |
80 |
uint32_t i, j, k, intra, last, run, run_esc, level, level_esc, escape, escape_len, offset, limit; |
uint32_t i, j, k, intra, last, run, run_esc, level, level_esc, escape, escape_len, offset; |
81 |
int32_t l; |
int32_t l; |
82 |
|
|
|
#ifdef BIGLUT |
|
|
intra_table = coeff_VLC[1]; |
|
|
inter_table = coeff_VLC[0]; |
|
|
#endif |
|
|
|
|
|
|
|
83 |
for (intra = 0; intra < 2; intra++) |
for (intra = 0; intra < 2; intra++) |
84 |
for (i = 0; i < 4096; i++) |
for (i = 0; i < 4096; i++) |
85 |
DCT3D[intra][i].event.level = 0; |
DCT3D[intra][i].event.level = 0; |
86 |
|
|
87 |
for (intra = 0; intra < 2; intra++) |
for (intra = 0; intra < 2; intra++) { |
88 |
for (last = 0; last < 2; last++) |
for (last = 0; last < 2; last++) { |
89 |
{ |
for (run = 0; run < 63 + last; run++) { |
90 |
for (run = 0; run < 63 + last; run++) |
for (level = 0; level < (uint32_t)(32 << intra); level++) { |
|
for (level = 0; level < 32 << intra; level++) |
|
|
{ |
|
|
#ifdef BIGLUT |
|
|
offset = LEVELOFFSET; |
|
|
#else |
|
91 |
offset = !intra * LEVELOFFSET; |
offset = !intra * LEVELOFFSET; |
|
#endif |
|
92 |
coeff_VLC[intra][last][level + offset][run].len = 128; |
coeff_VLC[intra][last][level + offset][run].len = 128; |
93 |
} |
} |
94 |
} |
} |
95 |
|
} |
96 |
|
} |
97 |
|
|
98 |
for (intra = 0; intra < 2; intra++) |
for (intra = 0; intra < 2; intra++) { |
99 |
for (i = 0; i < 102; i++) |
for (i = 0; i < 102; i++) { |
|
{ |
|
|
#ifdef BIGLUT |
|
|
offset = LEVELOFFSET; |
|
|
#else |
|
100 |
offset = !intra * LEVELOFFSET; |
offset = !intra * LEVELOFFSET; |
101 |
#endif |
|
102 |
for (j = 0; j < 1 << (12 - coeff_tab[intra][i].vlc.len); j++) |
for (j = 0; j < (uint32_t)(1 << (12 - coeff_tab[intra][i].vlc.len)); j++) { |
|
{ |
|
103 |
DCT3D[intra][(coeff_tab[intra][i].vlc.code << (12 - coeff_tab[intra][i].vlc.len)) | j].len = coeff_tab[intra][i].vlc.len; |
DCT3D[intra][(coeff_tab[intra][i].vlc.code << (12 - coeff_tab[intra][i].vlc.len)) | j].len = coeff_tab[intra][i].vlc.len; |
104 |
DCT3D[intra][(coeff_tab[intra][i].vlc.code << (12 - coeff_tab[intra][i].vlc.len)) | j].event = coeff_tab[intra][i].event; |
DCT3D[intra][(coeff_tab[intra][i].vlc.code << (12 - coeff_tab[intra][i].vlc.len)) | j].event = coeff_tab[intra][i].event; |
105 |
} |
} |
108 |
= coeff_tab[intra][i].vlc.code << 1; |
= coeff_tab[intra][i].vlc.code << 1; |
109 |
coeff_VLC[intra][coeff_tab[intra][i].event.last][coeff_tab[intra][i].event.level + offset][coeff_tab[intra][i].event.run].len |
coeff_VLC[intra][coeff_tab[intra][i].event.last][coeff_tab[intra][i].event.level + offset][coeff_tab[intra][i].event.run].len |
110 |
= coeff_tab[intra][i].vlc.len + 1; |
= coeff_tab[intra][i].vlc.len + 1; |
111 |
#ifndef BIGLUT |
|
112 |
if (!intra) |
if (!intra) { |
|
#endif |
|
|
{ |
|
113 |
coeff_VLC[intra][coeff_tab[intra][i].event.last][offset - coeff_tab[intra][i].event.level][coeff_tab[intra][i].event.run].code |
coeff_VLC[intra][coeff_tab[intra][i].event.last][offset - coeff_tab[intra][i].event.level][coeff_tab[intra][i].event.run].code |
114 |
= (coeff_tab[intra][i].vlc.code << 1) | 1; |
= (coeff_tab[intra][i].vlc.code << 1) | 1; |
115 |
coeff_VLC[intra][coeff_tab[intra][i].event.last][offset - coeff_tab[intra][i].event.level][coeff_tab[intra][i].event.run].len |
coeff_VLC[intra][coeff_tab[intra][i].event.last][offset - coeff_tab[intra][i].event.level][coeff_tab[intra][i].event.run].len |
116 |
= coeff_tab[intra][i].vlc.len + 1; |
= coeff_tab[intra][i].vlc.len + 1; |
117 |
} |
} |
118 |
} |
} |
119 |
|
} |
120 |
|
|
121 |
|
for (intra = 0; intra < 2; intra++) { |
122 |
|
for (last = 0; last < 2; last++) { |
123 |
|
for (run = 0; run < 63 + last; run++) { |
124 |
|
for (level = 1; level < (uint32_t)(32 << intra); level++) { |
125 |
|
|
|
for (intra = 0; intra < 2; intra++) |
|
|
for (last = 0; last < 2; last++) |
|
|
for (run = 0; run < 63 + last; run++) |
|
|
{ |
|
|
for (level = 1; level < 32 << intra; level++) |
|
|
{ |
|
126 |
if (level <= max_level[intra][last][run] && run <= max_run[intra][last][level]) |
if (level <= max_level[intra][last][run] && run <= max_run[intra][last][level]) |
127 |
continue; |
continue; |
128 |
|
|
|
#ifdef BIGLUT |
|
|
offset = LEVELOFFSET; |
|
|
#else |
|
129 |
offset = !intra * LEVELOFFSET; |
offset = !intra * LEVELOFFSET; |
|
#endif |
|
130 |
level_esc = level - max_level[intra][last][run]; |
level_esc = level - max_level[intra][last][run]; |
131 |
run_esc = run - 1 - max_run[intra][last][level]; |
run_esc = run - 1 - max_run[intra][last][level]; |
|
/*use this test to use shorter esc2 codes when possible |
|
|
if (level_esc <= max_level[intra][last][run] && run <= max_run[intra][last][level_esc] |
|
|
&& !(coeff_VLC[intra][last][level_esc + offset][run].len + 7 + 1 |
|
|
> coeff_VLC[intra][last][level + offset][run_esc].code + 7 + 2))*/ |
|
132 |
|
|
133 |
if (level_esc <= max_level[intra][last][run] && run <= max_run[intra][last][level_esc]) |
if (level_esc <= max_level[intra][last][run] && run <= max_run[intra][last][level_esc]) { |
|
{ |
|
134 |
escape = ESCAPE1; |
escape = ESCAPE1; |
135 |
escape_len = 7 + 1; |
escape_len = 7 + 1; |
136 |
run_esc = run; |
run_esc = run; |
137 |
} |
} else { |
138 |
else |
if (run_esc <= max_run[intra][last][level] && level <= max_level[intra][last][run_esc]) { |
|
{ |
|
|
if (level <= max_level[intra][last][run_esc] && run_esc <= max_run[intra][last][level]) |
|
|
{ |
|
139 |
escape = ESCAPE2; |
escape = ESCAPE2; |
140 |
escape_len = 7 + 2; |
escape_len = 7 + 2; |
141 |
level_esc = level; |
level_esc = level; |
142 |
} |
} else { |
143 |
else |
if (!intra) { |
|
{ |
|
|
#ifndef BIGLUT |
|
|
if (!intra) |
|
|
#endif |
|
|
{ |
|
144 |
coeff_VLC[intra][last][level + offset][run].code |
coeff_VLC[intra][last][level + offset][run].code |
145 |
= (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((level & 0xfff) << 1) | 1; |
= (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((level & 0xfff) << 1) | 1; |
146 |
coeff_VLC[intra][last][level + offset][run].len = 30; |
coeff_VLC[intra][last][level + offset][run].len = 30; |
147 |
coeff_VLC[intra][last][offset - level][run].code |
coeff_VLC[intra][last][offset - level][run].code |
148 |
= (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((-level & 0xfff) << 1) | 1; |
= (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((-(int32_t)level & 0xfff) << 1) | 1; |
149 |
coeff_VLC[intra][last][offset - level][run].len = 30; |
coeff_VLC[intra][last][offset - level][run].len = 30; |
150 |
} |
} |
151 |
continue; |
continue; |
157 |
| coeff_VLC[intra][last][level_esc + offset][run_esc].code; |
| coeff_VLC[intra][last][level_esc + offset][run_esc].code; |
158 |
coeff_VLC[intra][last][level + offset][run].len |
coeff_VLC[intra][last][level + offset][run].len |
159 |
= coeff_VLC[intra][last][level_esc + offset][run_esc].len + escape_len; |
= coeff_VLC[intra][last][level_esc + offset][run_esc].len + escape_len; |
160 |
#ifndef BIGLUT |
|
161 |
if (!intra) |
if (!intra) { |
|
#endif |
|
|
{ |
|
162 |
coeff_VLC[intra][last][offset - level][run].code |
coeff_VLC[intra][last][offset - level][run].code |
163 |
= (escape << coeff_VLC[intra][last][level_esc + offset][run_esc].len) |
= (escape << coeff_VLC[intra][last][level_esc + offset][run_esc].len) |
164 |
| coeff_VLC[intra][last][level_esc + offset][run_esc].code | 1; |
| coeff_VLC[intra][last][level_esc + offset][run_esc].code | 1; |
167 |
} |
} |
168 |
} |
} |
169 |
|
|
170 |
#ifdef BIGLUT |
if (!intra) { |
|
for (level = 32 << intra; level < 2048; level++) |
|
|
{ |
|
|
coeff_VLC[intra][last][level + offset][run].code |
|
|
= (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((level & 0xfff) << 1) | 1; |
|
|
coeff_VLC[intra][last][level + offset][run].len = 30; |
|
|
|
|
|
coeff_VLC[intra][last][offset - level][run].code |
|
|
= (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((-level & 0xfff) << 1) | 1; |
|
|
coeff_VLC[intra][last][offset - level][run].len = 30; |
|
|
} |
|
|
#else |
|
|
if (!intra) |
|
|
{ |
|
171 |
coeff_VLC[intra][last][0][run].code |
coeff_VLC[intra][last][0][run].code |
172 |
= (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((-32 & 0xfff) << 1) | 1; |
= (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((-32 & 0xfff) << 1) | 1; |
173 |
coeff_VLC[intra][last][0][run].len = 30; |
coeff_VLC[intra][last][0][run].len = 30; |
174 |
} |
} |
|
#endif |
|
175 |
} |
} |
176 |
/* init sprite_trajectory tables */ |
} |
177 |
/* even if GMC is not specified (it might be used later...) */ |
} |
178 |
|
|
179 |
|
/* init sprite_trajectory tables |
180 |
|
* even if GMC is not specified (it might be used later...) */ |
181 |
|
|
182 |
sprite_trajectory_code[0+16384].code = 0; |
sprite_trajectory_code[0+16384].code = 0; |
183 |
sprite_trajectory_code[0+16384].len = 0; |
sprite_trajectory_code[0+16384].len = 0; |
184 |
for (k=0;k<14;k++) |
for (k=0;k<14;k++) { |
|
{ |
|
185 |
int limit = (1<<k); |
int limit = (1<<k); |
186 |
|
|
187 |
for (l=-(2*limit-1); l <= -limit; l++) |
for (l=-(2*limit-1); l <= -limit; l++) { |
188 |
{ |
sprite_trajectory_code[l+16384].code = (2*limit-1)+l; |
189 |
sprite_trajectory_code[i+16384].code = (2*limit-1)+l; |
sprite_trajectory_code[l+16384].len = k+1; |
|
sprite_trajectory_code[i+16384].len = k+1; |
|
190 |
} |
} |
191 |
|
|
192 |
for (l=limit; l<= 2*limit-1; l++) |
for (l=limit; l<= 2*limit-1; l++) { |
193 |
{ |
sprite_trajectory_code[l+16384].code = l; |
194 |
sprite_trajectory_code[i+16384].code = l; |
sprite_trajectory_code[l+16384].len = k+1; |
|
sprite_trajectory_code[i+16384].len = k+1; |
|
195 |
} |
} |
196 |
} |
} |
197 |
} |
} |
199 |
static __inline void |
static __inline void |
200 |
CodeVector(Bitstream * bs, |
CodeVector(Bitstream * bs, |
201 |
int32_t value, |
int32_t value, |
202 |
int32_t f_code, |
int32_t f_code) |
|
Statistics * pStat) |
|
203 |
{ |
{ |
204 |
|
|
205 |
const int scale_factor = 1 << (f_code - 1); |
const int scale_factor = 1 << (f_code - 1); |
211 |
if (value > (cmp - 1)) |
if (value > (cmp - 1)) |
212 |
value -= 64 * scale_factor; |
value -= 64 * scale_factor; |
213 |
|
|
|
pStat->iMvSum += value * value; |
|
|
pStat->iMvCount++; |
|
|
|
|
214 |
if (value == 0) { |
if (value == 0) { |
215 |
BitstreamPutBits(bs, mb_motion_table[32].code, |
BitstreamPutBits(bs, mb_motion_table[32].code, |
216 |
mb_motion_table[32].len); |
mb_motion_table[32].len); |
247 |
|
|
248 |
} |
} |
249 |
|
|
|
#ifdef BIGLUT |
|
|
|
|
|
static __inline void |
|
|
CodeCoeff(Bitstream * bs, |
|
|
const int16_t qcoeff[64], |
|
|
VLC * table, |
|
|
const uint16_t * zigzag, |
|
|
uint16_t intra) |
|
|
{ |
|
|
|
|
|
uint32_t j, last; |
|
|
short v; |
|
|
VLC *vlc; |
|
|
|
|
|
j = intra; |
|
|
last = intra; |
|
|
|
|
|
while (j < 64 && (v = qcoeff[zigzag[j]]) == 0) |
|
|
j++; |
|
|
|
|
|
do { |
|
|
vlc = table + 64 * 2048 + (v << 6) + j - last; |
|
|
last = ++j; |
|
|
|
|
|
/* count zeroes */ |
|
|
while (j < 64 && (v = qcoeff[zigzag[j]]) == 0) |
|
|
j++; |
|
|
|
|
|
/* write code */ |
|
|
if (j != 64) { |
|
|
BitstreamPutBits(bs, vlc->code, vlc->len); |
|
|
} else { |
|
|
vlc += 64 * 4096; |
|
|
BitstreamPutBits(bs, vlc->code, vlc->len); |
|
|
break; |
|
|
} |
|
|
} while (1); |
|
|
|
|
|
} |
|
|
|
|
|
#else |
|
|
|
|
250 |
static __inline void |
static __inline void |
251 |
CodeCoeffInter(Bitstream * bs, |
CodeCoeffInter(Bitstream * bs, |
252 |
const int16_t qcoeff[64], |
const int16_t qcoeff[64], |
314 |
i = 1; |
i = 1; |
315 |
run = 0; |
run = 0; |
316 |
|
|
317 |
while (!(level = qcoeff[zigzag[i++]])) |
while (i<64 && !(level = qcoeff[zigzag[i++]])) |
318 |
run++; |
run++; |
319 |
|
|
320 |
prev_level = level; |
prev_level = level; |
325 |
{ |
{ |
326 |
if ((level = qcoeff[zigzag[i++]]) != 0) |
if ((level = qcoeff[zigzag[i++]]) != 0) |
327 |
{ |
{ |
328 |
abs_level = ABS(prev_level); |
abs_level = abs(prev_level); |
329 |
abs_level = abs_level < 64 ? abs_level : 0; |
abs_level = abs_level < 64 ? abs_level : 0; |
330 |
code = coeff_VLC[1][0][abs_level][prev_run].code; |
code = coeff_VLC[1][0][abs_level][prev_run].code; |
331 |
len = coeff_VLC[1][0][abs_level][prev_run].len; |
len = coeff_VLC[1][0][abs_level][prev_run].len; |
345 |
run++; |
run++; |
346 |
} |
} |
347 |
|
|
348 |
abs_level = ABS(prev_level); |
abs_level = abs(prev_level); |
349 |
abs_level = abs_level < 64 ? abs_level : 0; |
abs_level = abs_level < 64 ? abs_level : 0; |
350 |
code = coeff_VLC[1][1][abs_level][prev_run].code; |
code = coeff_VLC[1][1][abs_level][prev_run].code; |
351 |
len = coeff_VLC[1][1][abs_level][prev_run].len; |
len = coeff_VLC[1][1][abs_level][prev_run].len; |
359 |
BitstreamPutBits(bs, code, len); |
BitstreamPutBits(bs, code, len); |
360 |
} |
} |
361 |
|
|
362 |
#endif |
|
363 |
|
|
364 |
|
/* returns the number of bits required to encode qcoeff */ |
365 |
|
|
366 |
|
int |
367 |
|
CodeCoeffIntra_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag) |
368 |
|
{ |
369 |
|
int bits = 0; |
370 |
|
uint32_t i, abs_level, run, prev_run, len; |
371 |
|
int32_t level, prev_level; |
372 |
|
|
373 |
|
i = 1; |
374 |
|
run = 0; |
375 |
|
|
376 |
|
while (i<64 && !(level = qcoeff[zigzag[i++]])) |
377 |
|
run++; |
378 |
|
|
379 |
|
if (i >= 64) return 0; /* empty block */ |
380 |
|
|
381 |
|
prev_level = level; |
382 |
|
prev_run = run; |
383 |
|
run = 0; |
384 |
|
|
385 |
|
while (i < 64) |
386 |
|
{ |
387 |
|
if ((level = qcoeff[zigzag[i++]]) != 0) |
388 |
|
{ |
389 |
|
abs_level = abs(prev_level); |
390 |
|
abs_level = abs_level < 64 ? abs_level : 0; |
391 |
|
len = coeff_VLC[1][0][abs_level][prev_run].len; |
392 |
|
bits += len!=128 ? len : 30; |
393 |
|
|
394 |
|
prev_level = level; |
395 |
|
prev_run = run; |
396 |
|
run = 0; |
397 |
|
} |
398 |
|
else |
399 |
|
run++; |
400 |
|
} |
401 |
|
|
402 |
|
abs_level = abs(prev_level); |
403 |
|
abs_level = abs_level < 64 ? abs_level : 0; |
404 |
|
len = coeff_VLC[1][1][abs_level][prev_run].len; |
405 |
|
bits += len!=128 ? len : 30; |
406 |
|
|
407 |
|
return bits; |
408 |
|
} |
409 |
|
|
410 |
|
int |
411 |
|
CodeCoeffInter_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag) |
412 |
|
{ |
413 |
|
uint32_t i, run, prev_run, len; |
414 |
|
int32_t level, prev_level, level_shifted; |
415 |
|
int bits = 0; |
416 |
|
|
417 |
|
i = 0; |
418 |
|
run = 0; |
419 |
|
|
420 |
|
while (!(level = qcoeff[zigzag[i++]])) |
421 |
|
run++; |
422 |
|
|
423 |
|
prev_level = level; |
424 |
|
prev_run = run; |
425 |
|
run = 0; |
426 |
|
|
427 |
|
while (i < 64) { |
428 |
|
if ((level = qcoeff[zigzag[i++]]) != 0) { |
429 |
|
level_shifted = prev_level + 32; |
430 |
|
if (!(level_shifted & -64)) |
431 |
|
len = coeff_VLC[0][0][level_shifted][prev_run].len; |
432 |
|
else |
433 |
|
len = 30; |
434 |
|
|
435 |
|
bits += len; |
436 |
|
prev_level = level; |
437 |
|
prev_run = run; |
438 |
|
run = 0; |
439 |
|
} |
440 |
|
else |
441 |
|
run++; |
442 |
|
} |
443 |
|
|
444 |
|
level_shifted = prev_level + 32; |
445 |
|
if (!(level_shifted & -64)) |
446 |
|
len = coeff_VLC[0][1][level_shifted][prev_run].len; |
447 |
|
else |
448 |
|
len = 30; |
449 |
|
bits += len; |
450 |
|
|
451 |
|
return bits; |
452 |
|
} |
453 |
|
|
454 |
|
static const int iDQtab[5] = { |
455 |
|
1, 0, -1 /* no change */, 2, 3 |
456 |
|
}; |
457 |
|
#define DQ_VALUE2INDEX(value) iDQtab[(value)+2] |
458 |
|
|
459 |
|
|
460 |
static __inline void |
static __inline void |
461 |
CodeBlockIntra(const FRAMEINFO * const frame, |
CodeBlockIntra(const FRAMEINFO * const frame, |
469 |
|
|
470 |
cbpy = pMB->cbp >> 2; |
cbpy = pMB->cbp >> 2; |
471 |
|
|
472 |
// write mcbpc |
/* write mcbpc */ |
473 |
if (frame->coding_type == I_VOP) { |
if (frame->coding_type == I_VOP) { |
474 |
mcbpc = ((pMB->mode >> 1) & 3) | ((pMB->cbp & 3) << 2); |
mcbpc = ((pMB->mode >> 1) & 3) | ((pMB->cbp & 3) << 2); |
475 |
BitstreamPutBits(bs, mcbpc_intra_tab[mcbpc].code, |
BitstreamPutBits(bs, mcbpc_intra_tab[mcbpc].code, |
480 |
mcbpc_inter_tab[mcbpc].len); |
mcbpc_inter_tab[mcbpc].len); |
481 |
} |
} |
482 |
|
|
483 |
// ac prediction flag |
/* ac prediction flag */ |
484 |
if (pMB->acpred_directions[0]) |
if (pMB->acpred_directions[0]) |
485 |
BitstreamPutBits(bs, 1, 1); |
BitstreamPutBits(bs, 1, 1); |
486 |
else |
else |
487 |
BitstreamPutBits(bs, 0, 1); |
BitstreamPutBits(bs, 0, 1); |
488 |
|
|
489 |
// write cbpy |
/* write cbpy */ |
490 |
BitstreamPutBits(bs, cbpy_tab[cbpy].code, cbpy_tab[cbpy].len); |
BitstreamPutBits(bs, xvid_cbpy_tab[cbpy].code, xvid_cbpy_tab[cbpy].len); |
491 |
|
|
492 |
// write dquant |
/* write dquant */ |
493 |
if (pMB->mode == MODE_INTRA_Q) |
if (pMB->mode == MODE_INTRA_Q) |
494 |
BitstreamPutBits(bs, pMB->dquant, 2); |
BitstreamPutBits(bs, DQ_VALUE2INDEX(pMB->dquant), 2); |
495 |
|
|
496 |
// write interlacing |
/* write interlacing */ |
497 |
if (frame->global_flags & XVID_INTERLACING) { |
if (frame->vol_flags & XVID_VOL_INTERLACING) { |
498 |
BitstreamPutBit(bs, pMB->field_dct); |
BitstreamPutBit(bs, pMB->field_dct); |
499 |
} |
} |
500 |
// code block coeffs |
/* code block coeffs */ |
501 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
502 |
if (i < 4) |
if (i < 4) |
503 |
BitstreamPutBits(bs, dcy_tab[qcoeff[i * 64 + 0] + 255].code, |
BitstreamPutBits(bs, dcy_tab[qcoeff[i * 64 + 0] + 255].code, |
508 |
|
|
509 |
if (pMB->cbp & (1 << (5 - i))) { |
if (pMB->cbp & (1 << (5 - i))) { |
510 |
const uint16_t *scan_table = |
const uint16_t *scan_table = |
511 |
frame->global_flags & XVID_ALTERNATESCAN ? |
frame->vop_flags & XVID_VOP_ALTERNATESCAN ? |
512 |
scan_tables[2] : scan_tables[pMB->acpred_directions[i]]; |
scan_tables[2] : scan_tables[pMB->acpred_directions[i]]; |
513 |
|
|
514 |
bits = BitstreamPos(bs); |
bits = BitstreamPos(bs); |
515 |
|
|
|
#ifdef BIGLUT |
|
|
CodeCoeff(bs, &qcoeff[i * 64], intra_table, scan_table, 1); |
|
|
#else |
|
516 |
CodeCoeffIntra(bs, &qcoeff[i * 64], scan_table); |
CodeCoeffIntra(bs, &qcoeff[i * 64], scan_table); |
|
#endif |
|
517 |
|
|
518 |
bits = BitstreamPos(bs) - bits; |
bits = BitstreamPos(bs) - bits; |
519 |
pStat->iTextBits += bits; |
pStat->iTextBits += bits; |
537 |
mcbpc = (pMB->mode & 7) | ((pMB->cbp & 3) << 3); |
mcbpc = (pMB->mode & 7) | ((pMB->cbp & 3) << 3); |
538 |
cbpy = 15 - (pMB->cbp >> 2); |
cbpy = 15 - (pMB->cbp >> 2); |
539 |
|
|
540 |
// write mcbpc |
/* write mcbpc */ |
541 |
BitstreamPutBits(bs, mcbpc_inter_tab[mcbpc].code, |
BitstreamPutBits(bs, mcbpc_inter_tab[mcbpc].code, |
542 |
mcbpc_inter_tab[mcbpc].len); |
mcbpc_inter_tab[mcbpc].len); |
543 |
|
|
544 |
if ( (frame->coding_type == S_VOP) && (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) ) |
if ( (frame->coding_type == S_VOP) && (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) ) |
545 |
BitstreamPutBit(bs, pMB->mcsel); // mcsel: '0'=local motion, '1'=GMC |
BitstreamPutBit(bs, pMB->mcsel); /* mcsel: '0'=local motion, '1'=GMC */ |
546 |
|
|
547 |
// write cbpy |
/* write cbpy */ |
548 |
BitstreamPutBits(bs, cbpy_tab[cbpy].code, cbpy_tab[cbpy].len); |
BitstreamPutBits(bs, xvid_cbpy_tab[cbpy].code, xvid_cbpy_tab[cbpy].len); |
549 |
|
|
550 |
// write dquant |
/* write dquant */ |
551 |
if (pMB->mode == MODE_INTER_Q) |
if (pMB->mode == MODE_INTER_Q) |
552 |
BitstreamPutBits(bs, pMB->dquant, 2); |
BitstreamPutBits(bs, DQ_VALUE2INDEX(pMB->dquant), 2); |
553 |
|
|
554 |
// interlacing |
/* interlacing */ |
555 |
if (frame->global_flags & XVID_INTERLACING) { |
if (frame->vol_flags & XVID_VOL_INTERLACING) { |
556 |
if (pMB->cbp) { |
if (pMB->cbp) { |
557 |
BitstreamPutBit(bs, pMB->field_dct); |
BitstreamPutBit(bs, pMB->field_dct); |
558 |
DPRINTF(DPRINTF_MB,"codep: field_dct: %i", pMB->field_dct); |
DPRINTF(XVID_DEBUG_MB,"codep: field_dct: %i\n", pMB->field_dct); |
559 |
} |
} |
560 |
|
|
561 |
// if inter block, write field ME flag |
/* if inter block, write field ME flag */ |
562 |
if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) { |
if ((pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) && (pMB->mcsel == 0)) { |
563 |
BitstreamPutBit(bs, pMB->field_pred); |
BitstreamPutBit(bs, 0 /*pMB->field_pred*/); /* not implemented yet */ |
564 |
DPRINTF(DPRINTF_MB,"codep: field_pred: %i", pMB->field_pred); |
DPRINTF(XVID_DEBUG_MB,"codep: field_pred: %i\n", pMB->field_pred); |
565 |
|
|
566 |
// write field prediction references |
/* write field prediction references */ |
567 |
|
#if 0 /* Remove the #if once field_pred is supported */ |
568 |
if (pMB->field_pred) { |
if (pMB->field_pred) { |
569 |
BitstreamPutBit(bs, pMB->field_for_top); |
BitstreamPutBit(bs, pMB->field_for_top); |
570 |
BitstreamPutBit(bs, pMB->field_for_bot); |
BitstreamPutBit(bs, pMB->field_for_bot); |
571 |
} |
} |
572 |
|
#endif |
573 |
} |
} |
574 |
} |
} |
575 |
// code motion vector(s) if motion is local |
/* code motion vector(s) if motion is local */ |
576 |
if (!pMB->mcsel) |
if (!pMB->mcsel) |
577 |
for (i = 0; i < (pMB->mode == MODE_INTER4V ? 4 : 1); i++) { |
for (i = 0; i < (pMB->mode == MODE_INTER4V ? 4 : 1); i++) { |
578 |
CodeVector(bs, pMB->pmvs[i].x, frame->fcode, pStat); |
CodeVector(bs, pMB->pmvs[i].x, frame->fcode); |
579 |
CodeVector(bs, pMB->pmvs[i].y, frame->fcode, pStat); |
CodeVector(bs, pMB->pmvs[i].y, frame->fcode); |
580 |
} |
} |
581 |
|
|
582 |
bits = BitstreamPos(bs); |
bits = BitstreamPos(bs); |
583 |
|
|
584 |
// code block coeffs |
/* code block coeffs */ |
585 |
for (i = 0; i < 6; i++) |
for (i = 0; i < 6; i++) |
586 |
if (pMB->cbp & (1 << (5 - i))) |
if (pMB->cbp & (1 << (5 - i))) { |
|
{ |
|
587 |
const uint16_t *scan_table = |
const uint16_t *scan_table = |
588 |
frame->global_flags & XVID_ALTERNATESCAN ? |
frame->vop_flags & XVID_VOP_ALTERNATESCAN ? |
589 |
scan_tables[2] : scan_tables[0]; |
scan_tables[2] : scan_tables[0]; |
590 |
|
|
|
#ifdef BIGLUT |
|
|
CodeCoeff(bs, &qcoeff[i * 64], inter_table, scan_table, 0); |
|
|
#else |
|
591 |
CodeCoeffInter(bs, &qcoeff[i * 64], scan_table); |
CodeCoeffInter(bs, &qcoeff[i * 64], scan_table); |
|
#endif |
|
592 |
} |
} |
593 |
|
|
594 |
bits = BitstreamPos(bs) - bits; |
bits = BitstreamPos(bs) - bits; |
604 |
Statistics * pStat) |
Statistics * pStat) |
605 |
{ |
{ |
606 |
if (frame->coding_type != I_VOP) |
if (frame->coding_type != I_VOP) |
607 |
BitstreamPutBit(bs, 0); // not_coded |
BitstreamPutBit(bs, 0); /* not_coded */ |
608 |
|
|
609 |
|
if (frame->vop_flags & XVID_VOP_GREYSCALE) { |
610 |
|
pMB->cbp &= 0x3C; /* keep only bits 5-2 */ |
611 |
|
qcoeff[4*64+0]=0; /* for INTRA DC value is saved */ |
612 |
|
qcoeff[5*64+0]=0; |
613 |
|
} |
614 |
|
|
615 |
if (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q) |
if (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q) |
616 |
CodeBlockIntra(frame, pMB, qcoeff, bs, pStat); |
CodeBlockIntra(frame, pMB, qcoeff, bs, pStat); |
619 |
|
|
620 |
} |
} |
621 |
|
|
|
/* |
|
|
// moved to mbcoding.h so that in can be 'static __inline' |
|
|
void |
|
|
MBSkip(Bitstream * bs) |
|
|
{ |
|
|
BitstreamPutBit(bs, 1); // not coded |
|
|
} |
|
|
*/ |
|
|
|
|
622 |
/*************************************************************** |
/*************************************************************** |
623 |
* bframe encoding start |
* bframe encoding start |
624 |
***************************************************************/ |
***************************************************************/ |
675 |
BitstreamPutBit(bs, 1); |
BitstreamPutBit(bs, 1); |
676 |
return; |
return; |
677 |
|
|
678 |
default:; // invalid |
default:; /* invalid */ |
679 |
} |
} |
680 |
} |
} |
681 |
|
|
682 |
|
|
683 |
|
|
684 |
void |
void |
685 |
MBCodingBVOP(const MACROBLOCK * mb, |
MBCodingBVOP(const FRAMEINFO * const frame, |
686 |
|
const MACROBLOCK * mb, |
687 |
const int16_t qcoeff[6 * 64], |
const int16_t qcoeff[6 * 64], |
688 |
const int32_t fcode, |
const int32_t fcode, |
689 |
const int32_t bcode, |
const int32_t bcode, |
690 |
Bitstream * bs, |
Bitstream * bs, |
691 |
Statistics * pStat, |
Statistics * pStat) |
|
int direction) |
|
692 |
{ |
{ |
693 |
int vcode = fcode; |
int vcode = fcode; |
694 |
unsigned int i; |
unsigned int i; |
695 |
|
|
696 |
|
const uint16_t *scan_table = |
697 |
|
frame->vop_flags & XVID_VOP_ALTERNATESCAN ? |
698 |
|
scan_tables[2] : scan_tables[0]; |
699 |
|
int bits; |
700 |
|
|
701 |
/* ------------------------------------------------------------------ |
/* ------------------------------------------------------------------ |
702 |
when a block is skipped it is decoded DIRECT(0,0) |
when a block is skipped it is decoded DIRECT(0,0) |
703 |
hence is interpolated from forward & backward frames |
hence is interpolated from forward & backward frames |
704 |
------------------------------------------------------------------ */ |
------------------------------------------------------------------ */ |
705 |
|
|
706 |
if (mb->mode == MODE_DIRECT_NONE_MV) { |
if (mb->mode == MODE_DIRECT_NONE_MV) { |
707 |
BitstreamPutBit(bs, 1); // skipped |
BitstreamPutBit(bs, 1); /* skipped */ |
708 |
return; |
return; |
709 |
} |
} |
710 |
|
|
711 |
BitstreamPutBit(bs, 0); // not skipped |
BitstreamPutBit(bs, 0); /* not skipped */ |
712 |
|
|
713 |
if (mb->cbp == 0) { |
if (mb->cbp == 0) { |
714 |
BitstreamPutBit(bs, 1); // cbp == 0 |
BitstreamPutBit(bs, 1); /* cbp == 0 */ |
715 |
} else { |
} else { |
716 |
BitstreamPutBit(bs, 0); // cbp == xxx |
BitstreamPutBit(bs, 0); /* cbp == xxx */ |
717 |
} |
} |
718 |
|
|
719 |
put_bvop_mbtype(bs, mb->mode); |
put_bvop_mbtype(bs, mb->mode); |
723 |
} |
} |
724 |
|
|
725 |
if (mb->mode != MODE_DIRECT && mb->cbp != 0) { |
if (mb->mode != MODE_DIRECT && mb->cbp != 0) { |
726 |
put_bvop_dbquant(bs, 0); // todo: mb->dquant = 0 |
put_bvop_dbquant(bs, 0); /* todo: mb->dquant = 0 */ |
727 |
} |
} |
728 |
|
|
729 |
|
if (frame->vol_flags & XVID_VOL_INTERLACING) { |
730 |
|
if (mb->cbp) { |
731 |
|
BitstreamPutBit(bs, mb->field_dct); |
732 |
|
DPRINTF(XVID_DEBUG_MB,"codep: field_dct: %i\n", mb->field_dct); |
733 |
|
} |
734 |
|
|
735 |
|
/* if not direct block, write field ME flag */ |
736 |
|
if (mb->mode != MODE_DIRECT) { |
737 |
|
BitstreamPutBit(bs, 0 /*mb->field_pred*/); /* field ME not implemented */ |
738 |
|
|
739 |
|
/* write field prediction references */ |
740 |
|
#if 0 /* Remove the #if once field_pred is supported */ |
741 |
|
if (mb->field_pred) { |
742 |
|
BitstreamPutBit(bs, mb->field_for_top); |
743 |
|
BitstreamPutBit(bs, mb->field_for_bot); |
744 |
|
} |
745 |
|
#endif |
746 |
|
} |
747 |
|
} |
748 |
|
|
749 |
|
|
750 |
switch (mb->mode) { |
switch (mb->mode) { |
751 |
case MODE_INTERPOLATE: |
case MODE_INTERPOLATE: |
752 |
CodeVector(bs, mb->pmvs[1].x, vcode, pStat); //forward vector of interpolate mode |
CodeVector(bs, mb->pmvs[1].x, vcode); /* forward vector of interpolate mode */ |
753 |
CodeVector(bs, mb->pmvs[1].y, vcode, pStat); |
CodeVector(bs, mb->pmvs[1].y, vcode); |
754 |
case MODE_BACKWARD: |
case MODE_BACKWARD: |
755 |
vcode = bcode; |
vcode = bcode; |
756 |
case MODE_FORWARD: |
case MODE_FORWARD: |
757 |
CodeVector(bs, mb->pmvs[0].x, vcode, pStat); |
CodeVector(bs, mb->pmvs[0].x, vcode); |
758 |
CodeVector(bs, mb->pmvs[0].y, vcode, pStat); |
CodeVector(bs, mb->pmvs[0].y, vcode); |
759 |
break; |
break; |
760 |
case MODE_DIRECT: |
case MODE_DIRECT: |
761 |
CodeVector(bs, mb->pmvs[3].x, 1, pStat); // fcode is always 1 for delta vector |
CodeVector(bs, mb->pmvs[3].x, 1); /* fcode is always 1 for delta vector */ |
762 |
CodeVector(bs, mb->pmvs[3].y, 1, pStat); // prediction is always (0,0) |
CodeVector(bs, mb->pmvs[3].y, 1); /* prediction is always (0,0) */ |
763 |
default: break; |
default: break; |
764 |
} |
} |
765 |
|
|
766 |
|
bits = BitstreamPos(bs); |
767 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
768 |
if (mb->cbp & (1 << (5 - i))) { |
if (mb->cbp & (1 << (5 - i))) { |
769 |
#ifdef BIGLUT |
CodeCoeffInter(bs, &qcoeff[i * 64], scan_table); |
|
CodeCoeff(bs, &qcoeff[i * 64], inter_table, scan_tables[0], 0); |
|
|
#else |
|
|
CodeCoeffInter(bs, &qcoeff[i * 64], scan_tables[0]); |
|
|
#endif |
|
770 |
} |
} |
771 |
} |
} |
772 |
|
pStat->iTextBits += BitstreamPos(bs) - bits; |
773 |
} |
} |
774 |
|
|
775 |
|
|
779 |
***************************************************************/ |
***************************************************************/ |
780 |
|
|
781 |
|
|
782 |
// for IVOP addbits == 0 |
/* |
783 |
// for PVOP addbits == fcode - 1 |
* for IVOP addbits == 0 |
784 |
// for BVOP addbits == max(fcode,bcode) - 1 |
* for PVOP addbits == fcode - 1 |
785 |
// returns true or false |
* for BVOP addbits == max(fcode,bcode) - 1 |
786 |
|
* returns true or false |
787 |
|
*/ |
788 |
int |
int |
789 |
check_resync_marker(Bitstream * bs, int addbits) |
check_resync_marker(Bitstream * bs, int addbits) |
790 |
{ |
{ |
898 |
return data; |
return data; |
899 |
|
|
900 |
res = BitstreamGetBits(bs, fcode - 1); |
res = BitstreamGetBits(bs, fcode - 1); |
901 |
mv = ((ABS(data) - 1) * scale_fac) + res + 1; |
mv = ((abs(data) - 1) * scale_fac) + res + 1; |
902 |
|
|
903 |
return data < 0 ? -mv : mv; |
return data < 0 ? -mv : mv; |
904 |
|
|
961 |
|
|
962 |
} |
} |
963 |
|
|
964 |
|
#define GET_BITS(cache, n) ((cache)>>(32-(n))) |
965 |
|
|
966 |
static __inline int |
static __inline int |
967 |
get_coeff(Bitstream * bs, |
get_coeff(Bitstream * bs, |
968 |
int *run, |
int *run, |
975 |
int32_t level; |
int32_t level; |
976 |
REVERSE_EVENT *reverse_event; |
REVERSE_EVENT *reverse_event; |
977 |
|
|
978 |
|
uint32_t cache = BitstreamShowBits(bs, 32); |
979 |
|
|
980 |
if (short_video_header) /* inter-VLCs will be used for both intra and inter blocks */ |
if (short_video_header) /* inter-VLCs will be used for both intra and inter blocks */ |
981 |
intra = 0; |
intra = 0; |
982 |
|
|
983 |
if (BitstreamShowBits(bs, 7) != ESCAPE) { |
if (GET_BITS(cache, 7) != ESCAPE) { |
984 |
reverse_event = &DCT3D[intra][BitstreamShowBits(bs, 12)]; |
reverse_event = &DCT3D[intra][GET_BITS(cache, 12)]; |
985 |
|
|
986 |
if ((level = reverse_event->event.level) == 0) |
if ((level = reverse_event->event.level) == 0) |
987 |
goto error; |
goto error; |
989 |
*last = reverse_event->event.last; |
*last = reverse_event->event.last; |
990 |
*run = reverse_event->event.run; |
*run = reverse_event->event.run; |
991 |
|
|
992 |
BitstreamSkip(bs, reverse_event->len); |
/* Don't forget to update the bitstream position */ |
993 |
|
BitstreamSkip(bs, reverse_event->len+1); |
994 |
|
|
995 |
return BitstreamGetBits(bs, 1) ? -level : level; |
return (GET_BITS(cache, reverse_event->len+1)&0x01) ? -level : level; |
996 |
} |
} |
997 |
|
|
998 |
BitstreamSkip(bs, 7); |
/* flush 7bits of cache */ |
999 |
|
cache <<= 7; |
1000 |
|
|
1001 |
if (short_video_header) { |
if (short_video_header) { |
1002 |
/* escape mode 4 - H.263 type, only used if short_video_header = 1 */ |
/* escape mode 4 - H.263 type, only used if short_video_header = 1 */ |
1003 |
*last = BitstreamGetBit(bs); |
*last = GET_BITS(cache, 1); |
1004 |
*run = BitstreamGetBits(bs, 6); |
*run = (GET_BITS(cache, 7) &0x3f); |
1005 |
level = BitstreamGetBits(bs, 8); |
level = (GET_BITS(cache, 15)&0xff); |
1006 |
|
|
1007 |
if (level == 0 || level == 128) |
if (level == 0 || level == 128) |
1008 |
DPRINTF(DPRINTF_ERROR, "Illegal LEVEL for ESCAPE mode 4: %d", level); |
DPRINTF(XVID_DEBUG_ERROR, "Illegal LEVEL for ESCAPE mode 4: %d\n", level); |
1009 |
|
|
1010 |
|
/* We've "eaten" 22 bits */ |
1011 |
|
BitstreamSkip(bs, 22); |
1012 |
|
|
1013 |
return (level << 24) >> 24; |
return (level << 24) >> 24; |
1014 |
} |
} |
1015 |
|
|
1016 |
mode = BitstreamShowBits(bs, 2); |
if ((mode = GET_BITS(cache, 2)) < 3) { |
1017 |
|
const int skip[3] = {1, 1, 2}; |
1018 |
|
cache <<= skip[mode]; |
1019 |
|
|
1020 |
if (mode < 3) { |
reverse_event = &DCT3D[intra][GET_BITS(cache, 12)]; |
|
BitstreamSkip(bs, (mode == 2) ? 2 : 1); |
|
|
|
|
|
reverse_event = &DCT3D[intra][BitstreamShowBits(bs, 12)]; |
|
1021 |
|
|
1022 |
if ((level = reverse_event->event.level) == 0) |
if ((level = reverse_event->event.level) == 0) |
1023 |
goto error; |
goto error; |
1025 |
*last = reverse_event->event.last; |
*last = reverse_event->event.last; |
1026 |
*run = reverse_event->event.run; |
*run = reverse_event->event.run; |
1027 |
|
|
1028 |
BitstreamSkip(bs, reverse_event->len); |
if (mode < 2) { |
1029 |
|
/* first escape mode, level is offset */ |
|
if (mode < 2) /* first escape mode, level is offset */ |
|
1030 |
level += max_level[intra][*last][*run]; |
level += max_level[intra][*last][*run]; |
1031 |
else /* second escape mode, run is offset */ |
} else { |
1032 |
|
/* second escape mode, run is offset */ |
1033 |
*run += max_run[intra][*last][level] + 1; |
*run += max_run[intra][*last][level] + 1; |
1034 |
|
} |
1035 |
|
|
1036 |
|
/* Update bitstream position */ |
1037 |
|
BitstreamSkip(bs, 7 + skip[mode] + reverse_event->len + 1); |
1038 |
|
|
1039 |
return BitstreamGetBits(bs, 1) ? -level : level; |
return (GET_BITS(cache, reverse_event->len+1)&0x01) ? -level : level; |
1040 |
} |
} |
1041 |
|
|
1042 |
/* third escape mode - fixed length codes */ |
/* third escape mode - fixed length codes */ |
1043 |
BitstreamSkip(bs, 2); |
cache <<= 2; |
1044 |
*last = BitstreamGetBits(bs, 1); |
*last = GET_BITS(cache, 1); |
1045 |
*run = BitstreamGetBits(bs, 6); |
*run = (GET_BITS(cache, 7)&0x3f); |
1046 |
BitstreamSkip(bs, 1); /* marker */ |
level = (GET_BITS(cache, 20)&0xfff); |
1047 |
level = BitstreamGetBits(bs, 12); |
|
1048 |
BitstreamSkip(bs, 1); /* marker */ |
/* Update bitstream position */ |
1049 |
|
BitstreamSkip(bs, 30); |
1050 |
|
|
1051 |
return (level << 20) >> 20; |
return (level << 20) >> 20; |
1052 |
|
|
1067 |
|
|
1068 |
do { |
do { |
1069 |
level = get_coeff(bs, &run, &last, 1, 0); |
level = get_coeff(bs, &run, &last, 1, 0); |
1070 |
if (run == -1) { |
coeff += run; |
1071 |
DPRINTF(DPRINTF_ERROR,"fatal: invalid run"); |
if ((run|coeff)&~63) { |
1072 |
|
DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run or index"); |
1073 |
break; |
break; |
1074 |
} |
} |
1075 |
coeff += run; |
|
1076 |
block[scan[coeff]] = level; |
block[scan[coeff]] = level; |
1077 |
|
|
1078 |
DPRINTF(DPRINTF_COEFF,"block[%i] %i", scan[coeff], level); |
DPRINTF(XVID_DEBUG_COEFF,"block[%i] %i\n", scan[coeff], level); |
1079 |
//DPRINTF(DPRINTF_COEFF,"block[%i] %i %08x", scan[coeff], level, BitstreamShowBits(bs, 32)); |
#if 0 |
1080 |
|
DPRINTF(XVID_DEBUG_COEFF,"block[%i] %i %08x\n", scan[coeff], level, BitstreamShowBits(bs, 32)); |
1081 |
|
#endif |
1082 |
|
|
1083 |
if (level < -2047 || level > 2047) { |
if (level < -2047 || level > 2047) { |
1084 |
DPRINTF(DPRINTF_ERROR,"warning: intra_overflow %i", level); |
DPRINTF(XVID_DEBUG_ERROR,"warning: intra_overflow %i\n", level); |
1085 |
} |
} |
1086 |
coeff++; |
coeff++; |
1087 |
} while (!last); |
} while (!last); |
1089 |
} |
} |
1090 |
|
|
1091 |
void |
void |
1092 |
get_inter_block(Bitstream * bs, |
get_inter_block_h263( |
1093 |
|
Bitstream * bs, |
1094 |
int16_t * block, |
int16_t * block, |
1095 |
int direction) |
int direction, |
1096 |
|
const int quant, |
1097 |
|
const uint16_t *matrix) |
1098 |
{ |
{ |
1099 |
|
|
1100 |
const uint16_t *scan = scan_tables[direction]; |
const uint16_t *scan = scan_tables[direction]; |
1101 |
|
const uint16_t quant_m_2 = quant << 1; |
1102 |
|
const uint16_t quant_add = (quant & 1 ? quant : quant - 1); |
1103 |
int p; |
int p; |
1104 |
int level; |
int level; |
1105 |
int run; |
int run; |
1108 |
p = 0; |
p = 0; |
1109 |
do { |
do { |
1110 |
level = get_coeff(bs, &run, &last, 0, 0); |
level = get_coeff(bs, &run, &last, 0, 0); |
1111 |
if (run == -1) { |
p += run; |
1112 |
DPRINTF(DPRINTF_ERROR,"fatal: invalid run"); |
if ((run|p)&~63) { |
1113 |
|
DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run or index"); |
1114 |
break; |
break; |
1115 |
} |
} |
|
p += run; |
|
1116 |
|
|
1117 |
block[scan[p]] = level; |
if (level < 0) { |
1118 |
|
level = level*quant_m_2 - quant_add; |
1119 |
|
block[scan[p]] = (level >= -2048 ? level : -2048); |
1120 |
|
} else { |
1121 |
|
level = level * quant_m_2 + quant_add; |
1122 |
|
block[scan[p]] = (level <= 2047 ? level : 2047); |
1123 |
|
} |
1124 |
|
p++; |
1125 |
|
} while (!last); |
1126 |
|
} |
1127 |
|
|
1128 |
DPRINTF(DPRINTF_COEFF,"block[%i] %i", scan[p], level); |
void |
1129 |
// DPRINTF(DPRINTF_COEFF,"block[%i] %i %08x", scan[p], level, BitstreamShowBits(bs, 32)); |
get_inter_block_mpeg( |
1130 |
|
Bitstream * bs, |
1131 |
|
int16_t * block, |
1132 |
|
int direction, |
1133 |
|
const int quant, |
1134 |
|
const uint16_t *matrix) |
1135 |
|
{ |
1136 |
|
const uint16_t *scan = scan_tables[direction]; |
1137 |
|
uint32_t sum = 0; |
1138 |
|
int p; |
1139 |
|
int level; |
1140 |
|
int run; |
1141 |
|
int last; |
1142 |
|
|
1143 |
if (level < -2047 || level > 2047) { |
p = 0; |
1144 |
DPRINTF(DPRINTF_ERROR,"warning: inter overflow %i", level); |
do { |
1145 |
|
level = get_coeff(bs, &run, &last, 0, 0); |
1146 |
|
p += run; |
1147 |
|
if ((run|p)&~63) { |
1148 |
|
DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run or index"); |
1149 |
|
break; |
1150 |
|
} |
1151 |
|
|
1152 |
|
if (level < 0) { |
1153 |
|
level = ((2 * -level + 1) * matrix[scan[p]] * quant) >> 4; |
1154 |
|
block[scan[p]] = (level <= 2048 ? -level : -2048); |
1155 |
|
} else { |
1156 |
|
level = ((2 * level + 1) * matrix[scan[p]] * quant) >> 4; |
1157 |
|
block[scan[p]] = (level <= 2047 ? level : 2047); |
1158 |
} |
} |
1159 |
|
|
1160 |
|
sum ^= block[scan[p]]; |
1161 |
|
|
1162 |
p++; |
p++; |
1163 |
} while (!last); |
} while (!last); |
1164 |
|
|
1165 |
} |
/* mismatch control */ |
1166 |
|
if ((sum & 1) == 0) { |
1167 |
|
block[63] ^= 1; |
1168 |
|
} |
1169 |
|
} |
1170 |
|
|
1171 |
|
|
1172 |
|
/***************************************************************************** |
1173 |
|
* VLC tables and other constant arrays |
1174 |
|
****************************************************************************/ |
1175 |
|
|
1176 |
|
VLC_TABLE const coeff_tab[2][102] = |
1177 |
|
{ |
1178 |
|
/* intra = 0 */ |
1179 |
|
{ |
1180 |
|
{{ 2, 2}, {0, 0, 1}}, |
1181 |
|
{{15, 4}, {0, 0, 2}}, |
1182 |
|
{{21, 6}, {0, 0, 3}}, |
1183 |
|
{{23, 7}, {0, 0, 4}}, |
1184 |
|
{{31, 8}, {0, 0, 5}}, |
1185 |
|
{{37, 9}, {0, 0, 6}}, |
1186 |
|
{{36, 9}, {0, 0, 7}}, |
1187 |
|
{{33, 10}, {0, 0, 8}}, |
1188 |
|
{{32, 10}, {0, 0, 9}}, |
1189 |
|
{{ 7, 11}, {0, 0, 10}}, |
1190 |
|
{{ 6, 11}, {0, 0, 11}}, |
1191 |
|
{{32, 11}, {0, 0, 12}}, |
1192 |
|
{{ 6, 3}, {0, 1, 1}}, |
1193 |
|
{{20, 6}, {0, 1, 2}}, |
1194 |
|
{{30, 8}, {0, 1, 3}}, |
1195 |
|
{{15, 10}, {0, 1, 4}}, |
1196 |
|
{{33, 11}, {0, 1, 5}}, |
1197 |
|
{{80, 12}, {0, 1, 6}}, |
1198 |
|
{{14, 4}, {0, 2, 1}}, |
1199 |
|
{{29, 8}, {0, 2, 2}}, |
1200 |
|
{{14, 10}, {0, 2, 3}}, |
1201 |
|
{{81, 12}, {0, 2, 4}}, |
1202 |
|
{{13, 5}, {0, 3, 1}}, |
1203 |
|
{{35, 9}, {0, 3, 2}}, |
1204 |
|
{{13, 10}, {0, 3, 3}}, |
1205 |
|
{{12, 5}, {0, 4, 1}}, |
1206 |
|
{{34, 9}, {0, 4, 2}}, |
1207 |
|
{{82, 12}, {0, 4, 3}}, |
1208 |
|
{{11, 5}, {0, 5, 1}}, |
1209 |
|
{{12, 10}, {0, 5, 2}}, |
1210 |
|
{{83, 12}, {0, 5, 3}}, |
1211 |
|
{{19, 6}, {0, 6, 1}}, |
1212 |
|
{{11, 10}, {0, 6, 2}}, |
1213 |
|
{{84, 12}, {0, 6, 3}}, |
1214 |
|
{{18, 6}, {0, 7, 1}}, |
1215 |
|
{{10, 10}, {0, 7, 2}}, |
1216 |
|
{{17, 6}, {0, 8, 1}}, |
1217 |
|
{{ 9, 10}, {0, 8, 2}}, |
1218 |
|
{{16, 6}, {0, 9, 1}}, |
1219 |
|
{{ 8, 10}, {0, 9, 2}}, |
1220 |
|
{{22, 7}, {0, 10, 1}}, |
1221 |
|
{{85, 12}, {0, 10, 2}}, |
1222 |
|
{{21, 7}, {0, 11, 1}}, |
1223 |
|
{{20, 7}, {0, 12, 1}}, |
1224 |
|
{{28, 8}, {0, 13, 1}}, |
1225 |
|
{{27, 8}, {0, 14, 1}}, |
1226 |
|
{{33, 9}, {0, 15, 1}}, |
1227 |
|
{{32, 9}, {0, 16, 1}}, |
1228 |
|
{{31, 9}, {0, 17, 1}}, |
1229 |
|
{{30, 9}, {0, 18, 1}}, |
1230 |
|
{{29, 9}, {0, 19, 1}}, |
1231 |
|
{{28, 9}, {0, 20, 1}}, |
1232 |
|
{{27, 9}, {0, 21, 1}}, |
1233 |
|
{{26, 9}, {0, 22, 1}}, |
1234 |
|
{{34, 11}, {0, 23, 1}}, |
1235 |
|
{{35, 11}, {0, 24, 1}}, |
1236 |
|
{{86, 12}, {0, 25, 1}}, |
1237 |
|
{{87, 12}, {0, 26, 1}}, |
1238 |
|
{{ 7, 4}, {1, 0, 1}}, |
1239 |
|
{{25, 9}, {1, 0, 2}}, |
1240 |
|
{{ 5, 11}, {1, 0, 3}}, |
1241 |
|
{{15, 6}, {1, 1, 1}}, |
1242 |
|
{{ 4, 11}, {1, 1, 2}}, |
1243 |
|
{{14, 6}, {1, 2, 1}}, |
1244 |
|
{{13, 6}, {1, 3, 1}}, |
1245 |
|
{{12, 6}, {1, 4, 1}}, |
1246 |
|
{{19, 7}, {1, 5, 1}}, |
1247 |
|
{{18, 7}, {1, 6, 1}}, |
1248 |
|
{{17, 7}, {1, 7, 1}}, |
1249 |
|
{{16, 7}, {1, 8, 1}}, |
1250 |
|
{{26, 8}, {1, 9, 1}}, |
1251 |
|
{{25, 8}, {1, 10, 1}}, |
1252 |
|
{{24, 8}, {1, 11, 1}}, |
1253 |
|
{{23, 8}, {1, 12, 1}}, |
1254 |
|
{{22, 8}, {1, 13, 1}}, |
1255 |
|
{{21, 8}, {1, 14, 1}}, |
1256 |
|
{{20, 8}, {1, 15, 1}}, |
1257 |
|
{{19, 8}, {1, 16, 1}}, |
1258 |
|
{{24, 9}, {1, 17, 1}}, |
1259 |
|
{{23, 9}, {1, 18, 1}}, |
1260 |
|
{{22, 9}, {1, 19, 1}}, |
1261 |
|
{{21, 9}, {1, 20, 1}}, |
1262 |
|
{{20, 9}, {1, 21, 1}}, |
1263 |
|
{{19, 9}, {1, 22, 1}}, |
1264 |
|
{{18, 9}, {1, 23, 1}}, |
1265 |
|
{{17, 9}, {1, 24, 1}}, |
1266 |
|
{{ 7, 10}, {1, 25, 1}}, |
1267 |
|
{{ 6, 10}, {1, 26, 1}}, |
1268 |
|
{{ 5, 10}, {1, 27, 1}}, |
1269 |
|
{{ 4, 10}, {1, 28, 1}}, |
1270 |
|
{{36, 11}, {1, 29, 1}}, |
1271 |
|
{{37, 11}, {1, 30, 1}}, |
1272 |
|
{{38, 11}, {1, 31, 1}}, |
1273 |
|
{{39, 11}, {1, 32, 1}}, |
1274 |
|
{{88, 12}, {1, 33, 1}}, |
1275 |
|
{{89, 12}, {1, 34, 1}}, |
1276 |
|
{{90, 12}, {1, 35, 1}}, |
1277 |
|
{{91, 12}, {1, 36, 1}}, |
1278 |
|
{{92, 12}, {1, 37, 1}}, |
1279 |
|
{{93, 12}, {1, 38, 1}}, |
1280 |
|
{{94, 12}, {1, 39, 1}}, |
1281 |
|
{{95, 12}, {1, 40, 1}} |
1282 |
|
}, |
1283 |
|
/* intra = 1 */ |
1284 |
|
{ |
1285 |
|
{{ 2, 2}, {0, 0, 1}}, |
1286 |
|
{{15, 4}, {0, 0, 3}}, |
1287 |
|
{{21, 6}, {0, 0, 6}}, |
1288 |
|
{{23, 7}, {0, 0, 9}}, |
1289 |
|
{{31, 8}, {0, 0, 10}}, |
1290 |
|
{{37, 9}, {0, 0, 13}}, |
1291 |
|
{{36, 9}, {0, 0, 14}}, |
1292 |
|
{{33, 10}, {0, 0, 17}}, |
1293 |
|
{{32, 10}, {0, 0, 18}}, |
1294 |
|
{{ 7, 11}, {0, 0, 21}}, |
1295 |
|
{{ 6, 11}, {0, 0, 22}}, |
1296 |
|
{{32, 11}, {0, 0, 23}}, |
1297 |
|
{{ 6, 3}, {0, 0, 2}}, |
1298 |
|
{{20, 6}, {0, 1, 2}}, |
1299 |
|
{{30, 8}, {0, 0, 11}}, |
1300 |
|
{{15, 10}, {0, 0, 19}}, |
1301 |
|
{{33, 11}, {0, 0, 24}}, |
1302 |
|
{{80, 12}, {0, 0, 25}}, |
1303 |
|
{{14, 4}, {0, 1, 1}}, |
1304 |
|
{{29, 8}, {0, 0, 12}}, |
1305 |
|
{{14, 10}, {0, 0, 20}}, |
1306 |
|
{{81, 12}, {0, 0, 26}}, |
1307 |
|
{{13, 5}, {0, 0, 4}}, |
1308 |
|
{{35, 9}, {0, 0, 15}}, |
1309 |
|
{{13, 10}, {0, 1, 7}}, |
1310 |
|
{{12, 5}, {0, 0, 5}}, |
1311 |
|
{{34, 9}, {0, 4, 2}}, |
1312 |
|
{{82, 12}, {0, 0, 27}}, |
1313 |
|
{{11, 5}, {0, 2, 1}}, |
1314 |
|
{{12, 10}, {0, 2, 4}}, |
1315 |
|
{{83, 12}, {0, 1, 9}}, |
1316 |
|
{{19, 6}, {0, 0, 7}}, |
1317 |
|
{{11, 10}, {0, 3, 4}}, |
1318 |
|
{{84, 12}, {0, 6, 3}}, |
1319 |
|
{{18, 6}, {0, 0, 8}}, |
1320 |
|
{{10, 10}, {0, 4, 3}}, |
1321 |
|
{{17, 6}, {0, 3, 1}}, |
1322 |
|
{{ 9, 10}, {0, 8, 2}}, |
1323 |
|
{{16, 6}, {0, 4, 1}}, |
1324 |
|
{{ 8, 10}, {0, 5, 3}}, |
1325 |
|
{{22, 7}, {0, 1, 3}}, |
1326 |
|
{{85, 12}, {0, 1, 10}}, |
1327 |
|
{{21, 7}, {0, 2, 2}}, |
1328 |
|
{{20, 7}, {0, 7, 1}}, |
1329 |
|
{{28, 8}, {0, 1, 4}}, |
1330 |
|
{{27, 8}, {0, 3, 2}}, |
1331 |
|
{{33, 9}, {0, 0, 16}}, |
1332 |
|
{{32, 9}, {0, 1, 5}}, |
1333 |
|
{{31, 9}, {0, 1, 6}}, |
1334 |
|
{{30, 9}, {0, 2, 3}}, |
1335 |
|
{{29, 9}, {0, 3, 3}}, |
1336 |
|
{{28, 9}, {0, 5, 2}}, |
1337 |
|
{{27, 9}, {0, 6, 2}}, |
1338 |
|
{{26, 9}, {0, 7, 2}}, |
1339 |
|
{{34, 11}, {0, 1, 8}}, |
1340 |
|
{{35, 11}, {0, 9, 2}}, |
1341 |
|
{{86, 12}, {0, 2, 5}}, |
1342 |
|
{{87, 12}, {0, 7, 3}}, |
1343 |
|
{{ 7, 4}, {1, 0, 1}}, |
1344 |
|
{{25, 9}, {0, 11, 1}}, |
1345 |
|
{{ 5, 11}, {1, 0, 6}}, |
1346 |
|
{{15, 6}, {1, 1, 1}}, |
1347 |
|
{{ 4, 11}, {1, 0, 7}}, |
1348 |
|
{{14, 6}, {1, 2, 1}}, |
1349 |
|
{{13, 6}, {0, 5, 1}}, |
1350 |
|
{{12, 6}, {1, 0, 2}}, |
1351 |
|
{{19, 7}, {1, 5, 1}}, |
1352 |
|
{{18, 7}, {0, 6, 1}}, |
1353 |
|
{{17, 7}, {1, 3, 1}}, |
1354 |
|
{{16, 7}, {1, 4, 1}}, |
1355 |
|
{{26, 8}, {1, 9, 1}}, |
1356 |
|
{{25, 8}, {0, 8, 1}}, |
1357 |
|
{{24, 8}, {0, 9, 1}}, |
1358 |
|
{{23, 8}, {0, 10, 1}}, |
1359 |
|
{{22, 8}, {1, 0, 3}}, |
1360 |
|
{{21, 8}, {1, 6, 1}}, |
1361 |
|
{{20, 8}, {1, 7, 1}}, |
1362 |
|
{{19, 8}, {1, 8, 1}}, |
1363 |
|
{{24, 9}, {0, 12, 1}}, |
1364 |
|
{{23, 9}, {1, 0, 4}}, |
1365 |
|
{{22, 9}, {1, 1, 2}}, |
1366 |
|
{{21, 9}, {1, 10, 1}}, |
1367 |
|
{{20, 9}, {1, 11, 1}}, |
1368 |
|
{{19, 9}, {1, 12, 1}}, |
1369 |
|
{{18, 9}, {1, 13, 1}}, |
1370 |
|
{{17, 9}, {1, 14, 1}}, |
1371 |
|
{{ 7, 10}, {0, 13, 1}}, |
1372 |
|
{{ 6, 10}, {1, 0, 5}}, |
1373 |
|
{{ 5, 10}, {1, 1, 3}}, |
1374 |
|
{{ 4, 10}, {1, 2, 2}}, |
1375 |
|
{{36, 11}, {1, 3, 2}}, |
1376 |
|
{{37, 11}, {1, 4, 2}}, |
1377 |
|
{{38, 11}, {1, 15, 1}}, |
1378 |
|
{{39, 11}, {1, 16, 1}}, |
1379 |
|
{{88, 12}, {0, 14, 1}}, |
1380 |
|
{{89, 12}, {1, 0, 8}}, |
1381 |
|
{{90, 12}, {1, 5, 2}}, |
1382 |
|
{{91, 12}, {1, 6, 2}}, |
1383 |
|
{{92, 12}, {1, 17, 1}}, |
1384 |
|
{{93, 12}, {1, 18, 1}}, |
1385 |
|
{{94, 12}, {1, 19, 1}}, |
1386 |
|
{{95, 12}, {1, 20, 1}} |
1387 |
|
} |
1388 |
|
}; |
1389 |
|
|
1390 |
|
/* constants taken from momusys/vm_common/inlcude/max_level.h */ |
1391 |
|
uint8_t const max_level[2][2][64] = { |
1392 |
|
{ |
1393 |
|
/* intra = 0, last = 0 */ |
1394 |
|
{ |
1395 |
|
12, 6, 4, 3, 3, 3, 3, 2, |
1396 |
|
2, 2, 2, 1, 1, 1, 1, 1, |
1397 |
|
1, 1, 1, 1, 1, 1, 1, 1, |
1398 |
|
1, 1, 1, 0, 0, 0, 0, 0, |
1399 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1400 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1401 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1402 |
|
0, 0, 0, 0, 0, 0, 0, 0 |
1403 |
|
}, |
1404 |
|
/* intra = 0, last = 1 */ |
1405 |
|
{ |
1406 |
|
3, 2, 1, 1, 1, 1, 1, 1, |
1407 |
|
1, 1, 1, 1, 1, 1, 1, 1, |
1408 |
|
1, 1, 1, 1, 1, 1, 1, 1, |
1409 |
|
1, 1, 1, 1, 1, 1, 1, 1, |
1410 |
|
1, 1, 1, 1, 1, 1, 1, 1, |
1411 |
|
1, 0, 0, 0, 0, 0, 0, 0, |
1412 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1413 |
|
0, 0, 0, 0, 0, 0, 0, 0 |
1414 |
|
} |
1415 |
|
}, |
1416 |
|
{ |
1417 |
|
/* intra = 1, last = 0 */ |
1418 |
|
{ |
1419 |
|
27, 10, 5, 4, 3, 3, 3, 3, |
1420 |
|
2, 2, 1, 1, 1, 1, 1, 0, |
1421 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1422 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1423 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1424 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1425 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1426 |
|
0, 0, 0, 0, 0, 0, 0, 0 |
1427 |
|
}, |
1428 |
|
/* intra = 1, last = 1 */ |
1429 |
|
{ |
1430 |
|
8, 3, 2, 2, 2, 2, 2, 1, |
1431 |
|
1, 1, 1, 1, 1, 1, 1, 1, |
1432 |
|
1, 1, 1, 1, 1, 0, 0, 0, |
1433 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1434 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1435 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1436 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1437 |
|
0, 0, 0, 0, 0, 0, 0, 0 |
1438 |
|
} |
1439 |
|
} |
1440 |
|
}; |
1441 |
|
|
1442 |
|
uint8_t const max_run[2][2][64] = { |
1443 |
|
{ |
1444 |
|
/* intra = 0, last = 0 */ |
1445 |
|
{ |
1446 |
|
0, 26, 10, 6, 2, 1, 1, 0, |
1447 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1448 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1449 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1450 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1451 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1452 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1453 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1454 |
|
}, |
1455 |
|
/* intra = 0, last = 1 */ |
1456 |
|
{ |
1457 |
|
0, 40, 1, 0, 0, 0, 0, 0, |
1458 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1459 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1460 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1461 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1462 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1463 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1464 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1465 |
|
} |
1466 |
|
}, |
1467 |
|
{ |
1468 |
|
/* intra = 1, last = 0 */ |
1469 |
|
{ |
1470 |
|
0, 14, 9, 7, 3, 2, 1, 1, |
1471 |
|
1, 1, 1, 0, 0, 0, 0, 0, |
1472 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1473 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1474 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1475 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1476 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1477 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1478 |
|
}, |
1479 |
|
/* intra = 1, last = 1 */ |
1480 |
|
{ |
1481 |
|
0, 20, 6, 1, 0, 0, 0, 0, |
1482 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1483 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1484 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1485 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1486 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1487 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1488 |
|
0, 0, 0, 0, 0, 0, 0, 0, |
1489 |
|
} |
1490 |
|
} |
1491 |
|
}; |
1492 |
|
|
1493 |
|
/****************************************************************** |
1494 |
|
* encoder tables * |
1495 |
|
******************************************************************/ |
1496 |
|
|
1497 |
|
VLC sprite_trajectory_code[32768]; |
1498 |
|
|
1499 |
|
VLC sprite_trajectory_len[15] = { |
1500 |
|
{ 0x00 , 2}, |
1501 |
|
{ 0x02 , 3}, { 0x03, 3}, { 0x04, 3}, { 0x05, 3}, { 0x06, 3}, |
1502 |
|
{ 0x0E , 4}, { 0x1E, 5}, { 0x3E, 6}, { 0x7E, 7}, { 0xFE, 8}, |
1503 |
|
{ 0x1FE, 9}, {0x3FE,10}, {0x7FE,11}, {0xFFE,12} }; |
1504 |
|
|
1505 |
|
|
1506 |
|
/* DCT coefficients. Four tables, two for last = 0, two for last = 1. |
1507 |
|
the sign bit must be added afterwards. */ |
1508 |
|
|
1509 |
|
/* MCBPC Indexing by cbpc in first two bits, mode in last two. |
1510 |
|
CBPC as in table 4/H.263, MB type (mode): 3 = 01, 4 = 10. |
1511 |
|
Example: cbpc = 01 and mode = 4 gives index = 0110 = 6. */ |
1512 |
|
|
1513 |
|
VLC mcbpc_intra_tab[15] = { |
1514 |
|
{0x01, 9}, {0x01, 1}, {0x01, 4}, {0x00, 0}, |
1515 |
|
{0x00, 0}, {0x01, 3}, {0x01, 6}, {0x00, 0}, |
1516 |
|
{0x00, 0}, {0x02, 3}, {0x02, 6}, {0x00, 0}, |
1517 |
|
{0x00, 0}, {0x03, 3}, {0x03, 6} |
1518 |
|
}; |
1519 |
|
|
1520 |
|
/* MCBPC inter. |
1521 |
|
Addressing: 5 bit ccmmm (cc = CBPC, mmm = mode (1-4 binary)) */ |
1522 |
|
|
1523 |
|
VLC mcbpc_inter_tab[29] = { |
1524 |
|
{1, 1}, {3, 3}, {2, 3}, {3, 5}, {4, 6}, {1, 9}, {0, 0}, {0, 0}, |
1525 |
|
{3, 4}, {7, 7}, {5, 7}, {4, 8}, {4, 9}, {0, 0}, {0, 0}, {0, 0}, |
1526 |
|
{2, 4}, {6, 7}, {4, 7}, {3, 8}, {3, 9}, {0, 0}, {0, 0}, {0, 0}, |
1527 |
|
{5, 6}, {5, 9}, {5, 8}, {3, 7}, {2, 9} |
1528 |
|
}; |
1529 |
|
|
1530 |
|
const VLC xvid_cbpy_tab[16] = { |
1531 |
|
{3, 4}, {5, 5}, {4, 5}, {9, 4}, {3, 5}, {7, 4}, {2, 6}, {11, 4}, |
1532 |
|
{2, 5}, {3, 6}, {5, 4}, {10, 4}, {4, 4}, {8, 4}, {6, 4}, {3, 2} |
1533 |
|
}; |
1534 |
|
|
1535 |
|
const VLC dcy_tab[511] = { |
1536 |
|
{0x100, 15}, {0x101, 15}, {0x102, 15}, {0x103, 15}, |
1537 |
|
{0x104, 15}, {0x105, 15}, {0x106, 15}, {0x107, 15}, |
1538 |
|
{0x108, 15}, {0x109, 15}, {0x10a, 15}, {0x10b, 15}, |
1539 |
|
{0x10c, 15}, {0x10d, 15}, {0x10e, 15}, {0x10f, 15}, |
1540 |
|
{0x110, 15}, {0x111, 15}, {0x112, 15}, {0x113, 15}, |
1541 |
|
{0x114, 15}, {0x115, 15}, {0x116, 15}, {0x117, 15}, |
1542 |
|
{0x118, 15}, {0x119, 15}, {0x11a, 15}, {0x11b, 15}, |
1543 |
|
{0x11c, 15}, {0x11d, 15}, {0x11e, 15}, {0x11f, 15}, |
1544 |
|
{0x120, 15}, {0x121, 15}, {0x122, 15}, {0x123, 15}, |
1545 |
|
{0x124, 15}, {0x125, 15}, {0x126, 15}, {0x127, 15}, |
1546 |
|
{0x128, 15}, {0x129, 15}, {0x12a, 15}, {0x12b, 15}, |
1547 |
|
{0x12c, 15}, {0x12d, 15}, {0x12e, 15}, {0x12f, 15}, |
1548 |
|
{0x130, 15}, {0x131, 15}, {0x132, 15}, {0x133, 15}, |
1549 |
|
{0x134, 15}, {0x135, 15}, {0x136, 15}, {0x137, 15}, |
1550 |
|
{0x138, 15}, {0x139, 15}, {0x13a, 15}, {0x13b, 15}, |
1551 |
|
{0x13c, 15}, {0x13d, 15}, {0x13e, 15}, {0x13f, 15}, |
1552 |
|
{0x140, 15}, {0x141, 15}, {0x142, 15}, {0x143, 15}, |
1553 |
|
{0x144, 15}, {0x145, 15}, {0x146, 15}, {0x147, 15}, |
1554 |
|
{0x148, 15}, {0x149, 15}, {0x14a, 15}, {0x14b, 15}, |
1555 |
|
{0x14c, 15}, {0x14d, 15}, {0x14e, 15}, {0x14f, 15}, |
1556 |
|
{0x150, 15}, {0x151, 15}, {0x152, 15}, {0x153, 15}, |
1557 |
|
{0x154, 15}, {0x155, 15}, {0x156, 15}, {0x157, 15}, |
1558 |
|
{0x158, 15}, {0x159, 15}, {0x15a, 15}, {0x15b, 15}, |
1559 |
|
{0x15c, 15}, {0x15d, 15}, {0x15e, 15}, {0x15f, 15}, |
1560 |
|
{0x160, 15}, {0x161, 15}, {0x162, 15}, {0x163, 15}, |
1561 |
|
{0x164, 15}, {0x165, 15}, {0x166, 15}, {0x167, 15}, |
1562 |
|
{0x168, 15}, {0x169, 15}, {0x16a, 15}, {0x16b, 15}, |
1563 |
|
{0x16c, 15}, {0x16d, 15}, {0x16e, 15}, {0x16f, 15}, |
1564 |
|
{0x170, 15}, {0x171, 15}, {0x172, 15}, {0x173, 15}, |
1565 |
|
{0x174, 15}, {0x175, 15}, {0x176, 15}, {0x177, 15}, |
1566 |
|
{0x178, 15}, {0x179, 15}, {0x17a, 15}, {0x17b, 15}, |
1567 |
|
{0x17c, 15}, {0x17d, 15}, {0x17e, 15}, {0x17f, 15}, |
1568 |
|
{0x80, 13}, {0x81, 13}, {0x82, 13}, {0x83, 13}, |
1569 |
|
{0x84, 13}, {0x85, 13}, {0x86, 13}, {0x87, 13}, |
1570 |
|
{0x88, 13}, {0x89, 13}, {0x8a, 13}, {0x8b, 13}, |
1571 |
|
{0x8c, 13}, {0x8d, 13}, {0x8e, 13}, {0x8f, 13}, |
1572 |
|
{0x90, 13}, {0x91, 13}, {0x92, 13}, {0x93, 13}, |
1573 |
|
{0x94, 13}, {0x95, 13}, {0x96, 13}, {0x97, 13}, |
1574 |
|
{0x98, 13}, {0x99, 13}, {0x9a, 13}, {0x9b, 13}, |
1575 |
|
{0x9c, 13}, {0x9d, 13}, {0x9e, 13}, {0x9f, 13}, |
1576 |
|
{0xa0, 13}, {0xa1, 13}, {0xa2, 13}, {0xa3, 13}, |
1577 |
|
{0xa4, 13}, {0xa5, 13}, {0xa6, 13}, {0xa7, 13}, |
1578 |
|
{0xa8, 13}, {0xa9, 13}, {0xaa, 13}, {0xab, 13}, |
1579 |
|
{0xac, 13}, {0xad, 13}, {0xae, 13}, {0xaf, 13}, |
1580 |
|
{0xb0, 13}, {0xb1, 13}, {0xb2, 13}, {0xb3, 13}, |
1581 |
|
{0xb4, 13}, {0xb5, 13}, {0xb6, 13}, {0xb7, 13}, |
1582 |
|
{0xb8, 13}, {0xb9, 13}, {0xba, 13}, {0xbb, 13}, |
1583 |
|
{0xbc, 13}, {0xbd, 13}, {0xbe, 13}, {0xbf, 13}, |
1584 |
|
{0x40, 11}, {0x41, 11}, {0x42, 11}, {0x43, 11}, |
1585 |
|
{0x44, 11}, {0x45, 11}, {0x46, 11}, {0x47, 11}, |
1586 |
|
{0x48, 11}, {0x49, 11}, {0x4a, 11}, {0x4b, 11}, |
1587 |
|
{0x4c, 11}, {0x4d, 11}, {0x4e, 11}, {0x4f, 11}, |
1588 |
|
{0x50, 11}, {0x51, 11}, {0x52, 11}, {0x53, 11}, |
1589 |
|
{0x54, 11}, {0x55, 11}, {0x56, 11}, {0x57, 11}, |
1590 |
|
{0x58, 11}, {0x59, 11}, {0x5a, 11}, {0x5b, 11}, |
1591 |
|
{0x5c, 11}, {0x5d, 11}, {0x5e, 11}, {0x5f, 11}, |
1592 |
|
{0x20, 9}, {0x21, 9}, {0x22, 9}, {0x23, 9}, |
1593 |
|
{0x24, 9}, {0x25, 9}, {0x26, 9}, {0x27, 9}, |
1594 |
|
{0x28, 9}, {0x29, 9}, {0x2a, 9}, {0x2b, 9}, |
1595 |
|
{0x2c, 9}, {0x2d, 9}, {0x2e, 9}, {0x2f, 9}, |
1596 |
|
{0x10, 7}, {0x11, 7}, {0x12, 7}, {0x13, 7}, |
1597 |
|
{0x14, 7}, {0x15, 7}, {0x16, 7}, {0x17, 7}, |
1598 |
|
{0x10, 6}, {0x11, 6}, {0x12, 6}, {0x13, 6}, |
1599 |
|
{0x08, 4}, {0x09, 4}, {0x06, 3}, {0x03, 3}, |
1600 |
|
{0x07, 3}, {0x0a, 4}, {0x0b, 4}, {0x14, 6}, |
1601 |
|
{0x15, 6}, {0x16, 6}, {0x17, 6}, {0x18, 7}, |
1602 |
|
{0x19, 7}, {0x1a, 7}, {0x1b, 7}, {0x1c, 7}, |
1603 |
|
{0x1d, 7}, {0x1e, 7}, {0x1f, 7}, {0x30, 9}, |
1604 |
|
{0x31, 9}, {0x32, 9}, {0x33, 9}, {0x34, 9}, |
1605 |
|
{0x35, 9}, {0x36, 9}, {0x37, 9}, {0x38, 9}, |
1606 |
|
{0x39, 9}, {0x3a, 9}, {0x3b, 9}, {0x3c, 9}, |
1607 |
|
{0x3d, 9}, {0x3e, 9}, {0x3f, 9}, {0x60, 11}, |
1608 |
|
{0x61, 11}, {0x62, 11}, {0x63, 11}, {0x64, 11}, |
1609 |
|
{0x65, 11}, {0x66, 11}, {0x67, 11}, {0x68, 11}, |
1610 |
|
{0x69, 11}, {0x6a, 11}, {0x6b, 11}, {0x6c, 11}, |
1611 |
|
{0x6d, 11}, {0x6e, 11}, {0x6f, 11}, {0x70, 11}, |
1612 |
|
{0x71, 11}, {0x72, 11}, {0x73, 11}, {0x74, 11}, |
1613 |
|
{0x75, 11}, {0x76, 11}, {0x77, 11}, {0x78, 11}, |
1614 |
|
{0x79, 11}, {0x7a, 11}, {0x7b, 11}, {0x7c, 11}, |
1615 |
|
{0x7d, 11}, {0x7e, 11}, {0x7f, 11}, {0xc0, 13}, |
1616 |
|
{0xc1, 13}, {0xc2, 13}, {0xc3, 13}, {0xc4, 13}, |
1617 |
|
{0xc5, 13}, {0xc6, 13}, {0xc7, 13}, {0xc8, 13}, |
1618 |
|
{0xc9, 13}, {0xca, 13}, {0xcb, 13}, {0xcc, 13}, |
1619 |
|
{0xcd, 13}, {0xce, 13}, {0xcf, 13}, {0xd0, 13}, |
1620 |
|
{0xd1, 13}, {0xd2, 13}, {0xd3, 13}, {0xd4, 13}, |
1621 |
|
{0xd5, 13}, {0xd6, 13}, {0xd7, 13}, {0xd8, 13}, |
1622 |
|
{0xd9, 13}, {0xda, 13}, {0xdb, 13}, {0xdc, 13}, |
1623 |
|
{0xdd, 13}, {0xde, 13}, {0xdf, 13}, {0xe0, 13}, |
1624 |
|
{0xe1, 13}, {0xe2, 13}, {0xe3, 13}, {0xe4, 13}, |
1625 |
|
{0xe5, 13}, {0xe6, 13}, {0xe7, 13}, {0xe8, 13}, |
1626 |
|
{0xe9, 13}, {0xea, 13}, {0xeb, 13}, {0xec, 13}, |
1627 |
|
{0xed, 13}, {0xee, 13}, {0xef, 13}, {0xf0, 13}, |
1628 |
|
{0xf1, 13}, {0xf2, 13}, {0xf3, 13}, {0xf4, 13}, |
1629 |
|
{0xf5, 13}, {0xf6, 13}, {0xf7, 13}, {0xf8, 13}, |
1630 |
|
{0xf9, 13}, {0xfa, 13}, {0xfb, 13}, {0xfc, 13}, |
1631 |
|
{0xfd, 13}, {0xfe, 13}, {0xff, 13}, {0x180, 15}, |
1632 |
|
{0x181, 15}, {0x182, 15}, {0x183, 15}, {0x184, 15}, |
1633 |
|
{0x185, 15}, {0x186, 15}, {0x187, 15}, {0x188, 15}, |
1634 |
|
{0x189, 15}, {0x18a, 15}, {0x18b, 15}, {0x18c, 15}, |
1635 |
|
{0x18d, 15}, {0x18e, 15}, {0x18f, 15}, {0x190, 15}, |
1636 |
|
{0x191, 15}, {0x192, 15}, {0x193, 15}, {0x194, 15}, |
1637 |
|
{0x195, 15}, {0x196, 15}, {0x197, 15}, {0x198, 15}, |
1638 |
|
{0x199, 15}, {0x19a, 15}, {0x19b, 15}, {0x19c, 15}, |
1639 |
|
{0x19d, 15}, {0x19e, 15}, {0x19f, 15}, {0x1a0, 15}, |
1640 |
|
{0x1a1, 15}, {0x1a2, 15}, {0x1a3, 15}, {0x1a4, 15}, |
1641 |
|
{0x1a5, 15}, {0x1a6, 15}, {0x1a7, 15}, {0x1a8, 15}, |
1642 |
|
{0x1a9, 15}, {0x1aa, 15}, {0x1ab, 15}, {0x1ac, 15}, |
1643 |
|
{0x1ad, 15}, {0x1ae, 15}, {0x1af, 15}, {0x1b0, 15}, |
1644 |
|
{0x1b1, 15}, {0x1b2, 15}, {0x1b3, 15}, {0x1b4, 15}, |
1645 |
|
{0x1b5, 15}, {0x1b6, 15}, {0x1b7, 15}, {0x1b8, 15}, |
1646 |
|
{0x1b9, 15}, {0x1ba, 15}, {0x1bb, 15}, {0x1bc, 15}, |
1647 |
|
{0x1bd, 15}, {0x1be, 15}, {0x1bf, 15}, {0x1c0, 15}, |
1648 |
|
{0x1c1, 15}, {0x1c2, 15}, {0x1c3, 15}, {0x1c4, 15}, |
1649 |
|
{0x1c5, 15}, {0x1c6, 15}, {0x1c7, 15}, {0x1c8, 15}, |
1650 |
|
{0x1c9, 15}, {0x1ca, 15}, {0x1cb, 15}, {0x1cc, 15}, |
1651 |
|
{0x1cd, 15}, {0x1ce, 15}, {0x1cf, 15}, {0x1d0, 15}, |
1652 |
|
{0x1d1, 15}, {0x1d2, 15}, {0x1d3, 15}, {0x1d4, 15}, |
1653 |
|
{0x1d5, 15}, {0x1d6, 15}, {0x1d7, 15}, {0x1d8, 15}, |
1654 |
|
{0x1d9, 15}, {0x1da, 15}, {0x1db, 15}, {0x1dc, 15}, |
1655 |
|
{0x1dd, 15}, {0x1de, 15}, {0x1df, 15}, {0x1e0, 15}, |
1656 |
|
{0x1e1, 15}, {0x1e2, 15}, {0x1e3, 15}, {0x1e4, 15}, |
1657 |
|
{0x1e5, 15}, {0x1e6, 15}, {0x1e7, 15}, {0x1e8, 15}, |
1658 |
|
{0x1e9, 15}, {0x1ea, 15}, {0x1eb, 15}, {0x1ec, 15}, |
1659 |
|
{0x1ed, 15}, {0x1ee, 15}, {0x1ef, 15}, {0x1f0, 15}, |
1660 |
|
{0x1f1, 15}, {0x1f2, 15}, {0x1f3, 15}, {0x1f4, 15}, |
1661 |
|
{0x1f5, 15}, {0x1f6, 15}, {0x1f7, 15}, {0x1f8, 15}, |
1662 |
|
{0x1f9, 15}, {0x1fa, 15}, {0x1fb, 15}, {0x1fc, 15}, |
1663 |
|
{0x1fd, 15}, {0x1fe, 15}, {0x1ff, 15}, |
1664 |
|
}; |
1665 |
|
|
1666 |
|
const VLC dcc_tab[511] = { |
1667 |
|
{0x100, 16}, {0x101, 16}, {0x102, 16}, {0x103, 16}, |
1668 |
|
{0x104, 16}, {0x105, 16}, {0x106, 16}, {0x107, 16}, |
1669 |
|
{0x108, 16}, {0x109, 16}, {0x10a, 16}, {0x10b, 16}, |
1670 |
|
{0x10c, 16}, {0x10d, 16}, {0x10e, 16}, {0x10f, 16}, |
1671 |
|
{0x110, 16}, {0x111, 16}, {0x112, 16}, {0x113, 16}, |
1672 |
|
{0x114, 16}, {0x115, 16}, {0x116, 16}, {0x117, 16}, |
1673 |
|
{0x118, 16}, {0x119, 16}, {0x11a, 16}, {0x11b, 16}, |
1674 |
|
{0x11c, 16}, {0x11d, 16}, {0x11e, 16}, {0x11f, 16}, |
1675 |
|
{0x120, 16}, {0x121, 16}, {0x122, 16}, {0x123, 16}, |
1676 |
|
{0x124, 16}, {0x125, 16}, {0x126, 16}, {0x127, 16}, |
1677 |
|
{0x128, 16}, {0x129, 16}, {0x12a, 16}, {0x12b, 16}, |
1678 |
|
{0x12c, 16}, {0x12d, 16}, {0x12e, 16}, {0x12f, 16}, |
1679 |
|
{0x130, 16}, {0x131, 16}, {0x132, 16}, {0x133, 16}, |
1680 |
|
{0x134, 16}, {0x135, 16}, {0x136, 16}, {0x137, 16}, |
1681 |
|
{0x138, 16}, {0x139, 16}, {0x13a, 16}, {0x13b, 16}, |
1682 |
|
{0x13c, 16}, {0x13d, 16}, {0x13e, 16}, {0x13f, 16}, |
1683 |
|
{0x140, 16}, {0x141, 16}, {0x142, 16}, {0x143, 16}, |
1684 |
|
{0x144, 16}, {0x145, 16}, {0x146, 16}, {0x147, 16}, |
1685 |
|
{0x148, 16}, {0x149, 16}, {0x14a, 16}, {0x14b, 16}, |
1686 |
|
{0x14c, 16}, {0x14d, 16}, {0x14e, 16}, {0x14f, 16}, |
1687 |
|
{0x150, 16}, {0x151, 16}, {0x152, 16}, {0x153, 16}, |
1688 |
|
{0x154, 16}, {0x155, 16}, {0x156, 16}, {0x157, 16}, |
1689 |
|
{0x158, 16}, {0x159, 16}, {0x15a, 16}, {0x15b, 16}, |
1690 |
|
{0x15c, 16}, {0x15d, 16}, {0x15e, 16}, {0x15f, 16}, |
1691 |
|
{0x160, 16}, {0x161, 16}, {0x162, 16}, {0x163, 16}, |
1692 |
|
{0x164, 16}, {0x165, 16}, {0x166, 16}, {0x167, 16}, |
1693 |
|
{0x168, 16}, {0x169, 16}, {0x16a, 16}, {0x16b, 16}, |
1694 |
|
{0x16c, 16}, {0x16d, 16}, {0x16e, 16}, {0x16f, 16}, |
1695 |
|
{0x170, 16}, {0x171, 16}, {0x172, 16}, {0x173, 16}, |
1696 |
|
{0x174, 16}, {0x175, 16}, {0x176, 16}, {0x177, 16}, |
1697 |
|
{0x178, 16}, {0x179, 16}, {0x17a, 16}, {0x17b, 16}, |
1698 |
|
{0x17c, 16}, {0x17d, 16}, {0x17e, 16}, {0x17f, 16}, |
1699 |
|
{0x80, 14}, {0x81, 14}, {0x82, 14}, {0x83, 14}, |
1700 |
|
{0x84, 14}, {0x85, 14}, {0x86, 14}, {0x87, 14}, |
1701 |
|
{0x88, 14}, {0x89, 14}, {0x8a, 14}, {0x8b, 14}, |
1702 |
|
{0x8c, 14}, {0x8d, 14}, {0x8e, 14}, {0x8f, 14}, |
1703 |
|
{0x90, 14}, {0x91, 14}, {0x92, 14}, {0x93, 14}, |
1704 |
|
{0x94, 14}, {0x95, 14}, {0x96, 14}, {0x97, 14}, |
1705 |
|
{0x98, 14}, {0x99, 14}, {0x9a, 14}, {0x9b, 14}, |
1706 |
|
{0x9c, 14}, {0x9d, 14}, {0x9e, 14}, {0x9f, 14}, |
1707 |
|
{0xa0, 14}, {0xa1, 14}, {0xa2, 14}, {0xa3, 14}, |
1708 |
|
{0xa4, 14}, {0xa5, 14}, {0xa6, 14}, {0xa7, 14}, |
1709 |
|
{0xa8, 14}, {0xa9, 14}, {0xaa, 14}, {0xab, 14}, |
1710 |
|
{0xac, 14}, {0xad, 14}, {0xae, 14}, {0xaf, 14}, |
1711 |
|
{0xb0, 14}, {0xb1, 14}, {0xb2, 14}, {0xb3, 14}, |
1712 |
|
{0xb4, 14}, {0xb5, 14}, {0xb6, 14}, {0xb7, 14}, |
1713 |
|
{0xb8, 14}, {0xb9, 14}, {0xba, 14}, {0xbb, 14}, |
1714 |
|
{0xbc, 14}, {0xbd, 14}, {0xbe, 14}, {0xbf, 14}, |
1715 |
|
{0x40, 12}, {0x41, 12}, {0x42, 12}, {0x43, 12}, |
1716 |
|
{0x44, 12}, {0x45, 12}, {0x46, 12}, {0x47, 12}, |
1717 |
|
{0x48, 12}, {0x49, 12}, {0x4a, 12}, {0x4b, 12}, |
1718 |
|
{0x4c, 12}, {0x4d, 12}, {0x4e, 12}, {0x4f, 12}, |
1719 |
|
{0x50, 12}, {0x51, 12}, {0x52, 12}, {0x53, 12}, |
1720 |
|
{0x54, 12}, {0x55, 12}, {0x56, 12}, {0x57, 12}, |
1721 |
|
{0x58, 12}, {0x59, 12}, {0x5a, 12}, {0x5b, 12}, |
1722 |
|
{0x5c, 12}, {0x5d, 12}, {0x5e, 12}, {0x5f, 12}, |
1723 |
|
{0x20, 10}, {0x21, 10}, {0x22, 10}, {0x23, 10}, |
1724 |
|
{0x24, 10}, {0x25, 10}, {0x26, 10}, {0x27, 10}, |
1725 |
|
{0x28, 10}, {0x29, 10}, {0x2a, 10}, {0x2b, 10}, |
1726 |
|
{0x2c, 10}, {0x2d, 10}, {0x2e, 10}, {0x2f, 10}, |
1727 |
|
{0x10, 8}, {0x11, 8}, {0x12, 8}, {0x13, 8}, |
1728 |
|
{0x14, 8}, {0x15, 8}, {0x16, 8}, {0x17, 8}, |
1729 |
|
{0x08, 6}, {0x09, 6}, {0x0a, 6}, {0x0b, 6}, |
1730 |
|
{0x04, 4}, {0x05, 4}, {0x04, 3}, {0x03, 2}, |
1731 |
|
{0x05, 3}, {0x06, 4}, {0x07, 4}, {0x0c, 6}, |
1732 |
|
{0x0d, 6}, {0x0e, 6}, {0x0f, 6}, {0x18, 8}, |
1733 |
|
{0x19, 8}, {0x1a, 8}, {0x1b, 8}, {0x1c, 8}, |
1734 |
|
{0x1d, 8}, {0x1e, 8}, {0x1f, 8}, {0x30, 10}, |
1735 |
|
{0x31, 10}, {0x32, 10}, {0x33, 10}, {0x34, 10}, |
1736 |
|
{0x35, 10}, {0x36, 10}, {0x37, 10}, {0x38, 10}, |
1737 |
|
{0x39, 10}, {0x3a, 10}, {0x3b, 10}, {0x3c, 10}, |
1738 |
|
{0x3d, 10}, {0x3e, 10}, {0x3f, 10}, {0x60, 12}, |
1739 |
|
{0x61, 12}, {0x62, 12}, {0x63, 12}, {0x64, 12}, |
1740 |
|
{0x65, 12}, {0x66, 12}, {0x67, 12}, {0x68, 12}, |
1741 |
|
{0x69, 12}, {0x6a, 12}, {0x6b, 12}, {0x6c, 12}, |
1742 |
|
{0x6d, 12}, {0x6e, 12}, {0x6f, 12}, {0x70, 12}, |
1743 |
|
{0x71, 12}, {0x72, 12}, {0x73, 12}, {0x74, 12}, |
1744 |
|
{0x75, 12}, {0x76, 12}, {0x77, 12}, {0x78, 12}, |
1745 |
|
{0x79, 12}, {0x7a, 12}, {0x7b, 12}, {0x7c, 12}, |
1746 |
|
{0x7d, 12}, {0x7e, 12}, {0x7f, 12}, {0xc0, 14}, |
1747 |
|
{0xc1, 14}, {0xc2, 14}, {0xc3, 14}, {0xc4, 14}, |
1748 |
|
{0xc5, 14}, {0xc6, 14}, {0xc7, 14}, {0xc8, 14}, |
1749 |
|
{0xc9, 14}, {0xca, 14}, {0xcb, 14}, {0xcc, 14}, |
1750 |
|
{0xcd, 14}, {0xce, 14}, {0xcf, 14}, {0xd0, 14}, |
1751 |
|
{0xd1, 14}, {0xd2, 14}, {0xd3, 14}, {0xd4, 14}, |
1752 |
|
{0xd5, 14}, {0xd6, 14}, {0xd7, 14}, {0xd8, 14}, |
1753 |
|
{0xd9, 14}, {0xda, 14}, {0xdb, 14}, {0xdc, 14}, |
1754 |
|
{0xdd, 14}, {0xde, 14}, {0xdf, 14}, {0xe0, 14}, |
1755 |
|
{0xe1, 14}, {0xe2, 14}, {0xe3, 14}, {0xe4, 14}, |
1756 |
|
{0xe5, 14}, {0xe6, 14}, {0xe7, 14}, {0xe8, 14}, |
1757 |
|
{0xe9, 14}, {0xea, 14}, {0xeb, 14}, {0xec, 14}, |
1758 |
|
{0xed, 14}, {0xee, 14}, {0xef, 14}, {0xf0, 14}, |
1759 |
|
{0xf1, 14}, {0xf2, 14}, {0xf3, 14}, {0xf4, 14}, |
1760 |
|
{0xf5, 14}, {0xf6, 14}, {0xf7, 14}, {0xf8, 14}, |
1761 |
|
{0xf9, 14}, {0xfa, 14}, {0xfb, 14}, {0xfc, 14}, |
1762 |
|
{0xfd, 14}, {0xfe, 14}, {0xff, 14}, {0x180, 16}, |
1763 |
|
{0x181, 16}, {0x182, 16}, {0x183, 16}, {0x184, 16}, |
1764 |
|
{0x185, 16}, {0x186, 16}, {0x187, 16}, {0x188, 16}, |
1765 |
|
{0x189, 16}, {0x18a, 16}, {0x18b, 16}, {0x18c, 16}, |
1766 |
|
{0x18d, 16}, {0x18e, 16}, {0x18f, 16}, {0x190, 16}, |
1767 |
|
{0x191, 16}, {0x192, 16}, {0x193, 16}, {0x194, 16}, |
1768 |
|
{0x195, 16}, {0x196, 16}, {0x197, 16}, {0x198, 16}, |
1769 |
|
{0x199, 16}, {0x19a, 16}, {0x19b, 16}, {0x19c, 16}, |
1770 |
|
{0x19d, 16}, {0x19e, 16}, {0x19f, 16}, {0x1a0, 16}, |
1771 |
|
{0x1a1, 16}, {0x1a2, 16}, {0x1a3, 16}, {0x1a4, 16}, |
1772 |
|
{0x1a5, 16}, {0x1a6, 16}, {0x1a7, 16}, {0x1a8, 16}, |
1773 |
|
{0x1a9, 16}, {0x1aa, 16}, {0x1ab, 16}, {0x1ac, 16}, |
1774 |
|
{0x1ad, 16}, {0x1ae, 16}, {0x1af, 16}, {0x1b0, 16}, |
1775 |
|
{0x1b1, 16}, {0x1b2, 16}, {0x1b3, 16}, {0x1b4, 16}, |
1776 |
|
{0x1b5, 16}, {0x1b6, 16}, {0x1b7, 16}, {0x1b8, 16}, |
1777 |
|
{0x1b9, 16}, {0x1ba, 16}, {0x1bb, 16}, {0x1bc, 16}, |
1778 |
|
{0x1bd, 16}, {0x1be, 16}, {0x1bf, 16}, {0x1c0, 16}, |
1779 |
|
{0x1c1, 16}, {0x1c2, 16}, {0x1c3, 16}, {0x1c4, 16}, |
1780 |
|
{0x1c5, 16}, {0x1c6, 16}, {0x1c7, 16}, {0x1c8, 16}, |
1781 |
|
{0x1c9, 16}, {0x1ca, 16}, {0x1cb, 16}, {0x1cc, 16}, |
1782 |
|
{0x1cd, 16}, {0x1ce, 16}, {0x1cf, 16}, {0x1d0, 16}, |
1783 |
|
{0x1d1, 16}, {0x1d2, 16}, {0x1d3, 16}, {0x1d4, 16}, |
1784 |
|
{0x1d5, 16}, {0x1d6, 16}, {0x1d7, 16}, {0x1d8, 16}, |
1785 |
|
{0x1d9, 16}, {0x1da, 16}, {0x1db, 16}, {0x1dc, 16}, |
1786 |
|
{0x1dd, 16}, {0x1de, 16}, {0x1df, 16}, {0x1e0, 16}, |
1787 |
|
{0x1e1, 16}, {0x1e2, 16}, {0x1e3, 16}, {0x1e4, 16}, |
1788 |
|
{0x1e5, 16}, {0x1e6, 16}, {0x1e7, 16}, {0x1e8, 16}, |
1789 |
|
{0x1e9, 16}, {0x1ea, 16}, {0x1eb, 16}, {0x1ec, 16}, |
1790 |
|
{0x1ed, 16}, {0x1ee, 16}, {0x1ef, 16}, {0x1f0, 16}, |
1791 |
|
{0x1f1, 16}, {0x1f2, 16}, {0x1f3, 16}, {0x1f4, 16}, |
1792 |
|
{0x1f5, 16}, {0x1f6, 16}, {0x1f7, 16}, {0x1f8, 16}, |
1793 |
|
{0x1f9, 16}, {0x1fa, 16}, {0x1fb, 16}, {0x1fc, 16}, |
1794 |
|
{0x1fd, 16}, {0x1fe, 16}, {0x1ff, 16}, |
1795 |
|
}; |
1796 |
|
|
1797 |
|
|
1798 |
|
const VLC mb_motion_table[65] = { |
1799 |
|
{0x05, 13}, {0x07, 13}, {0x05, 12}, {0x07, 12}, |
1800 |
|
{0x09, 12}, {0x0b, 12}, {0x0d, 12}, {0x0f, 12}, |
1801 |
|
{0x09, 11}, {0x0b, 11}, {0x0d, 11}, {0x0f, 11}, |
1802 |
|
{0x11, 11}, {0x13, 11}, {0x15, 11}, {0x17, 11}, |
1803 |
|
{0x19, 11}, {0x1b, 11}, {0x1d, 11}, {0x1f, 11}, |
1804 |
|
{0x21, 11}, {0x23, 11}, {0x13, 10}, {0x15, 10}, |
1805 |
|
{0x17, 10}, {0x07, 8}, {0x09, 8}, {0x0b, 8}, |
1806 |
|
{0x07, 7}, {0x03, 5}, {0x03, 4}, {0x03, 3}, |
1807 |
|
{0x01, 1}, {0x02, 3}, {0x02, 4}, {0x02, 5}, |
1808 |
|
{0x06, 7}, {0x0a, 8}, {0x08, 8}, {0x06, 8}, |
1809 |
|
{0x16, 10}, {0x14, 10}, {0x12, 10}, {0x22, 11}, |
1810 |
|
{0x20, 11}, {0x1e, 11}, {0x1c, 11}, {0x1a, 11}, |
1811 |
|
{0x18, 11}, {0x16, 11}, {0x14, 11}, {0x12, 11}, |
1812 |
|
{0x10, 11}, {0x0e, 11}, {0x0c, 11}, {0x0a, 11}, |
1813 |
|
{0x08, 11}, {0x0e, 12}, {0x0c, 12}, {0x0a, 12}, |
1814 |
|
{0x08, 12}, {0x06, 12}, {0x04, 12}, {0x06, 13}, |
1815 |
|
{0x04, 13} |
1816 |
|
}; |
1817 |
|
|
1818 |
|
|
1819 |
|
/****************************************************************** |
1820 |
|
* decoder tables * |
1821 |
|
******************************************************************/ |
1822 |
|
|
1823 |
|
VLC const mcbpc_intra_table[64] = { |
1824 |
|
{-1, 0}, {20, 6}, {36, 6}, {52, 6}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, |
1825 |
|
{19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, |
1826 |
|
{35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, |
1827 |
|
{51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3}, |
1828 |
|
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
1829 |
|
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
1830 |
|
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, |
1831 |
|
{3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1} |
1832 |
|
}; |
1833 |
|
|
1834 |
|
VLC const mcbpc_inter_table[257] = { |
1835 |
|
{VLC_ERROR, 0}, {255, 9}, {52, 9}, {36, 9}, {20, 9}, {49, 9}, {35, 8}, {35, 8}, |
1836 |
|
{19, 8}, {19, 8}, {50, 8}, {50, 8}, {51, 7}, {51, 7}, {51, 7}, {51, 7}, |
1837 |
|
{34, 7}, {34, 7}, {34, 7}, {34, 7}, {18, 7}, {18, 7}, {18, 7}, {18, 7}, |
1838 |
|
{33, 7}, {33, 7}, {33, 7}, {33, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, |
1839 |
|
{4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, |
1840 |
|
{48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, |
1841 |
|
{3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, |
1842 |
|
{3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, |
1843 |
|
{32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, |
1844 |
|
{32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, |
1845 |
|
{32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, |
1846 |
|
{32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, |
1847 |
|
{16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, |
1848 |
|
{16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, |
1849 |
|
{16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, |
1850 |
|
{16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, |
1851 |
|
{2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, |
1852 |
|
{2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, |
1853 |
|
{2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, |
1854 |
|
{2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, |
1855 |
|
{2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, |
1856 |
|
{2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, |
1857 |
|
{2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, |
1858 |
|
{2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, |
1859 |
|
{1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, |
1860 |
|
{1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, |
1861 |
|
{1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, |
1862 |
|
{1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, |
1863 |
|
{1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, |
1864 |
|
{1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, |
1865 |
|
{1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, |
1866 |
|
{1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, |
1867 |
|
{0, 1} |
1868 |
|
}; |
1869 |
|
|
1870 |
|
VLC const cbpy_table[64] = { |
1871 |
|
{-1, 0}, {-1, 0}, {6, 6}, {9, 6}, {8, 5}, {8, 5}, {4, 5}, {4, 5}, |
1872 |
|
{2, 5}, {2, 5}, {1, 5}, {1, 5}, {0, 4}, {0, 4}, {0, 4}, {0, 4}, |
1873 |
|
{12, 4}, {12, 4}, {12, 4}, {12, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, |
1874 |
|
{14, 4}, {14, 4}, {14, 4}, {14, 4}, {5, 4}, {5, 4}, {5, 4}, {5, 4}, |
1875 |
|
{13, 4}, {13, 4}, {13, 4}, {13, 4}, {3, 4}, {3, 4}, {3, 4}, {3, 4}, |
1876 |
|
{11, 4}, {11, 4}, {11, 4}, {11, 4}, {7, 4}, {7, 4}, {7, 4}, {7, 4}, |
1877 |
|
{15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, |
1878 |
|
{15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2} |
1879 |
|
}; |
1880 |
|
|
1881 |
|
VLC const TMNMVtab0[] = { |
1882 |
|
{3, 4}, {-3, 4}, {2, 3}, {2, 3}, {-2, 3}, {-2, 3}, {1, 2}, |
1883 |
|
{1, 2}, {1, 2}, {1, 2}, {-1, 2}, {-1, 2}, {-1, 2}, {-1, 2} |
1884 |
|
}; |
1885 |
|
|
1886 |
|
VLC const TMNMVtab1[] = { |
1887 |
|
{12, 10}, {-12, 10}, {11, 10}, {-11, 10}, |
1888 |
|
{10, 9}, {10, 9}, {-10, 9}, {-10, 9}, |
1889 |
|
{9, 9}, {9, 9}, {-9, 9}, {-9, 9}, |
1890 |
|
{8, 9}, {8, 9}, {-8, 9}, {-8, 9}, |
1891 |
|
{7, 7}, {7, 7}, {7, 7}, {7, 7}, |
1892 |
|
{7, 7}, {7, 7}, {7, 7}, {7, 7}, |
1893 |
|
{-7, 7}, {-7, 7}, {-7, 7}, {-7, 7}, |
1894 |
|
{-7, 7}, {-7, 7}, {-7, 7}, {-7, 7}, |
1895 |
|
{6, 7}, {6, 7}, {6, 7}, {6, 7}, |
1896 |
|
{6, 7}, {6, 7}, {6, 7}, {6, 7}, |
1897 |
|
{-6, 7}, {-6, 7}, {-6, 7}, {-6, 7}, |
1898 |
|
{-6, 7}, {-6, 7}, {-6, 7}, {-6, 7}, |
1899 |
|
{5, 7}, {5, 7}, {5, 7}, {5, 7}, |
1900 |
|
{5, 7}, {5, 7}, {5, 7}, {5, 7}, |
1901 |
|
{-5, 7}, {-5, 7}, {-5, 7}, {-5, 7}, |
1902 |
|
{-5, 7}, {-5, 7}, {-5, 7}, {-5, 7}, |
1903 |
|
{4, 6}, {4, 6}, {4, 6}, {4, 6}, |
1904 |
|
{4, 6}, {4, 6}, {4, 6}, {4, 6}, |
1905 |
|
{4, 6}, {4, 6}, {4, 6}, {4, 6}, |
1906 |
|
{4, 6}, {4, 6}, {4, 6}, {4, 6}, |
1907 |
|
{-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, |
1908 |
|
{-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, |
1909 |
|
{-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, |
1910 |
|
{-4, 6}, {-4, 6}, {-4, 6}, {-4, 6} |
1911 |
|
}; |
1912 |
|
|
1913 |
|
VLC const TMNMVtab2[] = { |
1914 |
|
{32, 12}, {-32, 12}, {31, 12}, {-31, 12}, |
1915 |
|
{30, 11}, {30, 11}, {-30, 11}, {-30, 11}, |
1916 |
|
{29, 11}, {29, 11}, {-29, 11}, {-29, 11}, |
1917 |
|
{28, 11}, {28, 11}, {-28, 11}, {-28, 11}, |
1918 |
|
{27, 11}, {27, 11}, {-27, 11}, {-27, 11}, |
1919 |
|
{26, 11}, {26, 11}, {-26, 11}, {-26, 11}, |
1920 |
|
{25, 11}, {25, 11}, {-25, 11}, {-25, 11}, |
1921 |
|
{24, 10}, {24, 10}, {24, 10}, {24, 10}, |
1922 |
|
{-24, 10}, {-24, 10}, {-24, 10}, {-24, 10}, |
1923 |
|
{23, 10}, {23, 10}, {23, 10}, {23, 10}, |
1924 |
|
{-23, 10}, {-23, 10}, {-23, 10}, {-23, 10}, |
1925 |
|
{22, 10}, {22, 10}, {22, 10}, {22, 10}, |
1926 |
|
{-22, 10}, {-22, 10}, {-22, 10}, {-22, 10}, |
1927 |
|
{21, 10}, {21, 10}, {21, 10}, {21, 10}, |
1928 |
|
{-21, 10}, {-21, 10}, {-21, 10}, {-21, 10}, |
1929 |
|
{20, 10}, {20, 10}, {20, 10}, {20, 10}, |
1930 |
|
{-20, 10}, {-20, 10}, {-20, 10}, {-20, 10}, |
1931 |
|
{19, 10}, {19, 10}, {19, 10}, {19, 10}, |
1932 |
|
{-19, 10}, {-19, 10}, {-19, 10}, {-19, 10}, |
1933 |
|
{18, 10}, {18, 10}, {18, 10}, {18, 10}, |
1934 |
|
{-18, 10}, {-18, 10}, {-18, 10}, {-18, 10}, |
1935 |
|
{17, 10}, {17, 10}, {17, 10}, {17, 10}, |
1936 |
|
{-17, 10}, {-17, 10}, {-17, 10}, {-17, 10}, |
1937 |
|
{16, 10}, {16, 10}, {16, 10}, {16, 10}, |
1938 |
|
{-16, 10}, {-16, 10}, {-16, 10}, {-16, 10}, |
1939 |
|
{15, 10}, {15, 10}, {15, 10}, {15, 10}, |
1940 |
|
{-15, 10}, {-15, 10}, {-15, 10}, {-15, 10}, |
1941 |
|
{14, 10}, {14, 10}, {14, 10}, {14, 10}, |
1942 |
|
{-14, 10}, {-14, 10}, {-14, 10}, {-14, 10}, |
1943 |
|
{13, 10}, {13, 10}, {13, 10}, {13, 10}, |
1944 |
|
{-13, 10}, {-13, 10}, {-13, 10}, {-13, 10} |
1945 |
|
}; |
1946 |
|
|
1947 |
|
short const dc_threshold[] = { |
1948 |
|
26708, 29545, 29472, 26223, 30580, 29281, 8293, 29545, |
1949 |
|
25632, 29285, 30313, 25701, 26144, 28530, 8301, 26740, |
1950 |
|
8293, 20039, 8277, 20551, 8268, 30296, 17513, 25376, |
1951 |
|
25711, 25445, 10272, 11825, 11825, 10544, 2606, 28505, |
1952 |
|
29301, 29472, 26223, 30580, 29281, 8293, 26980, 29811, |
1953 |
|
26994, 30050, 28532, 8306, 24936, 8307, 28532, 26400, |
1954 |
|
30313, 8293, 25441, 25955, 29555, 29728, 8303, 29801, |
1955 |
|
8307, 28531, 29301, 25955, 25376, 25711, 11877, 10 |
1956 |
|
}; |
1957 |
|
|
1958 |
|
VLC const dc_lum_tab[] = { |
1959 |
|
{0, 0}, {4, 3}, {3, 3}, {0, 3}, |
1960 |
|
{2, 2}, {2, 2}, {1, 2}, {1, 2}, |
1961 |
|
}; |