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

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

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

revision 248, Fri Jun 28 15:14:40 2002 UTC revision 252, Sun Jun 30 10:46:29 2002 UTC
# Line 50  Line 50 
50   *  22.12.2001  lock based interpolation   *  22.12.2001  lock based interpolation
51   *  01.12.2001  inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>   *  01.12.2001  inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>
52   *   *
53   *  $Id: decoder.c,v 1.22 2002-06-28 15:14:40 suxen_drol Exp $   *  $Id: decoder.c,v 1.23 2002-06-30 10:46:29 suxen_drol Exp $
54   *   *
55   *************************************************************************/   *************************************************************************/
56    
# Line 205  Line 205 
205                                  Bitstream * bs,                                  Bitstream * bs,
206                                  const uint32_t quant,                                  const uint32_t quant,
207                                  const uint32_t intra_dc_threshold,                                  const uint32_t intra_dc_threshold,
208                                  const unsigned int bound_x,                                  const unsigned int bound)
                                 const unsigned int bound_y)  
209  {  {
210    
211          DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE);
# Line 232  Line 231 
231    
232                  start_timer();                  start_timer();
233                  predict_acdc(dec->mbs, x_pos, y_pos, dec->mb_width, i, &block[i * 64],                  predict_acdc(dec->mbs, x_pos, y_pos, dec->mb_width, i, &block[i * 64],
234                                           iQuant, iDcScaler, predictors, bound_x, bound_y);                                           iQuant, iDcScaler, predictors, bound);
235                  if (!acpred_flag) {                  if (!acpred_flag) {
236                          pMB->acpred_directions[i] = 0;                          pMB->acpred_directions[i] = 0;
237                  }                  }
# Line 251  Line 250 
250    
251                          block[i * 64 + 0] = dc_dif;                          block[i * 64 + 0] = dc_dif;
252                          start_coeff = 1;                          start_coeff = 1;
253    
254                            DPRINTF(DPRINTF_COEFF,"block[0] %i", dc_dif);
255                  } else {                  } else {
256                          start_coeff = 0;                          start_coeff = 0;
257                  }                  }
# Line 425  Line 426 
426                             int quant,                             int quant,
427                             int intra_dc_threshold)                             int intra_dc_threshold)
428  {  {
429          uint32_t bound_x, bound_y;          uint32_t bound;
430          uint32_t x, y;          uint32_t x, y;
431    
432          bound_x = bound_y = 0;          bound = 0;
433    
434          for (y = 0; y < dec->mb_height; y++) {          for (y = 0; y < dec->mb_height; y++) {
435                  for (x = 0; x < dec->mb_width; x++) {                  for (x = 0; x < dec->mb_width; x++) {
436                          MACROBLOCK *mb;                          MACROBLOCK *mb;
   
437                          uint32_t mcbpc;                          uint32_t mcbpc;
438                          uint32_t cbpc;                          uint32_t cbpc;
439                          uint32_t acpred_flag;                          uint32_t acpred_flag;
440                          uint32_t cbpy;                          uint32_t cbpy;
441                          uint32_t cbp;                          uint32_t cbp;
442    
443                          skip_stuffing(bs);                          while (BitstreamShowBits(bs, 9) == 1)
444                                    BitstreamSkip(bs, 9);
445    
446                          if (check_resync_marker(bs, 0))                          if (check_resync_marker(bs, 0))
447                          {                          {
448                                  int mbnum = read_video_packet_header(bs, 0);                                  bound = read_video_packet_header(bs, 0, &quant);
449                                  x = bound_x = mbnum % dec->mb_width;                                  x = bound % dec->mb_width;
450                                  y = bound_y = mbnum / dec->mb_width;                                  y = bound / dec->mb_width;
451                          }                          }
   
452                          mb = &dec->mbs[y * dec->mb_width + x];                          mb = &dec->mbs[y * dec->mb_width + x];
453    
454                            DPRINTF(DPRINTF_MB, "macroblock (%i,%i) %08x", x, y, BitstreamShowBits(bs, 32));
455    
456                          mcbpc = get_mcbpc_intra(bs);                          mcbpc = get_mcbpc_intra(bs);
457                          mb->mode = mcbpc & 7;                          mb->mode = mcbpc & 7;
458                          cbpc = (mcbpc >> 4);                          cbpc = (mcbpc >> 4);
# Line 475  Line 478 
478                          }                          }
479    
480                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,
481                                                          intra_dc_threshold, bound_x, bound_y);                                                          intra_dc_threshold, bound);
482                  }                  }
483          }          }
484    
# Line 490  Line 493 
493                                    int k,                                    int k,
494                                    VECTOR * mv,                                    VECTOR * mv,
495                                    int fcode,                                    int fcode,
496                                    const int bound_x,                                    const int bound)
                                   const int bound_y)  
