[cvs] / xvidcore / src / bitstream / mbcoding.c Repository:
ViewVC logotype

Diff of /xvidcore/src/bitstream/mbcoding.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.39, Sun Jan 26 01:44:07 2003 UTC revision 1.44.2.11, Mon Jun 9 01:17:20 2003 UTC
# Line 1  Line 1 
1  /*****************************************************************************   /******************************************************************************
2   *    *                                                                            *
3   *  XVID MPEG-4 VIDEO CODEC    *  This file is part of XviD, a free MPEG-4 video encoder/decoder            *
4   *  - Macro Block coding functions -    *                                                                            *
5   *    *  XviD is an implementation of a part of one or more MPEG-4 Video tools     *
6   *  Copyright(C) 2002 Michael Militzer <isibaar@xvid.org>    *  as specified in ISO/IEC 14496-2 standard.  Those intending to use this    *
7   *    *  software module in hardware or software products are advised that its     *
8   *  This file is part of XviD, a free MPEG-4 video encoder/decoder    *  use may infringe existing patents or copyrights, and any such use         *
9   *    *  would be at such party's own risk.  The original developer of this        *
10   *  XviD is free software; you can redistribute it and/or modify it    *  software module and his/her company, and subsequent editors and their     *
11   *  under the terms of the GNU General Public License as published by    *  companies, will have no liability for use of this software or             *
12   *  the Free Software Foundation; either version 2 of the License, or    *  modifications or derivatives thereof.                                     *
13   *  (at your option) any later version.    *                                                                            *
14   *    *  XviD is free software; you can redistribute it and/or modify it           *
15   *  This program is distributed in the hope that it will be useful,    *  under the terms of the GNU General Public License as published by         *
16   *  but WITHOUT ANY WARRANTY; without even the implied warranty of    *  the Free Software Foundation; either version 2 of the License, or         *
17   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *  (at your option) any later version.                                       *
18   *  GNU General Public License for more details.    *                                                                            *
19   *    *  XviD is distributed in the hope that it will be useful, but               *
20   *  You should have received a copy of the GNU General Public License    *  WITHOUT ANY WARRANTY; without even the implied warranty of                *
21   *  along with this program; if not, write to the Free Software    *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
22   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA    *  GNU General Public License for more details.                              *
23   *    *                                                                            *
24   *  Under section 8 of the GNU General Public License, the copyright    *  You should have received a copy of the GNU General Public License         *
25   *  holders of XVID explicitly forbid distribution in the following    *  along with this program; if not, write to the Free Software               *
26   *  countries:    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA  *
27   *    *                                                                            *
28   *    - Japan    ******************************************************************************/
29   *    - United States of America  
30   *   /******************************************************************************
31   *  Linking XviD statically or dynamically with other modules is making a    *                                                                            *
32   *  combined work based on XviD.  Thus, the terms and conditions of the    *  mbcoding.c                                                                *
33   *  GNU General Public License cover the whole combination.    *                                                                            *
34   *    *  Copyright (C) 2002 - Michael Militzer <isibaar@xvid.org>                  *
35   *  As a special exception, the copyright holders of XviD give you    *                                                                            *
36   *  permission to link XviD with independent modules that communicate with    *  For more information visit the XviD homepage: http://www.xvid.org         *
37   *  XviD solely through the VFW1.1 and DShow interfaces, regardless of the    *                                                                            *
38   *  license terms of these independent modules, and to copy and distribute    ******************************************************************************/
39   *  the resulting combined work under terms of your choice, provided that  
40   *  every copy of the combined work is accompanied by a complete copy of   /******************************************************************************
41   *  the source code of XviD (the version of XviD used to produce the    *                                                                                                                                                        *
42   *  combined work), being distributed under the terms of the GNU General    *  Revision history:                                                         *
43   *  Public License plus this exception.  An independent module is a module    *                                                                            *
44   *  which is not derived from or based on XviD.    *  28.10.2002 GMC support - gruel                                                                                        *
45   *    *  28.06.2002 added check_resync_marker()                                    *
46   *  Note that people who make modified versions of XviD are not obligated    *  14.04.2002 bframe encoding                                                                                            *
47   *  to grant this special exception for their modified versions; it is    *  08.03.2002 initial version; isibaar                                                           *
48   *  their choice whether to do so.  The GNU General Public License gives    *                                                                                                                                                        *
49   *  permission to release a modified version without this exception; this    ******************************************************************************/
  *  exception also makes it possible to release a modified version which  
  *  carries forward this exception.  
  *  
  * $Id$  
  *  
  ****************************************************************************/  
50    
51    
52    #include <stdio.h>
53  #include <stdlib.h>  #include <stdlib.h>
54    #include <string.h>
55    
56  #include "../portab.h"  #include "../portab.h"
57    #include "../global.h"
58  #include "bitstream.h"  #include "bitstream.h"
59  #include "zigzag.h"  #include "zigzag.h"
60  #include "vlc_codes.h"  #include "vlc_codes.h"
# Line 63  Line 62 
62    
63  #include "../utils/mbfunctions.h"  #include "../utils/mbfunctions.h"
64    
 #define ABS(X) (((X)>0)?(X):-(X))  
 #define CLIP(X,A) (X > A) ? (A) : (X)  
   
65  /* #define BIGLUT */  /* #define BIGLUT */
66    
67  #ifdef BIGLUT  #ifdef BIGLUT
# Line 74  Line 70 
70  #define LEVELOFFSET 32  #define LEVELOFFSET 32
71  #endif  #endif
72    
 /*****************************************************************************  
  * Local data  
  ****************************************************************************/  
   
