[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.52, Thu Apr 1 11:11:28 2004 UTC revision 1.59, Sat Jun 12 13:02:12 2004 UTC
# Line 222  Line 222 
222          dec->time = dec->time_base = dec->last_time_base = 0;          dec->time = dec->time_base = dec->last_time_base = 0;
223          dec->low_delay = 0;          dec->low_delay = 0;
224          dec->packed_mode = 0;          dec->packed_mode = 0;
225            dec->time_inc_resolution = 1; /* until VOL header says otherwise */
226    
227          dec->fixed_dimensions = (dec->width > 0 && dec->height > 0);          dec->fixed_dimensions = (dec->width > 0 && dec->height > 0);
228    
# Line 338  Line 339 
339                  stop_coding_timer();                  stop_coding_timer();
340    
341                  start_timer();                  start_timer();
342                  add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors);                  add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors, dec->bs_version);
343                  stop_prediction_timer();                  stop_prediction_timer();
344    
345                  start_timer();                  start_timer();
# Line 496  Line 497 
497                          mv[i] = pMB->mvs[i];                          mv[i] = pMB->mvs[i];
498          }          }
499    
500            for (i = 0; i < 4; i++) {
501                    /* clip to valid range */
502                    int border = (int)(dec->mb_width - x_pos) << (5 + dec->quarterpel);
503                    if (mv[i].x > border) {
504                            DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", mv[i].x, border, x_pos, y_pos);
505                            mv[i].x = border;
506                    } else {
507                            border = (-(int)x_pos-1) << (5 + dec->quarterpel);
508                            if (mv[i].x < border) {
509                                    DPRINTF(XVID_DEBUG_MV, "mv.x < min -- %d < %d, MB %d, %d", mv[i].x, border, x_pos, y_pos);
510                                    mv[i].x = border;
511                            }
512                    }
513    
514                    border = (int)(dec->mb_height - y_pos) << (5 + dec->quarterpel);
515                    if (mv[i].y >  border) {
516                            DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", mv[i].y, border, x_pos, y_pos);
517                            mv[i].y = border;
518                    } else {
519                            border = (-(int)y_pos-1) << (5 + dec->quarterpel);
520                            if (mv[i].y < border) {
521                                    DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", mv[i].y, border, x_pos, y_pos);
522                                    mv[i].y = border;
523                            }
524                    }
525            }
526    
527          start_timer();          start_timer();
528    
529          if (pMB->mode != MODE_INTER4V) { /* INTER, INTER_Q, NOT_CODED, FORWARD, BACKWARD */          if (pMB->mode != MODE_INTER4V) { /* INTER, INTER_Q, NOT_CODED, FORWARD, BACKWARD */
# Line 761  Line 789 
789                  mv.y -= range;                  mv.y -= range;
790          }          }
791    
         /* clip to valid range */  
   
         if (mv.x > ((int)(dec->mb_width - x) << (5 + dec->quarterpel)) )  
                 mv.x = (int)(dec->mb_width - x) << (5 + dec->quarterpel);  
   
         else if (mv.x < (int)(-x-1) << (5 + dec->quarterpel))  
                 mv.x = (int)(-x-1) << (5 + dec->quarterpel);  
   
         if (mv.y > ((int)(dec->mb_height - y) << (5 + dec->quarterpel)) )  
                 mv.y = (int)(dec->mb_height - y) << (5 + dec->quarterpel);  
   
         else if (mv.y < ((int)(-y-1)) << (5 + dec->quarterpel) )  
                 mv.y = (int)(-y-1) << (5 + dec->quarterpel);  
   
