[svn] / branches / dev-api-3 / xvidcore / src / bitstream / mbcoding.c Repository:
ViewVC logotype

Diff of /branches/dev-api-3/xvidcore/src/bitstream/mbcoding.c

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

revision 820, Sat Feb 8 03:53:08 2003 UTC revision 821, Sun Feb 9 06:33:52 2003 UTC
# Line 72  Line 72 
72    
73  #ifdef BIGLUT  #ifdef BIGLUT
74  static VLC coeff_VLC[2][2][4096][64];  static VLC coeff_VLC[2][2][4096][64];
75  static VLC *intra_table, *inter_table;  VLC *intra_table;
76    static VLC *inter_table;
77  #else  #else
78  static VLC coeff_VLC[2][2][64][64];  static VLC coeff_VLC[2][2][64][64];
79  #endif  #endif
# Line 373  Line 374 
374    
375  }  }
376    
377    
378    
379    /* returns the number of bits required to encode qcoeff */
380    int
381    CodeCoeff_CalcBits(const int16_t qcoeff[64],
382                      VLC * table,
383                      const uint16_t * zigzag,
384                      uint16_t intra)
385    {
386            int bits = 0;
387            uint32_t j, last;
388            short v;
389            VLC *vlc;
390    
391            j = intra;
392            last = intra;
393    
394            while (j < 64 && (v = qcoeff[zigzag[j]]) == 0)
395                    j++;
396    
397            if (j >= 64) return 0;  /* empty block */
398    
399            do {
400                    vlc = table + 64 * 2048 + (v << 6) + j - last;
401                    last = ++j;
402    
403                    /* count zeroes */
404                    while (j < 64 && (v = qcoeff[zigzag[j]]) == 0)
405                            j++;
406    
407                    /* write code */
408                    if (j != 64) {
409                            bits += vlc->len;
410                    } else {
411                            vlc += 64 * 4096;
412                            bits += vlc->len;
413                            break;
414                    }
415            } while (1);
416    
417            return bits;
418    }
419    
420    
421  #else  #else
422    
423  static __inline void  static __inline void
# Line 442  Line 487 
487          i       = 1;          i       = 1;
488          run = 0;          run = 0;
489    
490          while (!(level = qcoeff[zigzag[i++]]))          while (i<64 && !(level = qcoeff[zigzag[i++]]))
491                  run++;                  run++;
492    
493          prev_level = level;          prev_level = level;
# Line 487  Line 532 
532          BitstreamPutBits(bs, code, len);          BitstreamPutBits(bs, code, len);
533  }  }
534    
535    
536    
537    /* returns the number of bits required to encode qcoeff */
538    
539    int
540    CodeCoeffIntra_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag)
541    {
542            int bits = 0;
543            uint32_t i, abs_level, run, prev_run, len;
544            int32_t level, prev_level;
545    
546            i       = 1;
547            run = 0;
548    
549            while (i<64 && !(level = qcoeff[zigzag[i++]]))
550                    run++;
551    
552            if (i >= 64) return 0;  /* empty block */
553    
554            prev_level = level;
555            prev_run   = run;
556            run = 0;
557    
558            while (i < 64)
559            {
560                    if ((level = qcoeff[zigzag[i++]]) != 0)
561                    {
562                            abs_level = ABS(prev_level);
563                            abs_level = abs_level < 64 ? abs_level : 0;
564                            len               = coeff_VLC[1][0][abs_level][prev_run].len;
565                            bits      += len!=128 ? len : 30;
566    
567                            prev_level = level;
568                            prev_run   = run;
569                            run = 0;
570                    }
571                    else
572                            run++;
573            }
574    
575            abs_level = ABS(prev_level);
576            abs_level = abs_level < 64 ? abs_level : 0;
577            len               = coeff_VLC[1][1][abs_level][prev_run].len;
578            bits      += len!=128 ? len : 30;
579    
580            return bits;
581    }
582    
583    
584  #endif  #endif
585    
586  static __inline void  static __inline void

Legend:
Removed from v.820  
changed lines
  Added in v.821

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