73  static REVERSE_EVENT DCT3D[2][4096];  static REVERSE_EVENT DCT3D[2][4096];
74    
75  #ifdef BIGLUT  #ifdef BIGLUT
76  static VLC coeff_VLC[2][2][4096][64];  static VLC coeff_VLC[2][2][4096][64];
77  static VLC *intra_table, *inter_table;  VLC *intra_table;
78    static VLC *inter_table;
79  #else  #else
80  static VLC coeff_VLC[2][2][64][64];  static VLC coeff_VLC[2][2][64][64];
81  #endif  #endif
82    
83  /*****************************************************************************  /* not really MB related, but VLCs are only available here */
84   * Vector Length Coding Initialization  void bs_put_spritetrajectory(Bitstream * bs, const int val)
85   ****************************************************************************/  {
86            const int code = sprite_trajectory_code[val+16384].code;
87            const int len = sprite_trajectory_code[val+16384].len;
88            const int code2 = sprite_trajectory_len[len].code;
89            const int len2 = sprite_trajectory_len[len].len;
90    
91    #if 0
92            printf("GMC=%d Code/Len  = %d / %d ",val, code,len);
93            printf("Code2 / Len2 = %d / %d \n",code2,len2);
94    #endif
95    
96            BitstreamPutBits(bs, code2, len2);
97            if (len) BitstreamPutBits(bs, code, len);
98    }
99    
100    int bs_get_spritetrajectory(Bitstream * bs)
101    {
102            int i;
103            for (i = 0; i < 12; i++)
104            {
105                    if (BitstreamShowBits(bs, sprite_trajectory_len[i].len) == sprite_trajectory_len[i].code)
106                    {
107                            BitstreamSkip(bs, sprite_trajectory_len[i].len);
108                            return i;
109                    }
110            }
111            return -1;
112    }
113    
114  void  void
115  init_vlc_tables(void)  init_vlc_tables(void)
116  {  {
117          ptr_t i, j, intra, last, run,  run_esc, level, level_esc, escape, escape_len, offset;          uint32_t i, j, k, intra, last, run,  run_esc, level, level_esc, escape, escape_len, offset;
118            int32_t l;
119    
120  #ifdef BIGLUT  #ifdef BIGLUT
121          intra_table = (VLC*)coeff_VLC[1];          intra_table = coeff_VLC[1];
122          inter_table = (VLC*)coeff_VLC[0];          inter_table = coeff_VLC[0];
123  #endif  #endif
124    
125    
# Line 110  Line 131 
131                  for (last = 0; last < 2; last++)                  for (last = 0; last < 2; last++)
132                  {                  {
133                          for (run = 0; run < 63 + last; run++)                          for (run = 0; run < 63 + last; run++)
134                                  for (level = 0; level < 32 << intra; level++)                                  for (level = 0; level < (uint32_t)(32 << intra); level++)
135                                  {                                  {
136  #ifdef BIGLUT  #ifdef BIGLUT
137                                          offset = LEVELOFFSET;                                          offset = LEVELOFFSET;
# Line 129  Line 150 
150  #else  #else
151                          offset = !intra * LEVELOFFSET;                          offset = !intra * LEVELOFFSET;
152  #endif  #endif
153                          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++)
154                          {                          {
155                                  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;
156                                  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;
# Line 154  Line 175 
175                  for (last = 0; last < 2; last++)                  for (last = 0; last < 2; last++)
176                          for (run = 0; run < 63 + last; run++)                          for (run = 0; run < 63 + last; run++)
177                          {                          {
178                                  for (level = 1; level < 32 << intra; level++)                                  for (level = 1; level < (uint32_t)(32 << intra); level++)
179                                  {                                  {
180                                          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])
181                                              continue;                                              continue;
# Line 179  Line 200 
200                                          }                                          }
201                                          else                                          else
202                                          {                                          {
203                                                  if (level <= max_level[intra][last][run_esc] && run_esc <= max_run[intra][last][level])                                                  if (run_esc <= max_run[intra][last][level] && level <= max_level[intra][last][run_esc])
204                                                  {                                                  {
205                                                          escape     = ESCAPE2;                                                          escape     = ESCAPE2;
206                                                          escape_len = 7 + 2;                                                          escape_len = 7 + 2;
# Line 195  Line 216 
216                                                                          = (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((level & 0xfff) << 1) | 1;                                                                          = (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((level & 0xfff) << 1) | 1;
217                                                                  coeff_VLC[intra][last][level + offset][run].len = 30;                                                                  coeff_VLC[intra][last][level + offset][run].len = 30;
218                                                                          coeff_VLC[intra][last][offset - level][run].code                                                                          coeff_VLC[intra][last][offset - level][run].code
219                                                                          = (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;
220                                                                  coeff_VLC[intra][last][offset - level][run].len = 30;                                                                  coeff_VLC[intra][last][offset - level][run].len = 30;
221                                                          }                                                          }
222                                                          continue;                                                          continue;
# Line 239  Line 260 
260                                  }                                  }
261  #endif  #endif
262                          }                          }
263    /* init sprite_trajectory tables */
264    /* even if GMC is not specified (it might be used later...) */
265    
266            sprite_trajectory_code[0+16384].code = 0;
267            sprite_trajectory_code[0+16384].len = 0;
268            for (k=0;k<14;k++)
269            {
270                    int limit = (1<<k);
271    
272                    for (l=-(2*limit-1); l <= -limit; l++)
273                    {
274                            sprite_trajectory_code[l+16384].code = (2*limit-1)+l;
275                            sprite_trajectory_code[l+16384].len = k+1;
276  }  }
277    
278  /*****************************************************************************                  for (l=limit; l<= 2*limit-1; l++)
279   * Local inlined functions for MB coding                  {
280   ****************************************************************************/                          sprite_trajectory_code[l+16384].code = l;
281                            sprite_trajectory_code[l+16384].len = k+1;
282                    }
283            }
284    }
285    
286  static __inline void  static __inline void
287  CodeVector(Bitstream * bs,  CodeVector(Bitstream * bs,
# Line 340  Line 378 
378    
379  }  }
380    
381    
382    
383    /* returns the number of bits required to encode qcoeff */
384    int
385    CodeCoeff_CalcBits(const int16_t qcoeff[64],
386                      VLC * table,
387                      const uint16_t * zigzag,
388                      uint16_t intra)
389    {
390            int bits = 0;
391            uint32_t j, last;
392            short v;
393            VLC *vlc;
394    
395            j = intra;
396            last = intra;
397    
398            while (j < 64 && (v = qcoeff[zigzag[j]]) == 0)
399                    j++;
400    
401            if (j >= 64) return 0;  /* empty block */
402    
403            do {
404                    vlc = table + 64 * 2048 + (v << 6) + j - last;
405                    last = ++j;
406    
407                    /* count zeroes */
408                    while (j < 64 && (v = qcoeff[zigzag[j]]) == 0)
409                            j++;
410    
411                    /* write code */
412                    if (j != 64) {
413                            bits += vlc->len;
414                    } else {
415                            vlc += 64 * 4096;
416                            bits += vlc->len;
417                            break;
418                    }
419            } while (1);
420    
421            return bits;
422    }
423    
424    
425  #else  #else
426    
427  static __inline void  static __inline void
# Line 409  Line 491 
491          i       = 1;          i       = 1;
492          run = 0;          run = 0;
493    
494          while (!(level = qcoeff[zigzag[i++]]))          while (i<64 && !(level = qcoeff[zigzag[i++]]))
495                  run++;                  run++;
496    
497          prev_level = level;          prev_level = level;
# Line 420  Line 502 
502          {          {
503                  if ((level = qcoeff[zigzag[i++]]) != 0)                  if ((level = qcoeff[zigzag[i++]]) != 0)
504                  {                  {
505                          abs_level = ABS(prev_level);                          abs_level = abs(prev_level);
506                          abs_level = abs_level < 64 ? abs_level : 0;                          abs_level = abs_level < 64 ? abs_level : 0;
507                          code      = coeff_VLC[1][0][abs_level][prev_run].code;                          code      = coeff_VLC[1][0][abs_level][prev_run].code;
508                          len               = coeff_VLC[1][0][abs_level][prev_run].len;                          len               = coeff_VLC[1][0][abs_level][prev_run].len;
# Line 440  Line 522 
522                          run++;                          run++;
523          }          }
524    
525          abs_level = ABS(prev_level);          abs_level = abs(prev_level);
526          abs_level = abs_level < 64 ? abs_level : 0;          abs_level = abs_level < 64 ? abs_level : 0;
527          code      = coeff_VLC[1][1][abs_level][prev_run].code;          code      = coeff_VLC[1][1][abs_level][prev_run].code;
528          len               = coeff_VLC[1][1][abs_level][prev_run].len;          len               = coeff_VLC[1][1][abs_level][prev_run].len;
# Line 454  Line 536 
536          BitstreamPutBits(bs, code, len);          BitstreamPutBits(bs, code, len);
537  }  }
538    
539    
540    
541    /* returns the number of bits required to encode qcoeff */
542    
543    int
544    CodeCoeffIntra_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag)
545    {
546            int bits = 0;
547            uint32_t i, abs_level, run, prev_run, len;
548            int32_t level, prev_level;
549    
550            i       = 1;
551            run = 0;
552    
553            while (i<64 && !(level = qcoeff[zigzag[i++]]))
554                    run++;
555    
556            if (i >= 64) return 0;  /* empty block */
557    
558            prev_level = level;
559            prev_run   = run;
560            run = 0;
561    
562            while (i < 64)
563            {
564                    if ((level = qcoeff[zigzag[i++]]) != 0)
565                    {
566                            abs_level = abs(prev_level);
567                            abs_level = abs_level < 64 ? abs_level : 0;
568                            len               = coeff_VLC[1][0][abs_level][prev_run].len;
569                            bits      += len!=128 ? len : 30;
570    
571                            prev_level = level;
572                            prev_run   = run;
573                            run = 0;
574                    }
575                    else
576                            run++;
577            }
578    
579            abs_level = abs(prev_level);
580            abs_level = abs_level < 64 ? abs_level : 0;
581            len               = coeff_VLC[1][1][abs_level][prev_run].len;
582            bits      += len!=128 ? len : 30;
583    
584            return bits;
585    }
586    
587    int
588    CodeCoeffInter_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag)
589    {
590            uint32_t i, run, prev_run, len;
591            int32_t level, prev_level, level_shifted;
592            int bits = 0;
593    
594            i       = 0;
595            run = 0;
596    
597            while (!(level = qcoeff[zigzag[i++]]))
598                    run++;
599    
600            prev_level = level;
601            prev_run   = run;
602            run = 0;
603    
604            while (i < 64) {
605                    if ((level = qcoeff[zigzag[i++]]) != 0) {
606                            level_shifted = prev_level + 32;
607                            if (!(level_shifted & -64))
608                                    len      = coeff_VLC[0][0][level_shifted][prev_run].len;
609                            else
610                                    len  = 30;
611    
612                            bits += len;
613                            prev_level = level;
614                            prev_run   = run;
615                            run = 0;
616                    }
617                    else
618                            run++;
619            }
620    
621            level_shifted = prev_level + 32;
622            if (!(level_shifted & -64))
623                    len      = coeff_VLC[0][1][level_shifted][prev_run].len;
624            else
625                    len  = 30;
626            bits += len;
627    
628            return bits;
629    }
630    
631    
632  #endif  #endif
633    
 /*****************************************************************************  
  * Local functions  
  ****************************************************************************/  
634    
635  static void  static int iDQtab[5] = {
636  CodeBlockIntra(const FRAMEINFO * frame,          1, 0, -1 /* no change */, 2, 3
637    };
638    #define DQ_VALUE2INDEX(value)  iDQtab[(value)+2]
639    
640    
641    static __inline void
642    CodeBlockIntra(const FRAMEINFO * const frame,
643                             const MACROBLOCK * pMB,                             const MACROBLOCK * pMB,
644                             int16_t qcoeff[6 * 64],                             int16_t qcoeff[6 * 64],
645                             Bitstream * bs,                             Bitstream * bs,
# Line 490  Line 668 
668                  BitstreamPutBits(bs, 0, 1);                  BitstreamPutBits(bs, 0, 1);
669    
670          /* write cbpy */          /* write cbpy */
671          BitstreamPutBits(bs, cbpy_tab[cbpy].code, cbpy_tab[cbpy].len);          BitstreamPutBits(bs, xvid_cbpy_tab[cbpy].code, xvid_cbpy_tab[cbpy].len);
672    
673          /* write dquant */          /* write dquant */
674          if (pMB->mode == MODE_INTRA_Q)          if (pMB->mode == MODE_INTRA_Q)
675                  BitstreamPutBits(bs, pMB->dquant, 2);                  BitstreamPutBits(bs, DQ_VALUE2INDEX(pMB->dquant), 2);
676    
677          /* write interlacing */          /* write interlacing */
678          if (frame->global_flags & XVID_INTERLACING) {          if (frame->vol_flags & XVID_VOL_INTERLACING) {
679                  BitstreamPutBit(bs, pMB->field_dct);                  BitstreamPutBit(bs, pMB->field_dct);
680          }          }
681          /* code block coeffs */          /* code block coeffs */
# Line 510  Line 688 
688                                                           dcc_tab[qcoeff[i * 64 + 0] + 255].len);                                                           dcc_tab[qcoeff[i * 64 + 0] + 255].len);
689    
690                  if (pMB->cbp & (1 << (5 - i))) {                  if (pMB->cbp & (1 << (5 - i))) {
691                            const uint16_t *scan_table =
692                                    frame->vop_flags & XVID_VOP_ALTERNATESCAN ?
693                                    scan_tables[2] : scan_tables[pMB->acpred_directions[i]];
694    
695                          bits = BitstreamPos(bs);                          bits = BitstreamPos(bs);
696    
697  #ifdef BIGLUT  #ifdef BIGLUT
698                          CodeCoeff(bs, &qcoeff[i * 64], intra_table,                          CodeCoeff(bs, &qcoeff[i * 64], intra_table, scan_table, 1);
                                           scan_tables[pMB->acpred_directions[i]], 1);  
699  #else  #else
700                          CodeCoeffIntra(bs, &qcoeff[i * 64], scan_tables[pMB->acpred_directions[i]]);                          CodeCoeffIntra(bs, &qcoeff[i * 64], scan_table);
701  #endif  #endif
702    
703                          bits = BitstreamPos(bs) - bits;                          bits = BitstreamPos(bs) - bits;
704                          pStat->iTextBits += bits;                          pStat->iTextBits += bits;
705                  }                  }
# Line 527  Line 709 
709    
710    
711  static void  static void
712  CodeBlockInter(const FRAMEINFO * frame,  CodeBlockInter(const FRAMEINFO * const frame,
713                             const MACROBLOCK * pMB,                             const MACROBLOCK * pMB,
714                             int16_t qcoeff[6 * 64],                             int16_t qcoeff[6 * 64],
715                             Bitstream * bs,                             Bitstream * bs,
# Line 544  Line 726 
726          BitstreamPutBits(bs, mcbpc_inter_tab[mcbpc].code,          BitstreamPutBits(bs, mcbpc_inter_tab[mcbpc].code,
727                                           mcbpc_inter_tab[mcbpc].len);                                           mcbpc_inter_tab[mcbpc].len);
728    
729            if ( (frame->coding_type == S_VOP) && (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) )
730                    BitstreamPutBit(bs, pMB->mcsel);                /* mcsel: '0'=local motion, '1'=GMC */
731    
732          /* write cbpy */          /* write cbpy */
733          BitstreamPutBits(bs, cbpy_tab[cbpy].code, cbpy_tab[cbpy].len);          BitstreamPutBits(bs, xvid_cbpy_tab[cbpy].code, xvid_cbpy_tab[cbpy].len);
734    
735          /* write dquant */          /* write dquant */
736          if (pMB->mode == MODE_INTER_Q)          if (pMB->mode == MODE_INTER_Q)
737                  BitstreamPutBits(bs, pMB->dquant, 2);                  BitstreamPutBits(bs, DQ_VALUE2INDEX(pMB->dquant), 2);
738    
739          /* interlacing */          /* interlacing */
740          if (frame->global_flags & XVID_INTERLACING) {          if (frame->vol_flags & XVID_VOL_INTERLACING) {
741                  if (pMB->cbp) {                  if (pMB->cbp) {
742                          BitstreamPutBit(bs, pMB->field_dct);                          BitstreamPutBit(bs, pMB->field_dct);
743                          DPRINTF(DPRINTF_DEBUG, "codep: field_dct: %d", pMB->field_dct);                          DPRINTF(XVID_DEBUG_MB,"codep: field_dct: %i\n", pMB->field_dct);
744                  }                  }
745    
746                  /* if inter block, write field ME flag */                  /* if inter block, write field ME flag */
747                  if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) {                  if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) {
748                          BitstreamPutBit(bs, pMB->field_pred);                          BitstreamPutBit(bs, pMB->field_pred);
749                          DPRINTF(DPRINTF_DEBUG, "codep: field_pred: %d", pMB->field_pred);                          DPRINTF(XVID_DEBUG_MB,"codep: field_pred: %i\n", pMB->field_pred);
750    
751                          /* write field prediction references */                          /* write field prediction references */
752                          if (pMB->field_pred) {                          if (pMB->field_pred) {
# Line 570  Line 755 
755                          }                          }
756                  }                  }
757          }          }
758          /* code motion vector(s) */          /* code motion vector(s) if motion is local  */
759            if (!pMB->mcsel)
760          for (i = 0; i < (pMB->mode == MODE_INTER4V ? 4 : 1); i++) {          for (i = 0; i < (pMB->mode == MODE_INTER4V ? 4 : 1); i++) {
761                  CodeVector(bs, pMB->pmvs[i].x, frame->fcode, pStat);                  CodeVector(bs, pMB->pmvs[i].x, frame->fcode, pStat);
762                  CodeVector(bs, pMB->pmvs[i].y, frame->fcode, pStat);                  CodeVector(bs, pMB->pmvs[i].y, frame->fcode, pStat);
# Line 581  Line 767 
767          /* code block coeffs */          /* code block coeffs */
768          for (i = 0; i < 6; i++)          for (i = 0; i < 6; i++)
769                  if (pMB->cbp & (1 << (5 - i)))                  if (pMB->cbp & (1 << (5 - i)))
770                    {
771                            const uint16_t *scan_table =
772                                    frame->vop_flags & XVID_VOP_ALTERNATESCAN ?
773                                    scan_tables[2] : scan_tables[0];
774    
775  #ifdef BIGLUT  #ifdef BIGLUT
776                          CodeCoeff(bs, &qcoeff[i * 64], inter_table, scan_tables[0], 0);                          CodeCoeff(bs, &qcoeff[i * 64], inter_table, scan_table, 0);
777  #else  #else
778                          CodeCoeffInter(bs, &qcoeff[i * 64], scan_tables[0]);                          CodeCoeffInter(bs, &qcoeff[i * 64], scan_table);
779  #endif  #endif
780                    }
781    
782          bits = BitstreamPos(bs) - bits;          bits = BitstreamPos(bs) - bits;
783          pStat->iTextBits += bits;          pStat->iTextBits += bits;
   
784  }  }
785    
 /*****************************************************************************  
  * Macro Block bitstream encoding functions  
  ****************************************************************************/  
786    
787  void  void
788  MBCoding(const FRAMEINFO * frame,  MBCoding(const FRAMEINFO * const frame,
789                   MACROBLOCK * pMB,                   MACROBLOCK * pMB,
790                   int16_t qcoeff[6 * 64],                   int16_t qcoeff[6 * 64],
791                   Bitstream * bs,                   Bitstream * bs,
792                   Statistics * pStat)                   Statistics * pStat)
793  {  {
794            if (frame->coding_type != I_VOP)
795          if (frame->coding_type == P_VOP) {                          BitstreamPutBit(bs, 0); /* not_coded */
                         BitstreamPutBit(bs, 0); /* coded */  
         }  
796    
797          if (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q)          if (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q)
798                  CodeBlockIntra(frame, pMB, qcoeff, bs, pStat);                  CodeBlockIntra(frame, pMB, qcoeff, bs, pStat);
# Line 616  Line 802 
802  }  }
803    
804    
805    /* moved to mbcoding.h so that in can be 'static __inline' */
806    #if 0
807  void  void
808  MBSkip(Bitstream * bs)  MBSkip(Bitstream * bs)
809  {  {
810          BitstreamPutBit(bs, 1); /* not coded */          BitstreamPutBit(bs, 1); /* not coded */
811    }
812    #endif
813    
814    /***************************************************************
815     * bframe encoding start
816     ***************************************************************/
817    
818    /*
819            mbtype
820            0       1b              direct(h263)            mvdb
821            1       01b             interpolate mc+q        dbquant, mvdf, mvdb
822            2       001b    backward mc+q           dbquant, mvdb
823            3       0001b   forward mc+q            dbquant, mvdf
824    */
825    
826    static __inline void
827    put_bvop_mbtype(Bitstream * bs,
828                                    int value)
829    {
830            switch (value) {
831                    case MODE_FORWARD:
832                            BitstreamPutBit(bs, 0);
833                    case MODE_BACKWARD:
834                            BitstreamPutBit(bs, 0);
835                    case MODE_INTERPOLATE:
836                            BitstreamPutBit(bs, 0);
837                    case MODE_DIRECT:
838                            BitstreamPutBit(bs, 1);
839                    default:
840                            break;
841            }
842    }
843    
844    /*
845            dbquant
846            -2      10b
847            0       0b
848            +2      11b
849    */
850    
851    static __inline void
852    put_bvop_dbquant(Bitstream * bs,
853                                     int value)
854    {
855            switch (value) {
856            case 0:
857                    BitstreamPutBit(bs, 0);
858                    return;
859    
860            case -2:
861                    BitstreamPutBit(bs, 1);
862                    BitstreamPutBit(bs, 0);
863                    return;
864    
865            case 2:
866                    BitstreamPutBit(bs, 1);
867                    BitstreamPutBit(bs, 1);
868          return;          return;
869    
870            default:;                                       /* invalid */
871            }
872  }  }
873    
874  /*****************************************************************************  
875   * decoding stuff starts here  
876   ****************************************************************************/  void
877    MBCodingBVOP(const MACROBLOCK * mb,
878                             const int16_t qcoeff[6 * 64],
879                             const int32_t fcode,
880                             const int32_t bcode,
881                             Bitstream * bs,
882                             Statistics * pStat,
883                             int direction)
884    {
885            int vcode = fcode;
886            unsigned int i;
887    
888    /*      ------------------------------------------------------------------
889                    when a block is skipped it is decoded DIRECT(0,0)
890                    hence is interpolated from forward & backward frames
891            ------------------------------------------------------------------ */
892    
893            if (mb->mode == MODE_DIRECT_NONE_MV) {
894                    BitstreamPutBit(bs, 1); /* skipped */
895                    return;
896            }
897    
898            BitstreamPutBit(bs, 0);         /* not skipped */
899    
900            if (mb->cbp == 0) {
901                    BitstreamPutBit(bs, 1); /* cbp == 0 */
902            } else {
903                    BitstreamPutBit(bs, 0); /* cbp == xxx */
904            }
905    
906            put_bvop_mbtype(bs, mb->mode);
907    
908            if (mb->cbp) {
909                    BitstreamPutBits(bs, mb->cbp, 6);
910            }
911    
912            if (mb->mode != MODE_DIRECT && mb->cbp != 0) {
913                    put_bvop_dbquant(bs, 0);        /* todo: mb->dquant = 0 */
914            }
915    
916            switch (mb->mode) {
917                    case MODE_INTERPOLATE:
918                            CodeVector(bs, mb->pmvs[1].x, vcode, pStat); /* forward vector of interpolate mode */
919                            CodeVector(bs, mb->pmvs[1].y, vcode, pStat);
920                    case MODE_BACKWARD:
921                            vcode = bcode;
922                    case MODE_FORWARD:
923                            CodeVector(bs, mb->pmvs[0].x, vcode, pStat);
924                            CodeVector(bs, mb->pmvs[0].y, vcode, pStat);
925                            break;
926                    case MODE_DIRECT:
927                            CodeVector(bs, mb->pmvs[3].x, 1, pStat);        /* fcode is always 1 for delta vector */
928                            CodeVector(bs, mb->pmvs[3].y, 1, pStat);        /* prediction is always (0,0) */
929                    default: break;
930            }
931    
932            for (i = 0; i < 6; i++) {
933                    if (mb->cbp & (1 << (5 - i))) {
934    #ifdef BIGLUT
935                            CodeCoeff(bs, &qcoeff[i * 64], inter_table, scan_tables[0], 0);
936    #else
937                            CodeCoeffInter(bs, &qcoeff[i * 64], scan_tables[0]);
938    #endif
939                    }
940            }
941    }
942    
943    
944    
945    /***************************************************************
946     * decoding stuff starts here                                  *
947     ***************************************************************/
948    
949    
950  /*  /*
951   * For IVOP addbits == 0   * for IVOP addbits == 0
952   * For PVOP addbits == fcode - 1   * for PVOP addbits == fcode - 1
953   * For BVOP addbits == max(fcode,bcode) - 1   * for BVOP addbits == max(fcode,bcode) - 1
954   * returns true or false   * returns true or false
955   */   */
   
956  int  int
957  check_resync_marker(Bitstream * bs, int addbits)  check_resync_marker(Bitstream * bs, int addbits)
958  {  {
# Line 675  Line 994 
994    
995          uint32_t index;          uint32_t index;
996    
997          index = CLIP(BitstreamShowBits(bs, 9), 256);          index = MIN(BitstreamShowBits(bs, 9), 256);
998    
999          BitstreamSkip(bs, mcbpc_inter_table[index].len);          BitstreamSkip(bs, mcbpc_inter_table[index].len);
1000    
# Line 701  Line 1020 
1020    
1021  }  }
1022    
1023  int  static __inline int
1024  get_mv_data(Bitstream * bs)  get_mv_data(Bitstream * bs)
1025  {  {
1026    
# Line 747  Line 1066 
1066                  return data;                  return data;
1067    
1068          res = BitstreamGetBits(bs, fcode - 1);          res = BitstreamGetBits(bs, fcode - 1);
1069          mv = ((ABS(data) - 1) * scale_fac) + res + 1;          mv = ((abs(data) - 1) * scale_fac) + res + 1;
1070    
1071          return data < 0 ? -mv : mv;          return data < 0 ? -mv : mv;
1072    
# Line 810  Line 1129 
1129    
1130  }  }
1131    
 /*****************************************************************************  
  * Local inlined function to "decode" written vlc codes  
  ****************************************************************************/  
   
1132  static __inline int  static __inline int
1133  get_coeff(Bitstream * bs,  get_coeff(Bitstream * bs,
1134                    int *run,                    int *run,
# Line 852  Line 1167 
1167                  level = BitstreamGetBits(bs, 8);                  level = BitstreamGetBits(bs, 8);
1168    
1169                  if (level == 0 || level == 128)                  if (level == 0 || level == 128)
1170                          DPRINTF(DPRINTF_ERROR, "Illegal LEVEL for ESCAPE mode 4: %d", level);                          DPRINTF(XVID_DEBUG_ERROR, "Illegal LEVEL for ESCAPE mode 4: %d\n", level);
1171    
1172                  return (level << 24) >> 24;                  return (level << 24) >> 24;
1173          }          }
# Line 895  Line 1210 
1210          return 0;          return 0;
1211  }  }
1212    
 /*****************************************************************************  
  * MB reading functions  
  ****************************************************************************/  
   
1213  void  void
1214  get_intra_block(Bitstream * bs,  get_intra_block(Bitstream * bs,
1215                                  int16_t * block,                                  int16_t * block,
# Line 907  Line 1218 
1218  {  {
1219    
1220          const uint16_t *scan = scan_tables[direction];          const uint16_t *scan = scan_tables[direction];
1221          int level;          int level, run, last;
         int run;  
         int last;  
1222    
1223          do {          do {
1224                  level = get_coeff(bs, &run, &last, 1, 0);                  level = get_coeff(bs, &run, &last, 1, 0);
1225                  if (run == -1) {                  if (run == -1) {
1226                          DPRINTF(DPRINTF_DEBUG, "fatal: invalid run");                          DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run");
1227                          break;                          break;
1228                  }                  }
1229                  coeff += run;                  coeff += run;
1230                  block[scan[coeff]] = level;                  block[scan[coeff]] = level;
1231    
1232                  DPRINTF(DPRINTF_COEFF,"block[%i] %i", scan[coeff], level);                  DPRINTF(XVID_DEBUG_COEFF,"block[%i] %i\n", scan[coeff], level);
1233                  /*DPRINTF(DPRINTF_COEFF,"block[%i] %i %08x", scan[coeff], level, BitstreamShowBits(bs, 32)); */  #if 0
1234                    DPRINTF(XVID_DEBUG_COEFF,"block[%i] %i %08x\n", scan[coeff], level, BitstreamShowBits(bs, 32));
1235    #endif
1236    
1237                  if (level < -2047 || level > 2047) {                  if (level < -2047 || level > 2047) {
1238                          DPRINTF(DPRINTF_DEBUG, "warning: intra_overflow: %d", level);                          DPRINTF(XVID_DEBUG_ERROR,"warning: intra_overflow %i\n", level);
1239                  }                  }
1240                  coeff++;                  coeff++;
1241          } while (!last);          } while (!last);
# Line 933  Line 1244 
1244    
1245  void  void
1246  get_inter_block(Bitstream * bs,  get_inter_block(Bitstream * bs,
1247                                  int16_t * block)                                  int16_t * block,
1248                                    int direction)
1249  {  {
1250    
1251          const uint16_t *scan = scan_tables[0];          const uint16_t *scan = scan_tables[direction];
1252          int p;          int p;
1253          int level;          int level;
1254          int run;          int run;
# Line 946  Line 1258 
1258          do {          do {
1259                  level = get_coeff(bs, &run, &last, 0, 0);                  level = get_coeff(bs, &run, &last, 0, 0);
1260                  if (run == -1) {                  if (run == -1) {
1261                          DPRINTF(DPRINTF_ERROR, "fatal: invalid run");                          DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run");
1262                          break;                          break;
1263                  }                  }
1264                  p += run;                  p += run;
1265    
1266                  block[scan[p]] = level;                  block[scan[p]] = level;
1267    
1268                  DPRINTF(DPRINTF_COEFF,"block[%i] %i", scan[p], level);                  DPRINTF(XVID_DEBUG_COEFF,"block[%i] %i\n", scan[p], level);
1269                    /* DPRINTF(XVID_DEBUG_COEFF,"block[%i] %i %08x\n", scan[p], level, BitstreamShowBits(bs, 32)); */
1270    
1271                  if (level < -2047 || level > 2047) {                  if (level < -2047 || level > 2047) {
1272                          DPRINTF(DPRINTF_DEBUG, "warning: inter_overflow: %d", level);                          DPRINTF(XVID_DEBUG_ERROR,"warning: inter overflow %i\n", level);
1273                  }                  }
1274                  p++;                  p++;
1275          } while (!last);          } while (!last);
1276    
1277  }  }
1278    
1279    
1280    /*****************************************************************************
1281     * VLC tables and other constant arrays
1282     ****************************************************************************/
1283    
1284    VLC_TABLE const coeff_tab[2][102] =
1285    {
1286            /* intra = 0 */
1287            {
1288                    {{ 2,  2}, {0, 0, 1}},
1289                    {{15,  4}, {0, 0, 2}},
1290                    {{21,  6}, {0, 0, 3}},
1291                    {{23,  7}, {0, 0, 4}},
1292                    {{31,  8}, {0, 0, 5}},
1293                    {{37,  9}, {0, 0, 6}},
1294                    {{36,  9}, {0, 0, 7}},
1295                    {{33, 10}, {0, 0, 8}},
1296                    {{32, 10}, {0, 0, 9}},
1297                    {{ 7, 11}, {0, 0, 10}},
1298                    {{ 6, 11}, {0, 0, 11}},
1299                    {{32, 11}, {0, 0, 12}},
1300                    {{ 6,  3}, {0, 1, 1}},
1301                    {{20,  6}, {0, 1, 2}},
1302                    {{30,  8}, {0, 1, 3}},
1303                    {{15, 10}, {0, 1, 4}},
1304                    {{33, 11}, {0, 1, 5}},
1305                    {{80, 12}, {0, 1, 6}},
1306                    {{14,  4}, {0, 2, 1}},
1307                    {{29,  8}, {0, 2, 2}},
1308                    {{14, 10}, {0, 2, 3}},
1309                    {{81, 12}, {0, 2, 4}},
1310                    {{13,  5}, {0, 3, 1}},
1311                    {{35,  9}, {0, 3, 2}},
1312                    {{13, 10}, {0, 3, 3}},
1313                    {{12,  5}, {0, 4, 1}},
1314                    {{34,  9}, {0, 4, 2}},
1315                    {{82, 12}, {0, 4, 3}},
1316                    {{11,  5}, {0, 5, 1}},
1317                    {{12, 10}, {0, 5, 2}},
1318                    {{83, 12}, {0, 5, 3}},
1319                    {{19,  6}, {0, 6, 1}},
1320                    {{11, 10}, {0, 6, 2}},
1321                    {{84, 12}, {0, 6, 3}},
1322                    {{18,  6}, {0, 7, 1}},
1323                    {{10, 10}, {0, 7, 2}},
1324                    {{17,  6}, {0, 8, 1}},
1325                    {{ 9, 10}, {0, 8, 2}},
1326                    {{16,  6}, {0, 9, 1}},
1327                    {{ 8, 10}, {0, 9, 2}},
1328                    {{22,  7}, {0, 10, 1}},
1329                    {{85, 12}, {0, 10, 2}},
1330                    {{21,  7}, {0, 11, 1}},
1331                    {{20,  7}, {0, 12, 1}},
1332                    {{28,  8}, {0, 13, 1}},
1333                    {{27,  8}, {0, 14, 1}},
1334                    {{33,  9}, {0, 15, 1}},
1335                    {{32,  9}, {0, 16, 1}},
1336                    {{31,  9}, {0, 17, 1}},
1337                    {{30,  9}, {0, 18, 1}},
1338                    {{29,  9}, {0, 19, 1}},
1339                    {{28,  9}, {0, 20, 1}},
1340                    {{27,  9}, {0, 21, 1}},
1341                    {{26,  9}, {0, 22, 1}},
1342                    {{34, 11}, {0, 23, 1}},
1343                    {{35, 11}, {0, 24, 1}},
1344                    {{86, 12}, {0, 25, 1}},
1345                    {{87, 12}, {0, 26, 1}},
1346                    {{ 7,  4}, {1, 0, 1}},
1347                    {{25,  9}, {1, 0, 2}},
1348                    {{ 5, 11}, {1, 0, 3}},
1349                    {{15,  6}, {1, 1, 1}},
1350                    {{ 4, 11}, {1, 1, 2}},
1351                    {{14,  6}, {1, 2, 1}},
1352                    {{13,  6}, {1, 3, 1}},
1353                    {{12,  6}, {1, 4, 1}},
1354                    {{19,  7}, {1, 5, 1}},
1355                    {{18,  7}, {1, 6, 1}},
1356                    {{17,  7}, {1, 7, 1}},
1357                    {{16,  7}, {1, 8, 1}},
1358                    {{26,  8}, {1, 9, 1}},
1359                    {{25,  8}, {1, 10, 1}},
1360                    {{24,  8}, {1, 11, 1}},
1361                    {{23,  8}, {1, 12, 1}},
1362                    {{22,  8}, {1, 13, 1}},
1363                    {{21,  8}, {1, 14, 1}},
1364                    {{20,  8}, {1, 15, 1}},
1365                    {{19,  8}, {1, 16, 1}},
1366                    {{24,  9}, {1, 17, 1}},
1367                    {{23,  9}, {1, 18, 1}},
1368                    {{22,  9}, {1, 19, 1}},
1369                    {{21,  9}, {1, 20, 1}},
1370                    {{20,  9}, {1, 21, 1}},
1371                    {{19,  9}, {1, 22, 1}},
1372                    {{18,  9}, {1, 23, 1}},
1373                    {{17,  9}, {1, 24, 1}},
1374                    {{ 7, 10}, {1, 25, 1}},
1375                    {{ 6, 10}, {1, 26, 1}},
1376                    {{ 5, 10}, {1, 27, 1}},
1377                    {{ 4, 10}, {1, 28, 1}},
1378                    {{36, 11}, {1, 29, 1}},
1379                    {{37, 11}, {1, 30, 1}},
1380                    {{38, 11}, {1, 31, 1}},
1381                    {{39, 11}, {1, 32, 1}},
1382                    {{88, 12}, {1, 33, 1}},
1383                    {{89, 12}, {1, 34, 1}},
1384                    {{90, 12}, {1, 35, 1}},
1385                    {{91, 12}, {1, 36, 1}},
1386                    {{92, 12}, {1, 37, 1}},
1387                    {{93, 12}, {1, 38, 1}},
1388                    {{94, 12}, {1, 39, 1}},
1389                    {{95, 12}, {1, 40, 1}}
1390            },
1391            /* intra = 1 */
1392            {
1393                    {{ 2,  2}, {0, 0, 1}},
1394                    {{15,  4}, {0, 0, 3}},
1395                    {{21,  6}, {0, 0, 6}},
1396                    {{23,  7}, {0, 0, 9}},
1397                    {{31,  8}, {0, 0, 10}},
1398                    {{37,  9}, {0, 0, 13}},
1399                    {{36,  9}, {0, 0, 14}},
1400                    {{33, 10}, {0, 0, 17}},
1401                    {{32, 10}, {0, 0, 18}},
1402                    {{ 7, 11}, {0, 0, 21}},
1403                    {{ 6, 11}, {0, 0, 22}},
1404                    {{32, 11}, {0, 0, 23}},
1405                    {{ 6,  3}, {0, 0, 2}},
1406                    {{20,  6}, {0, 1, 2}},
1407                    {{30,  8}, {0, 0, 11}},
1408                    {{15, 10}, {0, 0, 19}},
1409                    {{33, 11}, {0, 0, 24}},
1410                    {{80, 12}, {0, 0, 25}},
1411                    {{14,  4}, {0, 1, 1}},
1412                    {{29,  8}, {0, 0, 12}},
1413                    {{14, 10}, {0, 0, 20}},
1414                    {{81, 12}, {0, 0, 26}},
1415                    {{13,  5}, {0, 0, 4}},
1416                    {{35,  9}, {0, 0, 15}},
1417                    {{13, 10}, {0, 1, 7}},
1418                    {{12,  5}, {0, 0, 5}},
1419                    {{34,  9}, {0, 4, 2}},
1420                    {{82, 12}, {0, 0, 27}},
1421                    {{11,  5}, {0, 2, 1}},
1422                    {{12, 10}, {0, 2, 4}},
1423                    {{83, 12}, {0, 1, 9}},
1424                    {{19,  6}, {0, 0, 7}},
1425                    {{11, 10}, {0, 3, 4}},
1426                    {{84, 12}, {0, 6, 3}},
1427                    {{18,  6}, {0, 0, 8}},
1428                    {{10, 10}, {0, 4, 3}},
1429                    {{17,  6}, {0, 3, 1}},
1430                    {{ 9, 10}, {0, 8, 2}},
1431                    {{16,  6}, {0, 4, 1}},
1432                    {{ 8, 10}, {0, 5, 3}},
1433                    {{22,  7}, {0, 1, 3}},
1434                    {{85, 12}, {0, 1, 10}},
1435                    {{21,  7}, {0, 2, 2}},
1436                    {{20,  7}, {0, 7, 1}},
1437                    {{28,  8}, {0, 1, 4}},
1438                    {{27,  8}, {0, 3, 2}},
1439                    {{33,  9}, {0, 0, 16}},
1440                    {{32,  9}, {0, 1, 5}},
1441                    {{31,  9}, {0, 1, 6}},
1442                    {{30,  9}, {0, 2, 3}},
1443                    {{29,  9}, {0, 3, 3}},
1444                    {{28,  9}, {0, 5, 2}},
1445                    {{27,  9}, {0, 6, 2}},
1446                    {{26,  9}, {0, 7, 2}},
1447                    {{34, 11}, {0, 1, 8}},
1448                    {{35, 11}, {0, 9, 2}},
1449                    {{86, 12}, {0, 2, 5}},
1450                    {{87, 12}, {0, 7, 3}},
1451                    {{ 7,  4}, {1, 0, 1}},
1452                    {{25,  9}, {0, 11, 1}},
1453                    {{ 5, 11}, {1, 0, 6}},
1454                    {{15,  6}, {1, 1, 1}},
1455                    {{ 4, 11}, {1, 0, 7}},
1456                    {{14,  6}, {1, 2, 1}},
1457                    {{13,  6}, {0, 5, 1}},
1458                    {{12,  6}, {1, 0, 2}},
1459                    {{19,  7}, {1, 5, 1}},
1460                    {{18,  7}, {0, 6, 1}},
1461                    {{17,  7}, {1, 3, 1}},
1462                    {{16,  7}, {1, 4, 1}},
1463                    {{26,  8}, {1, 9, 1}},
1464                    {{25,  8}, {0, 8, 1}},
1465                    {{24,  8}, {0, 9, 1}},
1466                    {{23,  8}, {0, 10, 1}},
1467                    {{22,  8}, {1, 0, 3}},
1468                    {{21,  8}, {1, 6, 1}},
1469                    {{20,  8}, {1, 7, 1}},
1470                    {{19,  8}, {1, 8, 1}},
1471                    {{24,  9}, {0, 12, 1}},
1472                    {{23,  9}, {1, 0, 4}},
1473                    {{22,  9}, {1, 1, 2}},
1474                    {{21,  9}, {1, 10, 1}},
1475                    {{20,  9}, {1, 11, 1}},
1476                    {{19,  9}, {1, 12, 1}},
1477                    {{18,  9}, {1, 13, 1}},
1478                    {{17,  9}, {1, 14, 1}},
1479                    {{ 7, 10}, {0, 13, 1}},
1480                    {{ 6, 10}, {1, 0, 5}},
1481                    {{ 5, 10}, {1, 1, 3}},
1482                    {{ 4, 10}, {1, 2, 2}},
1483                    {{36, 11}, {1, 3, 2}},
1484                    {{37, 11}, {1, 4, 2}},
1485                    {{38, 11}, {1, 15, 1}},
1486                    {{39, 11}, {1, 16, 1}},
1487                    {{88, 12}, {0, 14, 1}},
1488                    {{89, 12}, {1, 0, 8}},
1489                    {{90, 12}, {1, 5, 2}},
1490                    {{91, 12}, {1, 6, 2}},
1491                    {{92, 12}, {1, 17, 1}},
1492                    {{93, 12}, {1, 18, 1}},
1493                    {{94, 12}, {1, 19, 1}},
1494                    {{95, 12}, {1, 20, 1}}
1495            }
1496    };
1497    
1498    /* constants taken from momusys/vm_common/inlcude/max_level.h */
1499    uint8_t const max_level[2][2][64] = {
1500            {
1501                    /* intra = 0, last = 0 */
1502                    {
1503                            12, 6, 4, 3, 3, 3, 3, 2,
1504                            2, 2, 2, 1, 1, 1, 1, 1,
1505                            1, 1, 1, 1, 1, 1, 1, 1,
1506                            1, 1, 1, 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                            0, 0, 0, 0, 0, 0, 0, 0
1511                    },
1512                    /* intra = 0, last = 1 */
1513                    {
1514                            3, 2, 1, 1, 1, 1, 1, 1,
1515                            1, 1, 1, 1, 1, 1, 1, 1,
1516                            1, 1, 1, 1, 1, 1, 1, 1,
1517                            1, 1, 1, 1, 1, 1, 1, 1,
1518                            1, 1, 1, 1, 1, 1, 1, 1,
1519                            1, 0, 0, 0, 0, 0, 0, 0,
1520                            0, 0, 0, 0, 0, 0, 0, 0,
1521                            0, 0, 0, 0, 0, 0, 0, 0
1522                    }
1523            },
1524            {
1525                    /* intra = 1, last = 0 */
1526                    {
1527                            27, 10, 5, 4, 3, 3, 3, 3,
1528                            2, 2, 1, 1, 1, 1, 1, 0,
1529                            0, 0, 0, 0, 0, 0, 0, 0,
1530                            0, 0, 0, 0, 0, 0, 0, 0,
1531                            0, 0, 0, 0, 0, 0, 0, 0,
1532                            0, 0, 0, 0, 0, 0, 0, 0,
1533                            0, 0, 0, 0, 0, 0, 0, 0,
1534                            0, 0, 0, 0, 0, 0, 0, 0
1535                    },
1536                    /* intra = 1, last = 1 */
1537                    {
1538                            8, 3, 2, 2, 2, 2, 2, 1,
1539                            1, 1, 1, 1, 1, 1, 1, 1,
1540                            1, 1, 1, 1, 1, 0, 0, 0,
1541                            0, 0, 0, 0, 0, 0, 0, 0,
1542                            0, 0, 0, 0, 0, 0, 0, 0,
1543                            0, 0, 0, 0, 0, 0, 0, 0,
1544                            0, 0, 0, 0, 0, 0, 0, 0,
1545                            0, 0, 0, 0, 0, 0, 0, 0
1546                    }
1547            }
1548    };
1549    
1550    uint8_t const max_run[2][2][64] = {
1551            {
1552                    /* intra = 0, last = 0 */
1553                    {
1554                            0, 26, 10, 6, 2, 1, 1, 0,
1555                            0, 0, 0, 0, 0, 0, 0, 0,
1556                            0, 0, 0, 0, 0, 0, 0, 0,
1557                            0, 0, 0, 0, 0, 0, 0, 0,
1558                            0, 0, 0, 0, 0, 0, 0, 0,
1559                            0, 0, 0, 0, 0, 0, 0, 0,
1560                            0, 0, 0, 0, 0, 0, 0, 0,
1561                            0, 0, 0, 0, 0, 0, 0, 0,
1562                    },
1563                    /* intra = 0, last = 1 */
1564                    {
1565                            0, 40, 1, 0, 0, 0, 0, 0,
1566                            0, 0, 0, 0, 0, 0, 0, 0,
1567                            0, 0, 0, 0, 0, 0, 0, 0,
1568                            0, 0, 0, 0, 0, 0, 0, 0,
1569                            0, 0, 0, 0, 0, 0, 0, 0,
1570                            0, 0, 0, 0, 0, 0, 0, 0,
1571                            0, 0, 0, 0, 0, 0, 0, 0,
1572                            0, 0, 0, 0, 0, 0, 0, 0,
1573                    }
1574            },
1575            {
1576                    /* intra = 1, last = 0 */
1577                    {
1578                            0, 14, 9, 7, 3, 2, 1, 1,
1579                            1, 1, 1, 0, 0, 0, 0, 0,
1580                            0, 0, 0, 0, 0, 0, 0, 0,
1581                            0, 0, 0, 0, 0, 0, 0, 0,
1582                            0, 0, 0, 0, 0, 0, 0, 0,
1583                            0, 0, 0, 0, 0, 0, 0, 0,
1584                            0, 0, 0, 0, 0, 0, 0, 0,
1585                            0, 0, 0, 0, 0, 0, 0, 0,
1586                    },
1587                    /* intra = 1, last = 1 */
1588                    {
1589                            0, 20, 6, 1, 0, 0, 0, 0,
1590                            0, 0, 0, 0, 0, 0, 0, 0,
1591                            0, 0, 0, 0, 0, 0, 0, 0,
1592                            0, 0, 0, 0, 0, 0, 0, 0,
1593                            0, 0, 0, 0, 0, 0, 0, 0,
1594                            0, 0, 0, 0, 0, 0, 0, 0,
1595                            0, 0, 0, 0, 0, 0, 0, 0,
1596                            0, 0, 0, 0, 0, 0, 0, 0,
1597                    }
1598            }
1599    };
1600    
1601    /******************************************************************
1602     * encoder tables                                                 *
1603     ******************************************************************/
1604    
1605    VLC sprite_trajectory_code[32768];
1606    
1607    VLC sprite_trajectory_len[15] = {
1608            { 0x00 , 2},
1609            { 0x02 , 3}, { 0x03, 3}, { 0x04, 3}, { 0x05, 3}, { 0x06, 3},
1610            { 0x0E , 4}, { 0x1E, 5}, { 0x3E, 6}, { 0x7F, 7}, { 0xFE, 8},
1611            { 0x1FE, 9}, {0x3FE,10}, {0x7FE,11}, {0xFFE,12} };
1612    
1613    
1614    /* DCT coefficients. Four tables, two for last = 0, two for last = 1.
1615       the sign bit must be added afterwards. */
1616    
1617    /* MCBPC Indexing by cbpc in first two bits, mode in last two.
1618     CBPC as in table 4/H.263, MB type (mode): 3 = 01, 4 = 10.
1619     Example: cbpc = 01 and mode = 4 gives index = 0110 = 6. */
1620    
1621    VLC mcbpc_intra_tab[15] = {
1622            {0x01, 9}, {0x01, 1}, {0x01, 4}, {0x00, 0},
1623            {0x00, 0}, {0x01, 3}, {0x01, 6}, {0x00, 0},
1624            {0x00, 0}, {0x02, 3}, {0x02, 6}, {0x00, 0},
1625            {0x00, 0}, {0x03, 3}, {0x03, 6}
1626    };
1627    
1628    /* MCBPC inter.
1629       Addressing: 5 bit ccmmm (cc = CBPC, mmm = mode (1-4 binary)) */
1630    
1631    VLC mcbpc_inter_tab[29] = {
1632            {1, 1}, {3, 3}, {2, 3}, {3, 5}, {4, 6}, {1, 9}, {0, 0}, {0, 0},
1633            {3, 4}, {7, 7}, {5, 7}, {4, 8}, {4, 9}, {0, 0}, {0, 0}, {0, 0},
1634            {2, 4}, {6, 7}, {4, 7}, {3, 8}, {3, 9}, {0, 0}, {0, 0}, {0, 0},
1635            {5, 6}, {5, 9}, {5, 8}, {3, 7}, {2, 9}
1636    };
1637    
1638    const VLC xvid_cbpy_tab[16] = {
1639            {3, 4}, {5, 5}, {4, 5}, {9, 4}, {3, 5}, {7, 4}, {2, 6}, {11, 4},
1640            {2, 5}, {3, 6}, {5, 4}, {10, 4}, {4, 4}, {8, 4}, {6, 4}, {3, 2}
1641    };
1642    
1643    const VLC dcy_tab[511] = {
1644            {0x100, 15}, {0x101, 15}, {0x102, 15}, {0x103, 15},
1645            {0x104, 15}, {0x105, 15}, {0x106, 15}, {0x107, 15},
1646            {0x108, 15}, {0x109, 15}, {0x10a, 15}, {0x10b, 15},
1647            {0x10c, 15}, {0x10d, 15}, {0x10e, 15}, {0x10f, 15},
1648            {0x110, 15}, {0x111, 15}, {0x112, 15}, {0x113, 15},
1649            {0x114, 15}, {0x115, 15}, {0x116, 15}, {0x117, 15},
1650            {0x118, 15}, {0x119, 15}, {0x11a, 15}, {0x11b, 15},
1651            {0x11c, 15}, {0x11d, 15}, {0x11e, 15}, {0x11f, 15},
1652            {0x120, 15}, {0x121, 15}, {0x122, 15}, {0x123, 15},
1653            {0x124, 15}, {0x125, 15}, {0x126, 15}, {0x127, 15},
1654            {0x128, 15}, {0x129, 15}, {0x12a, 15}, {0x12b, 15},
1655            {0x12c, 15}, {0x12d, 15}, {0x12e, 15}, {0x12f, 15},
1656            {0x130, 15}, {0x131, 15}, {0x132, 15}, {0x133, 15},
1657            {0x134, 15}, {0x135, 15}, {0x136, 15}, {0x137, 15},
1658            {0x138, 15}, {0x139, 15}, {0x13a, 15}, {0x13b, 15},
1659            {0x13c, 15}, {0x13d, 15}, {0x13e, 15}, {0x13f, 15},
1660            {0x140, 15}, {0x141, 15}, {0x142, 15}, {0x143, 15},
1661            {0x144, 15}, {0x145, 15}, {0x146, 15}, {0x147, 15},
1662            {0x148, 15}, {0x149, 15}, {0x14a, 15}, {0x14b, 15},
1663            {0x14c, 15}, {0x14d, 15}, {0x14e, 15}, {0x14f, 15},
1664            {0x150, 15}, {0x151, 15}, {0x152, 15}, {0x153, 15},
1665            {0x154, 15}, {0x155, 15}, {0x156, 15}, {0x157, 15},
1666            {0x158, 15}, {0x159, 15}, {0x15a, 15}, {0x15b, 15},
1667            {0x15c, 15}, {0x15d, 15}, {0x15e, 15}, {0x15f, 15},
1668            {0x160, 15}, {0x161, 15}, {0x162, 15}, {0x163, 15},
1669            {0x164, 15}, {0x165, 15}, {0x166, 15}, {0x167, 15},
1670            {0x168, 15}, {0x169, 15}, {0x16a, 15}, {0x16b, 15},
1671            {0x16c, 15}, {0x16d, 15}, {0x16e, 15}, {0x16f, 15},
1672            {0x170, 15}, {0x171, 15}, {0x172, 15}, {0x173, 15},
1673            {0x174, 15}, {0x175, 15}, {0x176, 15}, {0x177, 15},
1674            {0x178, 15}, {0x179, 15}, {0x17a, 15}, {0x17b, 15},
1675            {0x17c, 15}, {0x17d, 15}, {0x17e, 15}, {0x17f, 15},
1676            {0x80, 13}, {0x81, 13}, {0x82, 13}, {0x83, 13},
1677            {0x84, 13}, {0x85, 13}, {0x86, 13}, {0x87, 13},
1678            {0x88, 13}, {0x89, 13}, {0x8a, 13}, {0x8b, 13},
1679            {0x8c, 13}, {0x8d, 13}, {0x8e, 13}, {0x8f, 13},
1680            {0x90, 13}, {0x91, 13}, {0x92, 13}, {0x93, 13},
1681            {0x94, 13}, {0x95, 13}, {0x96, 13}, {0x97, 13},
1682            {0x98, 13}, {0x99, 13}, {0x9a, 13}, {0x9b, 13},
1683            {0x9c, 13}, {0x9d, 13}, {0x9e, 13}, {0x9f, 13},
1684            {0xa0, 13}, {0xa1, 13}, {0xa2, 13}, {0xa3, 13},
1685            {0xa4, 13}, {0xa5, 13}, {0xa6, 13}, {0xa7, 13},
1686            {0xa8, 13}, {0xa9, 13}, {0xaa, 13}, {0xab, 13},
1687            {0xac, 13}, {0xad, 13}, {0xae, 13}, {0xaf, 13},
1688            {0xb0, 13}, {0xb1, 13}, {0xb2, 13}, {0xb3, 13},
1689            {0xb4, 13}, {0xb5, 13}, {0xb6, 13}, {0xb7, 13},
1690            {0xb8, 13}, {0xb9, 13}, {0xba, 13}, {0xbb, 13},
1691            {0xbc, 13}, {0xbd, 13}, {0xbe, 13}, {0xbf, 13},
1692            {0x40, 11}, {0x41, 11}, {0x42, 11}, {0x43, 11},
1693            {0x44, 11}, {0x45, 11}, {0x46, 11}, {0x47, 11},
1694            {0x48, 11}, {0x49, 11}, {0x4a, 11}, {0x4b, 11},
1695            {0x4c, 11}, {0x4d, 11}, {0x4e, 11}, {0x4f, 11},
1696            {0x50, 11}, {0x51, 11}, {0x52, 11}, {0x53, 11},
1697            {0x54, 11}, {0x55, 11}, {0x56, 11}, {0x57, 11},
1698            {0x58, 11}, {0x59, 11}, {0x5a, 11}, {0x5b, 11},
1699            {0x5c, 11}, {0x5d, 11}, {0x5e, 11}, {0x5f, 11},
1700            {0x20, 9}, {0x21, 9}, {0x22, 9}, {0x23, 9},
1701            {0x24, 9}, {0x25, 9}, {0x26, 9}, {0x27, 9},
1702            {0x28, 9}, {0x29, 9}, {0x2a, 9}, {0x2b, 9},
1703            {0x2c, 9}, {0x2d, 9}, {0x2e, 9}, {0x2f, 9},
1704            {0x10, 7}, {0x11, 7}, {0x12, 7}, {0x13, 7},
1705            {0x14, 7}, {0x15, 7}, {0x16, 7}, {0x17, 7},
1706            {0x10, 6}, {0x11, 6}, {0x12, 6}, {0x13, 6},
1707            {0x08, 4}, {0x09, 4}, {0x06, 3}, {0x03, 3},
1708            {0x07, 3}, {0x0a, 4}, {0x0b, 4}, {0x14, 6},
1709            {0x15, 6}, {0x16, 6}, {0x17, 6}, {0x18, 7},
1710            {0x19, 7}, {0x1a, 7}, {0x1b, 7}, {0x1c, 7},
1711            {0x1d, 7}, {0x1e, 7}, {0x1f, 7}, {0x30, 9},
1712            {0x31, 9}, {0x32, 9}, {0x33, 9}, {0x34, 9},
1713            {0x35, 9}, {0x36, 9}, {0x37, 9}, {0x38, 9},
1714            {0x39, 9}, {0x3a, 9}, {0x3b, 9}, {0x3c, 9},
1715            {0x3d, 9}, {0x3e, 9}, {0x3f, 9}, {0x60, 11},
1716            {0x61, 11}, {0x62, 11}, {0x63, 11}, {0x64, 11},
1717            {0x65, 11}, {0x66, 11}, {0x67, 11}, {0x68, 11},
1718            {0x69, 11}, {0x6a, 11}, {0x6b, 11}, {0x6c, 11},
1719            {0x6d, 11}, {0x6e, 11}, {0x6f, 11}, {0x70, 11},
1720            {0x71, 11}, {0x72, 11}, {0x73, 11}, {0x74, 11},
1721            {0x75, 11}, {0x76, 11}, {0x77, 11}, {0x78, 11},
1722            {0x79, 11}, {0x7a, 11}, {0x7b, 11}, {0x7c, 11},
1723            {0x7d, 11}, {0x7e, 11}, {0x7f, 11}, {0xc0, 13},
1724            {0xc1, 13}, {0xc2, 13}, {0xc3, 13}, {0xc4, 13},
1725            {0xc5, 13}, {0xc6, 13}, {0xc7, 13}, {0xc8, 13},
1726            {0xc9, 13}, {0xca, 13}, {0xcb, 13}, {0xcc, 13},
1727            {0xcd, 13}, {0xce, 13}, {0xcf, 13}, {0xd0, 13},
1728            {0xd1, 13}, {0xd2, 13}, {0xd3, 13}, {0xd4, 13},
1729            {0xd5, 13}, {0xd6, 13}, {0xd7, 13}, {0xd8, 13},
1730            {0xd9, 13}, {0xda, 13}, {0xdb, 13}, {0xdc, 13},
1731            {0xdd, 13}, {0xde, 13}, {0xdf, 13}, {0xe0, 13},
1732            {0xe1, 13}, {0xe2, 13}, {0xe3, 13}, {0xe4, 13},
1733            {0xe5, 13}, {0xe6, 13}, {0xe7, 13}, {0xe8, 13},
1734            {0xe9, 13}, {0xea, 13}, {0xeb, 13}, {0xec, 13},
1735            {0xed, 13}, {0xee, 13}, {0xef, 13}, {0xf0, 13},
1736            {0xf1, 13}, {0xf2, 13}, {0xf3, 13}, {0xf4, 13},
1737            {0xf5, 13}, {0xf6, 13}, {0xf7, 13}, {0xf8, 13},
1738            {0xf9, 13}, {0xfa, 13}, {0xfb, 13}, {0xfc, 13},
1739            {0xfd, 13}, {0xfe, 13}, {0xff, 13}, {0x180, 15},
1740            {0x181, 15}, {0x182, 15}, {0x183, 15}, {0x184, 15},
1741            {0x185, 15}, {0x186, 15}, {0x187, 15}, {0x188, 15},
1742            {0x189, 15}, {0x18a, 15}, {0x18b, 15}, {0x18c, 15},
1743            {0x18d, 15}, {0x18e, 15}, {0x18f, 15}, {0x190, 15},
1744            {0x191, 15}, {0x192, 15}, {0x193, 15}, {0x194, 15},
1745            {0x195, 15}, {0x196, 15}, {0x197, 15}, {0x198, 15},
1746            {0x199, 15}, {0x19a, 15}, {0x19b, 15}, {0x19c, 15},
1747            {0x19d, 15}, {0x19e, 15}, {0x19f, 15}, {0x1a0, 15},
1748            {0x1a1, 15}, {0x1a2, 15}, {0x1a3, 15}, {0x1a4, 15},
1749            {0x1a5, 15}, {0x1a6, 15}, {0x1a7, 15}, {0x1a8, 15},
1750            {0x1a9, 15}, {0x1aa, 15}, {0x1ab, 15}, {0x1ac, 15},
1751            {0x1ad, 15}, {0x1ae, 15}, {0x1af, 15}, {0x1b0, 15},
1752            {0x1b1, 15}, {0x1b2, 15}, {0x1b3, 15}, {0x1b4, 15},
1753            {0x1b5, 15}, {0x1b6, 15}, {0x1b7, 15}, {0x1b8, 15},
1754            {0x1b9, 15}, {0x1ba, 15}, {0x1bb, 15}, {0x1bc, 15},
1755            {0x1bd, 15}, {0x1be, 15}, {0x1bf, 15}, {0x1c0, 15},
1756            {0x1c1, 15}, {0x1c2, 15}, {0x1c3, 15}, {0x1c4, 15},
1757            {0x1c5, 15}, {0x1c6, 15}, {0x1c7, 15}, {0x1c8, 15},
1758            {0x1c9, 15}, {0x1ca, 15}, {0x1cb, 15}, {0x1cc, 15},
1759            {0x1cd, 15}, {0x1ce, 15}, {0x1cf, 15}, {0x1d0, 15},
1760            {0x1d1, 15}, {0x1d2, 15}, {0x1d3, 15}, {0x1d4, 15},
1761            {0x1d5, 15}, {0x1d6, 15}, {0x1d7, 15}, {0x1d8, 15},
1762            {0x1d9, 15}, {0x1da, 15}, {0x1db, 15}, {0x1dc, 15},
1763            {0x1dd, 15}, {0x1de, 15}, {0x1df, 15}, {0x1e0, 15},
1764            {0x1e1, 15}, {0x1e2, 15}, {0x1e3, 15}, {0x1e4, 15},
1765            {0x1e5, 15}, {0x1e6, 15}, {0x1e7, 15}, {0x1e8, 15},
1766            {0x1e9, 15}, {0x1ea, 15}, {0x1eb, 15}, {0x1ec, 15},
1767            {0x1ed, 15}, {0x1ee, 15}, {0x1ef, 15}, {0x1f0, 15},
1768            {0x1f1, 15}, {0x1f2, 15}, {0x1f3, 15}, {0x1f4, 15},
1769            {0x1f5, 15}, {0x1f6, 15}, {0x1f7, 15}, {0x1f8, 15},
1770            {0x1f9, 15}, {0x1fa, 15}, {0x1fb, 15}, {0x1fc, 15},
1771            {0x1fd, 15}, {0x1fe, 15}, {0x1ff, 15},
1772    };
1773    
1774    const VLC dcc_tab[511] = {
1775            {0x100, 16}, {0x101, 16}, {0x102, 16}, {0x103, 16},
1776            {0x104, 16}, {0x105, 16}, {0x106, 16}, {0x107, 16},
1777            {0x108, 16}, {0x109, 16}, {0x10a, 16}, {0x10b, 16},
1778            {0x10c, 16}, {0x10d, 16}, {0x10e, 16}, {0x10f, 16},
1779            {0x110, 16}, {0x111, 16}, {0x112, 16}, {0x113, 16},
1780            {0x114, 16}, {0x115, 16}, {0x116, 16}, {0x117, 16},
1781            {0x118, 16}, {0x119, 16}, {0x11a, 16}, {0x11b, 16},
1782            {0x11c, 16}, {0x11d, 16}, {0x11e, 16}, {0x11f, 16},
1783            {0x120, 16}, {0x121, 16}, {0x122, 16}, {0x123, 16},
1784            {0x124, 16}, {0x125, 16}, {0x126, 16}, {0x127, 16},
1785            {0x128, 16}, {0x129, 16}, {0x12a, 16}, {0x12b, 16},
1786            {0x12c, 16}, {0x12d, 16}, {0x12e, 16}, {0x12f, 16},
1787            {0x130, 16}, {0x131, 16}, {0x132, 16}, {0x133, 16},
1788            {0x134, 16}, {0x135, 16}, {0x136, 16}, {0x137, 16},
1789            {0x138, 16}, {0x139, 16}, {0x13a, 16}, {0x13b, 16},
1790            {0x13c, 16}, {0x13d, 16}, {0x13e, 16}, {0x13f, 16},
1791            {0x140, 16}, {0x141, 16}, {0x142, 16}, {0x143, 16},
1792            {0x144, 16}, {0x145, 16}, {0x146, 16}, {0x147, 16},
1793            {0x148, 16}, {0x149, 16}, {0x14a, 16}, {0x14b, 16},
1794            {0x14c, 16}, {0x14d, 16}, {0x14e, 16}, {0x14f, 16},
1795            {0x150, 16}, {0x151, 16}, {0x152, 16}, {0x153, 16},
1796            {0x154, 16}, {0x155, 16}, {0x156, 16}, {0x157, 16},
1797            {0x158, 16}, {0x159, 16}, {0x15a, 16}, {0x15b, 16},
1798            {0x15c, 16}, {0x15d, 16}, {0x15e, 16}, {0x15f, 16},
1799            {0x160, 16}, {0x161, 16}, {0x162, 16}, {0x163, 16},
1800            {0x164, 16}, {0x165, 16}, {0x166, 16}, {0x167, 16},
1801            {0x168, 16}, {0x169, 16}, {0x16a, 16}, {0x16b, 16},
1802            {0x16c, 16}, {0x16d, 16}, {0x16e, 16}, {0x16f, 16},
1803            {0x170, 16}, {0x171, 16}, {0x172, 16}, {0x173, 16},
1804            {0x174, 16}, {0x175, 16}, {0x176, 16}, {0x177, 16},
1805            {0x178, 16}, {0x179, 16}, {0x17a, 16}, {0x17b, 16},
1806            {0x17c, 16}, {0x17d, 16}, {0x17e, 16}, {0x17f, 16},
1807            {0x80, 14}, {0x81, 14}, {0x82, 14}, {0x83, 14},
1808            {0x84, 14}, {0x85, 14}, {0x86, 14}, {0x87, 14},
1809            {0x88, 14}, {0x89, 14}, {0x8a, 14}, {0x8b, 14},
1810            {0x8c, 14}, {0x8d, 14}, {0x8e, 14}, {0x8f, 14},
1811            {0x90, 14}, {0x91, 14}, {0x92, 14}, {0x93, 14},
1812            {0x94, 14}, {0x95, 14}, {0x96, 14}, {0x97, 14},
1813            {0x98, 14}, {0x99, 14}, {0x9a, 14}, {0x9b, 14},
1814            {0x9c, 14}, {0x9d, 14}, {0x9e, 14}, {0x9f, 14},
1815            {0xa0, 14}, {0xa1, 14}, {0xa2, 14}, {0xa3, 14},
1816            {0xa4, 14}, {0xa5, 14}, {0xa6, 14}, {0xa7, 14},
1817            {0xa8, 14}, {0xa9, 14}, {0xaa, 14}, {0xab, 14},
1818            {0xac, 14}, {0xad, 14}, {0xae, 14}, {0xaf, 14},
1819            {0xb0, 14}, {0xb1, 14}, {0xb2, 14}, {0xb3, 14},
1820            {0xb4, 14}, {0xb5, 14}, {0xb6, 14}, {0xb7, 14},
1821            {0xb8, 14}, {0xb9, 14}, {0xba, 14}, {0xbb, 14},
1822            {0xbc, 14}, {0xbd, 14}, {0xbe, 14}, {0xbf, 14},
1823            {0x40, 12}, {0x41, 12}, {0x42, 12}, {0x43, 12},
1824            {0x44, 12}, {0x45, 12}, {0x46, 12}, {0x47, 12},
1825            {0x48, 12}, {0x49, 12}, {0x4a, 12}, {0x4b, 12},
1826            {0x4c, 12}, {0x4d, 12}, {0x4e, 12}, {0x4f, 12},
1827            {0x50, 12}, {0x51, 12}, {0x52, 12}, {0x53, 12},
1828            {0x54, 12}, {0x55, 12}, {0x56, 12}, {0x57, 12},
1829            {0x58, 12}, {0x59, 12}, {0x5a, 12}, {0x5b, 12},
1830            {0x5c, 12}, {0x5d, 12}, {0x5e, 12}, {0x5f, 12},
1831            {0x20, 10}, {0x21, 10}, {0x22, 10}, {0x23, 10},
1832            {0x24, 10}, {0x25, 10}, {0x26, 10}, {0x27, 10},
1833            {0x28, 10}, {0x29, 10}, {0x2a, 10}, {0x2b, 10},
1834            {0x2c, 10}, {0x2d, 10}, {0x2e, 10}, {0x2f, 10},
1835            {0x10, 8}, {0x11, 8}, {0x12, 8}, {0x13, 8},
1836            {0x14, 8}, {0x15, 8}, {0x16, 8}, {0x17, 8},
1837            {0x08, 6}, {0x09, 6}, {0x0a, 6}, {0x0b, 6},
1838            {0x04, 4}, {0x05, 4}, {0x04, 3}, {0x03, 2},
1839            {0x05, 3}, {0x06, 4}, {0x07, 4}, {0x0c, 6},
1840            {0x0d, 6}, {0x0e, 6}, {0x0f, 6}, {0x18, 8},
1841            {0x19, 8}, {0x1a, 8}, {0x1b, 8}, {0x1c, 8},
1842            {0x1d, 8}, {0x1e, 8}, {0x1f, 8}, {0x30, 10},
1843            {0x31, 10}, {0x32, 10}, {0x33, 10}, {0x34, 10},
1844            {0x35, 10}, {0x36, 10}, {0x37, 10}, {0x38, 10},
1845            {0x39, 10}, {0x3a, 10}, {0x3b, 10}, {0x3c, 10},
1846            {0x3d, 10}, {0x3e, 10}, {0x3f, 10}, {0x60, 12},
1847            {0x61, 12}, {0x62, 12}, {0x63, 12}, {0x64, 12},
1848            {0x65, 12}, {0x66, 12}, {0x67, 12}, {0x68, 12},
1849            {0x69, 12}, {0x6a, 12}, {0x6b, 12}, {0x6c, 12},
1850            {0x6d, 12}, {0x6e, 12}, {0x6f, 12}, {0x70, 12},
1851            {0x71, 12}, {0x72, 12}, {0x73, 12}, {0x74, 12},
1852            {0x75, 12}, {0x76, 12}, {0x77, 12}, {0x78, 12},
1853            {0x79, 12}, {0x7a, 12}, {0x7b, 12}, {0x7c, 12},
1854            {0x7d, 12}, {0x7e, 12}, {0x7f, 12}, {0xc0, 14},
1855            {0xc1, 14}, {0xc2, 14}, {0xc3, 14}, {0xc4, 14},
1856            {0xc5, 14}, {0xc6, 14}, {0xc7, 14}, {0xc8, 14},
1857            {0xc9, 14}, {0xca, 14}, {0xcb, 14}, {0xcc, 14},
1858            {0xcd, 14}, {0xce, 14}, {0xcf, 14}, {0xd0, 14},
1859            {0xd1, 14}, {0xd2, 14}, {0xd3, 14}, {0xd4, 14},
1860            {0xd5, 14}, {0xd6, 14}, {0xd7, 14}, {0xd8, 14},
1861            {0xd9, 14}, {0xda, 14}, {0xdb, 14}, {0xdc, 14},
1862            {0xdd, 14}, {0xde, 14}, {0xdf, 14}, {0xe0, 14},
1863            {0xe1, 14}, {0xe2, 14}, {0xe3, 14}, {0xe4, 14},
1864            {0xe5, 14}, {0xe6, 14}, {0xe7, 14}, {0xe8, 14},
1865            {0xe9, 14}, {0xea, 14}, {0xeb, 14}, {0xec, 14},
1866            {0xed, 14}, {0xee, 14}, {0xef, 14}, {0xf0, 14},
1867            {0xf1, 14}, {0xf2, 14}, {0xf3, 14}, {0xf4, 14},
1868            {0xf5, 14}, {0xf6, 14}, {0xf7, 14}, {0xf8, 14},
1869            {0xf9, 14}, {0xfa, 14}, {0xfb, 14}, {0xfc, 14},
1870            {0xfd, 14}, {0xfe, 14}, {0xff, 14}, {0x180, 16},
1871            {0x181, 16}, {0x182, 16}, {0x183, 16}, {0x184, 16},
1872            {0x185, 16}, {0x186, 16}, {0x187, 16}, {0x188, 16},
1873            {0x189, 16}, {0x18a, 16}, {0x18b, 16}, {0x18c, 16},
1874            {0x18d, 16}, {0x18e, 16}, {0x18f, 16}, {0x190, 16},
1875            {0x191, 16}, {0x192, 16}, {0x193, 16}, {0x194, 16},
1876            {0x195, 16}, {0x196, 16}, {0x197, 16}, {0x198, 16},
1877            {0x199, 16}, {0x19a, 16}, {0x19b, 16}, {0x19c, 16},
1878            {0x19d, 16}, {0x19e, 16}, {0x19f, 16}, {0x1a0, 16},
1879            {0x1a1, 16}, {0x1a2, 16}, {0x1a3, 16}, {0x1a4, 16},
1880            {0x1a5, 16}, {0x1a6, 16}, {0x1a7, 16}, {0x1a8, 16},
1881            {0x1a9, 16}, {0x1aa, 16}, {0x1ab, 16}, {0x1ac, 16},
1882            {0x1ad, 16}, {0x1ae, 16}, {0x1af, 16}, {0x1b0, 16},
1883            {0x1b1, 16}, {0x1b2, 16}, {0x1b3, 16}, {0x1b4, 16},
1884            {0x1b5, 16}, {0x1b6, 16}, {0x1b7, 16}, {0x1b8, 16},
1885            {0x1b9, 16}, {0x1ba, 16}, {0x1bb, 16}, {0x1bc, 16},
1886            {0x1bd, 16}, {0x1be, 16}, {0x1bf, 16}, {0x1c0, 16},
1887            {0x1c1, 16}, {0x1c2, 16}, {0x1c3, 16}, {0x1c4, 16},
1888            {0x1c5, 16}, {0x1c6, 16}, {0x1c7, 16}, {0x1c8, 16},
1889            {0x1c9, 16}, {0x1ca, 16}, {0x1cb, 16}, {0x1cc, 16},
1890            {0x1cd, 16}, {0x1ce, 16}, {0x1cf, 16}, {0x1d0, 16},
1891            {0x1d1, 16}, {0x1d2, 16}, {0x1d3, 16}, {0x1d4, 16},
1892            {0x1d5, 16}, {0x1d6, 16}, {0x1d7, 16}, {0x1d8, 16},
1893            {0x1d9, 16}, {0x1da, 16}, {0x1db, 16}, {0x1dc, 16},
1894            {0x1dd, 16}, {0x1de, 16}, {0x1df, 16}, {0x1e0, 16},
1895            {0x1e1, 16}, {0x1e2, 16}, {0x1e3, 16}, {0x1e4, 16},
1896            {0x1e5, 16}, {0x1e6, 16}, {0x1e7, 16}, {0x1e8, 16},
1897            {0x1e9, 16}, {0x1ea, 16}, {0x1eb, 16}, {0x1ec, 16},
1898            {0x1ed, 16}, {0x1ee, 16}, {0x1ef, 16}, {0x1f0, 16},
1899            {0x1f1, 16}, {0x1f2, 16}, {0x1f3, 16}, {0x1f4, 16},
1900            {0x1f5, 16}, {0x1f6, 16}, {0x1f7, 16}, {0x1f8, 16},
1901            {0x1f9, 16}, {0x1fa, 16}, {0x1fb, 16}, {0x1fc, 16},
1902            {0x1fd, 16}, {0x1fe, 16}, {0x1ff, 16},
1903    };
1904    
1905    
1906    const VLC mb_motion_table[65] = {
1907            {0x05, 13}, {0x07, 13}, {0x05, 12}, {0x07, 12},
1908            {0x09, 12}, {0x0b, 12}, {0x0d, 12}, {0x0f, 12},
1909            {0x09, 11}, {0x0b, 11}, {0x0d, 11}, {0x0f, 11},
1910            {0x11, 11}, {0x13, 11}, {0x15, 11}, {0x17, 11},
1911            {0x19, 11}, {0x1b, 11}, {0x1d, 11}, {0x1f, 11},
1912            {0x21, 11}, {0x23, 11}, {0x13, 10}, {0x15, 10},
1913            {0x17, 10}, {0x07, 8}, {0x09, 8}, {0x0b, 8},
1914            {0x07, 7}, {0x03, 5}, {0x03, 4}, {0x03, 3},
1915            {0x01, 1}, {0x02, 3}, {0x02, 4}, {0x02, 5},
1916            {0x06, 7}, {0x0a, 8}, {0x08, 8}, {0x06, 8},
1917            {0x16, 10}, {0x14, 10}, {0x12, 10}, {0x22, 11},
1918            {0x20, 11}, {0x1e, 11}, {0x1c, 11}, {0x1a, 11},
1919            {0x18, 11}, {0x16, 11}, {0x14, 11}, {0x12, 11},
1920            {0x10, 11}, {0x0e, 11}, {0x0c, 11}, {0x0a, 11},
1921            {0x08, 11}, {0x0e, 12}, {0x0c, 12}, {0x0a, 12},
1922            {0x08, 12}, {0x06, 12}, {0x04, 12}, {0x06, 13},
1923            {0x04, 13}
1924    };
1925    
1926    
1927    /******************************************************************
1928     * decoder tables                                                 *
1929     ******************************************************************/
1930    
1931    VLC const mcbpc_intra_table[64] = {
1932            {-1, 0}, {20, 6}, {36, 6}, {52, 6}, {4, 4},  {4, 4},  {4, 4},  {4, 4},
1933            {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3},
1934            {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3},
1935            {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3},
1936            {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},
1937            {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},
1938            {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},
1939            {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1}
1940    };
1941    
1942    VLC const mcbpc_inter_table[257] = {
1943            {VLC_ERROR, 0}, {255, 9}, {52, 9}, {36, 9}, {20, 9}, {49, 9}, {35, 8}, {35, 8},
1944            {19, 8}, {19, 8}, {50, 8}, {50, 8}, {51, 7}, {51, 7}, {51, 7}, {51, 7},
1945            {34, 7}, {34, 7}, {34, 7}, {34, 7}, {18, 7}, {18, 7}, {18, 7}, {18, 7},
1946            {33, 7}, {33, 7}, {33, 7}, {33, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
1947            {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6},
1948            {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6},
1949            {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5},
1950            {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5},
1951            {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4},
1952            {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4},
1953            {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4},
1954            {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4},
1955            {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
1956            {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
1957            {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
1958            {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
1959            {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
1960            {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
1961            {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
1962            {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
1963            {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
1964            {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
1965            {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
1966            {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
1967            {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
1968            {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
1969            {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
1970            {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
1971            {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
1972            {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
1973            {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
1974            {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
1975            {0, 1}
1976    };
1977    
1978    VLC const cbpy_table[64] = {
1979            {-1, 0}, {-1, 0}, {6, 6},  {9, 6},  {8, 5},  {8, 5},  {4, 5},  {4, 5},
1980            {2, 5},  {2, 5},  {1, 5},  {1, 5},  {0, 4},  {0, 4},  {0, 4},  {0, 4},
1981            {12, 4}, {12, 4}, {12, 4}, {12, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4},
1982            {14, 4}, {14, 4}, {14, 4}, {14, 4}, {5, 4},  {5, 4},  {5, 4},  {5, 4},
1983            {13, 4}, {13, 4}, {13, 4}, {13, 4}, {3, 4},  {3, 4},  {3, 4},  {3, 4},
1984            {11, 4}, {11, 4}, {11, 4}, {11, 4}, {7, 4},  {7, 4},  {7, 4},  {7, 4},
1985            {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2},
1986            {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}
1987    };
1988    
1989    VLC const TMNMVtab0[] = {
1990            {3, 4}, {-3, 4}, {2, 3}, {2, 3}, {-2, 3}, {-2, 3}, {1, 2},
1991            {1, 2}, {1, 2}, {1, 2}, {-1, 2}, {-1, 2}, {-1, 2}, {-1, 2}
1992    };
1993    
1994    VLC const TMNMVtab1[] = {
1995            {12, 10}, {-12, 10}, {11, 10}, {-11, 10},
1996            {10, 9}, {10, 9}, {-10, 9}, {-10, 9},
1997            {9, 9}, {9, 9}, {-9, 9}, {-9, 9},
1998            {8, 9}, {8, 9}, {-8, 9}, {-8, 9},
1999            {7, 7}, {7, 7}, {7, 7}, {7, 7},
2000            {7, 7}, {7, 7}, {7, 7}, {7, 7},
2001            {-7, 7}, {-7, 7}, {-7, 7}, {-7, 7},
2002            {-7, 7}, {-7, 7}, {-7, 7}, {-7, 7},
2003            {6, 7}, {6, 7}, {6, 7}, {6, 7},
2004            {6, 7}, {6, 7}, {6, 7}, {6, 7},
2005            {-6, 7}, {-6, 7}, {-6, 7}, {-6, 7},
2006            {-6, 7}, {-6, 7}, {-6, 7}, {-6, 7},
2007            {5, 7}, {5, 7}, {5, 7}, {5, 7},
2008            {5, 7}, {5, 7}, {5, 7}, {5, 7},
2009            {-5, 7}, {-5, 7}, {-5, 7}, {-5, 7},
2010            {-5, 7}, {-5, 7}, {-5, 7}, {-5, 7},
2011            {4, 6}, {4, 6}, {4, 6}, {4, 6},
2012            {4, 6}, {4, 6}, {4, 6}, {4, 6},
2013            {4, 6}, {4, 6}, {4, 6}, {4, 6},
2014            {4, 6}, {4, 6}, {4, 6}, {4, 6},
2015            {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6},
2016            {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6},
2017            {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6},
2018            {-4, 6}, {-4, 6}, {-4, 6}, {-4, 6}
2019    };
2020    
2021    VLC const TMNMVtab2[] = {
2022            {32, 12}, {-32, 12}, {31, 12}, {-31, 12},
2023            {30, 11}, {30, 11}, {-30, 11}, {-30, 11},
2024            {29, 11}, {29, 11}, {-29, 11}, {-29, 11},
2025            {28, 11}, {28, 11}, {-28, 11}, {-28, 11},
2026            {27, 11}, {27, 11}, {-27, 11}, {-27, 11},
2027            {26, 11}, {26, 11}, {-26, 11}, {-26, 11},
2028            {25, 11}, {25, 11}, {-25, 11}, {-25, 11},
2029            {24, 10}, {24, 10}, {24, 10}, {24, 10},
2030            {-24, 10}, {-24, 10}, {-24, 10}, {-24, 10},
2031            {23, 10}, {23, 10}, {23, 10}, {23, 10},
2032            {-23, 10}, {-23, 10}, {-23, 10}, {-23, 10},
2033            {22, 10}, {22, 10}, {22, 10}, {22, 10},
2034            {-22, 10}, {-22, 10}, {-22, 10}, {-22, 10},
2035            {21, 10}, {21, 10}, {21, 10}, {21, 10},
2036            {-21, 10}, {-21, 10}, {-21, 10}, {-21, 10},
2037            {20, 10}, {20, 10}, {20, 10}, {20, 10},
2038            {-20, 10}, {-20, 10}, {-20, 10}, {-20, 10},
2039            {19, 10}, {19, 10}, {19, 10}, {19, 10},
2040            {-19, 10}, {-19, 10}, {-19, 10}, {-19, 10},
2041            {18, 10}, {18, 10}, {18, 10}, {18, 10},
2042            {-18, 10}, {-18, 10}, {-18, 10}, {-18, 10},
2043            {17, 10}, {17, 10}, {17, 10}, {17, 10},
2044            {-17, 10}, {-17, 10}, {-17, 10}, {-17, 10},
2045            {16, 10}, {16, 10}, {16, 10}, {16, 10},
2046            {-16, 10}, {-16, 10}, {-16, 10}, {-16, 10},
2047            {15, 10}, {15, 10}, {15, 10}, {15, 10},
2048            {-15, 10}, {-15, 10}, {-15, 10}, {-15, 10},
2049            {14, 10}, {14, 10}, {14, 10}, {14, 10},
2050            {-14, 10}, {-14, 10}, {-14, 10}, {-14, 10},
2051            {13, 10}, {13, 10}, {13, 10}, {13, 10},
2052            {-13, 10}, {-13, 10}, {-13, 10}, {-13, 10}
2053    };
2054    
2055    short const dc_threshold[] = {
2056            21514, 26984,  8307, 28531, 29798, 24951, 25970, 26912,
2057             8307, 25956, 26994, 25974,  8292, 29286, 28015, 29728,
2058            25960, 18208, 21838, 18208, 19536, 22560, 26998,  8260,
2059            28515, 25956,  8291, 25640, 30309, 27749, 11817, 22794,
2060            30063,  8306, 28531, 29798, 24951, 25970, 25632, 29545,
2061            29300, 25193, 29813, 29295, 26656, 29537, 29728,  8303,
2062            26983, 25974, 24864, 25443, 29541,  8307, 28532, 26912,
2063            29556, 29472, 30063, 25458,  8293, 28515, 25956,  2606
2064    };
2065    
2066    VLC const dc_lum_tab[] = {
2067            {0, 0}, {4, 3}, {3, 3}, {0, 3},
2068            {2, 2}, {2, 2}, {1, 2}, {1, 2},
2069    };

Legend:
Removed from v.1.39  
changed lines
  Added in v.1.44.2.11

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4