Parent Directory
|
Revision Log
Revision 1.52 - (view) (download) (as text)
| 1 : | edgomez | 1.46 | /***************************************************************************** |
| 2 : | * | ||
| 3 : | * XVID MPEG-4 VIDEO CODEC | ||
| 4 : | * - MB coding - | ||
| 5 : | * | ||
| 6 : | * Copyright (C) 2002 Michael Militzer <isibaar@xvid.org> | ||
| 7 : | * | ||
| 8 : | * This program is free software ; you can redistribute it and/or modify | ||
| 9 : | * it under the terms of the GNU General Public License as published by | ||
| 10 : | * the Free Software Foundation ; either version 2 of the License, or | ||
| 11 : | * (at your option) any later version. | ||
| 12 : | * | ||
| 13 : | * This program is distributed in the hope that it will be useful, | ||
| 14 : | * but WITHOUT ANY WARRANTY ; without even the implied warranty of | ||
| 15 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 : | * GNU General Public License for more details. | ||
| 17 : | * | ||
| 18 : | * You should have received a copy of the GNU General Public License | ||
| 19 : | * along with this program ; if not, write to the Free Software | ||
| 20 : | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 21 : | * | ||
| 22 : | edgomez | 1.51 | * $Id$ |
| 23 : | edgomez | 1.46 | * |
| 24 : | ****************************************************************************/ | ||
| 25 : | edgomez | 1.42 | |
| 26 : | #include <stdio.h> | ||
| 27 : | Isibaar | 1.8 | #include <stdlib.h> |
| 28 : | edgomez | 1.46 | #include <string.h> |
| 29 : | |||
| 30 : | Isibaar | 1.1 | #include "../portab.h" |
| 31 : | edgomez | 1.42 | #include "../global.h" |
| 32 : | Isibaar | 1.1 | #include "bitstream.h" |
| 33 : | #include "zigzag.h" | ||
| 34 : | #include "vlc_codes.h" | ||
| 35 : | Isibaar | 1.8 | #include "mbcoding.h" |
| 36 : | Isibaar | 1.1 | |
| 37 : | #include "../utils/mbfunctions.h" | ||
| 38 : | |||
| 39 : | edgomez | 1.37 | #define LEVELOFFSET 32 |
| 40 : | |||
| 41 : | edgomez | 1.48 | /* Initialized once during xvid_global call |
| 42 : | * RO access is thread safe */ | ||
| 43 : | edgomez | 1.37 | static REVERSE_EVENT DCT3D[2][4096]; |
| 44 : | static VLC coeff_VLC[2][2][64][64]; | ||
| 45 : | edgomez | 1.26 | |
| 46 : | edgomez | 1.42 | /* not really MB related, but VLCs are only available here */ |
| 47 : | void bs_put_spritetrajectory(Bitstream * bs, const int val) | ||
| 48 : | { | ||
| 49 : | const int code = sprite_trajectory_code[val+16384].code; | ||
| 50 : | const int len = sprite_trajectory_code[val+16384].len; | ||
| 51 : | const int code2 = sprite_trajectory_len[len].code; | ||
| 52 : | const int len2 = sprite_trajectory_len[len].len; | ||
| 53 : | |||
| 54 : | edgomez | 1.46 | #if 0 |
| 55 : | printf("GMC=%d Code/Len = %d / %d ",val, code,len); | ||
| 56 : | printf("Code2 / Len2 = %d / %d \n",code2,len2); | ||
| 57 : | #endif | ||
| 58 : | edgomez | 1.42 | |
| 59 : | BitstreamPutBits(bs, code2, len2); | ||
| 60 : | if (len) BitstreamPutBits(bs, code, len); | ||
| 61 : | } | ||
| 62 : | |||
| 63 : | int bs_get_spritetrajectory(Bitstream * bs) | ||
| 64 : | { | ||
| 65 : | int i; | ||
| 66 : | for (i = 0; i < 12; i++) | ||
| 67 : | { | ||
| 68 : | if (BitstreamShowBits(bs, sprite_trajectory_len[i].len) == sprite_trajectory_len[i].code) | ||
| 69 : | { | ||
| 70 : | BitstreamSkip(bs, sprite_trajectory_len[i].len); | ||
| 71 : | return i; | ||
| 72 : | } | ||
| 73 : | } | ||
| 74 : | return -1; | ||
| 75 : | } | ||
| 76 : | Isibaar | 1.1 | |
| 77 : | edgomez | 1.17 | void |
| 78 : | init_vlc_tables(void) | ||
| 79 : | Isibaar | 1.1 | { |
| 80 : | edgomez | 1.42 | uint32_t i, j, k, intra, last, run, run_esc, level, level_esc, escape, escape_len, offset; |
| 81 : | int32_t l; | ||
| 82 : | edgomez | 1.38 | |
| 83 : | edgomez | 1.37 | for (intra = 0; intra < 2; intra++) |
| 84 : | for (i = 0; i < 4096; i++) | ||
| 85 : | DCT3D[intra][i].event.level = 0; | ||
| 86 : | |||
| 87 : | edgomez | 1.46 | for (intra = 0; intra < 2; intra++) { |
| 88 : | for (last = 0; last < 2; last++) { | ||
| 89 : | for (run = 0; run < 63 + last; run++) { | ||
| 90 : | for (level = 0; level < (uint32_t)(32 << intra); level++) { | ||
| 91 : | edgomez | 1.37 | offset = !intra * LEVELOFFSET; |
| 92 : | coeff_VLC[intra][last][level + offset][run].len = 128; | ||
| 93 : | Isibaar | 1.1 | } |
| 94 : | edgomez | 1.46 | } |
| 95 : | edgomez | 1.37 | } |
| 96 : | edgomez | 1.46 | } |
| 97 : | Isibaar | 1.8 | |
| 98 : | edgomez | 1.46 | for (intra = 0; intra < 2; intra++) { |
| 99 : | for (i = 0; i < 102; i++) { | ||
| 100 : | edgomez | 1.37 | offset = !intra * LEVELOFFSET; |
| 101 : | edgomez | 1.46 | |
| 102 : | for (j = 0; j < (uint32_t)(1 << (12 - coeff_tab[intra][i].vlc.len)); j++) { | ||
| 103 : | edgomez | 1.37 | 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; | ||
| 105 : | } | ||
| 106 : | Isibaar | 1.8 | |
| 107 : | edgomez | 1.37 | coeff_VLC[intra][coeff_tab[intra][i].event.last][coeff_tab[intra][i].event.level + offset][coeff_tab[intra][i].event.run].code |
| 108 : | = 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 | ||
| 110 : | = coeff_tab[intra][i].vlc.len + 1; | ||
| 111 : | edgomez | 1.46 | |
| 112 : | if (!intra) { | ||
| 113 : | edgomez | 1.37 | 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; | ||
| 115 : | 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; | ||
| 117 : | Isibaar | 1.1 | } |
| 118 : | } | ||
| 119 : | edgomez | 1.46 | } |
| 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 : | Isibaar | 1.1 | |
| 126 : | edgomez | 1.38 | if (level <= max_level[intra][last][run] && run <= max_run[intra][last][level]) |
| 127 : | continue; | ||
| 128 : | |||
| 129 : | edgomez | 1.37 | offset = !intra * LEVELOFFSET; |
| 130 : | edgomez | 1.38 | level_esc = level - max_level[intra][last][run]; |
| 131 : | run_esc = run - 1 - max_run[intra][last][level]; | ||
| 132 : | |||
| 133 : | edgomez | 1.46 | if (level_esc <= max_level[intra][last][run] && run <= max_run[intra][last][level_esc]) { |
| 134 : | edgomez | 1.38 | escape = ESCAPE1; |
| 135 : | escape_len = 7 + 1; | ||
| 136 : | run_esc = run; | ||
| 137 : | edgomez | 1.46 | } else { |
| 138 : | if (run_esc <= max_run[intra][last][level] && level <= max_level[intra][last][run_esc]) { | ||
| 139 : | edgomez | 1.38 | escape = ESCAPE2; |
| 140 : | escape_len = 7 + 2; | ||
| 141 : | level_esc = level; | ||
| 142 : | edgomez | 1.46 | } else { |
| 143 : | if (!intra) { | ||
| 144 : | edgomez | 1.38 | coeff_VLC[intra][last][level + offset][run].code |
| 145 : | = (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((level & 0xfff) << 1) | 1; | ||
| 146 : | coeff_VLC[intra][last][level + offset][run].len = 30; | ||
| 147 : | coeff_VLC[intra][last][offset - level][run].code | ||
| 148 : | suxen_drol | 1.44 | = (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((-(int32_t)level & 0xfff) << 1) | 1; |
| 149 : | edgomez | 1.38 | coeff_VLC[intra][last][offset - level][run].len = 30; |
| 150 : | edgomez | 1.37 | } |
| 151 : | edgomez | 1.38 | continue; |
| 152 : | edgomez | 1.37 | } |
| 153 : | edgomez | 1.38 | } |
| 154 : | |||
| 155 : | coeff_VLC[intra][last][level + offset][run].code | ||
| 156 : | = (escape << coeff_VLC[intra][last][level_esc + offset][run_esc].len) | ||
| 157 : | | coeff_VLC[intra][last][level_esc + offset][run_esc].code; | ||
| 158 : | coeff_VLC[intra][last][level + offset][run].len | ||
| 159 : | = coeff_VLC[intra][last][level_esc + offset][run_esc].len + escape_len; | ||
| 160 : | edgomez | 1.46 | |
| 161 : | if (!intra) { | ||
| 162 : | edgomez | 1.38 | coeff_VLC[intra][last][offset - level][run].code |
| 163 : | = (escape << coeff_VLC[intra][last][level_esc + offset][run_esc].len) | ||
| 164 : | | coeff_VLC[intra][last][level_esc + offset][run_esc].code | 1; | ||
| 165 : | coeff_VLC[intra][last][offset - level][run].len | ||
| 166 : | = coeff_VLC[intra][last][level_esc + offset][run_esc].len + escape_len; | ||
| 167 : | } | ||
| 168 : | edgomez | 1.37 | } |
| 169 : | edgomez | 1.38 | |
| 170 : | edgomez | 1.46 | if (!intra) { |
| 171 : | edgomez | 1.37 | coeff_VLC[intra][last][0][run].code |
| 172 : | = (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((-32 & 0xfff) << 1) | 1; | ||
| 173 : | coeff_VLC[intra][last][0][run].len = 30; | ||
| 174 : | } | ||
| 175 : | } | ||
| 176 : | edgomez | 1.46 | } |
| 177 : | } | ||
| 178 : | |||
| 179 : | /* init sprite_trajectory tables | ||
| 180 : | * even if GMC is not specified (it might be used later...) */ | ||
| 181 : | edgomez | 1.41 | |
| 182 : | edgomez | 1.42 | sprite_trajectory_code[0+16384].code = 0; |
| 183 : | sprite_trajectory_code[0+16384].len = 0; | ||
| 184 : | edgomez | 1.46 | for (k=0;k<14;k++) { |
| 185 : | edgomez | 1.42 | int limit = (1<<k); |
| 186 : | edgomez | 1.41 | |
| 187 : | edgomez | 1.46 | for (l=-(2*limit-1); l <= -limit; l++) { |
| 188 : | edgomez | 1.42 | sprite_trajectory_code[l+16384].code = (2*limit-1)+l; |
| 189 : | sprite_trajectory_code[l+16384].len = k+1; | ||
| 190 : | } | ||
| 191 : | |||
| 192 : | edgomez | 1.46 | for (l=limit; l<= 2*limit-1; l++) { |
| 193 : | sprite_trajectory_code[l+16384].code = l; | ||
| 194 : | edgomez | 1.42 | sprite_trajectory_code[l+16384].len = k+1; |
| 195 : | } | ||
| 196 : | } | ||
| 197 : | Isibaar | 1.1 | } |
| 198 : | |||
| 199 : | edgomez | 1.17 | static __inline void |
| 200 : | CodeVector(Bitstream * bs, | ||
| 201 : | int32_t value, | ||
| 202 : | syskin | 1.49 | int32_t f_code) |
| 203 : | Isibaar | 1.1 | { |
| 204 : | edgomez | 1.7 | |
| 205 : | Isibaar | 1.1 | const int scale_factor = 1 << (f_code - 1); |
| 206 : | const int cmp = scale_factor << 5; | ||
| 207 : | |||
| 208 : | edgomez | 1.17 | if (value < (-1 * cmp)) |
| 209 : | Isibaar | 1.1 | value += 64 * scale_factor; |
| 210 : | edgomez | 1.17 | |
| 211 : | if (value > (cmp - 1)) | ||
| 212 : | Isibaar | 1.1 | value -= 64 * scale_factor; |
| 213 : | |||
| 214 : | edgomez | 1.7 | if (value == 0) { |
| 215 : | edgomez | 1.17 | BitstreamPutBits(bs, mb_motion_table[32].code, |
| 216 : | mb_motion_table[32].len); | ||
| 217 : | edgomez | 1.7 | } else { |
| 218 : | Isibaar | 1.1 | uint16_t length, code, mv_res, sign; |
| 219 : | edgomez | 1.17 | |
| 220 : | Isibaar | 1.1 | length = 16 << f_code; |
| 221 : | f_code--; | ||
| 222 : | edgomez | 1.17 | |
| 223 : | Isibaar | 1.1 | sign = (value < 0); |
| 224 : | |||
| 225 : | edgomez | 1.17 | if (value >= length) |
| 226 : | Isibaar | 1.1 | value -= 2 * length; |
| 227 : | edgomez | 1.17 | else if (value < -length) |
| 228 : | Isibaar | 1.1 | value += 2 * length; |
| 229 : | |||
| 230 : | edgomez | 1.17 | if (sign) |
| 231 : | Isibaar | 1.1 | value = -value; |
| 232 : | |||
| 233 : | value--; | ||
| 234 : | mv_res = value & ((1 << f_code) - 1); | ||
| 235 : | code = ((value - mv_res) >> f_code) + 1; | ||
| 236 : | |||
| 237 : | edgomez | 1.17 | if (sign) |
| 238 : | Isibaar | 1.1 | code = -code; |
| 239 : | |||
| 240 : | code += 32; | ||
| 241 : | edgomez | 1.17 | BitstreamPutBits(bs, mb_motion_table[code].code, |
| 242 : | mb_motion_table[code].len); | ||
| 243 : | |||
| 244 : | if (f_code) | ||
| 245 : | Isibaar | 1.1 | BitstreamPutBits(bs, mv_res, f_code); |
| 246 : | edgomez | 1.7 | } |
| 247 : | |||
| 248 : | Isibaar | 1.1 | } |
| 249 : | |||
| 250 : | edgomez | 1.37 | static __inline void |
| 251 : | CodeCoeffInter(Bitstream * bs, | ||
| 252 : | const int16_t qcoeff[64], | ||
| 253 : | const uint16_t * zigzag) | ||
| 254 : | { | ||
| 255 : | uint32_t i, run, prev_run, code, len; | ||
| 256 : | int32_t level, prev_level, level_shifted; | ||
| 257 : | |||
| 258 : | i = 0; | ||
| 259 : | run = 0; | ||
| 260 : | |||
| 261 : | while (!(level = qcoeff[zigzag[i++]])) | ||
| 262 : | run++; | ||
| 263 : | |||
| 264 : | prev_level = level; | ||
| 265 : | prev_run = run; | ||
| 266 : | run = 0; | ||
| 267 : | |||
| 268 : | while (i < 64) | ||
| 269 : | { | ||
| 270 : | if ((level = qcoeff[zigzag[i++]]) != 0) | ||
| 271 : | { | ||
| 272 : | level_shifted = prev_level + 32; | ||
| 273 : | if (!(level_shifted & -64)) | ||
| 274 : | { | ||
| 275 : | code = coeff_VLC[0][0][level_shifted][prev_run].code; | ||
| 276 : | len = coeff_VLC[0][0][level_shifted][prev_run].len; | ||
| 277 : | } | ||
| 278 : | else | ||
| 279 : | { | ||
| 280 : | code = (ESCAPE3 << 21) | (prev_run << 14) | (1 << 13) | ((prev_level & 0xfff) << 1) | 1; | ||
| 281 : | len = 30; | ||
| 282 : | } | ||
| 283 : | BitstreamPutBits(bs, code, len); | ||
| 284 : | prev_level = level; | ||
| 285 : | prev_run = run; | ||
| 286 : | run = 0; | ||
| 287 : | } | ||
| 288 : | else | ||
| 289 : | run++; | ||
| 290 : | } | ||
| 291 : | |||
| 292 : | level_shifted = prev_level + 32; | ||
| 293 : | if (!(level_shifted & -64)) | ||
| 294 : | { | ||
| 295 : | code = coeff_VLC[0][1][level_shifted][prev_run].code; | ||
| 296 : | len = coeff_VLC[0][1][level_shifted][prev_run].len; | ||
| 297 : | } | ||
| 298 : | else | ||
| 299 : | { | ||
| 300 : | code = (ESCAPE3 << 21) | (1 << 20) | (prev_run << 14) | (1 << 13) | ((prev_level & 0xfff) << 1) | 1; | ||
| 301 : | len = 30; | ||
| 302 : | } | ||
| 303 : | BitstreamPutBits(bs, code, len); | ||
| 304 : | } | ||
| 305 : | |||
| 306 : | static __inline void | ||
| 307 : | CodeCoeffIntra(Bitstream * bs, | ||
| 308 : | const int16_t qcoeff[64], | ||
| 309 : | const uint16_t * zigzag) | ||
| 310 : | { | ||
| 311 : | uint32_t i, abs_level, run, prev_run, code, len; | ||
| 312 : | int32_t level, prev_level; | ||
| 313 : | |||
| 314 : | i = 1; | ||
| 315 : | run = 0; | ||
| 316 : | |||
| 317 : | edgomez | 1.42 | while (i<64 && !(level = qcoeff[zigzag[i++]])) |
| 318 : | edgomez | 1.37 | run++; |
| 319 : | |||
| 320 : | prev_level = level; | ||
| 321 : | prev_run = run; | ||
| 322 : | run = 0; | ||
| 323 : | |||
| 324 : | while (i < 64) | ||
| 325 : | { | ||
| 326 : | if ((level = qcoeff[zigzag[i++]]) != 0) | ||
| 327 : | { | ||
| 328 : | edgomez | 1.46 | abs_level = abs(prev_level); |
| 329 : | edgomez | 1.37 | abs_level = abs_level < 64 ? abs_level : 0; |
| 330 : | code = coeff_VLC[1][0][abs_level][prev_run].code; | ||
| 331 : | len = coeff_VLC[1][0][abs_level][prev_run].len; | ||
| 332 : | if (len != 128) | ||
| 333 : | code |= (prev_level < 0); | ||
| 334 : | else | ||
| 335 : | { | ||
| 336 : | code = (ESCAPE3 << 21) | (prev_run << 14) | (1 << 13) | ((prev_level & 0xfff) << 1) | 1; | ||
| 337 : | len = 30; | ||
| 338 : | } | ||
| 339 : | BitstreamPutBits(bs, code, len); | ||
| 340 : | prev_level = level; | ||
| 341 : | prev_run = run; | ||
| 342 : | run = 0; | ||
| 343 : | } | ||
| 344 : | else | ||
| 345 : | run++; | ||
| 346 : | } | ||
| 347 : | |||
| 348 : | edgomez | 1.46 | abs_level = abs(prev_level); |
| 349 : | edgomez | 1.37 | abs_level = abs_level < 64 ? abs_level : 0; |
| 350 : | code = coeff_VLC[1][1][abs_level][prev_run].code; | ||
| 351 : | len = coeff_VLC[1][1][abs_level][prev_run].len; | ||
| 352 : | if (len != 128) | ||
| 353 : | code |= (prev_level < 0); | ||
| 354 : | else | ||
| 355 : | { | ||
| 356 : | code = (ESCAPE3 << 21) | (1 << 20) | (prev_run << 14) | (1 << 13) | ((prev_level & 0xfff) << 1) | 1; | ||
| 357 : | len = 30; | ||
| 358 : | } | ||
| 359 : | BitstreamPutBits(bs, code, len); | ||
| 360 : | } | ||
| 361 : | |||
| 362 : | edgomez | 1.42 | |
| 363 : | |||
| 364 : | /* returns the number of bits required to encode qcoeff */ | ||
| 365 : | |||
| 366 : | edgomez | 1.46 | int |
| 367 : | edgomez | 1.42 | 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 : | edgomez | 1.46 | abs_level = abs(prev_level); |
| 390 : | edgomez | 1.42 | 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 : | edgomez | 1.46 | abs_level = abs(prev_level); |
| 403 : | edgomez | 1.42 | 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 : | edgomez | 1.48 | static const int iDQtab[5] = { |
| 455 : | edgomez | 1.46 | 1, 0, -1 /* no change */, 2, 3 |
| 456 : | }; | ||
| 457 : | #define DQ_VALUE2INDEX(value) iDQtab[(value)+2] | ||
| 458 : | edgomez | 1.42 | |
| 459 : | edgomez | 1.37 | |
| 460 : | edgomez | 1.42 | static __inline void |
| 461 : | CodeBlockIntra(const FRAMEINFO * const frame, | ||
| 462 : | edgomez | 1.17 | const MACROBLOCK * pMB, |
| 463 : | int16_t qcoeff[6 * 64], | ||
| 464 : | edgomez | 1.7 | Bitstream * bs, |
| 465 : | Statistics * pStat) | ||
| 466 : | Isibaar | 1.1 | { |
| 467 : | edgomez | 1.7 | |
| 468 : | Isibaar | 1.1 | uint32_t i, mcbpc, cbpy, bits; |
| 469 : | |||
| 470 : | cbpy = pMB->cbp >> 2; | ||
| 471 : | |||
| 472 : | edgomez | 1.46 | /* write mcbpc */ |
| 473 : | edgomez | 1.17 | if (frame->coding_type == I_VOP) { |
| 474 : | edgomez | 1.7 | mcbpc = ((pMB->mode >> 1) & 3) | ((pMB->cbp & 3) << 2); |
| 475 : | edgomez | 1.17 | BitstreamPutBits(bs, mcbpc_intra_tab[mcbpc].code, |
| 476 : | mcbpc_intra_tab[mcbpc].len); | ||
| 477 : | } else { | ||
| 478 : | edgomez | 1.7 | mcbpc = (pMB->mode & 7) | ((pMB->cbp & 3) << 3); |
| 479 : | edgomez | 1.17 | BitstreamPutBits(bs, mcbpc_inter_tab[mcbpc].code, |
| 480 : | mcbpc_inter_tab[mcbpc].len); | ||
| 481 : | Isibaar | 1.4 | } |
| 482 : | Isibaar | 1.1 | |
| 483 : | edgomez | 1.46 | /* ac prediction flag */ |
| 484 : | edgomez | 1.17 | if (pMB->acpred_directions[0]) |
| 485 : | edgomez | 1.7 | BitstreamPutBits(bs, 1, 1); |
| 486 : | Isibaar | 1.1 | else |
| 487 : | edgomez | 1.7 | BitstreamPutBits(bs, 0, 1); |
| 488 : | Isibaar | 1.1 | |
| 489 : | edgomez | 1.46 | /* write cbpy */ |
| 490 : | chl | 1.45 | BitstreamPutBits(bs, xvid_cbpy_tab[cbpy].code, xvid_cbpy_tab[cbpy].len); |
| 491 : | Isibaar | 1.1 | |
| 492 : | edgomez | 1.46 | /* write dquant */ |
| 493 : | edgomez | 1.17 | if (pMB->mode == MODE_INTRA_Q) |
| 494 : | edgomez | 1.46 | BitstreamPutBits(bs, DQ_VALUE2INDEX(pMB->dquant), 2); |
| 495 : | Isibaar | 1.1 | |
| 496 : | edgomez | 1.46 | /* write interlacing */ |
| 497 : | if (frame->vol_flags & XVID_VOL_INTERLACING) { | ||
| 498 : | h | 1.6 | BitstreamPutBit(bs, pMB->field_dct); |
| 499 : | } | ||
| 500 : | edgomez | 1.46 | /* code block coeffs */ |
| 501 : | edgomez | 1.17 | for (i = 0; i < 6; i++) { |
| 502 : | if (i < 4) | ||
| 503 : | BitstreamPutBits(bs, dcy_tab[qcoeff[i * 64 + 0] + 255].code, | ||
| 504 : | dcy_tab[qcoeff[i * 64 + 0] + 255].len); | ||
| 505 : | Isibaar | 1.1 | else |
| 506 : | edgomez | 1.17 | BitstreamPutBits(bs, dcc_tab[qcoeff[i * 64 + 0] + 255].code, |
| 507 : | dcc_tab[qcoeff[i * 64 + 0] + 255].len); | ||
| 508 : | |||
| 509 : | if (pMB->cbp & (1 << (5 - i))) { | ||
| 510 : | edgomez | 1.42 | const uint16_t *scan_table = |
| 511 : | edgomez | 1.46 | frame->vop_flags & XVID_VOP_ALTERNATESCAN ? |
| 512 : | edgomez | 1.42 | scan_tables[2] : scan_tables[pMB->acpred_directions[i]]; |
| 513 : | |||
| 514 : | Isibaar | 1.1 | bits = BitstreamPos(bs); |
| 515 : | |||
| 516 : | edgomez | 1.42 | CodeCoeffIntra(bs, &qcoeff[i * 64], scan_table); |
| 517 : | |||
| 518 : | Isibaar | 1.1 | bits = BitstreamPos(bs) - bits; |
| 519 : | pStat->iTextBits += bits; | ||
| 520 : | } | ||
| 521 : | } | ||
| 522 : | edgomez | 1.7 | |
| 523 : | Isibaar | 1.1 | } |
| 524 : | |||
| 525 : | |||
| 526 : | edgomez | 1.17 | static void |
| 527 : | edgomez | 1.42 | CodeBlockInter(const FRAMEINFO * const frame, |
| 528 : | edgomez | 1.17 | const MACROBLOCK * pMB, |
| 529 : | int16_t qcoeff[6 * 64], | ||
| 530 : | edgomez | 1.7 | Bitstream * bs, |
| 531 : | Statistics * pStat) | ||
| 532 : | Isibaar | 1.1 | { |
| 533 : | edgomez | 1.7 | |
| 534 : | Isibaar | 1.1 | int32_t i; |
| 535 : | uint32_t bits, mcbpc, cbpy; | ||
| 536 : | |||
| 537 : | edgomez | 1.7 | mcbpc = (pMB->mode & 7) | ((pMB->cbp & 3) << 3); |
| 538 : | Isibaar | 1.1 | cbpy = 15 - (pMB->cbp >> 2); |
| 539 : | |||
| 540 : | edgomez | 1.46 | /* write mcbpc */ |
| 541 : | edgomez | 1.17 | BitstreamPutBits(bs, mcbpc_inter_tab[mcbpc].code, |
| 542 : | mcbpc_inter_tab[mcbpc].len); | ||
| 543 : | Isibaar | 1.1 | |
| 544 : | edgomez | 1.42 | if ( (frame->coding_type == S_VOP) && (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) ) |
| 545 : | edgomez | 1.46 | BitstreamPutBit(bs, pMB->mcsel); /* mcsel: '0'=local motion, '1'=GMC */ |
| 546 : | edgomez | 1.42 | |
| 547 : | edgomez | 1.46 | /* write cbpy */ |
| 548 : | chl | 1.45 | BitstreamPutBits(bs, xvid_cbpy_tab[cbpy].code, xvid_cbpy_tab[cbpy].len); |
| 549 : | Isibaar | 1.1 | |
| 550 : | edgomez | 1.46 | /* write dquant */ |
| 551 : | edgomez | 1.17 | if (pMB->mode == MODE_INTER_Q) |
| 552 : | edgomez | 1.46 | BitstreamPutBits(bs, DQ_VALUE2INDEX(pMB->dquant), 2); |
| 553 : | edgomez | 1.17 | |
| 554 : | edgomez | 1.46 | /* interlacing */ |
| 555 : | if (frame->vol_flags & XVID_VOL_INTERLACING) { | ||
| 556 : | h | 1.25 | if (pMB->cbp) { |
| 557 : | BitstreamPutBit(bs, pMB->field_dct); | ||
| 558 : | edgomez | 1.46 | DPRINTF(XVID_DEBUG_MB,"codep: field_dct: %i\n", pMB->field_dct); |
| 559 : | h | 1.25 | } |
| 560 : | h | 1.6 | |
| 561 : | edgomez | 1.46 | /* if inter block, write field ME flag */ |
| 562 : | if ((pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) && (pMB->mcsel == 0)) { | ||
| 563 : | BitstreamPutBit(bs, 0 /*pMB->field_pred*/); /* not implemented yet */ | ||
| 564 : | DPRINTF(XVID_DEBUG_MB,"codep: field_pred: %i\n", pMB->field_pred); | ||
| 565 : | h | 1.6 | |
| 566 : | edgomez | 1.46 | /* write field prediction references */ |
| 567 : | #if 0 /* Remove the #if once field_pred is supported */ | ||
| 568 : | edgomez | 1.17 | if (pMB->field_pred) { |
| 569 : | h | 1.6 | BitstreamPutBit(bs, pMB->field_for_top); |
| 570 : | BitstreamPutBit(bs, pMB->field_for_bot); | ||
| 571 : | } | ||
| 572 : | edgomez | 1.46 | #endif |
| 573 : | h | 1.6 | } |
| 574 : | } | ||
| 575 : | edgomez | 1.46 | /* code motion vector(s) if motion is local */ |
| 576 : | edgomez | 1.42 | if (!pMB->mcsel) |
| 577 : | for (i = 0; i < (pMB->mode == MODE_INTER4V ? 4 : 1); i++) { | ||
| 578 : | syskin | 1.49 | CodeVector(bs, pMB->pmvs[i].x, frame->fcode); |
| 579 : | CodeVector(bs, pMB->pmvs[i].y, frame->fcode); | ||
| 580 : | edgomez | 1.42 | } |
| 581 : | Isibaar | 1.1 | |
| 582 : | bits = BitstreamPos(bs); | ||
| 583 : | edgomez | 1.17 | |
| 584 : | edgomez | 1.46 | /* code block coeffs */ |
| 585 : | edgomez | 1.17 | for (i = 0; i < 6; i++) |
| 586 : | edgomez | 1.46 | if (pMB->cbp & (1 << (5 - i))) { |
| 587 : | edgomez | 1.42 | const uint16_t *scan_table = |
| 588 : | edgomez | 1.46 | frame->vop_flags & XVID_VOP_ALTERNATESCAN ? |
| 589 : | edgomez | 1.42 | scan_tables[2] : scan_tables[0]; |
| 590 : | |||
| 591 : | CodeCoeffInter(bs, &qcoeff[i * 64], scan_table); | ||
| 592 : | } | ||
| 593 : | Isibaar | 1.1 | |
| 594 : | bits = BitstreamPos(bs) - bits; | ||
| 595 : | pStat->iTextBits += bits; | ||
| 596 : | } | ||
| 597 : | |||
| 598 : | |||
| 599 : | edgomez | 1.17 | void |
| 600 : | edgomez | 1.42 | MBCoding(const FRAMEINFO * const frame, |
| 601 : | edgomez | 1.17 | MACROBLOCK * pMB, |
| 602 : | int16_t qcoeff[6 * 64], | ||
| 603 : | Bitstream * bs, | ||
| 604 : | Statistics * pStat) | ||
| 605 : | Isibaar | 1.1 | { |
| 606 : | edgomez | 1.46 | if (frame->coding_type != I_VOP) |
| 607 : | BitstreamPutBit(bs, 0); /* not_coded */ | ||
| 608 : | |||
| 609 : | syskin | 1.50 | 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 : | chl | 1.22 | if (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q) |
| 616 : | suxen_drol | 1.13 | CodeBlockIntra(frame, pMB, qcoeff, bs, pStat); |
| 617 : | Isibaar | 1.1 | else |
| 618 : | suxen_drol | 1.13 | CodeBlockInter(frame, pMB, qcoeff, bs, pStat); |
| 619 : | edgomez | 1.7 | |
| 620 : | Isibaar | 1.1 | } |
| 621 : | chl | 1.24 | |
| 622 : | edgomez | 1.42 | /*************************************************************** |
| 623 : | * bframe encoding start | ||
| 624 : | ***************************************************************/ | ||
| 625 : | Isibaar | 1.1 | |
| 626 : | edgomez | 1.27 | /* |
| 627 : | edgomez | 1.42 | mbtype |
| 628 : | 0 1b direct(h263) mvdb | ||
| 629 : | 1 01b interpolate mc+q dbquant, mvdf, mvdb | ||
| 630 : | 2 001b backward mc+q dbquant, mvdb | ||
| 631 : | 3 0001b forward mc+q dbquant, mvdf | ||
| 632 : | */ | ||
| 633 : | suxen_drol | 1.19 | |
| 634 : | edgomez | 1.42 | static __inline void |
| 635 : | put_bvop_mbtype(Bitstream * bs, | ||
| 636 : | int value) | ||
| 637 : | { | ||
| 638 : | switch (value) { | ||
| 639 : | case MODE_FORWARD: | ||
| 640 : | BitstreamPutBit(bs, 0); | ||
| 641 : | case MODE_BACKWARD: | ||
| 642 : | BitstreamPutBit(bs, 0); | ||
| 643 : | case MODE_INTERPOLATE: | ||
| 644 : | BitstreamPutBit(bs, 0); | ||
| 645 : | case MODE_DIRECT: | ||
| 646 : | BitstreamPutBit(bs, 1); | ||
| 647 : | default: | ||
| 648 : | break; | ||
| 649 : | } | ||
| 650 : | } | ||
| 651 : | |||
| 652 : | /* | ||
| 653 : | dbquant | ||
| 654 : | -2 10b | ||
| 655 : | 0 0b | ||
| 656 : | +2 11b | ||
| 657 : | */ | ||
| 658 : | |||
| 659 : | static __inline void | ||
| 660 : | put_bvop_dbquant(Bitstream * bs, | ||
| 661 : | int value) | ||
| 662 : | { | ||
| 663 : | switch (value) { | ||
| 664 : | case 0: | ||
| 665 : | BitstreamPutBit(bs, 0); | ||
| 666 : | return; | ||
| 667 : | |||
| 668 : | case -2: | ||
| 669 : | BitstreamPutBit(bs, 1); | ||
| 670 : | BitstreamPutBit(bs, 0); | ||
| 671 : | return; | ||
| 672 : | |||
| 673 : | case 2: | ||
| 674 : | BitstreamPutBit(bs, 1); | ||
| 675 : | BitstreamPutBit(bs, 1); | ||
| 676 : | return; | ||
| 677 : | |||
| 678 : | edgomez | 1.46 | default:; /* invalid */ |
| 679 : | edgomez | 1.42 | } |
| 680 : | } | ||
| 681 : | |||
| 682 : | |||
| 683 : | |||
| 684 : | void | ||
| 685 : | edgomez | 1.46 | MBCodingBVOP(const FRAMEINFO * const frame, |
| 686 : | const MACROBLOCK * mb, | ||
| 687 : | edgomez | 1.42 | const int16_t qcoeff[6 * 64], |
| 688 : | const int32_t fcode, | ||
| 689 : | const int32_t bcode, | ||
| 690 : | Bitstream * bs, | ||
| 691 : | edgomez | 1.46 | Statistics * pStat) |
| 692 : | edgomez | 1.42 | { |
| 693 : | int vcode = fcode; | ||
| 694 : | unsigned int i; | ||
| 695 : | |||
| 696 : | edgomez | 1.46 | const uint16_t *scan_table = |
| 697 : | frame->vop_flags & XVID_VOP_ALTERNATESCAN ? | ||
| 698 : | scan_tables[2] : scan_tables[0]; | ||
| 699 : | int bits; | ||
| 700 : | |||
| 701 : | edgomez | 1.42 | /* ------------------------------------------------------------------ |
| 702 : | when a block is skipped it is decoded DIRECT(0,0) | ||
| 703 : | hence is interpolated from forward & backward frames | ||
| 704 : | ------------------------------------------------------------------ */ | ||
| 705 : | |||
| 706 : | if (mb->mode == MODE_DIRECT_NONE_MV) { | ||
| 707 : | edgomez | 1.46 | BitstreamPutBit(bs, 1); /* skipped */ |
| 708 : | edgomez | 1.42 | return; |
| 709 : | } | ||
| 710 : | |||
| 711 : | edgomez | 1.46 | BitstreamPutBit(bs, 0); /* not skipped */ |
| 712 : | edgomez | 1.42 | |
| 713 : | if (mb->cbp == 0) { | ||
| 714 : | edgomez | 1.46 | BitstreamPutBit(bs, 1); /* cbp == 0 */ |
| 715 : | edgomez | 1.42 | } else { |
| 716 : | edgomez | 1.46 | BitstreamPutBit(bs, 0); /* cbp == xxx */ |
| 717 : | edgomez | 1.42 | } |
| 718 : | |||
| 719 : | put_bvop_mbtype(bs, mb->mode); | ||
| 720 : | |||
| 721 : | if (mb->cbp) { | ||
| 722 : | BitstreamPutBits(bs, mb->cbp, 6); | ||
| 723 : | } | ||
| 724 : | |||
| 725 : | if (mb->mode != MODE_DIRECT && mb->cbp != 0) { | ||
| 726 : | edgomez | 1.46 | put_bvop_dbquant(bs, 0); /* todo: mb->dquant = 0 */ |
| 727 : | edgomez | 1.42 | } |
| 728 : | |||
| 729 : | edgomez | 1.46 | 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 : | edgomez | 1.42 | switch (mb->mode) { |
| 751 : | case MODE_INTERPOLATE: | ||
| 752 : | syskin | 1.49 | CodeVector(bs, mb->pmvs[1].x, vcode); /* forward vector of interpolate mode */ |
| 753 : | CodeVector(bs, mb->pmvs[1].y, vcode); | ||
| 754 : | edgomez | 1.42 | case MODE_BACKWARD: |
| 755 : | vcode = bcode; | ||
| 756 : | case MODE_FORWARD: | ||
| 757 : | syskin | 1.49 | CodeVector(bs, mb->pmvs[0].x, vcode); |
| 758 : | CodeVector(bs, mb->pmvs[0].y, vcode); | ||
| 759 : | edgomez | 1.42 | break; |
| 760 : | case MODE_DIRECT: | ||
| 761 : | syskin | 1.49 | CodeVector(bs, mb->pmvs[3].x, 1); /* fcode is always 1 for delta vector */ |
| 762 : | CodeVector(bs, mb->pmvs[3].y, 1); /* prediction is always (0,0) */ | ||
| 763 : | edgomez | 1.42 | default: break; |
| 764 : | } | ||
| 765 : | |||
| 766 : | edgomez | 1.46 | bits = BitstreamPos(bs); |
| 767 : | edgomez | 1.42 | for (i = 0; i < 6; i++) { |
| 768 : | if (mb->cbp & (1 << (5 - i))) { | ||
| 769 : | edgomez | 1.46 | CodeCoeffInter(bs, &qcoeff[i * 64], scan_table); |
| 770 : | edgomez | 1.42 | } |
| 771 : | } | ||
| 772 : | edgomez | 1.46 | pStat->iTextBits += BitstreamPos(bs) - bits; |
| 773 : | edgomez | 1.42 | } |
| 774 : | |||
| 775 : | |||
| 776 : | |||
| 777 : | /*************************************************************** | ||
| 778 : | * decoding stuff starts here * | ||
| 779 : | ***************************************************************/ | ||
| 780 : | |||
| 781 : | |||
| 782 : | edgomez | 1.46 | /* |
| 783 : | * for IVOP addbits == 0 | ||
| 784 : | * for PVOP addbits == fcode - 1 | ||
| 785 : | * for BVOP addbits == max(fcode,bcode) - 1 | ||
| 786 : | * returns true or false | ||
| 787 : | */ | ||
| 788 : | int | ||
| 789 : | suxen_drol | 1.19 | check_resync_marker(Bitstream * bs, int addbits) |
| 790 : | { | ||
| 791 : | uint32_t nbits; | ||
| 792 : | uint32_t code; | ||
| 793 : | uint32_t nbitsresyncmarker = NUMBITS_VP_RESYNC_MARKER + addbits; | ||
| 794 : | |||
| 795 : | nbits = BitstreamNumBitsToByteAlign(bs); | ||
| 796 : | code = BitstreamShowBits(bs, nbits); | ||
| 797 : | |||
| 798 : | if (code == (((uint32_t)1 << (nbits - 1)) - 1)) | ||
| 799 : | { | ||
| 800 : | return BitstreamShowBitsFromByteAlign(bs, nbitsresyncmarker) == RESYNC_MARKER; | ||
| 801 : | } | ||
| 802 : | |||
| 803 : | return 0; | ||
| 804 : | } | ||
| 805 : | |||
| 806 : | |||
| 807 : | |||
| 808 : | edgomez | 1.17 | int |
| 809 : | get_mcbpc_intra(Bitstream * bs) | ||
| 810 : | Isibaar | 1.1 | { |
| 811 : | edgomez | 1.7 | |
| 812 : | Isibaar | 1.1 | uint32_t index; |
| 813 : | edgomez | 1.17 | |
| 814 : | suxen_drol | 1.19 | index = BitstreamShowBits(bs, 9); |
| 815 : | Isibaar | 1.1 | index >>= 3; |
| 816 : | |||
| 817 : | BitstreamSkip(bs, mcbpc_intra_table[index].len); | ||
| 818 : | edgomez | 1.7 | |
| 819 : | Isibaar | 1.1 | return mcbpc_intra_table[index].code; |
| 820 : | edgomez | 1.7 | |
| 821 : | Isibaar | 1.1 | } |
| 822 : | |||
| 823 : | edgomez | 1.17 | int |
| 824 : | get_mcbpc_inter(Bitstream * bs) | ||
| 825 : | Isibaar | 1.1 | { |
| 826 : | edgomez | 1.7 | |
| 827 : | Isibaar | 1.1 | uint32_t index; |
| 828 : | edgomez | 1.46 | |
| 829 : | edgomez | 1.42 | index = MIN(BitstreamShowBits(bs, 9), 256); |
| 830 : | Isibaar | 1.1 | |
| 831 : | edgomez | 1.17 | BitstreamSkip(bs, mcbpc_inter_table[index].len); |
| 832 : | edgomez | 1.7 | |
| 833 : | Isibaar | 1.1 | return mcbpc_inter_table[index].code; |
| 834 : | edgomez | 1.7 | |
| 835 : | Isibaar | 1.1 | } |
| 836 : | |||
| 837 : | edgomez | 1.17 | int |
| 838 : | get_cbpy(Bitstream * bs, | ||
| 839 : | int intra) | ||
| 840 : | Isibaar | 1.1 | { |
| 841 : | edgomez | 1.7 | |
| 842 : | Isibaar | 1.1 | int cbpy; |
| 843 : | uint32_t index = BitstreamShowBits(bs, 6); | ||
| 844 : | |||
| 845 : | BitstreamSkip(bs, cbpy_table[index].len); | ||
| 846 : | cbpy = cbpy_table[index].code; | ||
| 847 : | |||
| 848 : | edgomez | 1.17 | if (!intra) |
| 849 : | Isibaar | 1.1 | cbpy = 15 - cbpy; |
| 850 : | |||
| 851 : | return cbpy; | ||
| 852 : | edgomez | 1.7 | |
| 853 : | Isibaar | 1.1 | } |
| 854 : | |||
| 855 : | edgomez | 1.42 | static __inline int |
| 856 : | edgomez | 1.17 | get_mv_data(Bitstream * bs) |
| 857 : | Isibaar | 1.1 | { |
| 858 : | edgomez | 1.7 | |
| 859 : | Isibaar | 1.1 | uint32_t index; |
| 860 : | |||
| 861 : | edgomez | 1.17 | if (BitstreamGetBit(bs)) |
| 862 : | Isibaar | 1.1 | return 0; |
| 863 : | edgomez | 1.17 | |
| 864 : | Isibaar | 1.1 | index = BitstreamShowBits(bs, 12); |
| 865 : | |||
| 866 : | edgomez | 1.17 | if (index >= 512) { |
| 867 : | Isibaar | 1.1 | index = (index >> 8) - 2; |
| 868 : | BitstreamSkip(bs, TMNMVtab0[index].len); | ||
| 869 : | return TMNMVtab0[index].code; | ||
| 870 : | } | ||
| 871 : | edgomez | 1.17 | |
| 872 : | if (index >= 128) { | ||
| 873 : | Isibaar | 1.1 | index = (index >> 2) - 32; |
| 874 : | BitstreamSkip(bs, TMNMVtab1[index].len); | ||
| 875 : | return TMNMVtab1[index].code; | ||
| 876 : | } | ||
| 877 : | |||
| 878 : | edgomez | 1.17 | index -= 4; |
| 879 : | Isibaar | 1.1 | |
| 880 : | BitstreamSkip(bs, TMNMVtab2[index].len); | ||
| 881 : | return TMNMVtab2[index].code; | ||
| 882 : | edgomez | 1.7 | |
| 883 : | Isibaar | 1.1 | } |
| 884 : | |||
| 885 : | edgomez | 1.17 | int |
| 886 : | get_mv(Bitstream * bs, | ||
| 887 : | int fcode) | ||
| 888 : | Isibaar | 1.1 | { |
| 889 : | edgomez | 1.7 | |
| 890 : | Isibaar | 1.1 | int data; |
| 891 : | int res; | ||
| 892 : | int mv; | ||
| 893 : | int scale_fac = 1 << (fcode - 1); | ||
| 894 : | |||
| 895 : | data = get_mv_data(bs); | ||
| 896 : | edgomez | 1.17 | |
| 897 : | if (scale_fac == 1 || data == 0) | ||
| 898 : | Isibaar | 1.1 | return data; |
| 899 : | |||
| 900 : | res = BitstreamGetBits(bs, fcode - 1); | ||
| 901 : | edgomez | 1.46 | mv = ((abs(data) - 1) * scale_fac) + res + 1; |
| 902 : | edgomez | 1.17 | |
| 903 : | Isibaar | 1.1 | return data < 0 ? -mv : mv; |
| 904 : | edgomez | 1.7 | |
| 905 : | Isibaar | 1.1 | } |
| 906 : | |||
| 907 : | edgomez | 1.17 | int |
| 908 : | get_dc_dif(Bitstream * bs, | ||
| 909 : | uint32_t dc_size) | ||
| 910 : | Isibaar | 1.1 | { |
| 911 : | edgomez | 1.7 | |
| 912 : | Isibaar | 1.1 | int code = BitstreamGetBits(bs, dc_size); |
| 913 : | int msb = code >> (dc_size - 1); | ||
| 914 : | |||
| 915 : | edgomez | 1.17 | if (msb == 0) |
| 916 : | return (-1 * (code ^ ((1 << dc_size) - 1))); | ||
| 917 : | Isibaar | 1.1 | |
| 918 : | return code; | ||
| 919 : | edgomez | 1.7 | |
| 920 : | Isibaar | 1.1 | } |
| 921 : | |||
| 922 : | edgomez | 1.17 | int |
| 923 : | get_dc_size_lum(Bitstream * bs) | ||
| 924 : | Isibaar | 1.1 | { |
| 925 : | edgomez | 1.7 | |
| 926 : | Isibaar | 1.1 | int code, i; |
| 927 : | edgomez | 1.17 | |
| 928 : | Isibaar | 1.1 | code = BitstreamShowBits(bs, 11); |
| 929 : | |||
| 930 : | edgomez | 1.17 | for (i = 11; i > 3; i--) { |
| 931 : | if (code == 1) { | ||
| 932 : | Isibaar | 1.1 | BitstreamSkip(bs, i); |
| 933 : | return i + 1; | ||
| 934 : | } | ||
| 935 : | code >>= 1; | ||
| 936 : | } | ||
| 937 : | |||
| 938 : | BitstreamSkip(bs, dc_lum_tab[code].len); | ||
| 939 : | return dc_lum_tab[code].code; | ||
| 940 : | edgomez | 1.7 | |
| 941 : | Isibaar | 1.1 | } |
| 942 : | |||
| 943 : | |||
| 944 : | edgomez | 1.17 | int |
| 945 : | get_dc_size_chrom(Bitstream * bs) | ||
| 946 : | Isibaar | 1.1 | { |
| 947 : | edgomez | 1.7 | |
| 948 : | Isibaar | 1.1 | uint32_t code, i; |
| 949 : | edgomez | 1.17 | |
| 950 : | Isibaar | 1.1 | code = BitstreamShowBits(bs, 12); |
| 951 : | |||
| 952 : | edgomez | 1.17 | for (i = 12; i > 2; i--) { |
| 953 : | if (code == 1) { | ||
| 954 : | Isibaar | 1.1 | BitstreamSkip(bs, i); |
| 955 : | return i; | ||
| 956 : | } | ||
| 957 : | code >>= 1; | ||
| 958 : | } | ||
| 959 : | |||
| 960 : | return 3 - BitstreamGetBits(bs, 2); | ||
| 961 : | edgomez | 1.7 | |
| 962 : | Isibaar | 1.1 | } |
| 963 : | edgomez | 1.27 | |
| 964 : | edgomez | 1.47 | #define GET_BITS(cache, n) ((cache)>>(32-(n))) |
| 965 : | |||
| 966 : | edgomez | 1.27 | static __inline int |
| 967 : | get_coeff(Bitstream * bs, | ||
| 968 : | int *run, | ||
| 969 : | int *last, | ||
| 970 : | int intra, | ||
| 971 : | int short_video_header) | ||
| 972 : | { | ||
| 973 : | |||
| 974 : | uint32_t mode; | ||
| 975 : | int32_t level; | ||
| 976 : | edgomez | 1.37 | REVERSE_EVENT *reverse_event; |
| 977 : | edgomez | 1.27 | |
| 978 : | edgomez | 1.47 | uint32_t cache = BitstreamShowBits(bs, 32); |
| 979 : | |||
| 980 : | edgomez | 1.34 | if (short_video_header) /* inter-VLCs will be used for both intra and inter blocks */ |
| 981 : | edgomez | 1.27 | intra = 0; |
| 982 : | |||
| 983 : | edgomez | 1.47 | if (GET_BITS(cache, 7) != ESCAPE) { |
| 984 : | reverse_event = &DCT3D[intra][GET_BITS(cache, 12)]; | ||
| 985 : | edgomez | 1.37 | |
| 986 : | if ((level = reverse_event->event.level) == 0) | ||
| 987 : | goto error; | ||
| 988 : | edgomez | 1.27 | |
| 989 : | edgomez | 1.37 | *last = reverse_event->event.last; |
| 990 : | *run = reverse_event->event.run; | ||
| 991 : | edgomez | 1.27 | |
| 992 : | edgomez | 1.47 | /* Don't forget to update the bitstream position */ |
| 993 : | BitstreamSkip(bs, reverse_event->len+1); | ||
| 994 : | edgomez | 1.27 | |
| 995 : | edgomez | 1.47 | return (GET_BITS(cache, reverse_event->len+1)&0x01) ? -level : level; |
| 996 : | edgomez | 1.27 | } |
| 997 : | |||
| 998 : | edgomez | 1.47 | /* flush 7bits of cache */ |
| 999 : | cache <<= 7; | ||
| 1000 : | edgomez | 1.37 | |
| 1001 : | edgomez | 1.27 | if (short_video_header) { |
| 1002 : | edgomez | 1.34 | /* escape mode 4 - H.263 type, only used if short_video_header = 1 */ |
| 1003 : | edgomez | 1.47 | *last = GET_BITS(cache, 1); |
| 1004 : | *run = (GET_BITS(cache, 7) &0x3f); | ||
| 1005 : | level = (GET_BITS(cache, 15)&0xff); | ||
| 1006 : | edgomez | 1.27 | |
| 1007 : | if (level == 0 || level == 128) | ||
| 1008 : | edgomez | 1.46 | DPRINTF(XVID_DEBUG_ERROR, "Illegal LEVEL for ESCAPE mode 4: %d\n", level); |
| 1009 : | edgomez | 1.27 | |
| 1010 : | edgomez | 1.47 | /* We've "eaten" 22 bits */ |
| 1011 : | BitstreamSkip(bs, 22); | ||
| 1012 : | |||
| 1013 : | edgomez | 1.37 | return (level << 24) >> 24; |
| 1014 : | edgomez | 1.27 | } |
| 1015 : | |||
| 1016 : | edgomez | 1.47 | if ((mode = GET_BITS(cache, 2)) < 3) { |
| 1017 : | const int skip[3] = {1, 1, 2}; | ||
| 1018 : | cache <<= skip[mode]; | ||
| 1019 : | edgomez | 1.27 | |
| 1020 : | edgomez | 1.47 | reverse_event = &DCT3D[intra][GET_BITS(cache, 12)]; |
| 1021 : | edgomez | 1.37 | |
| 1022 : | if ((level = reverse_event->event.level) == 0) | ||
| 1023 : | edgomez | 1.27 | goto error; |
| 1024 : | |||
| 1025 : | edgomez | 1.37 | *last = reverse_event->event.last; |
| 1026 : | *run = reverse_event->event.run; | ||
| 1027 : | edgomez | 1.27 | |
| 1028 : | edgomez | 1.47 | if (mode < 2) { |
| 1029 : | /* first escape mode, level is offset */ | ||
| 1030 : | edgomez | 1.37 | level += max_level[intra][*last][*run]; |
| 1031 : | edgomez | 1.47 | } else { |
| 1032 : | /* second escape mode, run is offset */ | ||
| 1033 : | edgomez | 1.37 | *run += max_run[intra][*last][level] + 1; |
| 1034 : | edgomez | 1.47 | } |
| 1035 : | |||
| 1036 : | /* Update bitstream position */ | ||
| 1037 : | BitstreamSkip(bs, 7 + skip[mode] + reverse_event->len + 1); | ||
| 1038 : | edgomez | 1.27 | |
| 1039 : | edgomez | 1.47 | return (GET_BITS(cache, reverse_event->len+1)&0x01) ? -level : level; |
| 1040 : | edgomez | 1.27 | } |
| 1041 : | edgomez | 1.37 | |
| 1042 : | edgomez | 1.34 | /* third escape mode - fixed length codes */ |
| 1043 : | edgomez | 1.47 | cache <<= 2; |
| 1044 : | *last = GET_BITS(cache, 1); | ||
| 1045 : | *run = (GET_BITS(cache, 7)&0x3f); | ||
| 1046 : | level = (GET_BITS(cache, 20)&0xfff); | ||
| 1047 : | |||
| 1048 : | /* Update bitstream position */ | ||
| 1049 : | BitstreamSkip(bs, 30); | ||
| 1050 : | edgomez | 1.27 | |
| 1051 : | edgomez | 1.37 | return (level << 20) >> 20; |
| 1052 : | edgomez | 1.27 | |
| 1053 : | error: | ||
| 1054 : | *run = VLC_ERROR; | ||
| 1055 : | return 0; | ||
| 1056 : | } | ||
| 1057 : | |||
| 1058 : | edgomez | 1.17 | void |
| 1059 : | get_intra_block(Bitstream * bs, | ||
| 1060 : | int16_t * block, | ||
| 1061 : | int direction, | ||
| 1062 : | int coeff) | ||
| 1063 : | Isibaar | 1.1 | { |
| 1064 : | edgomez | 1.7 | |
| 1065 : | edgomez | 1.17 | const uint16_t *scan = scan_tables[direction]; |
| 1066 : | edgomez | 1.42 | int level, run, last; |
| 1067 : | Isibaar | 1.1 | |
| 1068 : | edgomez | 1.17 | do { |
| 1069 : | Isibaar | 1.1 | level = get_coeff(bs, &run, &last, 1, 0); |
| 1070 : | edgomez | 1.17 | if (run == -1) { |
| 1071 : | edgomez | 1.46 | DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run"); |
| 1072 : | Isibaar | 1.1 | break; |
| 1073 : | } | ||
| 1074 : | coeff += run; | ||
| 1075 : | suxen_drol | 1.52 | |
| 1076 : | #ifdef _DEBUG | ||
| 1077 : | if(coeff>=64) { | ||
| 1078 : | DPRINTF(XVID_DEBUG_ERROR,"error: overflow in coefficient index\n"); | ||
| 1079 : | return; | ||
| 1080 : | } | ||
| 1081 : | #endif | ||
| 1082 : | |||
| 1083 : | edgomez | 1.17 | block[scan[coeff]] = level; |
| 1084 : | suxen_drol | 1.20 | |
| 1085 : | edgomez | 1.46 | DPRINTF(XVID_DEBUG_COEFF,"block[%i] %i\n", scan[coeff], level); |
| 1086 : | #if 0 | ||
| 1087 : | DPRINTF(XVID_DEBUG_COEFF,"block[%i] %i %08x\n", scan[coeff], level, BitstreamShowBits(bs, 32)); | ||
| 1088 : | #endif | ||
| 1089 : | suxen_drol | 1.20 | |
| 1090 : | suxen_drol | 1.36 | if (level < -2047 || level > 2047) { |
| 1091 : | edgomez | 1.46 | DPRINTF(XVID_DEBUG_ERROR,"warning: intra_overflow %i\n", level); |
| 1092 : | Isibaar | 1.1 | } |
| 1093 : | coeff++; | ||
| 1094 : | } while (!last); | ||
| 1095 : | edgomez | 1.7 | |
| 1096 : | Isibaar | 1.1 | } |
| 1097 : | |||
| 1098 : | edgomez | 1.17 | void |
| 1099 : | edgomez | 1.47 | get_inter_block_h263( |
| 1100 : | Bitstream * bs, | ||
| 1101 : | int16_t * block, | ||
| 1102 : | int direction, | ||
| 1103 : | const int quant, | ||
| 1104 : | const uint16_t *matrix) | ||
| 1105 : | Isibaar | 1.1 | { |
| 1106 : | edgomez | 1.7 | |
| 1107 : | edgomez | 1.42 | const uint16_t *scan = scan_tables[direction]; |
| 1108 : | edgomez | 1.47 | const uint16_t quant_m_2 = quant << 1; |
| 1109 : | const uint16_t quant_add = (quant & 1 ? quant : quant - 1); | ||
| 1110 : | Isibaar | 1.1 | int p; |
| 1111 : | int level; | ||
| 1112 : | int run; | ||
| 1113 : | int last; | ||
| 1114 : | |||
| 1115 : | p = 0; | ||
| 1116 : | edgomez | 1.17 | do { |
| 1117 : | Isibaar | 1.1 | level = get_coeff(bs, &run, &last, 0, 0); |
| 1118 : | edgomez | 1.17 | if (run == -1) { |
| 1119 : | edgomez | 1.46 | DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run"); |
| 1120 : | Isibaar | 1.1 | break; |
| 1121 : | } | ||
| 1122 : | p += run; | ||
| 1123 : | chenm001 | 1.16 | |
| 1124 : | suxen_drol | 1.52 | #ifdef _DEBUG |
| 1125 : | if(p>=64) { | ||
| 1126 : | DPRINTF(XVID_DEBUG_ERROR,"error: overflow in coefficient index\n"); | ||
| 1127 : | return; | ||
| 1128 : | } | ||
| 1129 : | #endif | ||
| 1130 : | |||
| 1131 : | edgomez | 1.47 | if (level < 0) { |
| 1132 : | level = level*quant_m_2 - quant_add; | ||
| 1133 : | block[scan[p]] = (level >= -2048 ? level : -2048); | ||
| 1134 : | } else { | ||
| 1135 : | level = level * quant_m_2 + quant_add; | ||
| 1136 : | block[scan[p]] = (level <= 2047 ? level : 2047); | ||
| 1137 : | } | ||
| 1138 : | p++; | ||
| 1139 : | } while (!last); | ||
| 1140 : | } | ||
| 1141 : | |||
| 1142 : | void | ||
| 1143 : | get_inter_block_mpeg( | ||
| 1144 : | Bitstream * bs, | ||
| 1145 : | int16_t * block, | ||
| 1146 : | int direction, | ||
| 1147 : | const int quant, | ||
| 1148 : | const uint16_t *matrix) | ||
| 1149 : | { | ||
| 1150 : | const uint16_t *scan = scan_tables[direction]; | ||
| 1151 : | uint32_t sum = 0; | ||
| 1152 : | int p; | ||
| 1153 : | int level; | ||
| 1154 : | int run; | ||
| 1155 : | int last; | ||
| 1156 : | suxen_drol | 1.20 | |
| 1157 : | edgomez | 1.47 | p = 0; |
| 1158 : | do { | ||
| 1159 : | level = get_coeff(bs, &run, &last, 0, 0); | ||
| 1160 : | if (run == -1) { | ||
| 1161 : | DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run"); | ||
| 1162 : | break; | ||
| 1163 : | } | ||
| 1164 : | p += run; | ||
| 1165 : | suxen_drol | 1.20 | |
| 1166 : | suxen_drol | 1.52 | #ifdef _DEBUG |
| 1167 : | if(p>=64) { | ||
| 1168 : | DPRINTF(XVID_DEBUG_ERROR,"error: overflow in coefficient index\n"); | ||
| 1169 : | return; | ||
| 1170 : | } | ||
| 1171 : | #endif | ||
| 1172 : | |||
| 1173 : | edgomez | 1.47 | if (level < 0) { |
| 1174 : | level = ((2 * -level + 1) * matrix[scan[p]] * quant) >> 4; | ||
| 1175 : | block[scan[p]] = (level <= 2048 ? -level : -2048); | ||
| 1176 : | } else { | ||
| 1177 : | level = ((2 * level + 1) * matrix[scan[p]] * quant) >> 4; | ||
| 1178 : | block[scan[p]] = (level <= 2047 ? level : 2047); | ||
| 1179 : | Isibaar | 1.1 | } |
| 1180 : | edgomez | 1.47 | |
| 1181 : | sum ^= block[scan[p]]; | ||
| 1182 : | |||
| 1183 : | Isibaar | 1.1 | p++; |
| 1184 : | } while (!last); | ||
| 1185 : | edgomez | 1.7 | |
| 1186 : | edgomez | 1.47 | /* mismatch control */ |
| 1187 : | if ((sum & 1) == 0) { | ||
| 1188 : | block[63] ^= 1; | ||
| 1189 : | } | ||
| 1190 : | Isibaar | 1.1 | } |
| 1191 : | edgomez | 1.43 | |
| 1192 : | edgomez | 1.46 | |
| 1193 : | edgomez | 1.43 | /***************************************************************************** |
| 1194 : | * VLC tables and other constant arrays | ||
| 1195 : | ****************************************************************************/ | ||
| 1196 : | |||
| 1197 : | VLC_TABLE const coeff_tab[2][102] = | ||
| 1198 : | { | ||
| 1199 : | /* intra = 0 */ | ||
| 1200 : | { | ||
| 1201 : | {{ 2, 2}, {0, 0, 1}}, | ||
| 1202 : | {{15, 4}, {0, 0, 2}}, | ||
| 1203 : | {{21, 6}, {0, 0, 3}}, | ||
| 1204 : | {{23, 7}, {0, 0, 4}}, | ||
| 1205 : | {{31, 8}, {0, 0, 5}}, | ||
| 1206 : | {{37, 9}, {0, 0, 6}}, | ||
| 1207 : | {{36, 9}, {0, 0, 7}}, | ||
| 1208 : | {{33, 10}, {0, 0, 8}}, | ||
| 1209 : | {{32, 10}, {0, 0, 9}}, | ||
| 1210 : | {{ 7, 11}, {0, 0, 10}}, | ||
| 1211 : | {{ 6, 11}, {0, 0, 11}}, | ||
| 1212 : | {{32, 11}, {0, 0, 12}}, | ||
| 1213 : | {{ 6, 3}, {0, 1, 1}}, | ||
| 1214 : | {{20, 6}, {0, 1, 2}}, | ||
| 1215 : | {{30, 8}, {0, 1, 3}}, | ||
| 1216 : | {{15, 10}, {0, 1, 4}}, | ||
| 1217 : | {{33, 11}, {0, 1, 5}}, | ||
| 1218 : | {{80, 12}, {0, 1, 6}}, | ||
| 1219 : | {{14, 4}, {0, 2, 1}}, | ||
| 1220 : | {{29, 8}, {0, 2, 2}}, | ||
| 1221 : | {{14, 10}, {0, 2, 3}}, | ||
| 1222 : | {{81, 12}, {0, 2, 4}}, | ||
| 1223 : | {{13, 5}, {0, 3, 1}}, | ||
| 1224 : | {{35, 9}, {0, 3, 2}}, | ||
| 1225 : | {{13, 10}, {0, 3, 3}}, | ||
| 1226 : | {{12, 5}, {0, 4, 1}}, | ||
| 1227 : | {{34, 9}, {0, 4, 2}}, | ||
| 1228 : | {{82, 12}, {0, 4, 3}}, | ||
| 1229 : | {{11, 5}, {0, 5, 1}}, | ||
| 1230 : | {{12, 10}, {0, 5, 2}}, | ||
| 1231 : | {{83, 12}, {0, 5, 3}}, | ||
| 1232 : | {{19, 6}, {0, 6, 1}}, | ||
| 1233 : | {{11, 10}, {0, 6, 2}}, | ||
| 1234 : | {{84, 12}, {0, 6, 3}}, | ||
| 1235 : | {{18, 6}, {0, 7, 1}}, | ||
| 1236 : | {{10, 10}, {0, 7, 2}}, | ||
| 1237 : | {{17, 6}, {0, 8, 1}}, | ||
| 1238 : | {{ 9, 10}, {0, 8, 2}}, | ||
| 1239 : | {{16, 6}, {0, 9, 1}}, | ||
| 1240 : | {{ 8, 10}, {0, 9, 2}}, | ||
| 1241 : | {{22, 7}, {0, 10, 1}}, | ||
| 1242 : | {{85, 12}, {0, 10, 2}}, | ||
| 1243 : | {{21, 7}, {0, 11, 1}}, | ||
| 1244 : | {{20, 7}, {0, 12, 1}}, | ||
| 1245 : | {{28, 8}, {0, 13, 1}}, | ||
| 1246 : | {{27, 8}, {0, 14, 1}}, | ||
| 1247 : | {{33, 9}, {0, 15, 1}}, | ||
| 1248 : | {{32, 9}, {0, 16, 1}}, | ||
| 1249 : | {{31, 9}, {0, 17, 1}}, | ||
| 1250 : | {{30, 9}, {0, 18, 1}}, | ||
| 1251 : | {{29, 9}, {0, 19, 1}}, | ||
| 1252 : | {{28, 9}, {0, 20, 1}}, | ||
| 1253 : | {{27, 9}, {0, 21, 1}}, | ||
| 1254 : | {{26, 9}, {0, 22, 1}}, | ||
| 1255 : | {{34, 11}, {0, 23, 1}}, | ||
| 1256 : | {{35, 11}, {0, 24, 1}}, | ||
| 1257 : | {{86, 12}, {0, 25, 1}}, | ||
| 1258 : | {{87, 12}, {0, 26, 1}}, | ||
| 1259 : | {{ 7, 4}, {1, 0, 1}}, | ||
| 1260 : | {{25, 9}, {1, 0, 2}}, | ||
| 1261 : | {{ 5, 11}, {1, 0, 3}}, | ||
| 1262 : | {{15, 6}, {1, 1, 1}}, | ||
| 1263 : | {{ 4, 11}, {1, 1, 2}}, | ||
| 1264 : | {{14, 6}, {1, 2, 1}}, | ||
| 1265 : | {{13, 6}, {1, 3, 1}}, | ||
| 1266 : | {{12, 6}, {1, 4, 1}}, | ||
| 1267 : | {{19, 7}, {1, 5, 1}}, | ||
| 1268 : | {{18, 7}, {1, 6, 1}}, | ||
| 1269 : | {{17, 7}, {1, 7, 1}}, | ||
| 1270 : | {{16, 7}, {1, 8, 1}}, | ||
| 1271 : | {{26, 8}, {1, 9, 1}}, | ||
| 1272 : | {{25, 8}, {1, 10, 1}}, | ||
| 1273 : | {{24, 8}, {1, 11, 1}}, | ||
| 1274 : | {{23, 8}, {1, 12, 1}}, | ||
| 1275 : | {{22, 8}, {1, 13, 1}}, | ||
| 1276 : | {{21, 8}, {1, 14, 1}}, | ||
| 1277 : | {{20, 8}, {1, 15, 1}}, | ||
| 1278 : | {{19, 8}, {1, 16, 1}}, | ||
| 1279 : | {{24, 9}, {1, 17, 1}}, | ||
| 1280 : | {{23, 9}, {1, 18, 1}}, | ||
| 1281 : | {{22, 9}, {1, 19, 1}}, | ||
| 1282 : | {{21, 9}, {1, 20, 1}}, | ||
| 1283 : | {{20, 9}, {1, 21, 1}}, | ||
| 1284 : | {{19, 9}, {1, 22, 1}}, | ||
| 1285 : | {{18, 9}, {1, 23, 1}}, | ||
| 1286 : | {{17, 9}, {1, 24, 1}}, | ||
| 1287 : | {{ 7, 10}, {1, 25, 1}}, | ||
| 1288 : | {{ 6, 10}, {1, 26, 1}}, | ||
| 1289 : | {{ 5, 10}, {1, 27, 1}}, | ||
| 1290 : | {{ 4, 10}, {1, 28, 1}}, | ||
| 1291 : | {{36, 11}, {1, 29, 1}}, | ||
| 1292 : | {{37, 11}, {1, 30, 1}}, | ||
| 1293 : | {{38, 11}, {1, 31, 1}}, | ||
| 1294 : | {{39, 11}, {1, 32, 1}}, | ||
| 1295 : | {{88, 12}, {1, 33, 1}}, | ||
| 1296 : | {{89, 12}, {1, 34, 1}}, | ||
| 1297 : | {{90, 12}, {1, 35, 1}}, | ||
| 1298 : | {{91, 12}, {1, 36, 1}}, | ||
| 1299 : | {{92, 12}, {1, 37, 1}}, | ||
| 1300 : | {{93, 12}, {1, 38, 1}}, | ||
| 1301 : | {{94, 12}, {1, 39, 1}}, | ||
| 1302 : | {{95, 12}, {1, 40, 1}} | ||
| 1303 : | }, | ||
| 1304 : | /* intra = 1 */ | ||
| 1305 : | { | ||
| 1306 : | {{ 2, 2}, {0, 0, 1}}, | ||
| 1307 : | {{15, 4}, {0, 0, 3}}, | ||
| 1308 : | {{21, 6}, {0, 0, 6}}, | ||
| 1309 : | {{23, 7}, {0, 0, 9}}, | ||
| 1310 : | {{31, 8}, {0, 0, 10}}, | ||
| 1311 : | {{37, 9}, {0, 0, 13}}, | ||
| 1312 : | {{36, 9}, {0, 0, 14}}, | ||
| 1313 : | {{33, 10}, {0, 0, 17}}, | ||
| 1314 : | {{32, 10}, {0, 0, 18}}, | ||
| 1315 : | {{ 7, 11}, {0, 0, 21}}, | ||
| 1316 : | {{ 6, 11}, {0, 0, 22}}, | ||
| 1317 : | {{32, 11}, {0, 0, 23}}, | ||
| 1318 : | {{ 6, 3}, {0, 0, 2}}, | ||
| 1319 : | {{20, 6}, {0, 1, 2}}, | ||
| 1320 : | {{30, 8}, {0, 0, 11}}, | ||
| 1321 : | {{15, 10}, {0, 0, 19}}, | ||
| 1322 : | {{33, 11}, {0, 0, 24}}, | ||
| 1323 : | {{80, 12}, {0, 0, 25}}, | ||
| 1324 : | {{14, 4}, {0, 1, 1}}, | ||
| 1325 : | {{29, 8}, {0, 0, 12}}, | ||
| 1326 : | {{14, 10}, {0, 0, 20}}, | ||
| 1327 : | {{81, 12}, {0, 0, 26}}, | ||
| 1328 : | {{13, 5}, {0, 0, 4}}, | ||
| 1329 : | {{35, 9}, {0, 0, 15}}, | ||
| 1330 : | {{13, 10}, {0, 1, 7}}, | ||
| 1331 : | {{12, 5}, {0, 0, 5}}, | ||
| 1332 : | {{34, 9}, {0, 4, 2}}, | ||
| 1333 : | {{82, 12}, {0, 0, 27}}, | ||
| 1334 : | {{11, 5}, {0, 2, 1}}, | ||
| 1335 : | {{12, 10}, {0, 2, 4}}, | ||
| 1336 : | {{83, 12}, {0, 1, 9}}, | ||
| 1337 : | {{19, 6}, {0, 0, 7}}, | ||
| 1338 : | {{11, 10}, {0, 3, 4}}, | ||
| 1339 : | {{84, 12}, {0, 6, 3}}, | ||
| 1340 : | {{18, 6}, {0, 0, 8}}, | ||
| 1341 : | {{10, 10}, {0, 4, 3}}, | ||
| 1342 : | {{17, 6}, {0, 3, 1}}, | ||
| 1343 : | {{ 9, 10}, {0, 8, 2}}, | ||
| 1344 : | {{16, 6}, {0, 4, 1}}, | ||
| 1345 : | {{ 8, 10}, {0, 5, 3}}, | ||
| 1346 : | {{22, 7}, {0, 1, 3}}, | ||
| 1347 : | {{85, 12}, {0, 1, 10}}, | ||
| 1348 : | {{21, 7}, {0, 2, 2}}, | ||
| 1349 : | {{20, 7}, {0, 7, 1}}, | ||
| 1350 : | {{28, 8}, {0, 1, 4}}, | ||
| 1351 : | {{27, 8}, {0, 3, 2}}, | ||
| 1352 : | {{33, 9}, {0, 0, 16}}, | ||
| 1353 : | {{32, 9}, {0, 1, 5}}, | ||
| 1354 : | {{31, 9}, {0, 1, 6}}, | ||
| 1355 : | {{30, 9}, {0, 2, 3}}, | ||
| 1356 : | {{29, 9}, {0, 3, 3}}, | ||
| 1357 : | {{28, 9}, {0, 5, 2}}, | ||
| 1358 : | {{27, 9}, {0, 6, 2}}, | ||
| 1359 : | {{26, 9}, {0, 7, 2}}, | ||
| 1360 : | {{34, 11}, {0, 1, 8}}, | ||
| 1361 : | {{35, 11}, {0, 9, 2}}, | ||
| 1362 : | {{86, 12}, {0, 2, 5}}, | ||
| 1363 : | {{87, 12}, {0, 7, 3}}, | ||
| 1364 : | {{ 7, 4}, {1, 0, 1}}, | ||
| 1365 : | {{25, 9}, {0, 11, 1}}, | ||
| 1366 : | {{ 5, 11}, {1, 0, 6}}, | ||
| 1367 : | {{15, 6}, {1, 1, 1}}, | ||
| 1368 : | {{ 4, 11}, {1, 0, 7}}, | ||
| 1369 : | {{14, 6}, {1, 2, 1}}, | ||
| 1370 : | {{13, 6}, {0, 5, 1}}, | ||
| 1371 : | {{12, 6}, {1, 0, 2}}, | ||
| 1372 : | {{19, 7}, {1, 5, 1}}, | ||
| 1373 : | {{18, 7}, {0, 6, 1}}, | ||
| 1374 : | {{17, 7}, {1, 3, 1}}, | ||
| 1375 : | {{16, 7}, {1, 4, 1}}, | ||
| 1376 : | {{26, 8}, {1, 9, 1}}, | ||
| 1377 : | {{25, 8}, {0, 8, 1}}, | ||
| 1378 : | {{24, 8}, {0, 9, 1}}, | ||
| 1379 : | {{23, 8}, {0, 10, 1}}, | ||
| 1380 : | {{22, 8}, {1, 0, 3}}, | ||
| 1381 : | {{21, 8}, {1, 6, 1}}, | ||
| 1382 : | {{20, 8}, {1, 7, 1}}, | ||
| 1383 : | {{19, 8}, {1, 8, 1}}, | ||
| 1384 : | {{24, 9}, {0, 12, 1}}, | ||
| 1385 : | {{23, 9}, {1, 0, 4}}, | ||
| 1386 : | {{22, 9}, {1, 1, 2}}, | ||
| 1387 : | {{21, 9}, {1, 10, 1}}, | ||
| 1388 : | {{20, 9}, {1, 11, 1}}, | ||
| 1389 : | {{19, 9}, {1, 12, 1}}, | ||
| 1390 : | {{18, 9}, {1, 13, 1}}, | ||
| 1391 : | {{17, 9}, {1, 14, 1}}, | ||
| 1392 : | {{ 7, 10}, {0, 13, 1}}, | ||
| 1393 : | {{ 6, 10}, {1, 0, 5}}, | ||
| 1394 : | {{ 5, 10}, {1, 1, 3}}, | ||
| 1395 : | {{ 4, 10}, {1, 2, 2}}, | ||
| 1396 : | {{36, 11}, {1, 3, 2}}, | ||
| 1397 : | {{37, 11}, {1, 4, 2}}, | ||
| 1398 : | {{38, 11}, {1, 15, 1}}, | ||
| 1399 : | {{39, 11}, {1, 16, 1}}, | ||
| 1400 : | {{88, 12}, {0, 14, 1}}, | ||
| 1401 : | {{89, 12}, {1, 0, 8}}, | ||
| 1402 : | {{90, 12}, {1, 5, 2}}, | ||
| 1403 : | {{91, 12}, {1, 6, 2}}, | ||
| 1404 : | {{92, 12}, {1, 17, 1}}, | ||
| 1405 : | {{93, 12}, {1, 18, 1}}, | ||
| 1406 : | {{94, 12}, {1, 19, 1}}, | ||
| 1407 : | {{95, 12}, {1, 20, 1}} | ||
| 1408 : | } | ||
| 1409 : | }; | ||
| 1410 : | |||
| 1411 : | /* constants taken from momusys/vm_common/inlcude/max_level.h */ | ||
| 1412 : | uint8_t const max_level[2][2][64] = { | ||
| 1413 : | { | ||
| 1414 : | /* intra = 0, last = 0 */ | ||
| 1415 : | { | ||
| 1416 : | 12, 6, 4, 3, 3, 3, 3, 2, | ||
| 1417 : | 2, 2, 2, 1, 1, 1, 1, 1, | ||
| 1418 : | 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 1419 : | 1, 1, 1, 0, 0, 0, 0, 0, | ||
| 1420 : | 0, 0, 0, 0, 0, 0, 0, 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 : | }, | ||
| 1425 : | /* intra = 0, last = 1 */ | ||
| 1426 : | { | ||
| 1427 : | 3, 2, 1, 1, 1, 1, 1, 1, | ||
| 1428 : | 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 1429 : | 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 1430 : | 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 1431 : | 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 1432 : | 1, 0, 0, 0, 0, 0, 0, 0, | ||
| 1433 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1434 : | 0, 0, 0, 0, 0, 0, 0, 0 | ||
| 1435 : | } | ||
| 1436 : | }, | ||
| 1437 : | { | ||
| 1438 : | /* intra = 1, last = 0 */ | ||
| 1439 : | { | ||
| 1440 : | 27, 10, 5, 4, 3, 3, 3, 3, | ||
| 1441 : | 2, 2, 1, 1, 1, 1, 1, 0, | ||
| 1442 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1443 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1444 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1445 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1446 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1447 : | 0, 0, 0, 0, 0, 0, 0, 0 | ||
| 1448 : | }, | ||
| 1449 : | /* intra = 1, last = 1 */ | ||
| 1450 : | { | ||
| 1451 : | 8, 3, 2, 2, 2, 2, 2, 1, | ||
| 1452 : | 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 1453 : | 1, 1, 1, 1, 1, 0, 0, 0, | ||
| 1454 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1455 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1456 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1457 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1458 : | 0, 0, 0, 0, 0, 0, 0, 0 | ||
| 1459 : | } | ||
| 1460 : | } | ||
| 1461 : | }; | ||
| 1462 : | |||
| 1463 : | uint8_t const max_run[2][2][64] = { | ||
| 1464 : | { | ||
| 1465 : | /* intra = 0, last = 0 */ | ||
| 1466 : | { | ||
| 1467 : | 0, 26, 10, 6, 2, 1, 1, 0, | ||
| 1468 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1469 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1470 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1471 : | 0, 0, 0, 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 : | }, | ||
| 1476 : | /* intra = 0, last = 1 */ | ||
| 1477 : | edgomez | 1.46 | { |
| 1478 : | edgomez | 1.43 | 0, 40, 1, 0, 0, 0, 0, 0, |
| 1479 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1480 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1481 : | 0, 0, 0, 0, 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 : | } | ||
| 1487 : | }, | ||
| 1488 : | { | ||
| 1489 : | /* intra = 1, last = 0 */ | ||
| 1490 : | { | ||
| 1491 : | 0, 14, 9, 7, 3, 2, 1, 1, | ||
| 1492 : | 1, 1, 1, 0, 0, 0, 0, 0, | ||
| 1493 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1494 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1495 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1496 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1497 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1498 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1499 : | }, | ||
| 1500 : | /* intra = 1, last = 1 */ | ||
| 1501 : | { | ||
| 1502 : | 0, 20, 6, 1, 0, 0, 0, 0, | ||
| 1503 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1504 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1505 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1506 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1507 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1508 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1509 : | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1510 : | } | ||
| 1511 : | } | ||
| 1512 : | }; | ||
| 1513 : | |||
| 1514 : | /****************************************************************** | ||
| 1515 : | * encoder tables * | ||
| 1516 : | ******************************************************************/ | ||
| 1517 : | |||
| 1518 : | VLC sprite_trajectory_code[32768]; | ||
| 1519 : | |||
| 1520 : | VLC sprite_trajectory_len[15] = { | ||
| 1521 : | edgomez | 1.46 | { 0x00 , 2}, |
| 1522 : | { 0x02 , 3}, { 0x03, 3}, { 0x04, 3}, { 0x05, 3}, { 0x06, 3}, | ||
| 1523 : | { 0x0E , 4}, { 0x1E, 5}, { 0x3E, 6}, { 0x7E, 7}, { 0xFE, 8}, | ||
| 1524 : | edgomez | 1.43 | { 0x1FE, 9}, {0x3FE,10}, {0x7FE,11}, {0xFFE,12} }; |
| 1525 : | |||
| 1526 : | |||
| 1527 : | /* DCT coefficients. Four tables, two for last = 0, two for last = 1. | ||
| 1528 : | the sign bit must be added afterwards. */ | ||
| 1529 : | |||
| 1530 : | /* MCBPC Indexing by cbpc in first two bits, mode in last two. | ||
| 1531 : | CBPC as in table 4/H.263, MB type (mode): 3 = 01, 4 = 10. | ||
| 1532 : | Example: cbpc = 01 and mode = 4 gives index = 0110 = 6. */ | ||
| 1533 : | |||
| 1534 : | VLC mcbpc_intra_tab[15] = { | ||
| 1535 : | {0x01, 9}, {0x01, 1}, {0x01, 4}, {0x00, 0}, | ||
| 1536 : | {0x00, 0}, {0x01, 3}, {0x01, 6}, {0x00, 0}, | ||
| 1537 : | {0x00, 0}, {0x02, 3}, {0x02, 6}, {0x00, 0}, | ||
| 1538 : | {0x00, 0}, {0x03, 3}, {0x03, 6} | ||
| 1539 : | }; | ||
| 1540 : | |||
| 1541 : | /* MCBPC inter. | ||
| 1542 : | Addressing: 5 bit ccmmm (cc = CBPC, mmm = mode (1-4 binary)) */ | ||
| 1543 : | |||
| 1544 : | VLC mcbpc_inter_tab[29] = { | ||
| 1545 : | {1, 1}, {3, 3}, {2, 3}, {3, 5}, {4, 6}, {1, 9}, {0, 0}, {0, 0}, | ||
| 1546 : | {3, 4}, {7, 7}, {5, 7}, {4, 8}, {4, 9}, {0, 0}, {0, 0}, {0, 0}, | ||
| 1547 : | {2, 4}, {6, 7}, {4, 7}, {3, 8}, {3, 9}, {0, 0}, {0, 0}, {0, 0}, | ||
| 1548 : | {5, 6}, {5, 9}, {5, 8}, {3, 7}, {2, 9} | ||
| 1549 : | }; | ||
| 1550 : | |||
| 1551 : | chl | 1.45 | const VLC xvid_cbpy_tab[16] = { |
| 1552 : | edgomez | 1.43 | {3, 4}, {5, 5}, {4, 5}, {9, 4}, {3, 5}, {7, 4}, {2, 6}, {11, 4}, |
| 1553 : | {2, 5}, {3, 6}, {5, 4}, {10, 4}, {4, 4}, {8, 4}, {6, 4}, {3, 2} | ||
| 1554 : | }; | ||
| 1555 : | |||
| 1556 : | const VLC dcy_tab[511] = { | ||
| 1557 : | {0x100, 15}, {0x101, 15}, {0x102, 15}, {0x103, 15}, | ||
| 1558 : | {0x104, 15}, {0x105, 15}, {0x106, 15}, {0x107, 15}, | ||
| 1559 : | {0x108, 15}, {0x109, 15}, {0x10a, 15}, {0x10b, 15}, | ||
| 1560 : | {0x10c, 15}, {0x10d, 15}, {0x10e, 15}, {0x10f, 15}, | ||
| 1561 : | {0x110, 15}, {0x111, 15}, {0x112, 15}, {0x113, 15}, | ||
| 1562 : | {0x114, 15}, {0x115, 15}, {0x116, 15}, {0x117, 15}, | ||
| 1563 : | {0x118, 15}, {0x119, 15}, {0x11a, 15}, {0x11b, 15}, | ||
| 1564 : | {0x11c, 15}, {0x11d, 15}, {0x11e, 15}, {0x11f, 15}, | ||
| 1565 : | {0x120, 15}, {0x121, 15}, {0x122, 15}, {0x123, 15}, | ||
| 1566 : | {0x124, 15}, {0x125, 15}, {0x126, 15}, {0x127, 15}, | ||
| 1567 : | {0x128, 15}, {0x129, 15}, {0x12a, 15}, {0x12b, 15}, | ||
| 1568 : | {0x12c, 15}, {0x12d, 15}, {0x12e, 15}, {0x12f, 15}, | ||
| 1569 : | {0x130, 15}, {0x131, 15}, {0x132, 15}, {0x133, 15}, | ||
| 1570 : | {0x134, 15}, {0x135, 15}, {0x136, 15}, {0x137, 15}, | ||
| 1571 : | {0x138, 15}, {0x139, 15}, {0x13a, 15}, {0x13b, 15}, | ||
| 1572 : | {0x13c, 15}, {0x13d, 15}, {0x13e, 15}, {0x13f, 15}, | ||
| 1573 : | {0x140, 15}, {0x141, 15}, {0x142, 15}, {0x143, 15}, | ||
| 1574 : | {0x144, 15}, {0x145, 15}, {0x146, 15}, {0x147, 15}, | ||
| 1575 : | {0x148, 15}, {0x149, 15}, {0x14a, 15}, {0x14b, 15}, | ||
| 1576 : | {0x14c, 15}, {0x14d, 15}, {0x14e, 15}, {0x14f, 15}, | ||
| 1577 : | {0x150, 15}, {0x151, 15}, {0x152, 15}, {0x153, 15}, | ||
| 1578 : | {0x154, 15}, {0x155, 15}, {0x156, 15}, {0x157, 15}, | ||
| 1579 : | {0x158, 15}, {0x159, 15}, {0x15a, 15}, {0x15b, 15}, | ||
| 1580 : | {0x15c, 15}, {0x15d, 15}, {0x15e, 15}, {0x15f, 15}, | ||
| 1581 : | {0x160, 15}, {0x161, 15}, {0x162, 15}, {0x163, 15}, | ||
| 1582 : | {0x164, 15}, {0x165, 15}, {0x166, 15}, {0x167, 15}, | ||
| 1583 : | {0x168, 15}, {0x169, 15}, {0x16a, 15}, {0x16b, 15}, | ||
| 1584 : | {0x16c, 15}, {0x16d, 15}, {0x16e, 15}, {0x16f, 15}, | ||
| 1585 : | {0x170, 15}, {0x171, 15}, {0x172, 15}, {0x173, 15}, | ||
| 1586 : | {0x174, 15}, {0x175, 15}, {0x176, 15}, {0x177, 15}, | ||
| 1587 : | {0x178, 15}, {0x179, 15}, {0x17a, 15}, {0x17b, 15}, | ||
| 1588 : | {0x17c, 15}, {0x17d, 15}, {0x17e, 15}, {0x17f, 15}, | ||
| 1589 : | {0x80, 13}, {0x81, 13}, {0x82, 13}, {0x83, 13}, | ||
| 1590 : | {0x84, 13}, {0x85, 13}, {0x86, 13}, {0x87, 13}, | ||
| 1591 : | {0x88, 13}, {0x89, 13}, {0x8a, 13}, {0x8b, 13}, | ||
| 1592 : | {0x8c, 13}, {0x8d, 13}, {0x8e, 13}, {0x8f, 13}, | ||
| 1593 : | {0x90, 13}, {0x91, 13}, {0x92, 13}, {0x93, 13}, | ||
| 1594 : | {0x94, 13}, {0x95, 13}, {0x96, 13}, {0x97, 13}, | ||
| 1595 : | {0x98, 13}, {0x99, 13}, {0x9a, 13}, {0x9b, 13}, | ||
| 1596 : | {0x9c, 13}, {0x9d, 13}, {0x9e, 13}, {0x9f, 13}, | ||
| 1597 : | {0xa0, 13}, {0xa1, 13}, {0xa2, 13}, {0xa3, 13}, | ||
| 1598 : | {0xa4, 13}, {0xa5, 13}, {0xa6, 13}, {0xa7, 13}, | ||
| 1599 : | {0xa8, 13}, {0xa9, 13}, {0xaa, 13}, {0xab, 13}, | ||
| 1600 : | {0xac, 13}, {0xad, 13}, {0xae, 13}, {0xaf, 13}, | ||
| 1601 : | {0xb0, 13}, {0xb1, 13}, {0xb2, 13}, {0xb3, 13}, | ||
| 1602 : | {0xb4, 13}, {0xb5, 13}, {0xb6, 13}, {0xb7, 13}, | ||
| 1603 : | {0xb8, 13}, {0xb9, 13}, {0xba, 13}, {0xbb, 13}, | ||
| 1604 : | {0xbc, 13}, {0xbd, 13}, {0xbe, 13}, {0xbf, 13}, | ||
| 1605 : | {0x40, 11}, {0x41, 11}, {0x42, 11}, {0x43, 11}, | ||
| 1606 : | {0x44, 11}, {0x45, 11}, {0x46, 11}, {0x47, 11}, | ||
| 1607 : | {0x48, 11}, {0x49, 11}, {0x4a, 11}, {0x4b, 11}, | ||
| 1608 : | {0x4c, 11}, {0x4d, 11}, {0x4e, 11}, {0x4f, 11}, | ||
| 1609 : | {0x50, 11}, {0x51, 11}, {0x52, 11}, {0x53, 11}, | ||
| 1610 : | {0x54, 11}, {0x55, 11}, {0x56, 11}, {0x57, 11}, | ||
| 1611 : | {0x58, 11}, {0x59, 11}, {0x5a, 11}, {0x5b, 11}, | ||
| 1612 : | {0x5c, 11}, {0x5d, 11}, {0x5e, 11}, {0x5f, 11}, | ||
| 1613 : | {0x20, 9}, {0x21, 9}, {0x22, 9}, {0x23, 9}, | ||
| 1614 : | {0x24, 9}, {0x25, 9}, {0x26, 9}, {0x27, 9}, | ||
| 1615 : | {0x28, 9}, {0x29, 9}, {0x2a, 9}, {0x2b, 9}, | ||
| 1616 : | {0x2c, 9}, {0x2d, 9}, {0x2e, 9}, {0x2f, 9}, | ||
| 1617 : | {0x10, 7}, {0x11, 7}, {0x12, 7}, {0x13, 7}, | ||
| 1618 : | {0x14, 7}, {0x15, 7}, {0x16, 7}, {0x17, 7}, | ||
| 1619 : | {0x10, 6}, {0x11, 6}, {0x12, 6}, {0x13, 6}, | ||
| 1620 : | {0x08, 4}, {0x09, 4}, {0x06, 3}, {0x03, 3}, | ||
| 1621 : | {0x07, 3}, {0x0a, 4}, {0x0b, 4}, {0x14, 6}, | ||
| 1622 : | {0x15, 6}, {0x16, 6}, {0x17, 6}, {0x18, 7}, | ||
| 1623 : | {0x19, 7}, {0x1a, 7}, {0x1b, 7}, {0x1c, 7}, | ||
| 1624 : | {0x1d, 7}, {0x1e, 7}, {0x1f, 7}, {0x30, 9}, | ||
| 1625 : | {0x31, 9}, {0x32, 9}, {0x33, 9}, {0x34, 9}, | ||
| 1626 : | {0x35, 9}, {0x36, 9}, {0x37, 9}, {0x38, 9}, | ||
| 1627 : | {0x39, 9}, {0x3a, 9}, {0x3b, 9}, {0x3c, 9}, | ||
| 1628 : | {0x3d, 9}, {0x3e, 9}, {0x3f, 9}, {0x60, 11}, | ||
| 1629 : | {0x61, 11}, {0x62, 11}, {0x63, 11}, {0x64, 11}, | ||
| 1630 : | {0x65, 11}, {0x66, 11}, {0x67, 11}, {0x68, 11}, | ||
| 1631 : | {0x69, 11}, {0x6a, 11}, {0x6b, 11}, {0x6c, 11}, | ||
| 1632 : | {0x6d, 11}, {0x6e, 11}, {0x6f, 11}, {0x70, 11}, | ||
| 1633 : | {0x71, 11}, {0x72, 11}, {0x73, 11}, {0x74, 11}, | ||
| 1634 : | {0x75, 11}, {0x76, 11}, {0x77, 11}, {0x78, 11}, | ||
| 1635 : | {0x79, 11}, {0x7a, 11}, {0x7b, 11}, {0x7c, 11}, | ||
| 1636 : | {0x7d, 11}, {0x7e, 11}, {0x7f, 11}, {0xc0, 13}, | ||
| 1637 : | {0xc1, 13}, {0xc2, 13}, {0xc3, 13}, {0xc4, 13}, | ||
| 1638 : | {0xc5, 13}, {0xc6, 13}, {0xc7, 13}, {0xc8, 13}, | ||
| 1639 : | {0xc9, 13}, {0xca, 13}, {0xcb, 13}, {0xcc, 13}, | ||
| 1640 : | {0xcd, 13}, {0xce, 13}, {0xcf, 13}, {0xd0, 13}, | ||
| 1641 : | {0xd1, 13}, {0xd2, 13}, {0xd3, 13}, {0xd4, 13}, | ||
| 1642 : | {0xd5, 13}, {0xd6, 13}, {0xd7, 13}, {0xd8, 13}, | ||
| 1643 : | {0xd9, 13}, {0xda, 13}, {0xdb, 13}, {0xdc, 13}, | ||
| 1644 : | {0xdd, 13}, {0xde, 13}, {0xdf, 13}, {0xe0, 13}, | ||
| 1645 : | {0xe1, 13}, {0xe2, 13}, {0xe3, 13}, {0xe4, 13}, | ||
| 1646 : | {0xe5, 13}, {0xe6, 13}, {0xe7, 13}, {0xe8, 13}, | ||
| 1647 : | {0xe9, 13}, {0xea, 13}, {0xeb, 13}, {0xec, 13}, | ||
| 1648 : | {0xed, 13}, {0xee, 13}, {0xef, 13}, {0xf0, 13}, | ||
| 1649 : | {0xf1, 13}, {0xf2, 13}, {0xf3, 13}, {0xf4, 13}, | ||
| 1650 : | {0xf5, 13}, {0xf6, 13}, {0xf7, 13}, {0xf8, 13}, | ||
| 1651 : | {0xf9, 13}, {0xfa, 13}, {0xfb, 13}, {0xfc, 13}, | ||
| 1652 : | {0xfd, 13}, {0xfe, 13}, {0xff, 13}, {0x180, 15}, | ||
| 1653 : | {0x181, 15}, {0x182, 15}, {0x183, 15}, {0x184, 15}, | ||
| 1654 : | {0x185, 15}, {0x186, 15}, {0x187, 15}, {0x188, 15}, | ||
| 1655 : | {0x189, 15}, {0x18a, 15}, {0x18b, 15}, {0x18c, 15}, | ||
| 1656 : | {0x18d, 15}, {0x18e, 15}, {0x18f, 15}, {0x190, 15}, | ||
| 1657 : | {0x191, 15}, {0x192, 15}, {0x193, 15}, {0x194, 15}, | ||
| 1658 : | {0x195, 15}, {0x196, 15}, {0x197, 15}, {0x198, 15}, | ||
| 1659 : | {0x199, 15}, {0x19a, 15}, {0x19b, 15}, {0x19c, 15}, | ||
| 1660 : | {0x19d, 15}, {0x19e, 15}, {0x19f, 15}, {0x1a0, 15}, | ||
| 1661 : | {0x1a1, 15}, {0x1a2, 15}, {0x1a3, 15}, {0x1a4, 15}, | ||
| 1662 : | {0x1a5, 15}, {0x1a6, 15}, {0x1a7, 15}, {0x1a8, 15}, | ||
| 1663 : | {0x1a9, 15}, {0x1aa, 15}, {0x1ab, 15}, {0x1ac, 15}, | ||
| 1664 : | {0x1ad, 15}, {0x1ae, 15}, {0x1af, 15}, {0x1b0, 15}, | ||
| 1665 : | {0x1b1, 15}, {0x1b2, 15}, {0x1b3, 15}, {0x1b4, 15}, | ||
| 1666 : | {0x1b5, 15}, {0x1b6, 15}, {0x1b7, 15}, {0x1b8, 15}, | ||
| 1667 : | {0x1b9, 15}, {0x1ba, 15}, {0x1bb, 15}, {0x1bc, 15}, | ||
| 1668 : | {0x1bd, 15}, {0x1be, 15}, {0x1bf, 15}, {0x1c0, 15}, | ||
| 1669 : | {0x1c1, 15}, {0x1c2, 15}, {0x1c3, 15}, {0x1c4, 15}, | ||
| 1670 : | {0x1c5, 15}, {0x1c6, 15}, {0x1c7, 15}, {0x1c8, 15}, | ||
| 1671 : | {0x1c9, 15}, {0x1ca, 15}, {0x1cb, 15}, {0x1cc, 15}, | ||
| 1672 : | {0x1cd, 15}, {0x1ce, 15}, {0x1cf, 15}, {0x1d0, 15}, | ||
| 1673 : | {0x1d1, 15}, {0x1d2, 15}, {0x1d3, 15}, {0x1d4, 15}, | ||
| 1674 : | {0x1d5, 15}, {0x1d6, 15}, {0x1d7, 15}, {0x1d8, 15}, | ||
| 1675 : | {0x1d9, 15}, {0x1da, 15}, {0x1db, 15}, {0x1dc, 15}, | ||
| 1676 : | {0x1dd, 15}, {0x1de, 15}, {0x1df, 15}, {0x1e0, 15}, | ||
| 1677 : | {0x1e1, 15}, {0x1e2, 15}, {0x1e3, 15}, {0x1e4, 15}, | ||
| 1678 : | {0x1e5, 15}, {0x1e6, 15}, {0x1e7, 15}, {0x1e8, 15}, | ||
| 1679 : | {0x1e9, 15}, {0x1ea, 15}, {0x1eb, 15}, {0x1ec, 15}, | ||
| 1680 : | {0x1ed, 15}, {0x1ee, 15}, {0x1ef, 15}, {0x1f0, 15}, | ||
| 1681 : | {0x1f1, 15}, {0x1f2, 15}, {0x1f3, 15}, {0x1f4, 15}, | ||
| 1682 : | {0x1f5, 15}, {0x1f6, 15}, {0x1f7, 15}, {0x1f8, 15}, | ||
| 1683 : | {0x1f9, 15}, {0x1fa, 15}, {0x1fb, 15}, {0x1fc, 15}, | ||
| 1684 : | {0x1fd, 15}, {0x1fe, 15}, {0x1ff, 15}, | ||
| 1685 : | }; | ||
| 1686 : | |||
| 1687 : | const VLC dcc_tab[511] = { | ||
| 1688 : | {0x100, 16}, {0x101, 16}, {0x102, 16}, {0x103, 16}, | ||
| 1689 : | {0x104, 16}, {0x105, 16}, {0x106, 16}, {0x107, 16}, | ||
| 1690 : | {0x108, 16}, {0x109, 16}, {0x10a, 16}, {0x10b, 16}, | ||
| 1691 : | {0x10c, 16}, {0x10d, 16}, {0x10e, 16}, {0x10f, 16}, | ||
| 1692 : | {0x110, 16}, {0x111, 16}, {0x112, 16}, {0x113, 16}, | ||
| 1693 : | {0x114, 16}, {0x115, 16}, {0x116, 16}, {0x117, 16}, | ||
| 1694 : | {0x118, 16}, {0x119, 16}, {0x11a, 16}, {0x11b, 16}, | ||
| 1695 : | {0x11c, 16}, {0x11d, 16}, {0x11e, 16}, {0x11f, 16}, | ||
| 1696 : | {0x120, 16}, {0x121, 16}, {0x122, 16}, {0x123, 16}, | ||
| 1697 : | {0x124, 16}, {0x125, 16}, {0x126, 16}, {0x127, 16}, | ||
| 1698 : | {0x128, 16}, {0x129, 16}, {0x12a, 16}, {0x12b, 16}, | ||
| 1699 : | {0x12c, 16}, {0x12d, 16}, {0x12e, 16}, {0x12f, 16}, | ||
| 1700 : | {0x130, 16}, {0x131, 16}, {0x132, 16}, {0x133, 16}, | ||
| 1701 : | {0x134, 16}, {0x135, 16}, {0x136, 16}, {0x137, 16}, | ||
| 1702 : | {0x138, 16}, {0x139, 16}, {0x13a, 16}, {0x13b, 16}, | ||
| 1703 : | {0x13c, 16}, {0x13d, 16}, {0x13e, 16}, {0x13f, 16}, | ||
| 1704 : | {0x140, 16}, {0x141, 16}, {0x142, 16}, {0x143, 16}, | ||
| 1705 : | {0x144, 16}, {0x145, 16}, {0x146, 16}, {0x147, 16}, | ||
| 1706 : | {0x148, 16}, {0x149, 16}, {0x14a, 16}, {0x14b, 16}, | ||
| 1707 : | {0x14c, 16}, {0x14d, 16}, {0x14e, 16}, {0x14f, 16}, | ||
| 1708 : | {0x150, 16}, {0x151, 16}, {0x152, 16}, {0x153, 16}, | ||
| 1709 : | {0x154, 16}, {0x155, 16}, {0x156, 16}, {0x157, 16}, | ||
| 1710 : | {0x158, 16}, {0x159, 16}, {0x15a, 16}, {0x15b, 16}, | ||
| 1711 : | {0x15c, 16}, {0x15d, 16}, {0x15e, 16}, {0x15f, 16}, | ||
| 1712 : | {0x160, 16}, {0x161, 16}, {0x162, 16}, {0x163, 16}, | ||
| 1713 : | {0x164, 16}, {0x165, 16}, {0x166, 16}, {0x167, 16}, | ||
| 1714 : | {0x168, 16}, {0x169, 16}, {0x16a, 16}, {0x16b, 16}, | ||
| 1715 : | {0x16c, 16}, {0x16d, 16}, {0x16e, 16}, {0x16f, 16}, | ||
| 1716 : | {0x170, 16}, {0x171, 16}, {0x172, 16}, {0x173, 16}, | ||
| 1717 : | {0x174, 16}, {0x175, 16}, {0x176, 16}, {0x177, 16}, | ||
| 1718 : | {0x178, 16}, {0x179, 16}, {0x17a, 16}, {0x17b, 16}, | ||
| 1719 : | {0x17c, 16}, {0x17d, 16}, {0x17e, 16}, {0x17f, 16}, | ||
| 1720 : | {0x80, 14}, {0x81, 14}, {0x82, 14}, {0x83, 14}, | ||
| 1721 : | {0x84, 14}, {0x85, 14}, {0x86, 14}, {0x87, 14}, | ||
| 1722 : | {0x88, 14}, {0x89, 14}, {0x8a, 14}, {0x8b, 14}, | ||
| 1723 : | {0x8c, 14}, {0x8d, 14}, {0x8e, 14}, {0x8f, 14}, | ||
| 1724 : | {0x90, 14}, {0x91, 14}, {0x92, 14}, {0x93, 14}, | ||
| 1725 : | {0x94, 14}, {0x95, 14}, {0x96, 14}, {0x97, 14}, | ||
| 1726 : | {0x98, 14}, {0x99, 14}, {0x9a, 14}, {0x9b, 14}, | ||
| 1727 : | {0x9c, 14}, {0x9d, 14}, {0x9e, 14}, {0x9f, 14}, | ||
| 1728 : | {0xa0, 14}, {0xa1, 14}, {0xa2, 14}, {0xa3, 14}, | ||
| 1729 : | {0xa4, 14}, {0xa5, 14}, {0xa6, 14}, {0xa7, 14}, | ||
| 1730 : | {0xa8, 14}, {0xa9, 14}, {0xaa, 14}, {0xab, 14}, | ||
| 1731 : | {0xac, 14}, {0xad, 14}, {0xae, 14}, {0xaf, 14}, | ||
| 1732 : | {0xb0, 14}, {0xb1, 14}, {0xb2, 14}, {0xb3, 14}, | ||
| 1733 : | {0xb4, 14}, {0xb5, 14}, {0xb6, 14}, {0xb7, 14}, | ||
| 1734 : | {0xb8, 14}, {0xb9, 14}, {0xba, 14}, {0xbb, 14}, | ||
| 1735 : | {0xbc, 14}, {0xbd, 14}, {0xbe, 14}, {0xbf, 14}, | ||
| 1736 : | {0x40, 12}, {0x41, 12}, {0x42, 12}, {0x43, 12}, | ||
| 1737 : | {0x44, 12}, {0x45, 12}, {0x46, 12}, {0x47, 12}, | ||
| 1738 : | {0x48, 12}, {0x49, 12}, {0x4a, 12}, {0x4b, 12}, | ||
| 1739 : | {0x4c, 12}, {0x4d, 12}, {0x4e, 12}, {0x4f, 12}, | ||
| 1740 : | {0x50, 12}, {0x51, 12}, {0x52, 12}, {0x53, 12}, | ||
| 1741 : | {0x54, 12}, {0x55, 12}, {0x56, 12}, {0x57, 12}, | ||
| 1742 : | {0x58, 12}, {0x59, 12}, {0x5a, 12}, {0x5b, 12}, | ||
| 1743 : | {0x5c, 12}, {0x5d, 12}, {0x5e, 12}, {0x5f, 12}, | ||
| 1744 : | {0x20, 10}, {0x21, 10}, {0x22, 10}, {0x23, 10}, | ||
| 1745 : | {0x24, 10}, {0x25, 10}, {0x26, 10}, {0x27, 10}, | ||
| 1746 : | {0x28, 10}, {0x29, 10}, {0x2a, 10}, {0x2b, 10}, | ||
| 1747 : | {0x2c, 10}, {0x2d, 10}, {0x2e, 10}, {0x2f, 10}, | ||
| 1748 : | {0x10, 8}, {0x11, 8}, {0x12, 8}, {0x13, 8}, | ||
| 1749 : | {0x14, 8}, {0x15, 8}, {0x16, 8}, {0x17, 8}, | ||
| 1750 : | {0x08, 6}, {0x09, 6}, {0x0a, 6}, {0x0b, 6}, | ||
| 1751 : | {0x04, 4}, {0x05, 4}, {0x04, 3}, {0x03, 2}, | ||
| 1752 : | {0x05, 3}, {0x06, 4}, {0x07, 4}, {0x0c, 6}, | ||
| 1753 : | {0x0d, 6}, {0x0e, 6}, {0x0f, 6}, {0x18, 8}, | ||
| 1754 : | {0x19, 8}, {0x1a, 8}, {0x1b, 8}, {0x1c, 8}, | ||
| 1755 : | {0x1d, 8}, {0x1e, 8}, {0x1f, 8}, {0x30, 10}, | ||
| 1756 : | {0x31, 10}, {0x32, 10}, {0x33, 10}, {0x34, 10}, | ||
| 1757 : | {0x35, 10}, {0x36, 10}, {0x37, 10}, {0x38, 10}, | ||
| 1758 : | {0x39, 10}, {0x3a, 10}, {0x3b, 10}, {0x3c, 10}, | ||
| 1759 : | {0x3d, 10}, {0x3e, 10}, {0x3f, 10}, {0x60, 12}, | ||
| 1760 : | {0x61, 12}, {0x62, 12}, {0x63, 12}, {0x64, 12}, | ||
| 1761 : | {0x65, 12}, {0x66, 12}, {0x67, 12}, {0x68, 12}, | ||
| 1762 : | {0x69, 12}, {0x6a, 12}, {0x6b, 12}, {0x6c, 12}, | ||
| 1763 : | {0x6d, 12}, {0x6e, 12}, {0x6f, 12}, {0x70, 12}, | ||
| 1764 : | {0x71, 12}, {0x72, 12}, {0x73, 12}, {0x74, 12}, | ||
| 1765 : | {0x75, 12}, {0x76, 12}, {0x77, 12}, {0x78, 12}, | ||
| 1766 : | {0x79, 12}, {0x7a, 12}, {0x7b, 12}, {0x7c, 12}, | ||
| 1767 : | {0x7d, 12}, {0x7e, 12}, {0x7f, 12}, {0xc0, 14}, | ||
| 1768 : | {0xc1, 14}, {0xc2, 14}, {0xc3, 14}, {0xc4, 14}, | ||
| 1769 : | {0xc5, 14}, {0xc6, 14}, {0xc7, 14}, {0xc8, 14}, | ||
| 1770 : | {0xc9, 14}, {0xca, 14}, {0xcb, 14}, {0xcc, 14}, | ||
| 1771 : | {0xcd, 14}, {0xce, 14}, {0xcf, 14}, {0xd0, 14}, | ||
| 1772 : | {0xd1, 14}, {0xd2, 14}, {0xd3, 14}, {0xd4, 14}, | ||
| 1773 : | {0xd5, 14}, {0xd6, 14}, {0xd7, 14}, {0xd8, 14}, | ||
| 1774 : | {0xd9, 14}, {0xda, 14}, {0xdb, 14}, {0xdc, 14}, | ||
| 1775 : | {0xdd, 14}, {0xde, 14}, {0xdf, 14}, {0xe0, 14}, | ||
| 1776 : | {0xe1, 14}, {0xe2, 14}, {0xe3, 14}, {0xe4, 14}, | ||
| 1777 : | {0xe5, 14}, {0xe6, 14}, {0xe7, 14}, {0xe8, 14}, | ||
| 1778 : | {0xe9, 14}, {0xea, 14}, {0xeb, 14}, {0xec, 14}, | ||
| 1779 : | {0xed, 14}, {0xee, 14}, {0xef, 14}, {0xf0, 14}, | ||
| 1780 : | {0xf1, 14}, {0xf2, 14}, {0xf3, 14}, {0xf4, 14}, | ||
| 1781 : | {0xf5, 14}, {0xf6, 14}, {0xf7, 14}, {0xf8, 14}, | ||
| 1782 : | {0xf9, 14}, {0xfa, 14}, {0xfb, 14}, {0xfc, 14}, | ||
| 1783 : | {0xfd, 14}, {0xfe, 14}, {0xff, 14}, {0x180, 16}, | ||
| 1784 : | {0x181, 16}, {0x182, 16}, {0x183, 16}, {0x184, 16}, | ||
| 1785 : | {0x185, 16}, {0x186, 16}, {0x187, 16}, {0x188, 16}, | ||
| 1786 : | {0x189, 16}, {0x18a, 16}, {0x18b, 16}, {0x18c, 16}, | ||
| 1787 : | {0x18d, 16}, {0x18e, 16}, {0x18f, 16}, {0x190, 16}, | ||
| 1788 : | {0x191, 16}, {0x192, 16}, {0x193, 16}, {0x194, 16}, | ||
| 1789 : | {0x195, 16}, {0x196, 16}, {0x197, 16}, {0x198, 16}, | ||
| 1790 : | {0x199, 16}, {0x19a, 16}, {0x19b, 16}, {0x19c, 16}, | ||
| 1791 : | {0x19d, 16}, {0x19e, 16}, {0x19f, 16}, {0x1a0, 16}, | ||
| 1792 : | {0x1a1, 16}, {0x1a2, 16}, {0x1a3, 16}, {0x1a4, 16}, | ||
| 1793 : | {0x1a5, 16}, {0x1a6, 16}, {0x1a7, 16}, {0x1a8, 16}, | ||
| 1794 : | {0x1a9, 16}, {0x1aa, 16}, {0x1ab, 16}, {0x1ac, 16}, | ||
| 1795 : | {0x1ad, 16}, {0x1ae, 16}, {0x1af, 16}, {0x1b0, 16}, | ||
| 1796 : | {0x1b1, 16}, {0x1b2, 16}, {0x1b3, 16}, {0x1b4, 16}, | ||
| 1797 : | {0x1b5, 16}, {0x1b6, 16}, {0x1b7, 16}, {0x1b8, 16}, | ||
| 1798 : | {0x1b9, 16}, {0x1ba, 16}, {0x1bb, 16}, {0x1bc, 16}, | ||
| 1799 : | {0x1bd, 16}, {0x1be, 16}, {0x1bf, 16}, {0x1c0, 16}, | ||
| 1800 : | {0x1c1, 16}, {0x1c2, 16}, {0x1c3, 16}, {0x1c4, 16}, | ||
| 1801 : | {0x1c5, 16}, {0x1c6, 16}, {0x1c7, 16}, {0x1c8, 16}, | ||
| 1802 : | {0x1c9, 16}, {0x1ca, 16}, {0x1cb, 16}, {0x1cc, 16}, | ||
| 1803 : | {0x1cd, 16}, {0x1ce, 16}, {0x1cf, 16}, {0x1d0, 16}, | ||
| 1804 : | {0x1d1, 16}, {0x1d2, 16}, {0x1d3, 16}, {0x1d4, 16}, | ||
| 1805 : | {0x1d5, 16}, {0x1d6, 16}, {0x1d7, 16}, {0x1d8, 16}, | ||
| 1806 : | {0x1d9, 16}, {0x1da, 16}, {0x1db, 16}, {0x1dc, 16}, | ||
| 1807 : | {0x1dd, 16}, {0x1de, 16}, {0x1df, 16}, {0x1e0, 16}, | ||
| 1808 : | {0x1e1, 16}, {0x1e2, 16}, {0x1e3, 16}, {0x1e4, 16}, | ||
| 1809 : | {0x1e5, 16}, {0x1e6, 16}, {0x1e7, 16}, {0x1e8, 16}, | ||
| 1810 : | {0x1e9, 16}, {0x1ea, 16}, {0x1eb, 16}, {0x1ec, 16}, | ||
| 1811 : | {0x1ed, 16}, {0x1ee, 16}, {0x1ef, 16}, {0x1f0, 16}, | ||
| 1812 : | {0x1f1, 16}, {0x1f2, 16}, {0x1f3, 16}, {0x1f4, 16}, | ||
| 1813 : | {0x1f5, 16}, {0x1f6, 16}, {0x1f7, 16}, {0x1f8, 16}, | ||
| 1814 : | {0x1f9, 16}, {0x1fa, 16}, {0x1fb, 16}, {0x1fc, 16}, | ||
| 1815 : | {0x1fd, 16}, {0x1fe, 16}, {0x1ff, 16}, | ||
| 1816 : | }; | ||
| 1817 : | |||
| 1818 : | |||
| 1819 : | const VLC mb_motion_table[65] = { | ||
| 1820 : | {0x05, 13}, {0x07, 13}, {0x05, 12}, {0x07, 12}, | ||
| 1821 : | {0x09, 12}, {0x0b, 12}, {0x0d, 12}, {0x0f, 12}, | ||
| 1822 : | {0x09, 11}, {0x0b, 11}, {0x0d, 11}, {0x0f, 11}, | ||
| 1823 : | {0x11, 11}, {0x13, 11}, {0x15, 11}, {0x17, 11}, | ||
| 1824 : | {0x19, 11}, {0x1b, 11}, {0x1d, 11}, {0x1f, 11}, | ||
| 1825 : | {0x21, 11}, {0x23, 11}, {0x13, 10}, {0x15, 10}, | ||
| 1826 : | {0x17, 10}, {0x07, 8}, {0x09, 8}, {0x0b, 8}, | ||
| 1827 : | {0x07, 7}, {0x03, 5}, {0x03, 4}, {0x03, 3}, | ||
| 1828 : | {0x01, 1}, {0x02, 3}, {0x02, 4}, {0x02, 5}, | ||
| 1829 : | {0x06, 7}, {0x0a, 8}, {0x08, 8}, {0x06, 8}, | ||
| 1830 : | {0x16, 10}, {0x14, 10}, {0x12, 10}, {0x22, 11}, | ||
| 1831 : | {0x20, 11}, {0x1e, 11}, {0x1c, 11}, {0x1a, 11}, | ||
| 1832 : | {0x18, 11}, {0x16, 11}, {0x14, 11}, {0x12, 11}, | ||
| 1833 : | {0x10, 11}, {0x0e, 11}, {0x0c, 11}, {0x0a, 11}, | ||
| 1834 : | {0x08, 11}, {0x0e, 12}, {0x0c, 12}, {0x0a, 12}, | ||
| 1835 : | {0x08, 12}, {0x06, 12}, {0x04, 12}, {0x06, 13}, | ||
| 1836 : | {0x04, 13} | ||
| 1837 : | }; | ||
| 1838 : | |||
| 1839 : | |||
| 1840 : | /****************************************************************** | ||
| 1841 : | * decoder tables * | ||
| 1842 : | ******************************************************************/ | ||
| 1843 : | |||
| 1844 : | VLC const mcbpc_intra_table[64] = { | ||
| 1845 : | {-1, 0}, {20, 6}, {36, 6}, {52, 6}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, | ||
| 1846 : | {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, | ||
| 1847 : | {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, | ||
| 1848 : | {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3}, | ||
| 1849 : | {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, | ||
| 1850 : | {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, | ||
| 1851 : | {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, | ||
| 1852 : | {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1}, {3, 1} | ||
| 1853 : | }; | ||
| 1854 : | |||
| 1855 : | VLC const mcbpc_inter_table[257] = { | ||
| 1856 : | {VLC_ERROR, 0}, {255, 9}, {52, 9}, {36, 9}, {20, 9}, {49, 9}, {35, 8}, {35, 8}, | ||
| 1857 : | {19, 8}, {19, 8}, {50, 8}, {50, 8}, {51, 7}, {51, 7}, {51, 7}, {51, 7}, | ||
| 1858 : | {34, 7}, {34, 7}, {34, 7}, {34, 7}, {18, 7}, {18, 7}, {18, 7}, {18, 7}, | ||
| 1859 : | {33, 7}, {33, 7}, {33, 7}, {33, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, | ||
| 1860 : | {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, | ||
| 1861 : | {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, | ||
| 1862 : | {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, | ||
| 1863 : | {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, | ||
| 1864 : | {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, | ||
| 1865 : | {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, | ||
| 1866 : | {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, | ||
| 1867 : | {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, | ||
| 1868 : | {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, | ||
| 1869 : | {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, | ||
| 1870 : | {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, | ||
| 1871 : | {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, | ||
| 1872 : | {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, | ||
| 1873 : | {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, | ||
| 1874 : | {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, | ||
| 1875 : | {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, | ||
| 1876 : | {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, | ||
| 1877 : | {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, | ||
| 1878 : | {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, | ||
| 1879 : | {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, | ||
| 1880 : | {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, | ||
| 1881 : | {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, | ||
| 1882 : | {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, | ||
| 1883 : | {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, | ||
| 1884 : | {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, | ||
| 1885 : | {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, | ||
| 1886 : | {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, | ||
| 1887 : | {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, | ||
| 1888 : | {0, 1} | ||
| 1889 : | }; | ||
| 1890 : | |||
| 1891 : | VLC const cbpy_table[64] = { | ||
| 1892 : | {-1, 0}, {-1, 0}, {6, 6}, {9, 6}, {8, 5}, {8, 5}, {4, 5}, {4, 5}, | ||
| 1893 : | {2, 5}, {2, 5}, {1, 5}, {1, 5}, {0, 4}, {0, 4}, {0, 4}, {0, 4}, | ||
| 1894 : | {12, 4}, {12, 4}, {12, 4}, {12, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, | ||
| 1895 : | {14, 4}, {14, 4}, {14, 4}, {14, 4}, {5, 4}, {5, 4}, {5, 4}, {5, 4}, | ||
| 1896 : | {13, 4}, {13, 4}, {13, 4}, {13, 4}, {3, 4}, {3, 4}, {3, 4}, {3, 4}, | ||
| 1897 : | {11, 4}, {11, 4}, {11, 4}, {11, 4}, {7, 4}, {7, 4}, {7, 4}, {7, 4}, | ||
| 1898 : | {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, | ||
| 1899 : | {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2} | ||
| 1900 : | }; | ||
| 1901 : | |||
| 1902 : | VLC const TMNMVtab0[] = { | ||
| 1903 : | {3, 4}, {-3, 4}, {2, 3}, {2, 3}, {-2, 3}, {-2, 3}, {1, 2}, | ||
| 1904 : | {1, 2}, {1, 2}, {1, 2}, {-1, 2}, {-1, 2}, {-1, 2}, {-1, 2} | ||
| 1905 : | }; | ||
| 1906 : | |||
| 1907 : | VLC const TMNMVtab1[] = { | ||
| 1908 : | {12, 10}, {-12, 10}, {11, 10}, {-11, 10}, | ||
| 1909 : | {10, 9}, {10, 9}, {-10, 9}, {-10, 9}, | ||
| 1910 : | {9, 9}, {9, 9}, {-9, 9}, {-9, 9}, | ||
| 1911 : | {8, 9}, {8, 9}, {-8, 9}, {-8, 9}, | ||
| 1912 : | {7, 7}, {7, 7}, {7, 7}, {7, 7}, | ||
| 1913 : | {7, 7}, {7, 7}, {7, 7}, {7, 7}, | ||
| 1914 : | {-7, 7}, {-7, 7}, {-7, 7}, {-7, 7}, | ||
| 1915 : | {-7, 7}, {-7, 7}, {-7, 7}, {-7, 7}, | ||
| 1916 : | {6, 7}, {6, 7}, {6, 7}, {6, 7}, | ||
| 1917 : | {6, 7}, {6, 7}, {6, 7}, {6, 7}, | ||
| 1918 : | {-6, 7}, {-6, 7}, {-6, 7}, {-6, 7}, | ||
| 1919 : | {-6, 7}, {-6, 7}, {-6, 7}, {-6, 7}, | ||
| 1920 : | {5, 7}, {5, 7}, {5, 7}, {5, 7}, | ||
| 1921 : | {5, 7}, {5, 7}, {5, 7}, {5, 7}, | ||
| 1922 : | {-5, 7}, {-5, 7}, {-5, 7}, {-5, 7}, | ||
| 1923 : | {-5, 7}, {-5, 7}, {-5, 7}, {-5, 7}, | ||
| 1924 : | {4, 6}, {4, 6}, {4, 6}, {4, 6}, | ||
| 1925 : | {4, 6}, {4, 6}, {4, 6}, {4, 6}, | ||
| 1926 : | {4, 6}, {4, 6}, {4, 6}, {4, 6}, | ||
| 1927 : | {4, 6}, {4, 6}, {4, 6}, {4, 6}, | ||
| 1928 : | {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, | ||
| 1929 : | {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, | ||
| 1930 : | {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}, | ||
| 1931 : | {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6} | ||
| 1932 : | }; | ||
| 1933 : | |||
| 1934 : | VLC const TMNMVtab2[] = { | ||
| 1935 : | {32, 12}, {-32, 12}, {31, 12}, {-31, 12}, | ||
| 1936 : | {30, 11}, {30, 11}, {-30, 11}, {-30, 11}, | ||
| 1937 : | {29, 11}, {29, 11}, {-29, 11}, {-29, 11}, | ||
| 1938 : | {28, 11}, {28, 11}, {-28, 11}, {-28, 11}, | ||
| 1939 : | {27, 11}, {27, 11}, {-27, 11}, {-27, 11}, | ||
| 1940 : | {26, 11}, {26, 11}, {-26, 11}, {-26, 11}, | ||
| 1941 : | {25, 11}, {25, 11}, {-25, 11}, {-25, 11}, | ||
| 1942 : | {24, 10}, {24, 10}, {24, 10}, {24, 10}, | ||
| 1943 : | {-24, 10}, {-24, 10}, {-24, 10}, {-24, 10}, | ||
| 1944 : | {23, 10}, {23, 10}, {23, 10}, {23, 10}, | ||
| 1945 : | {-23, 10}, {-23, 10}, {-23, 10}, {-23, 10}, | ||
| 1946 : | {22, 10}, {22, 10}, {22, 10}, {22, 10}, | ||
| 1947 : | {-22, 10}, {-22, 10}, {-22, 10}, {-22, 10}, | ||
| 1948 : | {21, 10}, {21, 10}, {21, 10}, {21, 10}, | ||
| 1949 : | {-21, 10}, {-21, 10}, {-21, 10}, {-21, 10}, | ||
| 1950 : | {20, 10}, {20, 10}, {20, 10}, {20, 10}, | ||
| 1951 : | {-20, 10}, {-20, 10}, {-20, 10}, {-20, 10}, | ||
| 1952 : | {19, 10}, {19, 10}, {19, 10}, {19, 10}, | ||
| 1953 : | {-19, 10}, {-19, 10}, {-19, 10}, {-19, 10}, | ||
| 1954 : | {18, 10}, {18, 10}, {18, 10}, {18, 10}, | ||
| 1955 : | {-18, 10}, {-18, 10}, {-18, 10}, {-18, 10}, | ||
| 1956 : | {17, 10}, {17, 10}, {17, 10}, {17, 10}, | ||
| 1957 : | {-17, 10}, {-17, 10}, {-17, 10}, {-17, 10}, | ||
| 1958 : | {16, 10}, {16, 10}, {16, 10}, {16, 10}, | ||
| 1959 : | {-16, 10}, {-16, 10}, {-16, 10}, {-16, 10}, | ||
| 1960 : | {15, 10}, {15, 10}, {15, 10}, {15, 10}, | ||
| 1961 : | {-15, 10}, {-15, 10}, {-15, 10}, {-15, 10}, | ||
| 1962 : | {14, 10}, {14, 10}, {14, 10}, {14, 10}, | ||
| 1963 : | {-14, 10}, {-14, 10}, {-14, 10}, {-14, 10}, | ||
| 1964 : | {13, 10}, {13, 10}, {13, 10}, {13, 10}, | ||
| 1965 : | {-13, 10}, {-13, 10}, {-13, 10}, {-13, 10} | ||
| 1966 : | }; | ||
| 1967 : | |||
| 1968 : | short const dc_threshold[] = { | ||
| 1969 : | edgomez | 1.51 | 26708, 29545, 29472, 26223, 30580, 29281, 8293, 29545, |
| 1970 : | 25632, 29285, 30313, 25701, 26144, 28530, 8301, 26740, | ||
| 1971 : | 8293, 20039, 8277, 20551, 8268, 30296, 17513, 25376, | ||
| 1972 : | 25711, 25445, 10272, 11825, 11825, 10544, 2606, 28505, | ||
| 1973 : | 29301, 29472, 26223, 30580, 29281, 8293, 26980, 29811, | ||
| 1974 : | 26994, 30050, 28532, 8306, 24936, 8307, 28532, 26400, | ||
| 1975 : | 30313, 8293, 25441, 25955, 29555, 29728, 8303, 29801, | ||
| 1976 : | 8307, 28531, 29301, 25955, 25376, 25711, 11877, 10 | ||
| 1977 : | edgomez | 1.43 | }; |
| 1978 : | |||
| 1979 : | VLC const dc_lum_tab[] = { | ||
| 1980 : | {0, 0}, {4, 3}, {3, 3}, {0, 3}, | ||
| 1981 : | {2, 2}, {2, 2}, {1, 2}, {1, 2}, | ||
| 1982 : | }; |
| No admin address has been configured | ViewVC Help |
| Powered by ViewVC 1.0.4 |