[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.51.2.5, Fri Jun 4 11:54:41 2004 UTC revision 1.52, Thu Apr 1 11:11:28 2004 UTC
# Line 4  Line 4 
4   *  - Decoder Module -   *  - Decoder Module -
5   *   *
6   *  Copyright(C) 2002      MinChen <chenm001@163.com>   *  Copyright(C) 2002      MinChen <chenm001@163.com>
7   *               2002-2003 Peter Ross <pross@xvid.org>   *               2002-2004 Peter Ross <pross@xvid.org>
8   *   *
9   *  This program is free software ; you can redistribute it and/or modify   *  This program is free software ; you can redistribute it and/or modify
10   *  it under the terms of the GNU General Public License as published by   *  it under the terms of the GNU General Public License as published by
# 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;
         dec->time_inc_resolution = 1; /* until VOL header says otherwise */  
225    
226          dec->fixed_dimensions = (dec->width > 0 && dec->height > 0);          dec->fixed_dimensions = (dec->width > 0 && dec->height > 0);
227    
# Line 339  Line 338 
338                  stop_coding_timer();                  stop_coding_timer();
339    
340                  start_timer();                  start_timer();
341                  add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors, dec->bs_version);                  add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors);
342                  stop_prediction_timer();                  stop_prediction_timer();
343    
344                  start_timer();                  start_timer();
# Line 497  Line 496 
496                          mv[i] = pMB->mvs[i];                          mv[i] = pMB->mvs[i];
497          }          }
498    
         for (i = 0; i < 4; i++) {  
                 /* clip to valid range */  
                 int border = (int)(dec->mb_width - x_pos) << (5 + dec->quarterpel);  
                 if (mv[i].x > border) {  
                         DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", mv[i].x, border, x_pos, y_pos);  
                         mv[i].x = border;  
                 } else {  
                         border = (-(int)x_pos-1) << (5 + dec->quarterpel);  
                         if (mv[i].x < border) {  
                                 DPRINTF(XVID_DEBUG_MV, "mv.x < min -- %d < %d, MB %d, %d", mv[i].x, border, x_pos, y_pos);  
                                 mv[i].x = border;  
                         }  
                 }  
   
                 border = (int)(dec->mb_height - y_pos) << (5 + dec->quarterpel);  
                 if (mv[i].y >  border) {  
                         DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", mv[i].y, border, x_pos, y_pos);  
                         mv[i].y = border;  
                 } else {  
                         border = (-(int)y_pos-1) << (5 + dec->quarterpel);  
                         if (mv[i].y < border) {  
                                 DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", mv[i].y, border, x_pos, y_pos);  
                                 mv[i].y = border;  
                         }  
                 }  
         }  
   
