[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.44, Fri Feb 21 08:32:34 2003 UTC revision 1.44.2.5, Thu Apr 10 13:05:54 2003 UTC
# Line 498  Line 498 
498          {          {
499                  if ((level = qcoeff[zigzag[i++]]) != 0)                  if ((level = qcoeff[zigzag[i++]]) != 0)
500                  {                  {
501                          abs_level = ABS(prev_level);                          abs_level = abs(prev_level);
502                          abs_level = abs_level < 64 ? abs_level : 0;                          abs_level = abs_level < 64 ? abs_level : 0;
503                          code      = coeff_VLC[1][0][abs_level][prev_run].code;                          code      = coeff_VLC[1][0][abs_level][prev_run].code;
504                          len               = coeff_VLC[1][0][abs_level][prev_run].len;                          len               = coeff_VLC[1][0][abs_level][prev_run].len;
# Line 518  Line 518 
518                          run++;                          run++;
519          }          }
520    
521          abs_level = ABS(prev_level);          abs_level = abs(prev_level);
522          abs_level = abs_level < 64 ? abs_level : 0;          abs_level = abs_level < 64 ? abs_level : 0;
523          code      = coeff_VLC[1][1][abs_level][prev_run].code;          code      = coeff_VLC[1][1][abs_level][prev_run].code;
524          len               = coeff_VLC[1][1][abs_level][prev_run].len;          len               = coeff_VLC[1][1][abs_level][prev_run].len;
# Line 559  Line 559 
559          {          {
560                  if ((level = qcoeff[zigzag[i++]]) != 0)                  if ((level = qcoeff[zigzag[i++]]) != 0)
561                  {                  {
562                          abs_level = ABS(prev_level);                          abs_level = abs(prev_level);
563                          abs_level = abs_level < 64 ? abs_level : 0;                          abs_level = abs_level < 64 ? abs_level : 0;
564                          len               = coeff_VLC[1][0][abs_level][prev_run].len;                          len               = coeff_VLC[1][0][abs_level][prev_run].len;
565                          bits      += len!=128 ? len : 30;                          bits      += len!=128 ? len : 30;
# Line 572  Line 572 
572                          run++;                          run++;
573          }          }
574    
575          abs_level = ABS(prev_level);          abs_level = abs(prev_level);
576          abs_level = abs_level < 64 ? abs_level : 0;          abs_level = abs_level < 64 ? abs_level : 0;
577          len               = coeff_VLC[1][1][abs_level][prev_run].len;          len               = coeff_VLC[1][1][abs_level][prev_run].len;
578          bits      += len!=128 ? len : 30;          bits      += len!=128 ? len : 30;
# Line 627  Line 627 
627    
628  #endif  #endif
629    
630    
631    static int iDQtab[5] = {
632            1, 0, -1 /* no change */, 2, 3
633    };
634    #define DQ_VALUE2INDEX(value)  iDQtab[(value)+2]
635    
636    
637  static __inline void  static __inline void
638  CodeBlockIntra(const FRAMEINFO * const frame,  CodeBlockIntra(const FRAMEINFO * const frame,
639                             const MACROBLOCK * pMB,                             const MACROBLOCK * pMB,
# Line 657  Line 664 
664                  BitstreamPutBits(bs, 0, 1);                  BitstreamPutBits(bs, 0, 1);
665    
666          // write cbpy          // write cbpy
667          BitstreamPutBits(bs, cbpy_tab[cbpy].code, cbpy_tab[cbpy].len);          BitstreamPutBits(bs, xvid_cbpy_tab[cbpy].code, xvid_cbpy_tab[cbpy].len);
668    
669          // write dquant          // write dquant
670          if (pMB->mode == MODE_INTRA_Q)          if (pMB->mode == MODE_INTRA_Q)
671                  BitstreamPutBits(bs, pMB->dquant, 2);                  BitstreamPutBits(bs, DQ_VALUE2INDEX(pMB->dquant), 2);
672    
673          // write interlacing          // write interlacing
674          if (frame->global_flags & XVID_INTERLACING) {          if (frame->vol_flags & XVID_VOL_INTERLACING) {
675                  BitstreamPutBit(bs, pMB->field_dct);                  BitstreamPutBit(bs, pMB->field_dct);
676          }          }
677          // code block coeffs          // code block coeffs
# Line 678  Line 685 
685    
686                  if (pMB->cbp & (1 << (5 - i))) {                  if (pMB->cbp & (1 << (5 - i))) {
687                          const uint16_t *scan_table =                          const uint16_t *scan_table =
688                                  frame->global_flags & XVID_ALTERNATESCAN ?                                  frame->vop_flags & XVID_VOP_ALTERNATESCAN ?
689                                  scan_tables[2] : scan_tables[pMB->acpred_directions[i]];                                  scan_tables[2] : scan_tables[pMB->acpred_directions[i]];
690    
691                          bits = BitstreamPos(bs);                          bits = BitstreamPos(bs);
# Line 719  Line 726 
726                  BitstreamPutBit(bs, pMB->mcsel);                // mcsel: '0'=local motion, '1'=GMC                  BitstreamPutBit(bs, pMB->mcsel);                // mcsel: '0'=local motion, '1'=GMC
727    
728          // write cbpy          // write cbpy
729          BitstreamPutBits(bs, cbpy_tab[cbpy].code, cbpy_tab[cbpy].len);          BitstreamPutBits(bs, xvid_cbpy_tab[cbpy].code, xvid_cbpy_tab[cbpy].len);
730    
731          // write dquant          // write dquant
732          if (pMB->mode == MODE_INTER_Q)          if (pMB->mode == MODE_INTER_Q)
733                  BitstreamPutBits(bs, pMB->dquant, 2);                  BitstreamPutBits(bs, DQ_VALUE2INDEX(pMB->dquant), 2);
734    
735          // interlacing          // interlacing
736          if (frame->global_flags & XVID_INTERLACING) {          if (frame->vol_flags & XVID_VOL_INTERLACING) {
737                  if (pMB->cbp) {                  if (pMB->cbp) {
738                          BitstreamPutBit(bs, pMB->field_dct);                          BitstreamPutBit(bs, pMB->field_dct);
739                          DPRINTF(DPRINTF_MB,"codep: field_dct: %i", pMB->field_dct);                          DPRINTF(DPRINTF_MB,"codep: field_dct: %i", pMB->field_dct);
# Line 758  Line 765 
765                  if (pMB->cbp & (1 << (5 - i)))                  if (pMB->cbp & (1 << (5 - i)))
766                  {                  {
767                          const uint16_t *scan_table =                          const uint16_t *scan_table =
768                                  frame->global_flags & XVID_ALTERNATESCAN ?                                  frame->vop_flags & XVID_VOP_ALTERNATESCAN ?
769                                  scan_tables[2] : scan_tables[0];                                  scan_tables[2] : scan_tables[0];
770    
771  #ifdef BIGLUT  #ifdef BIGLUT
# Line 1052  Line 1059 
1059                  return data;                  return data;
1060    
1061          res = BitstreamGetBits(bs, fcode - 1);          res = BitstreamGetBits(bs, fcode - 1);
1062          mv = ((ABS(data) - 1) * scale_fac) + res + 1;          mv = ((abs(data) - 1) * scale_fac) + res + 1;
1063    
1064          return data < 0 ? -mv : mv;          return data < 0 ? -mv : mv;
1065    
# Line 1618  Line 1625 
1625          {5, 6}, {5, 9}, {5, 8}, {3, 7}, {2, 9}          {5, 6}, {5, 9}, {5, 8}, {3, 7}, {2, 9}
1626  };  };
1627    
1628  const VLC cbpy_tab[16] = {  const VLC xvid_cbpy_tab[16] = {
1629          {3, 4}, {5, 5}, {4, 5}, {9, 4}, {3, 5}, {7, 4}, {2, 6}, {11, 4},          {3, 4}, {5, 5}, {4, 5}, {9, 4}, {3, 5}, {7, 4}, {2, 6}, {11, 4},
1630          {2, 5}, {3, 6}, {5, 4}, {10, 4}, {4, 4}, {8, 4}, {6, 4}, {3, 2}          {2, 5}, {3, 6}, {5, 4}, {10, 4}, {4, 4}, {8, 4}, {6, 4}, {3, 2}
1631  };  };

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.44.2.5

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