792          ret_mv->x = mv.x;          ret_mv->x = mv.x;
793          ret_mv->y = mv.y;          ret_mv->y = mv.y;
794  }  }
# Line 801  Line 815 
815                  mb_height = (dec->height + 31) / 32;                  mb_height = (dec->height + 31) / 32;
816          }          }
817    
818            if (!dec->is_edged[0]) {
819          start_timer();          start_timer();
820          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,
821                                          dec->width, dec->height, dec->bs_version);                                          dec->width, dec->height, dec->bs_version);
822                    dec->is_edged[0] = 1;
823          stop_edges_timer();          stop_edges_timer();
824            }
825    
826          if (gmc_warp) {          if (gmc_warp) {
827                  /* accuracy: 0==1/2, 1=1/4, 2=1/8, 3=1/16 */                  /* accuracy: 0==1/2, 1=1/4, 2=1/8, 3=1/16 */
# Line 986  Line 1003 
1003          else if (mv_y > high)          else if (mv_y > high)
1004                  mv_y -= range;                  mv_y -= range;
1005    
   
         /* clip to valid range */  
         if (mv_x > ((int)(dec->mb_width - x) << (5 + dec->quarterpel)) )  
                 mv_x = (int)(dec->mb_width - x) << (5 + dec->quarterpel);  
   
         else if (mv_x < (int)(-x-1) << (5 + dec->quarterpel))  
                 mv_x = (int)(-x-1) << (5 + dec->quarterpel);  
   
         if (mv_y > ((int)(dec->mb_height - y) << (5 + dec->quarterpel)) )  
                 mv_y = (int)(dec->mb_height - y) << (5 + dec->quarterpel);  
   
         else if (mv_y < ((int)(-y-1)) << (5 + dec->quarterpel) )  
                 mv_y = (int)(-y-1) << (5 + dec->quarterpel);  
   
1006          mv->x = mv_x;          mv->x = mv_x;
1007          mv->y = mv_y;          mv->y = mv_y;
1008  }  }
# Line 1215  Line 1218 
1218          uint32_t x, y;          uint32_t x, y;
1219          VECTOR mv;          VECTOR mv;
1220          const VECTOR zeromv = {0,0};          const VECTOR zeromv = {0,0};
         const int64_t TRB = dec->time_pp - dec->time_bp, TRD = dec->time_pp;  
