[cvs] / xvidcore / src / decoder.c Repository:
ViewVC logotype

Diff of /xvidcore/src/decoder.c

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

revision 1.22, Fri Jun 28 15:14:40 2002 UTC revision 1.26, Tue Jul 9 01:37:22 2002 UTC
# 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 499  Line 501 
501          int low = ((-32) * scale_fac);          int low = ((-32) * scale_fac);
502          int range = (64 * scale_fac);          int range = (64 * scale_fac);
503    
504          VECTOR pmv[4];          VECTOR pmv;
         int32_t psad[4];  
   
505          int mv_x, mv_y;          int mv_x, mv_y;
         int pmv_x, pmv_y;  
   
   
         get_pmvdata(dec->mbs, x, y, dec->mb_width, k, pmv, psad, bound_x, bound_y);  
506    
507          pmv_x = pmv[0].x;          pmv = get_pmv2(dec->mbs, dec->mb_width, bound, x, y, k);
         pmv_y = pmv[0].y;  
508    
509          mv_x = get_mv(bs, fcode);          mv_x = get_mv(bs, fcode);
510          mv_y = get_mv(bs, fcode);          mv_y = get_mv(bs, fcode);
511    
512          mv_x += pmv_x;          DPRINTF(DPRINTF_MV,"mv_diff (%i,%i) pred (%i,%i)", mv_x, mv_y, pmv.x, pmv.y);
513          mv_y += pmv_y;  
514            mv_x += pmv.x;
515            mv_y += pmv.y;
516    
517          if (mv_x < low) {          if (mv_x < low) {
518                  mv_x += range;                  mv_x += range;
# Line 545  Line 542 
542  {  {
543    
544          uint32_t x, y;          uint32_t x, y;
545          uint32_t bound_x, bound_y;          uint32_t bound;
546    
547          start_timer();          start_timer();
548          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,
549                                     dec->width, dec->height, dec->interlacing);                                     dec->width, dec->height, dec->interlacing);
550          stop_edges_timer();          stop_edges_timer();
551    
552          bound_x = bound_y = 0;          bound = 0;
553    
554          for (y = 0; y < dec->mb_height; y++) {          for (y = 0; y < dec->mb_height; y++) {
555                  for (x = 0; x < dec->mb_width; x++) {                  for (x = 0; x < dec->mb_width; x++) {
556                          MACROBLOCK *mb;                          MACROBLOCK *mb;
557    
558                          skip_stuffing(bs);                          // skip stuffing
559                          if (check_resync_marker(bs, 0))                          while (BitstreamShowBits(bs, 10) == 1)
560                          {                                  BitstreamSkip(bs, 10);
561                                  int mbnum = read_video_packet_header(bs, 0);  
562                                  x = bound_x = mbnum % dec->mb_width;                          if (check_resync_marker(bs, fcode - 1))
563                                  y = bound_y = mbnum / dec->mb_width;                          {
564                                    bound = read_video_packet_header(bs, fcode - 1, &quant);
565                                    x = bound % dec->mb_width;
566                                    y = bound / dec->mb_width;
567                          }                          }
568                          mb = &dec->mbs[y * dec->mb_width + x];                          mb = &dec->mbs[y * dec->mb_width + x];
569    
570                            DPRINTF(DPRINTF_MB, "macroblock (%i,%i) %08x", x, y, BitstreamShowBits(bs, 32));
571    
572                          //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
573                          if (!(BitstreamGetBit(bs)))     // not_coded                          if (!(BitstreamGetBit(bs)))     // not_coded
574                          {                          {
# Line 580  Line 582 
582                                  mcbpc = get_mcbpc_inter(bs);                                  mcbpc = get_mcbpc_inter(bs);
583                                  mb->mode = mcbpc & 7;                                  mb->mode = mcbpc & 7;
584                                  cbpc = (mcbpc >> 4);                                  cbpc = (mcbpc >> 4);
585    
586                                    DPRINTF(DPRINTF_MB, "mode %i", mb->mode);
587                                    DPRINTF(DPRINTF_MB, "cbpc %i", cbpc);
588                                  acpred_flag = 0;                                  acpred_flag = 0;
589    
590                                  intra = (mb->mode == MODE_INTRA || mb->mode == MODE_INTRA_Q);                                  intra = (mb->mode == MODE_INTRA || mb->mode == MODE_INTRA_Q);
# Line 589  Line 594 
594                                  }                                  }
595    
596                                  cbpy = get_cbpy(bs, intra);                                  cbpy = get_cbpy(bs, intra);
597                                    DPRINTF(DPRINTF_MB, "cbpy %i", cbpy);
598    
599                                  cbp = (cbpy << 2) | cbpc;                                  cbp = (cbpy << 2) | cbpc;
600    
601                                  if (mb->mode == MODE_INTER_Q || mb->mode == MODE_INTRA_Q) {                                  if (mb->mode == MODE_INTER_Q || mb->mode == MODE_INTRA_Q) {
602                                          quant += dquant_table[BitstreamGetBits(bs, 2)];                                          int dquant = dquant_table[BitstreamGetBits(bs, 2)];
603                                            DPRINTF(DPRINTF_MB, "dquant %i", dquant);
604                                            quant += dquant;
605                                          if (quant > 31) {                                          if (quant > 31) {
606                                                  quant = 31;                                                  quant = 31;
607                                          } else if (mb->quant < 1) {                                          } else if (quant < 1) {
608                                                  quant = 1;                                                  quant = 1;
609                                          }                                          }
610                                            DPRINTF(DPRINTF_MB, "quant %i", quant);
611                                  }                                  }
612                                  mb->quant = quant;                                  mb->quant = quant;
613    
# Line 621  Line 631 
631                                  if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) {                                  if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) {
632                                          if (dec->interlacing && mb->field_pred) {                                          if (dec->interlacing && mb->field_pred) {
633                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0],                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0],
634                                                                                    fcode, bound_x, bound_y);                                                                                    fcode, bound);
635                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[1],                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[1],
636                                                                                    fcode, bound_x, bound_y);                                                                                    fcode, bound);
637                                          } else {                                          } else {
638                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0],                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0],
639                                                                                    fcode, bound_x, bound_y);                                                                                    fcode, bound);
640                                                  mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x =                                                  mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x =
641                                                          mb->mvs[0].x;                                                          mb->mvs[0].x;
642                                                  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 644 
644                                          }                                          }
645                                  } else if (mb->mode ==                                  } else if (mb->mode ==
646                                                     MODE_INTER4V /* || mb->mode == MODE_INTER4V_Q */ ) {                                                     MODE_INTER4V /* || mb->mode == MODE_INTER4V_Q */ ) {
647                                          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);
648                                          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);
649                                          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);
650                                          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);
651                                  } else                  // MODE_INTRA, MODE_INTRA_Q                                  } else                  // MODE_INTRA, MODE_INTRA_Q
652                                  {                                  {
653                                          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 655 
655                                          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 =
656                                                  0;                                                  0;
657                                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,                                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,
658                                                                          intra_dc_threshold, bound_x, bound_y);                                                                          intra_dc_threshold, bound);
659                                          continue;                                          continue;
660                                  }                                  }
661    
# Line 1119  Line 1129 
1129    
1130                                          if (quant > 31) {                                          if (quant > 31) {
1131                                                  quant = 31;                                                  quant = 31;
1132                                          } else if (mb->quant < 1) {                                          } else if (quant < 1) {
1133                                                  quant = 1;                                                  quant = 1;
1134                                          }                                          }
1135                                  } else {                                  } else {
# Line 1262  Line 1272 
1272          case P_VOP:          case P_VOP:
1273                  decoder_pframe(dec, &bs, rounding, quant, fcode_forward,                  decoder_pframe(dec, &bs, rounding, quant, fcode_forward,
1274                                             intra_dc_threshold);                                             intra_dc_threshold);
1275    #ifdef BFRAMES_DEC
1276                  DEBUG1("P_VOP  Time=", dec->time);                  DEBUG1("P_VOP  Time=", dec->time);
1277    #endif
1278                  break;                  break;
1279    
1280          case I_VOP:          case I_VOP:
1281                  decoder_iframe(dec, &bs, quant, intra_dc_threshold);                  decoder_iframe(dec, &bs, quant, intra_dc_threshold);
1282    #ifdef BFRAMES_DEC
1283                  DEBUG1("I_VOP  Time=", dec->time);                  DEBUG1("I_VOP  Time=", dec->time);
1284    #endif
1285                  break;                  break;
1286    
1287          case B_VOP:          case B_VOP:

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.26

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