[svn] / branches / release-1_3-branch / xvidcore / src / bitstream / mbcoding.c Repository:
ViewVC logotype

Diff of /branches/release-1_3-branch/xvidcore/src/bitstream/mbcoding.c

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

revision 152, Wed May 1 13:00:02 2002 UTC revision 153, Thu May 2 00:36:50 2002 UTC
# Line 29  Line 29 
29    
30   /******************************************************************************   /******************************************************************************
31    *                                                                            *    *                                                                            *
32    *  bitstream.c                                                               *    *  mbcoding.c                                                                *
33    *                                                                            *    *                                                                            *
34    *  Copyright (C) 2001 - Peter Ross <pross@cs.rmit.edu.au>                    *    *  Copyright (C) 2002 - Michael Militzer <isibaar@xvid.org>                  *
35    *                                                                            *    *                                                                            *
36    *  For more information visit the XviD homepage: http://www.xvid.org         *    *  For more information visit the XviD homepage: http://www.xvid.org         *
37    *                                                                            *    *                                                                            *
# Line 41  Line 41 
41    *                                                                                                                                                        *    *                                                                                                                                                        *
42    *  Revision history:                                                         *    *  Revision history:                                                         *
43    *                                                                            *    *                                                                            *
44    *  14.04.2002 bframe encoding    *  14.04.2002 bframe encoding                                                                                            *
45    *  08.03.2002 initial version; isibaar                                                           *    *  08.03.2002 initial version; isibaar                                                           *
46    *                                                                                                                                                        *    *                                                                                                                                                        *
47    ******************************************************************************/    ******************************************************************************/
# Line 60  Line 60 
60  #define ABS(X) (((X)>0)?(X):-(X))  #define ABS(X) (((X)>0)?(X):-(X))
61  #define CLIP(X,A) (X > A) ? (A) : (X)  #define CLIP(X,A) (X > A) ? (A) : (X)
62    
63  VLC intra_table[65536];  VLC intra_table[524032];
64  VLC inter_table[65536];  VLC inter_table[524032];
65    
66  VLC DCT3Dintra[4096];  VLC DCT3Dintra[4096];
67  VLC DCT3Dinter[4096];  VLC DCT3Dinter[4096];
68    
 static int16_t clip_table[4096];  
   
69  void init_vlc_tables(void)  void init_vlc_tables(void)
70  {  {
71    
# Line 82  Line 80 
80          vlc[0] = intra_table;          vlc[0] = intra_table;
81          vlc[1] = inter_table;          vlc[1] = inter_table;
82    
         // initialize the clipping table  
         for(i = -2048; i < 2048; i++) {  
                 clip_table[i + 2048] = i;  
                 if(i < -255)  
                         clip_table[i + 2048] = -255;  
                 if(i > 255)  
                         clip_table[i + 2048] = 255;  
         }  
   
83          // generate encoding vlc lookup tables          // generate encoding vlc lookup tables
84            // the lookup table idea is taken from the excellent fame project by Vivien Chapellier
85          for(i = 0; i < 4; i++) {          for(i = 0; i < 4; i++) {
86                  intra = i % 2;                  intra = i % 2;
87                  last = i / 2;                  last = i / 2;
88    
89                  coeff_ptr = coeff_vlc[last + 2 * intra];                  coeff_ptr = coeff_vlc[last + 2 * intra];
90    
91                  for(k = -255; k < 256; k++) { // level                  for(k = -2047; k < 2048; k++) { // level
92                          int8_t *max_level_ptr = max_level[last + 2 * intra];                          int8_t *max_level_ptr = max_level[last + 2 * intra];
93                          int8_t *max_run_ptr = max_run[last + 2 * intra];                          int8_t *max_run_ptr = max_run[last + 2 * intra];
94    
# Line 259  Line 249 
249          j = intra;          j = intra;
250          last = intra;          last = intra;
251    
252          while((v = qcoeff[zigzag[j]]) == 0) j++;          while(j < 64 && (v = qcoeff[zigzag[j]]) == 0) j++;
253    
254          do {          do {
255                  // count zeroes                  vlc = table + 64 * 2047 + (v << 6) + j - last;
                 vlc = table + 64*255 + (clip_table[2048+v] << 6) + j - last;  
256                  last = ++j;                  last = ++j;
257    
258                    // count zeroes
259                  while(j < 64 && (v = qcoeff[zigzag[j]]) == 0) j++;                  while(j < 64 && (v = qcoeff[zigzag[j]]) == 0) j++;
260    
261                  // write code                  // write code
262                  if(j != 64) {                  if(j != 64) {
263                          BitstreamPutBits(bs, vlc->code, vlc->len);                          BitstreamPutBits(bs, vlc->code, vlc->len);
264                  } else {                  } else {
265                          vlc += 64*511;                          vlc += 64 * 4095;
266                          BitstreamPutBits(bs, vlc->code, vlc->len);                          BitstreamPutBits(bs, vlc->code, vlc->len);
267                          break;                          break;
268                  }                  }

Legend:
Removed from v.152  
changed lines
  Added in v.153

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