1221          int i;          int i;
1222    
1223            if (!dec->is_edged[0]) {
1224          start_timer();          start_timer();
1225          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,
1226                                          dec->width, dec->height, dec->bs_version);                                          dec->width, dec->height, dec->bs_version);
1227                    dec->is_edged[0] = 1;
1228                    stop_edges_timer();
1229            }
1230    
1231            if (!dec->is_edged[1]) {
1232                    start_timer();
1233          image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height,          image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height,
1234                                          dec->width, dec->height, dec->bs_version);                                          dec->width, dec->height, dec->bs_version);
1235                    dec->is_edged[1] = 1;
1236          stop_edges_timer();          stop_edges_timer();
1237            }
1238    
1239          for (y = 0; y < dec->mb_height; y++) {          for (y = 0; y < dec->mb_height; y++) {
1240                  /* Initialize Pred Motion Vector */                  /* Initialize Pred Motion Vector */
# Line 1310  Line 1321 
1321    
1322                          case MODE_DIRECT_NONE_MV:                          case MODE_DIRECT_NONE_MV:
1323                                  for (i = 0; i < 4; i++) {                                  for (i = 0; i < 4; i++) {
1324                                          mb->mvs[i].x = (int32_t) ((TRB * last_mb->mvs[i].x) / TRD + mv.x);                                          mb->mvs[i].x = last_mb->mvs[i].x*dec->time_bp/dec->time_pp + mv.x;
1325                                          mb->b_mvs[i].x = (int32_t) ((mv.x == 0)                                          mb->mvs[i].y = last_mb->mvs[i].y*dec->time_bp/dec->time_pp + mv.y;
1326                                                                          ? ((TRB - TRD) * last_mb->mvs[i].x) / TRD  
1327                                                                          : mb->mvs[i].x - last_mb->mvs[i].x);                                          mb->b_mvs[i].x = (mv.x)
1328                                          mb->mvs[i].y = (int32_t) ((TRB * last_mb->mvs[i].y) / TRD + mv.y);                                                  ?  mb->mvs[i].x - last_mb->mvs[i].x
1329                                          mb->b_mvs[i].y = (int32_t) ((mv.y == 0)                                                  : last_mb->mvs[i].x*(dec->time_bp - dec->time_pp)/dec->time_pp;
1330                                                                          ? ((TRB - TRD) * last_mb->mvs[i].y) / TRD                                          mb->b_mvs[i].y = (mv.y)
1331                                                                          : mb->mvs[i].y - last_mb->mvs[i].y);                                                  ? mb->mvs[i].y - last_mb->mvs[i].y
1332                                                    : last_mb->mvs[i].y*(dec->time_bp - dec->time_pp)/dec->time_pp;
1333                                  }                                  }
1334    
1335                                  decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0],                                  decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0],
# Line 1361  Line 1373 
1373                                          xvid_dec_frame_t * frame, xvid_dec_stats_t * stats,                                          xvid_dec_frame_t * frame, xvid_dec_stats_t * stats,
1374                                          int coding_type, int quant)                                          int coding_type, int quant)
1375  {  {
1376            const int brightness = XVID_VERSION_MINOR(frame->version) >= 1 ? frame->brightness : 0;
1377    
1378          if (dec->cartoon_mode)          if (dec->cartoon_mode)
1379                  frame->general &= ~XVID_FILMEFFECT;                  frame->general &= ~XVID_FILMEFFECT;
1380    
1381          if ((frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) || frame->brightness!=0)          if ((frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) || brightness!=0)
1382                  && mbs != NULL) /* post process */                  && mbs != NULL) /* post process */
1383          {          {
1384                  /* note: image is stored to tmp */                  /* note: image is stored to tmp */
1385                  image_copy(&dec->tmp, img, dec->edged_width, dec->height);                  image_copy(&dec->tmp, img, dec->edged_width, dec->height);
1386                  image_postproc(&dec->postproc, &dec->tmp, dec->edged_width,                  image_postproc(&dec->postproc, &dec->tmp, dec->edged_width,
1387                                             mbs, dec->mb_width, dec->mb_height, dec->mb_width,                                             mbs, dec->mb_width, dec->mb_height, dec->mb_width,
1388                                             frame->general, frame->brightness, dec->frames, (coding_type == B_VOP));                                             frame->general, brightness, dec->frames, (coding_type == B_VOP));
1389                  img = &dec->tmp;                  img = &dec->tmp;
1390          }          }
1391    
# Line 1491  Line 1505 
1505                  goto repeat;                  goto repeat;
1506          }          }
1507    
1508            if(dec->frames == 0 && coding_type != I_VOP) {
1509                    /* 1st frame is not an i-vop */
1510                    goto repeat;
1511            }
1512    
1513          dec->p_bmv.x = dec->p_bmv.y = dec->p_fmv.y = dec->p_fmv.y = 0;  /* init pred vector to 0 */          dec->p_bmv.x = dec->p_bmv.y = dec->p_fmv.y = dec->p_fmv.y = 0;  /* init pred vector to 0 */
1514    
1515          /* packed_mode: special-N_VOP treament */          /* packed_mode: special-N_VOP treament */
# Line 1540  Line 1559 
1559                  }                  }
1560    
1561                  image_swap(&dec->refn[0], &dec->refn[1]);                  image_swap(&dec->refn[0], &dec->refn[1]);
1562                    dec->is_edged[1] = dec->is_edged[0];
1563                  image_swap(&dec->cur, &dec->refn[0]);                  image_swap(&dec->cur, &dec->refn[0]);
1564                    dec->is_edged[0] = 0;
1565                  SWAP(MACROBLOCK *, dec->mbs, dec->last_mbs);                  SWAP(MACROBLOCK *, dec->mbs, dec->last_mbs);
1566                  dec->last_reduced_resolution = reduced_resolution;                  dec->last_reduced_resolution = reduced_resolution;
1567                  dec->last_coding_type = coding_type;                  dec->last_coding_type = coding_type;

Legend:
Removed from v.1.52  
changed lines
  Added in v.1.59

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