499          start_timer();          start_timer();
500    
501          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 789  Line 761 
761                  mv.y -= range;                  mv.y -= range;
762          }          }
763    
764            /* clip to valid range */
765    
766            if (mv.x > ((int)(dec->mb_width - x) << (5 + dec->quarterpel)) )
767                    mv.x = (int)(dec->mb_width - x) << (5 + dec->quarterpel);
768    
769            else if (mv.x < (int)(-x-1) << (5 + dec->quarterpel))
770                    mv.x = (int)(-x-1) << (5 + dec->quarterpel);
771    
772            if (mv.y > ((int)(dec->mb_height - y) << (5 + dec->quarterpel)) )
773                    mv.y = (int)(dec->mb_height - y) << (5 + dec->quarterpel);
774    
775            else if (mv.y < ((int)(-y-1)) << (5 + dec->quarterpel) )
776                    mv.y = (int)(-y-1) << (5 + dec->quarterpel);
777    
778          ret_mv->x = mv.x;          ret_mv->x = mv.x;
779          ret_mv->y = mv.y;          ret_mv->y = mv.y;
780  }  }
# Line 1000  Line 986 
986          else if (mv_y > high)          else if (mv_y > high)
987                  mv_y -= range;                  mv_y -= range;
988    
989    
990            /* clip to valid range */
991            if (mv_x > ((int)(dec->mb_width - x) << (5 + dec->quarterpel)) )
992                    mv_x = (int)(dec->mb_width - x) << (5 + dec->quarterpel);
993    
994            else if (mv_x < (int)(-x-1) << (5 + dec->quarterpel))
995                    mv_x = (int)(-x-1) << (5 + dec->quarterpel);
996    
997            if (mv_y > ((int)(dec->mb_height - y) << (5 + dec->quarterpel)) )
998                    mv_y = (int)(dec->mb_height - y) << (5 + dec->quarterpel);
999    
1000            else if (mv_y < ((int)(-y-1)) << (5 + dec->quarterpel) )
1001                    mv_y = (int)(-y-1) << (5 + dec->quarterpel);
1002    
1003          mv->x = mv_x;          mv->x = mv_x;
1004          mv->y = mv_y;          mv->y = mv_y;
1005  }  }
# Line 1215  Line 1215 
1215          uint32_t x, y;          uint32_t x, y;
1216          VECTOR mv;          VECTOR mv;
1217          const VECTOR zeromv = {0,0};          const VECTOR zeromv = {0,0};
1218            const int64_t TRB = dec->time_pp - dec->time_bp, TRD = dec->time_pp;
1219          int i;          int i;
1220    
1221          start_timer();          start_timer();
# Line 1309  Line 1310 
1310    
1311                          case MODE_DIRECT_NONE_MV:                          case MODE_DIRECT_NONE_MV:
1312                                  for (i = 0; i < 4; i++) {                                  for (i = 0; i < 4; i++) {
1313                                          mb->mvs[i].x = last_mb->mvs[i].x*dec->time_bp/dec->time_pp + mv.x;                                          mb->mvs[i].x = (int32_t) ((TRB * last_mb->mvs[i].x) / TRD + mv.x);
1314                                          mb->mvs[i].y = last_mb->mvs[i].y*dec->time_bp/dec->time_pp + mv.y;                                          mb->b_mvs[i].x = (int32_t) ((mv.x == 0)
1315                                                                            ? ((TRB - TRD) * last_mb->mvs[i].x) / TRD
1316                                          mb->b_mvs[i].x = (mv.x)                                                                          : mb->mvs[i].x - last_mb->mvs[i].x);
1317                                                  ?  mb->mvs[i].x - last_mb->mvs[i].x                                          mb->mvs[i].y = (int32_t) ((TRB * last_mb->mvs[i].y) / TRD + mv.y);
1318                                                  : last_mb->mvs[i].x*(dec->time_bp - dec->time_pp)/dec->time_pp;                                          mb->b_mvs[i].y = (int32_t) ((mv.y == 0)
1319                                          mb->b_mvs[i].y = (mv.y)                                                                          ? ((TRB - TRD) * last_mb->mvs[i].y) / TRD
1320                                                  ? mb->mvs[i].y - last_mb->mvs[i].y                                                                          : mb->mvs[i].y - last_mb->mvs[i].y);
                                                 : last_mb->mvs[i].y*(dec->time_bp - dec->time_pp)/dec->time_pp;  
1321                                  }                                  }
1322    
1323                                  decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0],                                  decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0],
# Line 1364  Line 1364 
1364          if (dec->cartoon_mode)          if (dec->cartoon_mode)
1365                  frame->general &= ~XVID_FILMEFFECT;                  frame->general &= ~XVID_FILMEFFECT;
1366    
1367          if (frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) && mbs != NULL)     /* post process */          if ((frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) || frame->brightness!=0)
1368                    && mbs != NULL) /* post process */
1369          {          {
1370                  /* note: image is stored to tmp */                  /* note: image is stored to tmp */
1371                  image_copy(&dec->tmp, img, dec->edged_width, dec->height);                  image_copy(&dec->tmp, img, dec->edged_width, dec->height);
1372                  image_postproc(&dec->postproc, &dec->tmp, dec->edged_width,                  image_postproc(&dec->postproc, &dec->tmp, dec->edged_width,
1373                                             mbs, dec->mb_width, dec->mb_height, dec->mb_width,                                             mbs, dec->mb_width, dec->mb_height, dec->mb_width,
1374                                             frame->general, dec->frames, (coding_type == B_VOP));                                             frame->general, frame->brightness, dec->frames, (coding_type == B_VOP));
1375                  img = &dec->tmp;                  img = &dec->tmp;
1376          }          }
1377    
# Line 1490  Line 1491 
1491                  goto repeat;                  goto repeat;
1492          }          }
1493    
         if(dec->frames == 0 && coding_type != I_VOP) {  
                 /* 1st frame is not an i-vop */  
                 goto repeat;  
         }  
   
1494          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 */
1495    
1496          /* packed_mode: special-N_VOP treament */          /* packed_mode: special-N_VOP treament */

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

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