[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.36, Sat Jan 4 04:28:48 2003 UTC revision 1.37, Sun Jan 5 16:54:36 2003 UTC
# Line 66  Line 66 
66  #define ABS(X) (((X)>0)?(X):-(X))  #define ABS(X) (((X)>0)?(X):-(X))
67  #define CLIP(X,A) (X > A) ? (A) : (X)  #define CLIP(X,A) (X > A) ? (A) : (X)
68    
69    /*#define _BIGLUT_*/
70    
71    #ifdef _BIGLUT_
72    #define LEVELOFFSET 2048
73    #else
74    #define LEVELOFFSET 32
75    #endif
76    
77  /*****************************************************************************  /*****************************************************************************
78   * Local data   * Local data
79   ****************************************************************************/   ****************************************************************************/
80    
81  /* msvc sp5+pp gets confused if they globals are made static */  static REVERSE_EVENT DCT3D[2][4096];
 static VLC intra_table[524288];  
 static VLC inter_table[524288];  
82    
83  static VLC DCT3Dintra[4096];  #ifdef _BIGLUT_
84  static VLC DCT3Dinter[4096];  static VLC coeff_VLC[2][2][4096][64];
85    VLC *intra_table, *inter_table;
86    #else
87    static VLC coeff_VLC[2][2][64][64];
88    #endif
89    
90  /*****************************************************************************  /*****************************************************************************
91   * Vector Length Coding Initialization   * Vector Length Coding Initialization
# Line 84  Line 94 
94  void  void
95  init_vlc_tables(void)  init_vlc_tables(void)
96  {  {
97            uint32_t i, j, intra, last, run, offset;
98            int32_t level;
99            VLC coeff_VLC_temp[2][2][64][64];
100    
101          int32_t k, l, i, intra, last;  #ifdef _BIGLUT_
102          VLC *vlc[2];          intra_table = coeff_VLC[1];
103          VLC const **coeff_ptr;          inter_table = coeff_VLC[0];
104          VLC *vlc1, *vlc2;  #endif
   
         vlc1 = DCT3Dintra;  
         vlc2 = DCT3Dinter;  
   
         vlc[0] = intra_table;  
         vlc[1] = inter_table;  
   
         /*  
          * Generate encoding vlc lookup tables  
          * the lookup table idea is taken from the excellent fame project  
          * by Vivien Chapellier  
          */  
         for (i = 0; i < 4; i++) {  
                 intra = i % 2;  
                 last = i / 2;  
   
                 coeff_ptr = coeff_vlc[last + 2 * intra];  
   
                 for (k = -2047; k < 2048; k++) {        /* level */  
                         int8_t const *max_level_ptr = max_level[last + 2 * intra];  
                         int8_t const *max_run_ptr = max_run[last + 2 * intra];  
   
                         for (l = 0; l < 64; l++) {      /* run */  
                                 int32_t level = k;  
                                 ptr_t run = l;  
   
                                 if ((abs(level) <= max_level_ptr[run]) && (run <= (uint32_t) max_run_ptr[abs(level)])) {        /* level < max_level and run < max_run */  
105    
                                         vlc[intra]->code = 0;  
                                         vlc[intra]->len = 0;  
                                         goto loop_end;  
                                 } else {  
                                         if (level > 0)  /* correct level */  
                                                 level -= max_level_ptr[run];  
                                         else  
                                                 level += max_level_ptr[run];  
106    
107                                          if ((abs(level) <= max_level_ptr[run]) &&          for (intra = 0; intra < 2; intra++)
108                                                  (run <= (uint32_t) max_run_ptr[abs(level)])) {                  for (i = 0; i < 4096; i++)
109                            DCT3D[intra][i].event.level = 0;
110    
111                                                  vlc[intra]->code = 0x06;          for (intra = 0; intra < 2; intra++)
112                                                  vlc[intra]->len = 8;                  for (last = 0; last < 2; last++)
113                                                  goto loop_end;                  {
114                            for (run = 0; run < 63 + last; run++)
115                                    for (level = 0; level < 32 << intra; level++)
116                                    {
117    #ifdef _BIGLUT_
118                                            offset = LEVELOFFSET;
119    #else
120                                            offset = !intra * LEVELOFFSET;
121    #endif
122                                            coeff_VLC_temp[intra][last][level][run].len             = 128;
123                                            coeff_VLC[intra][last][level + offset][run].len = 128;
124                                    }
125                                          }                                          }
126    
127                                          if (level > 0)  /* still here? */          for (intra = 0; intra < 2; intra++)
128                                                  level += max_level_ptr[run];    /* restore level */                  for (i = 0; i < 102; i++)
129                                          else                  {
130                                                  level -= max_level_ptr[run];  #ifdef _BIGLUT_
131                            offset = LEVELOFFSET;
132                                          run -= max_run_ptr[abs(level)] + 1;     /* and change run */  #else
133                            offset = !intra * LEVELOFFSET;
134    #endif
135                            for (j = 0; j < 1 << (12 - coeff_tab[intra][i].vlc.len); j++)
136                            {
137                                    DCT3D[intra][(coeff_tab[intra][i].vlc.code << (12 - coeff_tab[intra][i].vlc.len)) | j].len       = coeff_tab[intra][i].vlc.len;
138                                    DCT3D[intra][(coeff_tab[intra][i].vlc.code << (12 - coeff_tab[intra][i].vlc.len)) | j].event = coeff_tab[intra][i].event;
139                            }
140    
141                                          if ((abs(level) <= max_level_ptr[run]) &&                          coeff_VLC_temp[intra][coeff_tab[intra][i].event.last][coeff_tab[intra][i].event.level][coeff_tab[intra][i].event.run].code
142                                                  (run <= (uint32_t) max_run_ptr[abs(level)])) {                                  = coeff_tab[intra][i].vlc.code << 1;
143                            coeff_VLC_temp[intra][coeff_tab[intra][i].event.last][coeff_tab[intra][i].event.level][coeff_tab[intra][i].event.run].len
144                                    = coeff_tab[intra][i].vlc.len + 1;
145    
146                                                  vlc[intra]->code = 0x0e;                          coeff_VLC[intra][coeff_tab[intra][i].event.last][coeff_tab[intra][i].event.level + offset][coeff_tab[intra][i].event.run].code
147                                                  vlc[intra]->len = 9;                                  = coeff_tab[intra][i].vlc.code << 1;
148                                                  goto loop_end;                          coeff_VLC[intra][coeff_tab[intra][i].event.last][coeff_tab[intra][i].event.level + offset][coeff_tab[intra][i].event.run].len
149                                    = coeff_tab[intra][i].vlc.len + 1;
150    #ifndef _BIGLUT_
151                            if (!intra)
152    #endif
153                            {
154                                    coeff_VLC[intra][coeff_tab[intra][i].event.last][offset - coeff_tab[intra][i].event.level][coeff_tab[intra][i].event.run].code
155                                            = (coeff_tab[intra][i].vlc.code << 1) | 1;
156                                    coeff_VLC[intra][coeff_tab[intra][i].event.last][offset - coeff_tab[intra][i].event.level][coeff_tab[intra][i].event.run].len
157                                            = coeff_tab[intra][i].vlc.len + 1;
158                                          }                                          }
                                         run += max_run_ptr[abs(level)] + 1;  
159                                  }                                  }
160    
161                                  vlc[intra]->code =          for (intra = 0; intra < 2; intra++)
162                                          (uint32_t) ((l << 14) | (0x1e + last) << 20) | (1 << 13) |                  for (last = 0; last < 2; last++)
163                                          ((k & 0xfff) << 1) | 1;                          for (run = 0; run < 63 + last; run++)
164                            {
165                                  vlc[intra]->len = 30;                                  for (level = 1; level < 32 << intra; level++)
166                                  vlc[intra]++;                                  {
167                                  continue;  #ifdef _BIGLUT_
168                                            offset = LEVELOFFSET;
169                            loop_end:  #else
170                                  if (level != 0) {                                          offset = !intra * LEVELOFFSET;
171                                          vlc[intra]->code =  #endif
172                                                  (vlc[intra]->                                          if ((max_level[intra][last][run]) && (level > max_level[intra][last][run]))
173                                                   code << (coeff_ptr[run][abs(level) - 1].len +                                                  if (coeff_VLC_temp[intra][last][level - max_level[intra][last][run]][run].len != 128
174                                                                    1)) | (coeff_ptr[run][abs(level) -                                                          && coeff_VLC[intra][last][level + offset][run].len == 128)
175                                                                                                                  1].code << 1);                                                  {
176                                          vlc[intra]->len =                                                          coeff_VLC[intra][last][level + offset][run].code
177                                                  (coeff_ptr[run][abs(level) - 1].len + 1) +                                                                  = (ESCAPE1 << coeff_VLC_temp[intra][last][level - max_level[intra][last][run]][run].len)
178                                                  vlc[intra]->len;                                                                  |  coeff_VLC_temp[intra][last][level - max_level[intra][last][run]][run].code;
179                                                            coeff_VLC[intra][last][level + offset][run].len
180                                          if (level < 0)                                                                  = coeff_VLC_temp[intra][last][level - max_level[intra][last][run]][run].len + 7 + 1;
181                                                  vlc[intra]->code += 1;  #ifndef _BIGLUT_
182                                                            if (!intra)
183    #endif
184                                                            {
185                                                                    coeff_VLC[intra][last][offset - level][run].code
186                                                                            = (ESCAPE1 << coeff_VLC_temp[intra][last][level - max_level[intra][last][run]][run].len)
187                                                                            |  coeff_VLC_temp[intra][last][level - max_level[intra][last][run]][run].code | 1;
188                                                                    coeff_VLC[intra][last][offset - level][run].len
189                                                                            = coeff_VLC_temp[intra][last][level - max_level[intra][last][run]][run].len + 7 + 1;
190                                                            }
191                                                    }
192                                            if (run > max_run[intra][last][level])
193                                                    if (coeff_VLC_temp[intra][last][level][run - 1 - max_run[intra][last][level]].len != 128
194                                                            && coeff_VLC[intra][last][level + offset][run].len == 128)
195                                                    /*use the lower test instead of the upper to use shorter escape codes when possible :
196                                                    if (coeff_VLC_temp[intra][last][level][run - 1 - max_run[intra][last][level]].len + 7 + 2
197                                                            < coeff_VLC[intra][last][level + offset][run].len)*/
198                                                    {
199                                                            coeff_VLC[intra][last][level + offset][run].code
200                                                                    = (ESCAPE2 << coeff_VLC_temp[intra][last][level][run - 1 - max_run[intra][last][level]].len)
201                                                                    |  coeff_VLC_temp[intra][last][level][run - 1 - max_run[intra][last][level]].code;
202                                                            coeff_VLC[intra][last][level + offset][run].len
203                                                                    = coeff_VLC_temp[intra][last][level][run - 1 - max_run[intra][last][level]].len + 7 + 2;
204    #ifndef _BIGLUT_
205                                                            if (!intra)
206    #endif
207                                                            {
208                                                                    coeff_VLC[intra][last][offset - level][run].code
209                                                                            = (ESCAPE2 << coeff_VLC_temp[intra][last][level][run - 1 - max_run[intra][last][level]].len)
210                                                                            |  coeff_VLC_temp[intra][last][level][run - 1 - max_run[intra][last][level]].code | 1;
211                                                                    coeff_VLC[intra][last][offset - level][run].len
212                                                                            = coeff_VLC_temp[intra][last][level][run - 1 - max_run[intra][last][level]].len + 7 + 2;
213                                  }                                  }
   
                                 vlc[intra]++;  
214                          }                          }
215    #ifndef _BIGLUT_
216                                            if (!intra)
217    #endif
218                                                    if (coeff_VLC[intra][last][level + offset][run].len == 128)
219                                                    {
220                                                            coeff_VLC[intra][last][level + offset][run].code
221                                                                    = (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((level & 0xfff) << 1) | 1;
222                                                            coeff_VLC[intra][last][level + offset][run].len = 30;
223    
224                                                            coeff_VLC[intra][last][offset - level][run].code
225                                                                    = (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((-level & 0xfff) << 1) | 1;
226                                                            coeff_VLC[intra][last][offset - level][run].len = 30;
227                  }                  }
228          }          }
229    #ifdef _BIGLUT_
230                                    for (level = 32 << intra; level < 2048; level++)
231                                    {
232                                            coeff_VLC[intra][last][level + offset][run].code
233                                                    = (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((level & 0xfff) << 1) | 1;
234                                            coeff_VLC[intra][last][level + offset][run].len = 30;
235    
236          for (i = 0; i < 4096; i++) {                                          coeff_VLC[intra][last][offset - level][run].code
237                  if (i >= 512) {                                                  = (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((-level & 0xfff) << 1) | 1;
238                          *vlc1 = DCT3Dtab3[(i >> 5) - 16];                                          coeff_VLC[intra][last][offset - level][run].len = 30;
                         *vlc2 = DCT3Dtab0[(i >> 5) - 16];  
                 } else if (i >= 128) {  
                         *vlc1 = DCT3Dtab4[(i >> 2) - 32];  
                         *vlc2 = DCT3Dtab1[(i >> 2) - 32];  
                 } else if (i >= 8) {  
                         *vlc1 = DCT3Dtab5[i - 8];  
                         *vlc2 = DCT3Dtab2[i - 8];  
                 } else {  
                         *vlc1 = ERRtab[i];  
                         *vlc2 = ERRtab[i];  
239                  }                  }
240    #else
241                  vlc1++;                                  if (!intra)
242                  vlc2++;                                  {
243                                            coeff_VLC[intra][last][0][run].code
244                                                    = (ESCAPE3 << 21) | (last << 20) | (run << 14) | (1 << 13) | ((-32 & 0xfff) << 1) | 1;
245                                            coeff_VLC[intra][last][0][run].len = 30;
246                                    }
247    #endif
248          }          }
         DCT3D[0] = DCT3Dinter;  
         DCT3D[1] = DCT3Dintra;  
   
249  }  }
250    
251  /*****************************************************************************  /*****************************************************************************
# Line 261  Line 307 
307    
308  }  }
309    
310    #ifdef __BIGLUT_
311    
312  static __inline void  static __inline void
313  CodeCoeff(Bitstream * bs,  CodeCoeff(Bitstream * bs,
314                    const int16_t qcoeff[64],                    const int16_t qcoeff[64],
# Line 280  Line 328 
328                  j++;                  j++;
329    
330          do {          do {
331                  vlc = table + 64 * 2047 + (v << 6) + j - last;                  vlc = table + 64 * 2048 + (v << 6) + j - last;
332                  last = ++j;                  last = ++j;
333    
334                  /* count zeroes */                  /* count zeroes */
# Line 291  Line 339 
339                  if (j != 64) {                  if (j != 64) {
340                          BitstreamPutBits(bs, vlc->code, vlc->len);                          BitstreamPutBits(bs, vlc->code, vlc->len);
341                  } else {                  } else {
342                          vlc += 64 * 4095;                          vlc += 64 * 4096;
343                          BitstreamPutBits(bs, vlc->code, vlc->len);                          BitstreamPutBits(bs, vlc->code, vlc->len);
344                          break;                          break;
345                  }                  }
# Line 299  Line 347 
347    
348  }  }
349    
350    #else
351    
352    static __inline void
353    CodeCoeffInter(Bitstream * bs,
354                      const int16_t qcoeff[64],
355                      const uint16_t * zigzag)
356    {
357            uint32_t i, run, prev_run, code, len;
358            int32_t level, prev_level, level_shifted;
359    
360            i       = 0;
361            run = 0;
362    
363            while (!(level = qcoeff[zigzag[i++]]))
364                    run++;
365    
366            prev_level = level;
367            prev_run   = run;
368            run = 0;
369    
370            while (i < 64)
371            {
372                    if ((level = qcoeff[zigzag[i++]]) != 0)
373                    {
374                            level_shifted = prev_level + 32;
375                            if (!(level_shifted & -64))
376                            {
377                                    code = coeff_VLC[0][0][level_shifted][prev_run].code;
378                                    len      = coeff_VLC[0][0][level_shifted][prev_run].len;
379                            }
380                            else
381                            {
382                                    code = (ESCAPE3 << 21) | (prev_run << 14) | (1 << 13) | ((prev_level & 0xfff) << 1) | 1;
383                                    len  = 30;
384                            }
385                            BitstreamPutBits(bs, code, len);
386                            prev_level = level;
387                            prev_run   = run;
388                            run = 0;
389                    }
390                    else
391                            run++;
392            }
393    
394            level_shifted = prev_level + 32;
395            if (!(level_shifted & -64))
396            {
397                    code = coeff_VLC[0][1][level_shifted][prev_run].code;
398                    len      = coeff_VLC[0][1][level_shifted][prev_run].len;
399            }
400            else
401            {
402                    code = (ESCAPE3 << 21) | (1 << 20) | (prev_run << 14) | (1 << 13) | ((prev_level & 0xfff) << 1) | 1;
403                    len  = 30;
404            }
405            BitstreamPutBits(bs, code, len);
406    }
407    
408    static __inline void
409    CodeCoeffIntra(Bitstream * bs,
410                      const int16_t qcoeff[64],
411                      const uint16_t * zigzag)
412    {
413            uint32_t i, abs_level, run, prev_run, code, len;
414            int32_t level, prev_level;
415    
416            i       = 1;
417            run = 0;
418    
419            while (!(level = qcoeff[zigzag[i++]]))
420                    run++;
421    
422            prev_level = level;
423            prev_run   = run;
424            run = 0;
425    
426            while (i < 64)
427            {
428                    if ((level = qcoeff[zigzag[i++]]) != 0)
429                    {
430                            abs_level = ABS(prev_level);
431                            abs_level = abs_level < 64 ? abs_level : 0;
432                            code      = coeff_VLC[1][0][abs_level][prev_run].code;
433                            len               = coeff_VLC[1][0][abs_level][prev_run].len;
434                            if (len != 128)
435                                    code |= (prev_level < 0);
436                            else
437                            {
438                            code = (ESCAPE3 << 21) | (prev_run << 14) | (1 << 13) | ((prev_level & 0xfff) << 1) | 1;
439                                    len  = 30;
440                            }
441                            BitstreamPutBits(bs, code, len);
442                            prev_level = level;
443                            prev_run   = run;
444                            run = 0;
445                    }
446                    else
447                            run++;
448            }
449    
450            abs_level = ABS(prev_level);
451            abs_level = abs_level < 64 ? abs_level : 0;
452            code      = coeff_VLC[1][1][abs_level][prev_run].code;
453            len               = coeff_VLC[1][1][abs_level][prev_run].len;
454            if (len != 128)
455                    code |= (prev_level < 0);
456            else
457            {
458                    code = (ESCAPE3 << 21) | (1 << 20) | (prev_run << 14) | (1 << 13) | ((prev_level & 0xfff) << 1) | 1;
459                    len  = 30;
460            }
461            BitstreamPutBits(bs, code, len);
462    }
463    
464    #endif
465    
466  /*****************************************************************************  /*****************************************************************************
467   * Local functions   * Local functions
468   ****************************************************************************/   ****************************************************************************/
# Line 355  Line 519 
519                  if (pMB->cbp & (1 << (5 - i))) {                  if (pMB->cbp & (1 << (5 - i))) {
520                          bits = BitstreamPos(bs);                          bits = BitstreamPos(bs);
521    
522    #ifdef _BIGLUT_
523                          CodeCoeff(bs, &qcoeff[i * 64], intra_table,                          CodeCoeff(bs, &qcoeff[i * 64], intra_table,
524                                            scan_tables[pMB->acpred_directions[i]], 1);                                            scan_tables[pMB->acpred_directions[i]], 1);
525    #else
526                            CodeCoeffIntra(bs, &qcoeff[i * 64], scan_tables[pMB->acpred_directions[i]]);
527    #endif
528                          bits = BitstreamPos(bs) - bits;                          bits = BitstreamPos(bs) - bits;
529                          pStat->iTextBits += bits;                          pStat->iTextBits += bits;
530                  }                  }
# Line 421  Line 588 
588          /* code block coeffs */          /* code block coeffs */
589          for (i = 0; i < 6; i++)          for (i = 0; i < 6; i++)
590                  if (pMB->cbp & (1 << (5 - i)))                  if (pMB->cbp & (1 << (5 - i)))
591    #ifdef _BIGLUT_
592                          CodeCoeff(bs, &qcoeff[i * 64], inter_table, scan_tables[0], 0);                          CodeCoeff(bs, &qcoeff[i * 64], inter_table, scan_tables[0], 0);
593    #else
594                            CodeCoeffInter(bs, &qcoeff[i * 64], scan_tables[0]);
595    #endif
596    
597          bits = BitstreamPos(bs) - bits;          bits = BitstreamPos(bs) - bits;
598          pStat->iTextBits += bits;          pStat->iTextBits += bits;
# Line 659  Line 830 
830  {  {
831    
832          uint32_t mode;          uint32_t mode;
         const VLC *tab;  
833          int32_t level;          int32_t level;
834            REVERSE_EVENT *reverse_event;
835    
836          if (short_video_header)         /* inter-VLCs will be used for both intra and inter blocks */          if (short_video_header)         /* inter-VLCs will be used for both intra and inter blocks */
837                  intra = 0;                  intra = 0;
838    
839          tab = &DCT3D[intra][BitstreamShowBits(bs, 12)];          if (BitstreamShowBits(bs, 7) != ESCAPE) {
840                    reverse_event = &DCT3D[intra][BitstreamShowBits(bs, 12)];
841    
842          if (tab->code == -1)                  if ((level = reverse_event->event.level) == 0)
843                  goto error;                  goto error;
844    
845          BitstreamSkip(bs, tab->len);                  *last = reverse_event->event.last;
846                    *run  = reverse_event->event.run;
847    
848          if (tab->code != ESCAPE) {                  BitstreamSkip(bs, reverse_event->len);
849                  if (!intra) {  
850                          *run = (tab->code >> 4) & 255;                  return BitstreamGetBits(bs, 1) ? -level : level;
                         level = tab->code & 15;  
                         *last = (tab->code >> 12) & 1;  
                 } else {  
                         *run = (tab->code >> 8) & 255;  
                         level = tab->code & 255;  
                         *last = (tab->code >> 16) & 1;  
                 }  
                 return BitstreamGetBit(bs) ? -level : level;  
851          }          }
852    
853            BitstreamSkip(bs, 7);
854    
855          if (short_video_header) {          if (short_video_header) {
856                  /* escape mode 4 - H.263 type, only used if short_video_header = 1  */                  /* escape mode 4 - H.263 type, only used if short_video_header = 1  */
857                  *last = BitstreamGetBit(bs);                  *last = BitstreamGetBit(bs);
# Line 694  Line 861 
861                  if (level == 0 || level == 128)                  if (level == 0 || level == 128)
862                          DPRINTF(DPRINTF_ERROR, "Illegal LEVEL for ESCAPE mode 4: %d", level);                          DPRINTF(DPRINTF_ERROR, "Illegal LEVEL for ESCAPE mode 4: %d", level);
863    
864                  return (level >= 128 ? -(256 - level) : level);                  return (level << 24) >> 24;
865          }          }
866    
867          mode = BitstreamShowBits(bs, 2);          mode = BitstreamShowBits(bs, 2);
# Line 702  Line 869 
869          if (mode < 3) {          if (mode < 3) {
870                  BitstreamSkip(bs, (mode == 2) ? 2 : 1);                  BitstreamSkip(bs, (mode == 2) ? 2 : 1);
871    
872                  tab = &DCT3D[intra][BitstreamShowBits(bs, 12)];                  reverse_event = &DCT3D[intra][BitstreamShowBits(bs, 12)];
873                  if (tab->code == -1)  
874                    if ((level = reverse_event->event.level) == 0)
875                          goto error;                          goto error;
876    
877                  BitstreamSkip(bs, tab->len);                  *last = reverse_event->event.last;
878                    *run  = reverse_event->event.run;
879    
880                  if (!intra) {                  BitstreamSkip(bs, reverse_event->len);
                         *run = (tab->code >> 4) & 255;  
                         level = tab->code & 15;  
                         *last = (tab->code >> 12) & 1;  
                 } else {  
                         *run = (tab->code >> 8) & 255;  
                         level = tab->code & 255;  
                         *last = (tab->code >> 16) & 1;  
                 }  
881    
882                  if (mode < 2)                   /* first escape mode, level is offset */                  if (mode < 2)                   /* first escape mode, level is offset */
883                          level += max_level[*last + (!intra << 1)][*run];        /* need to add back the max level */                          level += max_level[intra][*last][*run];
884                  else if (mode == 2)             /* second escape mode, run is offset */                  else                                    /* second escape mode, run is offset */
885                          *run += max_run[*last + (!intra << 1)][level] + 1;                          *run += max_run[intra][*last][level] + 1;
886    
887                  return BitstreamGetBit(bs) ? -level : level;                  return BitstreamGetBits(bs, 1) ? -level : level;
888          }          }
889    
890          /* third escape mode - fixed length codes */          /* third escape mode - fixed length codes */
891          BitstreamSkip(bs, 2);          BitstreamSkip(bs, 2);
892          *last = BitstreamGetBits(bs, 1);          *last = BitstreamGetBits(bs, 1);
# Line 733  Line 895 
895          level = BitstreamGetBits(bs, 12);          level = BitstreamGetBits(bs, 12);
896          BitstreamSkip(bs, 1);           /* marker */          BitstreamSkip(bs, 1);           /* marker */
897    
898          return (level & 0x800) ? (level | (-1 ^ 0xfff)) : level;          return (level << 20) >> 20;
899    
900    error:    error:
901          *run = VLC_ERROR;          *run = VLC_ERROR;
902          return 0;          return 0;
   
903  }  }
904    
905  /*****************************************************************************  /*****************************************************************************

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

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