[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.16, Mon May 6 03:51:43 2002 UTC revision 1.17, Wed Jun 12 20:38:40 2002 UTC
# Line 66  Line 66 
66  VLC DCT3Dintra[4096];  VLC DCT3Dintra[4096];
67  VLC DCT3Dinter[4096];  VLC DCT3Dinter[4096];
68    
69  void init_vlc_tables(void)  void
70    init_vlc_tables(void)
71  {  {
72    
73          int32_t k, l, i, intra, last;          int32_t k, l, i, intra, last;
# Line 96  Line 97 
97                                  int32_t level = k;                                  int32_t level = k;
98                                  uint32_t run = l;                                  uint32_t run = l;
99    
100                                  if((abs(level) <= max_level_ptr[run]) &&                                  if ((abs(level) <= max_level_ptr[run]) && (run <= (uint32_t) max_run_ptr[abs(level)])) {        // level < max_level and run < max_run
                                    (run <= (uint32_t)max_run_ptr[abs(level)])) { // level < max_level and run < max_run  
101    
102                                                  vlc[intra]->code = 0;                                                  vlc[intra]->code = 0;
103                                                  vlc[intra]->len = 0;                                                  vlc[intra]->len = 0;
104                                                  goto loop_end;                                                  goto loop_end;
105                                  }                                  } else {
                                 else {  
106                                          if(level > 0)                                        // correct level                                          if(level > 0)                                        // correct level
107                                                  level -= max_level_ptr[run];                                                  level -= max_level_ptr[run];
108                                          else                                          else
# Line 134  Line 133 
133                                          run += max_run_ptr[abs(level)] + 1;                                          run += max_run_ptr[abs(level)] + 1;
134                                  }                                  }
135    
136                                  vlc[intra]->code = (uint32_t) ((l << 14) | (0x1e + last) << 20) |                                  vlc[intra]->code =
137                                                                                            (1 << 13) | ((k & 0xfff) << 1) | 1;                                          (uint32_t) ((l << 14) | (0x1e + last) << 20) | (1 << 13) |
138                                            ((k & 0xfff) << 1) | 1;
139    
140                                  vlc[intra]->len = 30;                                  vlc[intra]->len = 30;
141                                  vlc[intra]++;                                  vlc[intra]++;
# Line 143  Line 143 
143    
144  loop_end:  loop_end:
145                                  if(level != 0) {                                  if(level != 0) {
146                                          vlc[intra]->code = (vlc[intra]->code << (coeff_ptr[run][abs(level) - 1].len + 1)) |                                          vlc[intra]->code =
147                                                                             (coeff_ptr[run][abs(level) - 1].code << 1);                                                  (vlc[intra]->
148                                          vlc[intra]->len = (coeff_ptr[run][abs(level) - 1].len + 1) + vlc[intra]->len;                                                   code << (coeff_ptr[run][abs(level) - 1].len +
149                                                                      1)) | (coeff_ptr[run][abs(level) -
150                                                                                                                    1].code << 1);
151                                            vlc[intra]->len =
152                                                    (coeff_ptr[run][abs(level) - 1].len + 1) +
153                                                    vlc[intra]->len;
154    
155                                          if(level < 0)                                          if(level < 0)
156                                                  vlc[intra]->code += 1;                                                  vlc[intra]->code += 1;
# Line 160  Line 165 
165                  if(i >= 512) {                  if(i >= 512) {
166                          *vlc1 = DCT3Dtab3[(i >> 5) - 16];                          *vlc1 = DCT3Dtab3[(i >> 5) - 16];
167                          *vlc2 = DCT3Dtab0[(i >> 5) - 16];                          *vlc2 = DCT3Dtab0[(i >> 5) - 16];
168                  }                  } else if (i >= 128) {
                 else if(i >= 128) {  
169                          *vlc1 = DCT3Dtab4[(i >> 2) - 32];                          *vlc1 = DCT3Dtab4[(i >> 2) - 32];
170                          *vlc2 = DCT3Dtab1[(i >> 2) - 32];                          *vlc2 = DCT3Dtab1[(i >> 2) - 32];
171                  }                  } else if (i >= 8) {
                 else if(i >= 8) {  
172                          *vlc1 = DCT3Dtab5[i - 8];                          *vlc1 = DCT3Dtab5[i - 8];
173                          *vlc2 = DCT3Dtab2[i - 8];                          *vlc2 = DCT3Dtab2[i - 8];
174                  }                  } else {
                 else {  
175                          *vlc1 = ERRtab[i];                          *vlc1 = ERRtab[i];
176                          *vlc2 = ERRtab[i];                          *vlc2 = ERRtab[i];
177                  }                  }
# Line 182  Line 184 
184    
185  }  }
186    
187  static __inline void CodeVector(Bitstream *bs,  static __inline void
188    CodeVector(Bitstream * bs,
189                                  int32_t value,                                  int32_t value,
190                                  int32_t f_code,                                  int32_t f_code,
191                                  Statistics *pStat)                                  Statistics *pStat)
# Line 201  Line 204 
204          pStat->iMvCount++;          pStat->iMvCount++;
205    
206          if (value == 0) {          if (value == 0) {
207                  BitstreamPutBits(bs, mb_motion_table[32].code, mb_motion_table[32].len);                  BitstreamPutBits(bs, mb_motion_table[32].code,
208                                                     mb_motion_table[32].len);
209          } else {          } else {
210                  uint16_t length, code, mv_res, sign;                  uint16_t length, code, mv_res, sign;
211    
# Line 226  Line 230 
230                          code = -code;                          code = -code;
231    
232                  code += 32;                  code += 32;
233                  BitstreamPutBits(bs, mb_motion_table[code].code, mb_motion_table[code].len);                  BitstreamPutBits(bs, mb_motion_table[code].code,
234                                                     mb_motion_table[code].len);
235    
236                  if(f_code)                  if(f_code)
237                          BitstreamPutBits(bs, mv_res, f_code);                          BitstreamPutBits(bs, mv_res, f_code);
# Line 235  Line 240 
240  }  }
241    
242    
243  static __inline void CodeCoeff(Bitstream *bs,  static __inline void
244    CodeCoeff(Bitstream * bs,
245                                 const int16_t qcoeff[64],                                 const int16_t qcoeff[64],
246                                 VLC *table,                                 VLC *table,
247                                 const uint16_t *zigzag,                                 const uint16_t *zigzag,
# Line 249  Line 255 
255          j = intra;          j = intra;
256          last = intra;          last = intra;
257    
258          while(j < 64 && (v = qcoeff[zigzag[j]]) == 0) j++;          while (j < 64 && (v = qcoeff[zigzag[j]]) == 0)
259                    j++;
260    
261          do {          do {
262                  vlc = table + 64 * 2047 + (v << 6) + j - last;                  vlc = table + 64 * 2047 + (v << 6) + j - last;
263                  last = ++j;                  last = ++j;
264    
265                  // count zeroes                  // count zeroes
266                  while(j < 64 && (v = qcoeff[zigzag[j]]) == 0) j++;                  while (j < 64 && (v = qcoeff[zigzag[j]]) == 0)
267                            j++;
268    
269                  // write code                  // write code
270                  if(j != 64) {                  if(j != 64) {
# Line 271  Line 279 
279  }  }
280    
281    
282  static void CodeBlockIntra(const FRAMEINFO * frame,  static void
283    CodeBlockIntra(const FRAMEINFO * frame,
284                             const MACROBLOCK *pMB,                             const MACROBLOCK *pMB,
285                             int16_t qcoeff[6*64],                             int16_t qcoeff[6*64],
286                             Bitstream * bs,                             Bitstream * bs,
# Line 285  Line 294 
294          // write mcbpc          // write mcbpc
295          if(frame->coding_type == I_VOP) {          if(frame->coding_type == I_VOP) {
296                  mcbpc = ((pMB->mode >> 1) & 3) | ((pMB->cbp & 3) << 2);                  mcbpc = ((pMB->mode >> 1) & 3) | ((pMB->cbp & 3) << 2);
297                  BitstreamPutBits(bs, mcbpc_intra_tab[mcbpc].code, mcbpc_intra_tab[mcbpc].len);                  BitstreamPutBits(bs, mcbpc_intra_tab[mcbpc].code,
298          }                                                   mcbpc_intra_tab[mcbpc].len);
299          else {          } else {
300                  mcbpc = (pMB->mode & 7) | ((pMB->cbp & 3) << 3);                  mcbpc = (pMB->mode & 7) | ((pMB->cbp & 3) << 3);
301                  BitstreamPutBits(bs, mcbpc_inter_tab[mcbpc].code, mcbpc_inter_tab[mcbpc].len);                  BitstreamPutBits(bs, mcbpc_inter_tab[mcbpc].code,
302                                                     mcbpc_inter_tab[mcbpc].len);
303          }          }
304    
305          // ac prediction flag          // ac prediction flag
# Line 306  Line 316 
316                  BitstreamPutBits(bs, pMB->dquant, 2);                  BitstreamPutBits(bs, pMB->dquant, 2);
317    
318          // write interlacing          // write interlacing
319          if (frame->global_flags & XVID_INTERLACING)          if (frame->global_flags & XVID_INTERLACING) {
         {  
320                  BitstreamPutBit(bs, pMB->field_dct);                  BitstreamPutBit(bs, pMB->field_dct);
321          }          }
   
322          // code block coeffs          // code block coeffs
323          for(i = 0; i < 6; i++)          for (i = 0; i < 6; i++) {
         {  
324                  if(i < 4)                  if(i < 4)
325                          BitstreamPutBits(bs,                          BitstreamPutBits(bs, dcy_tab[qcoeff[i * 64 + 0] + 255].code,
                                          dcy_tab[qcoeff[i*64 + 0] + 255].code,  
326                                           dcy_tab[qcoeff[i*64 + 0] + 255].len);                                           dcy_tab[qcoeff[i*64 + 0] + 255].len);
327                  else                  else
328                          BitstreamPutBits(bs,                          BitstreamPutBits(bs, dcc_tab[qcoeff[i * 64 + 0] + 255].code,
                                          dcc_tab[qcoeff[i*64 + 0] + 255].code,  
329                                           dcc_tab[qcoeff[i*64 + 0] + 255].len);                                           dcc_tab[qcoeff[i*64 + 0] + 255].len);
330    
331                  if(pMB->cbp & (1 << (5 - i)))                  if (pMB->cbp & (1 << (5 - i))) {
                 {  
332                          bits = BitstreamPos(bs);                          bits = BitstreamPos(bs);
333    
334                          CodeCoeff(bs,                          CodeCoeff(bs, &qcoeff[i * 64], intra_table,
335                                    &qcoeff[i*64],                                            scan_tables[pMB->acpred_directions[i]], 1);
                                   intra_table,  
                                   scan_tables[pMB->acpred_directions[i]],  
                                   1);  
336    
337                          bits = BitstreamPos(bs) - bits;                          bits = BitstreamPos(bs) - bits;
338                          pStat->iTextBits += bits;                          pStat->iTextBits += bits;
# Line 341  Line 342 
342  }  }
343    
344    
345  static void CodeBlockInter(const FRAMEINFO * frame,  static void
346    CodeBlockInter(const FRAMEINFO * frame,
347                             const MACROBLOCK *pMB,                             const MACROBLOCK *pMB,
348                             int16_t qcoeff[6*64],                             int16_t qcoeff[6*64],
349                             Bitstream * bs,                             Bitstream * bs,
# Line 355  Line 357 
357          cbpy = 15 - (pMB->cbp >> 2);          cbpy = 15 - (pMB->cbp >> 2);
358    
359          // write mcbpc          // write mcbpc
360          BitstreamPutBits(bs, mcbpc_inter_tab[mcbpc].code, mcbpc_inter_tab[mcbpc].len);          BitstreamPutBits(bs, mcbpc_inter_tab[mcbpc].code,
361                                             mcbpc_inter_tab[mcbpc].len);
362    
363          // write cbpy          // write cbpy
364          BitstreamPutBits(bs, cbpy_tab[cbpy].code, cbpy_tab[cbpy].len);          BitstreamPutBits(bs, cbpy_tab[cbpy].code, cbpy_tab[cbpy].len);
# Line 365  Line 368 
368                  BitstreamPutBits(bs, pMB->dquant, 2);                  BitstreamPutBits(bs, pMB->dquant, 2);
369    
370          // interlacing          // interlacing
371          if (frame->global_flags & XVID_INTERLACING)          if (frame->global_flags & XVID_INTERLACING) {
         {  
372                  BitstreamPutBit(bs, pMB->field_dct);                  BitstreamPutBit(bs, pMB->field_dct);
373                  DEBUG1("codep: field_dct: ", pMB->field_dct);                  DEBUG1("codep: field_dct: ", pMB->field_dct);
374    
375                  // if inter block, write field ME flag                  // if inter block, write field ME flag
376                  if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q)                  if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) {
                 {  
377                          BitstreamPutBit(bs, pMB->field_pred);                          BitstreamPutBit(bs, pMB->field_pred);
378                          DEBUG1("codep: field_pred: ", pMB->field_pred);                          DEBUG1("codep: field_pred: ", pMB->field_pred);
379    
380                          // write field prediction references                          // write field prediction references
381                          if (pMB->field_pred)                          if (pMB->field_pred) {
                         {  
382                                  BitstreamPutBit(bs, pMB->field_for_top);                                  BitstreamPutBit(bs, pMB->field_for_top);
383                                  BitstreamPutBit(bs, pMB->field_for_bot);                                  BitstreamPutBit(bs, pMB->field_for_bot);
384                          }                          }
385                  }                  }
386          }          }
   
387          // code motion vector(s)          // code motion vector(s)
388          for(i = 0; i < (pMB->mode == MODE_INTER4V ? 4 : 1); i++)          for (i = 0; i < (pMB->mode == MODE_INTER4V ? 4 : 1); i++) {
         {  
389                  CodeVector(bs, pMB->pmvs[i].x, frame->fcode, pStat);                  CodeVector(bs, pMB->pmvs[i].x, frame->fcode, pStat);
390                  CodeVector(bs, pMB->pmvs[i].y, frame->fcode, pStat);                  CodeVector(bs, pMB->pmvs[i].y, frame->fcode, pStat);
391          }          }
# Line 405  Line 403 
403  }  }
404    
405    
406  void MBCoding(const FRAMEINFO * frame,  void
407    MBCoding(const FRAMEINFO * frame,
408                MACROBLOCK *pMB,                MACROBLOCK *pMB,
409                int16_t qcoeff[6*64],                int16_t qcoeff[6*64],
410                Bitstream * bs,                Bitstream * bs,
# Line 415  Line 414 
414          int intra = (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q);          int intra = (pMB->mode == MODE_INTRA || pMB->mode == MODE_INTRA_Q);
415    
416          if(frame->coding_type == P_VOP) {          if(frame->coding_type == P_VOP) {
417                  if(pMB->cbp == 0 && pMB->mode == MODE_INTER &&                  if (pMB->cbp == 0 && pMB->mode == MODE_INTER && pMB->mvs[0].x == 0 &&
418                     pMB->mvs[0].x == 0 && pMB->mvs[0].y == 0)                          pMB->mvs[0].y == 0) {
                 {  
419                          BitstreamPutBit(bs, 1);         // not_coded                          BitstreamPutBit(bs, 1);         // not_coded
420                          return;                          return;
421                  }                  } else
                 else  
422                          BitstreamPutBit(bs, 0);         // coded                          BitstreamPutBit(bs, 0);         // coded
423          }          }
424    
# Line 444  Line 441 
441          3       0001b   forward mc+q            dbquant, mvdf          3       0001b   forward mc+q            dbquant, mvdf
442  */  */
443    
444  void put_bvop_mbtype(Bitstream * bs, int value)  void
445  {  put_bvop_mbtype(Bitstream * bs,
446          switch(value)                                  int value)
447          {          {
448          case 0 :        BitstreamPutBit(bs, 1);          switch (value) {
449            case 0:
450                    BitstreamPutBit(bs, 1);
451                                  return;                                  return;
452    
453          case 1 :        BitstreamPutBit(bs, 0);          case 1:
454                    BitstreamPutBit(bs, 0);
455                                  BitstreamPutBit(bs, 1);                                  BitstreamPutBit(bs, 1);
456                                  return;                                  return;
457    
458          case 2 :        BitstreamPutBit(bs, 0);          case 2:
459                    BitstreamPutBit(bs, 0);
460                                  BitstreamPutBit(bs, 0);                                  BitstreamPutBit(bs, 0);
461                                  BitstreamPutBit(bs, 1);                                  BitstreamPutBit(bs, 1);
462                                  return;                                  return;
463    
464          case 3 :        BitstreamPutBit(bs, 0);          case 3:
465                    BitstreamPutBit(bs, 0);
466                                  BitstreamPutBit(bs, 0);                                  BitstreamPutBit(bs, 0);
467                                  BitstreamPutBit(bs, 0);                                  BitstreamPutBit(bs, 0);
468                                  BitstreamPutBit(bs, 1);                                  BitstreamPutBit(bs, 1);
# Line 479  Line 481 
481          +2      11b          +2      11b
482  */  */
483    
484  void put_bvop_dbquant(Bitstream *bs, int value)  void
485  {  put_bvop_dbquant(Bitstream * bs,
486          switch (value)                                   int value)
487          {          {
488          case 0 :        BitstreamPutBit(bs, 0);          switch (value) {
489            case 0:
490                    BitstreamPutBit(bs, 0);
491                                  return;                                  return;
492    
493          case -2 :       BitstreamPutBit(bs, 1);          case -2:
494                    BitstreamPutBit(bs, 1);
495                                  BitstreamPutBit(bs, 0);                                  BitstreamPutBit(bs, 0);
496                                  return;                                  return;
497    
498          case 2 :        BitstreamPutBit(bs, 1);          case 2:
499                    BitstreamPutBit(bs, 1);
500                                  BitstreamPutBit(bs, 1);                                  BitstreamPutBit(bs, 1);
501                                  return;                                  return;
502    
# Line 500  Line 506 
506    
507    
508    
509  void MBCodingBVOP(const MACROBLOCK * mb,  void
510    MBCodingBVOP(const MACROBLOCK * mb,
511                                    const int16_t qcoeff[6*64],                                    const int16_t qcoeff[6*64],
512                                    const int32_t fcode,                                    const int32_t fcode,
513                                    const int32_t bcode,                                    const int32_t bcode,
# Line 514  Line 521 
521                  hence are interpolated from forward & backward frames                  hence are interpolated from forward & backward frames
522          ------------------------------------------------------------------ */          ------------------------------------------------------------------ */
523    
524          if (mb->mode == 5)          if (mb->mode == 5) {
         {  
525                  BitstreamPutBit(bs, 1);         // skipped                  BitstreamPutBit(bs, 1);         // skipped
526                  return;                  return;
527          }          }
528    
529          BitstreamPutBit(bs, 0);         // not skipped          BitstreamPutBit(bs, 0);         // not skipped
530    
531          if (mb->cbp == 0)          if (mb->cbp == 0) {
         {  
532                  BitstreamPutBit(bs, 1);         // cbp == 0                  BitstreamPutBit(bs, 1);         // cbp == 0
533          }          } else {
         else  
         {  
534                  BitstreamPutBit(bs, 0);         // cbp == xxx                  BitstreamPutBit(bs, 0);         // cbp == xxx
535          }          }
536    
537          put_bvop_mbtype(bs, mb->mode);          put_bvop_mbtype(bs, mb->mode);
538    
539          if (mb->cbp)          if (mb->cbp) {
         {  
540                  BitstreamPutBits(bs, mb->cbp, 6);                  BitstreamPutBits(bs, mb->cbp, 6);
541          }          }
542    
543          if (mb->mode != MODE_DIRECT && mb->cbp != 0)          if (mb->mode != MODE_DIRECT && mb->cbp != 0) {
         {  
544                  put_bvop_dbquant(bs, 0); // todo: mb->dquant = 0                  put_bvop_dbquant(bs, 0); // todo: mb->dquant = 0
545          }          }
546    
547          if (mb->mode == MODE_INTERPOLATE || mb->mode == MODE_FORWARD)          if (mb->mode == MODE_INTERPOLATE || mb->mode == MODE_FORWARD) {
         {  
548              CodeVector(bs, mb->pmvs[0].x, fcode, pStat);              CodeVector(bs, mb->pmvs[0].x, fcode, pStat);
549              CodeVector(bs, mb->pmvs[0].y, fcode, pStat);              CodeVector(bs, mb->pmvs[0].y, fcode, pStat);
550          }          }
551    
552          if (mb->mode == MODE_INTERPOLATE || mb->mode == MODE_BACKWARD)          if (mb->mode == MODE_INTERPOLATE || mb->mode == MODE_BACKWARD) {
         {  
553              CodeVector(bs, mb->b_pmvs[0].x, bcode, pStat);              CodeVector(bs, mb->b_pmvs[0].x, bcode, pStat);
554              CodeVector(bs, mb->b_pmvs[0].y, bcode, pStat);              CodeVector(bs, mb->b_pmvs[0].y, bcode, pStat);
555          }          }
556    
557          if (mb->mode == MODE_DIRECT)          if (mb->mode == MODE_DIRECT) {
         {  
558                  // TODO: direct                  // TODO: direct
559          }          }
560    
561      for (i = 0; i < 6; i++)          for (i = 0; i < 6; i++) {
562      {                  if (mb->cbp & (1 << (5 - i))) {
                 if (mb->cbp & (1 << (5 - i)))  
                 {  
563                          CodeCoeff(bs, &qcoeff[i*64], inter_table, scan_tables[0], 0);                          CodeCoeff(bs, &qcoeff[i*64], inter_table, scan_tables[0], 0);
564                  }                  }
565      }      }
# Line 575  Line 571 
571   * decoding stuff starts here                                  *   * decoding stuff starts here                                  *
572   ***************************************************************/   ***************************************************************/
573    
574  int get_mcbpc_intra(Bitstream * bs)  int
575    get_mcbpc_intra(Bitstream * bs)
576  {  {
577    
578          uint32_t index;          uint32_t index;
# Line 591  Line 588 
588    
589  }  }
590    
591  int get_mcbpc_inter(Bitstream * bs)  int
592    get_mcbpc_inter(Bitstream * bs)
593  {  {
594    
595          uint32_t index;          uint32_t index;
# Line 605  Line 603 
603    
604  }  }
605    
606  int get_cbpy(Bitstream * bs, int intra)  int
607    get_cbpy(Bitstream * bs,
608                     int intra)
609  {  {
610    
611          int cbpy;          int cbpy;
# Line 621  Line 621 
621    
622  }  }
623    
624  int get_mv_data(Bitstream * bs)  int
625    get_mv_data(Bitstream * bs)
626  {  {
627    
628          uint32_t index;          uint32_t index;
# Line 631  Line 632 
632    
633          index = BitstreamShowBits(bs, 12);          index = BitstreamShowBits(bs, 12);
634    
635          if(index >= 512)          if (index >= 512) {
         {  
636                  index = (index >> 8) - 2;                  index = (index >> 8) - 2;
637                  BitstreamSkip(bs, TMNMVtab0[index].len);                  BitstreamSkip(bs, TMNMVtab0[index].len);
638                  return TMNMVtab0[index].code;                  return TMNMVtab0[index].code;
639          }          }
640    
641          if(index >= 128)          if (index >= 128) {
         {  
642                  index = (index >> 2) - 32;                  index = (index >> 2) - 32;
643                  BitstreamSkip(bs, TMNMVtab1[index].len);                  BitstreamSkip(bs, TMNMVtab1[index].len);
644                  return TMNMVtab1[index].code;                  return TMNMVtab1[index].code;
# Line 652  Line 651 
651    
652  }  }
653    
654  int get_mv(Bitstream * bs, int fcode)  int
655    get_mv(Bitstream * bs,
656               int fcode)
657  {  {
658    
659          int data;          int data;
# Line 672  Line 673 
673    
674  }  }
675    
676  int get_dc_dif(Bitstream * bs, uint32_t dc_size)  int
677    get_dc_dif(Bitstream * bs,
678                       uint32_t dc_size)
679  {  {
680    
681          int code = BitstreamGetBits(bs, dc_size);          int code = BitstreamGetBits(bs, dc_size);
# Line 685  Line 688 
688    
689  }  }
690    
691  int get_dc_size_lum(Bitstream * bs)  int
692    get_dc_size_lum(Bitstream * bs)
693  {  {
694    
695          int code, i;          int code, i;
696    
697          code = BitstreamShowBits(bs, 11);          code = BitstreamShowBits(bs, 11);
698    
699          for(i = 11; i > 3; i--) {          for(i = 11; i > 3; i--) {
# Line 705  Line 710 
710  }  }
711    
712    
713  int get_dc_size_chrom(Bitstream * bs)  int
714    get_dc_size_chrom(Bitstream * bs)
715  {  {
716    
717          uint32_t code, i;          uint32_t code, i;
718    
719          code = BitstreamShowBits(bs, 12);          code = BitstreamShowBits(bs, 12);
720    
721          for(i = 12; i > 2; i--) {          for(i = 12; i > 2; i--) {
# Line 723  Line 730 
730    
731  }  }
732    
733  void get_intra_block(Bitstream * bs, int16_t * block, int direction, int coeff)  void
734    get_intra_block(Bitstream * bs,
735                                    int16_t * block,
736                                    int direction,
737                                    int coeff)
738  {  {
739    
740          const uint16_t * scan = scan_tables[ direction ];          const uint16_t * scan = scan_tables[ direction ];
# Line 731  Line 742 
742          int run;          int run;
743          int last;          int last;
744    
745          do          do {
         {  
746                  level = get_coeff(bs, &run, &last, 1, 0);                  level = get_coeff(bs, &run, &last, 1, 0);
747                  if (run == -1)                  if (run == -1) {
                 {  
748                          DEBUG("fatal: invalid run");                          DEBUG("fatal: invalid run");
749                          break;                          break;
750                  }                  }
751                  coeff += run;                  coeff += run;
752                  block[ scan[coeff] ] = level;                  block[ scan[coeff] ] = level;
753                  if (level < -127 || level > 127)                  if (level < -127 || level > 127) {
                 {  
754                          DEBUG1("warning: intra_overflow", level);                          DEBUG1("warning: intra_overflow", level);
755                  }                  }
756                  coeff++;                  coeff++;
# Line 750  Line 758 
758    
759  }  }
760    
761  void get_inter_block(Bitstream * bs, int16_t * block)  void
762    get_inter_block(Bitstream * bs,
763                                    int16_t * block)
764  {  {
765    
766          const uint16_t * scan = scan_tables[0];          const uint16_t * scan = scan_tables[0];
# Line 760  Line 770 
770          int last;          int last;
771    
772          p = 0;          p = 0;
773          do          do {
         {  
774                  level = get_coeff(bs, &run, &last, 0, 0);                  level = get_coeff(bs, &run, &last, 0, 0);
775                  if (run == -1)                  if (run == -1) {
                 {  
776                          DEBUG("fatal: invalid run");                          DEBUG("fatal: invalid run");
777                          break;                          break;
778                  }                  }
779                  p += run;                  p += run;
780    
781                  block[ scan[p] ] = level;                  block[ scan[p] ] = level;
782                  if (level < -127 || level > 127)                  if (level < -127 || level > 127) {
                 {  
783                          DEBUG1("warning: inter_overflow", level);                          DEBUG1("warning: inter_overflow", level);
784                  }                  }
785                  p++;                  p++;

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

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