497  {  {
498    
499          int scale_fac = 1 << (fcode - 1);          int scale_fac = 1 << (fcode - 1);
# Line 506  Line 508 
508          int pmv_x, pmv_y;          int pmv_x, pmv_y;
509    
510    
511          get_pmvdata(dec->mbs, x, y, dec->mb_width, k, pmv, psad, bound_x, bound_y);          get_pmvdata2(dec->mbs, x, y, dec->mb_width, k, pmv, psad, bound);
512    
513          pmv_x = pmv[0].x;          pmv_x = pmv[0].x;
514          pmv_y = pmv[0].y;          pmv_y = pmv[0].y;
# Line 514  Line 516 
516          mv_x = get_mv(bs, fcode);          mv_x = get_mv(bs, fcode);
517          mv_y = get_mv(bs, fcode);          mv_y = get_mv(bs, fcode);
518    
519            DPRINTF(DPRINTF_MV,"mv_diff (%i,%i) pred (%i,%i)", mv_x, mv_y, pmv_x, pmv_y);
520    
521          mv_x += pmv_x;          mv_x += pmv_x;
522          mv_y += pmv_y;          mv_y += pmv_y;
523    
# Line 545  Line 549 
549  {  {
550    
551          uint32_t x, y;          uint32_t x, y;
552          uint32_t bound_x, bound_y;          uint32_t bound;
553    
554          start_timer();          start_timer();
555          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,
556                                     dec->width, dec->height, dec->interlacing);                                     dec->width, dec->height, dec->interlacing);
557          stop_edges_timer();          stop_edges_timer();
558    
559          bound_x = bound_y = 0;          bound = 0;
560    
561          for (y = 0; y < dec->mb_height; y++) {          for (y = 0; y < dec->mb_height; y++) {
562                  for (x = 0; x < dec->mb_width; x++) {                  for (x = 0; x < dec->mb_width; x++) {
563                          MACROBLOCK *mb;                          MACROBLOCK *mb;
564    
565                          skip_stuffing(bs);                          // skip stuffing
566                          if (check_resync_marker(bs, 0))                          while (BitstreamShowBits(bs, 10) == 1)
567                          {                                  BitstreamSkip(bs, 10);
568                                  int mbnum = read_video_packet_header(bs, 0);  
569                                  x = bound_x = mbnum % dec->mb_width;                          if (check_resync_marker(bs, fcode - 1))
570                                  y = bound_y = mbnum / dec->mb_width;                          {
571                                    bound = read_video_packet_header(bs, fcode - 1, &quant);
572                                    x = bound % dec->mb_width;
573                                    y = bound / dec->mb_width;
574                          }                          }
575                          mb = &dec->mbs[y * dec->mb_width + x];                          mb = &dec->mbs[y * dec->mb_width + x];
576    
577                            DPRINTF(DPRINTF_MB, "macroblock (%i,%i) %08x", x, y, BitstreamShowBits(bs, 32));
578    
579                          //if (!(dec->mb_skip[y*dec->mb_width + x]=BitstreamGetBit(bs)))         // not_coded                          //if (!(dec->mb_skip[y*dec->mb_width + x]=BitstreamGetBit(bs)))         // not_coded
580                          if (!(BitstreamGetBit(bs)))     // not_coded                          if (!(BitstreamGetBit(bs)))     // not_coded
581                          {                          {
# Line 580  Line 589 
589                                  mcbpc = get_mcbpc_inter(bs);                                  mcbpc = get_mcbpc_inter(bs);
590                                  mb->mode = mcbpc & 7;                                  mb->mode = mcbpc & 7;
591                                  cbpc = (mcbpc >> 4);                                  cbpc = (mcbpc >> 4);
592    
593                                    DPRINTF(DPRINTF_MB, "mode %i", mb->mode);
594                                    DPRINTF(DPRINTF_MB, "cbpc %i", cbpc);
595                                  acpred_flag = 0;                                  acpred_flag = 0;
596    
597                                  intra = (mb->mode == MODE_INTRA || mb->mode == MODE_INTRA_Q);                                  intra = (mb->mode == MODE_INTRA || mb->mode == MODE_INTRA_Q);
# Line 589  Line 601 
601                                  }                                  }
602    
603                                  cbpy = get_cbpy(bs, intra);                                  cbpy = get_cbpy(bs, intra);
604                                    DPRINTF(DPRINTF_MB, "cbpy %i", cbpy);
605    
606                                  cbp = (cbpy << 2) | cbpc;                                  cbp = (cbpy << 2) | cbpc;
607    
608                                  if (mb->mode == MODE_INTER_Q || mb->mode == MODE_INTRA_Q) {                                  if (mb->mode == MODE_INTER_Q || mb->mode == MODE_INTRA_Q) {
609                                          quant += dquant_table[BitstreamGetBits(bs, 2)];                                          int dquant = dquant_table[BitstreamGetBits(bs, 2)];
610                                            DPRINTF(DPRINTF_MB, "dquant %i", dquant);
611                                            quant += dquant;
612                                          if (quant > 31) {                                          if (quant > 31) {
613                                                  quant = 31;                                                  quant = 31;
614                                          } else if (mb->quant < 1) {                                          } else if (quant < 1) {
615                                                  quant = 1;                                                  quant = 1;
616                                          }                                          }
617                                            DPRINTF(DPRINTF_MB, "quant %i", quant);
618                                  }                                  }
619                                  mb->quant = quant;                                  mb->quant = quant;
620    
# Line 621  Line 638 
638                                  if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) {                                  if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) {
639                                          if (dec->interlacing && mb->field_pred) {                                          if (dec->interlacing && mb->field_pred) {
640                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0],                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0],
641                                                                                    fcode, bound_x, bound_y);                                                                                    fcode, bound);
642                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[1],                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[1],
643                                                                                    fcode, bound_x, bound_y);                                                                                    fcode, bound);
644                                          } else {                                          } else {
645                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0],                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0],
646                                                                                    fcode, bound_x, bound_y);                                                                                    fcode, bound);
647                                                  mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x =                                                  mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x =
648                                                          mb->mvs[0].x;                                                          mb->mvs[0].x;
649                                                  mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y =                                                  mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y =
# Line 634  Line 651 
651                                          }                                          }
652                                  } else if (mb->mode ==                                  } else if (mb->mode ==
653                                                     MODE_INTER4V /* || mb->mode == MODE_INTER4V_Q */ ) {                                                     MODE_INTER4V /* || mb->mode == MODE_INTER4V_Q */ ) {
654                                          get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], fcode, bound_x, bound_y);                                          get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0], fcode, bound);
655                                          get_motion_vector(dec, bs, x, y, 1, &mb->mvs[1], fcode, bound_x, bound_y);                                          get_motion_vector(dec, bs, x, y, 1, &mb->mvs[1], fcode, bound);
656                                          get_motion_vector(dec, bs, x, y, 2, &mb->mvs[2], fcode, bound_x, bound_y);                                          get_motion_vector(dec, bs, x, y, 2, &mb->mvs[2], fcode, bound);
657                                          get_motion_vector(dec, bs, x, y, 3, &mb->mvs[3], fcode, bound_x, bound_y);                                          get_motion_vector(dec, bs, x, y, 3, &mb->mvs[3], fcode, bound);
658                                  } else                  // MODE_INTRA, MODE_INTRA_Q                                  } else                  // MODE_INTRA, MODE_INTRA_Q
659                                  {                                  {
660                                          mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x =                                          mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x =
# Line 645  Line 662 
662                                          mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y =                                          mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y =
663                                                  0;                                                  0;
664                                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,                                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,
665                                                                          intra_dc_threshold, bound_x, bound_y);                                                                          intra_dc_threshold, bound);
666                                          continue;                                          continue;
667                                  }                                  }
668    
# Line 1119  Line 1136 
1136    
1137                                          if (quant > 31) {                                          if (quant > 31) {
1138                                                  quant = 31;                                                  quant = 31;
1139                                          } else if (mb->quant < 1) {                                          } else if (quant < 1) {
1140                                                  quant = 1;                                                  quant = 1;
1141                                          }                                          }
1142                                  } else {                                  } else {
# Line 1262  Line 1279 
1279          case P_VOP:          case P_VOP:
1280                  decoder_pframe(dec, &bs, rounding, quant, fcode_forward,                  decoder_pframe(dec, &bs, rounding, quant, fcode_forward,
1281                                             intra_dc_threshold);                                             intra_dc_threshold);
1282    #ifdef BFRAMES_DEC
1283                  DEBUG1("P_VOP  Time=", dec->time);                  DEBUG1("P_VOP  Time=", dec->time);
1284    #endif
1285                  break;                  break;
1286    
1287          case I_VOP:          case I_VOP:
1288                  decoder_iframe(dec, &bs, quant, intra_dc_threshold);                  decoder_iframe(dec, &bs, quant, intra_dc_threshold);
1289    #ifdef BFRAMES_DEC
1290                  DEBUG1("I_VOP  Time=", dec->time);                  DEBUG1("I_VOP  Time=", dec->time);
1291    #endif
1292                  break;                  break;
1293    
1294          case B_VOP:          case B_VOP:

Legend:
Removed from v.248  
changed lines
  Added in v.252

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