[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.56, Mon Apr 19 12:42:01 2004 UTC revision 1.67, Mon Aug 16 22:38:06 2004 UTC
# Line 48  Line 48 
48  #include "image/interpolate8x8.h"  #include "image/interpolate8x8.h"
49  #include "image/reduced.h"  #include "image/reduced.h"
50  #include "image/font.h"  #include "image/font.h"
51    #include "image/qpel.h"
52    
53  #include "bitstream/mbcoding.h"  #include "bitstream/mbcoding.h"
54  #include "prediction/mbprediction.h"  #include "prediction/mbprediction.h"
# Line 339  Line 340 
340                  stop_coding_timer();                  stop_coding_timer();
341    
342                  start_timer();                  start_timer();
343                  add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors);                  add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors, dec->bs_version);
344                  stop_prediction_timer();                  stop_prediction_timer();
345    
346                  start_timer();                  start_timer();
# Line 390  Line 391 
391                                  uint8_t * pY_Cur,                                  uint8_t * pY_Cur,
392                                  uint8_t * pU_Cur,                                  uint8_t * pU_Cur,
393                                  uint8_t * pV_Cur,                                  uint8_t * pV_Cur,
394                                  const int reduced_resolution,                                  int reduced_resolution,
395                                  const MACROBLOCK * pMB)                                  const MACROBLOCK * pMB)
396  {  {
397          DECLARE_ALIGNED_MATRIX(block, 1, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(data, 1, 64, int16_t, CACHE_LINE);
         DECLARE_ALIGNED_MATRIX(data, 6, 64, int16_t, CACHE_LINE);  
398    
399          int stride = dec->edged_width;          int stride = dec->edged_width;
400          int next_block = stride * (reduced_resolution ? 16 : 8);          int next_block = stride * (reduced_resolution ? 16 : 8);
         const int stride2 = stride/2;  
401          int i;          int i;
402          const uint32_t iQuant = pMB->quant;          const uint32_t iQuant = pMB->quant;
403          const int direction = dec->alternate_vertical_scan ? 2 : 0;          const int direction = dec->alternate_vertical_scan ? 2 : 0;
404          const quant_interFuncPtr dequant = dec->quant_type == 0 ? dequant_h263_inter : dequant_mpeg_inter;          typedef void (*get_inter_block_function_t)(
405                            Bitstream * bs,
406                            int16_t * block,
407                            int direction,
408                            const int quant,
409                            const uint16_t *matrix);
410            typedef void (*add_residual_function_t)(
411                            uint8_t *predicted_block,
412                            const int16_t *residual,
413                            int stride);
414    
415            const get_inter_block_function_t get_inter_block = (dec->quant_type == 0)
416                    ? (get_inter_block_function_t)get_inter_block_h263
417                    : (get_inter_block_function_t)get_inter_block_mpeg;
418    
419            const add_residual_function_t add_residual = (reduced_resolution)
420                    ? (add_residual_function_t)add_upsampled_8x8_16to8
421                    : (add_residual_function_t)transfer_16to8add;
422    
423          for (i = 0; i < 6; i++) {          uint8_t *dst[6];
424            int strides[6];
425    
426    
427            if (dec->interlacing && pMB->field_dct) {
428                    next_block = stride;
429                    stride *= 2;
430            }
431    
432            reduced_resolution = !!reduced_resolution;
433            dst[0] = pY_Cur;
434            dst[2] = pY_Cur + next_block;
435            dst[1] = dst[0] + (8<<reduced_resolution);
436            dst[3] = dst[2] + (8<<reduced_resolution);
437            dst[4] = pU_Cur;
438            dst[5] = pV_Cur;
439            strides[0] = strides[1] = strides[2] = strides[3] = stride;
440            strides[4] = stride/2;
441            strides[5] = stride/2;
442    
443                  if (cbp & (1 << (5 - i))) {     /* coded */          for (i = 0; i < 6; i++) {
444                    /* Process only coded blocks */
445                    if (cbp & (1 << (5 - i))) {
446    
447                          memset(block, 0, 64 * sizeof(int16_t)); /* clear */                          /* Clear the block */
448                            memset(&data[0], 0, 64*sizeof(int16_t));
449    
450                            /* Decode coeffs and dequantize on the fly */
451                          start_timer();                          start_timer();
452                          get_inter_block(bs, block, direction);                          get_inter_block(bs, &data[0], direction, iQuant, get_inter_matrix(dec->mpeg_quant_matrices));
453                          stop_coding_timer();                          stop_coding_timer();
454    
455                            /* iDCT */
456                          start_timer();                          start_timer();
457                          dequant(&data[i * 64], block, iQuant, dec->mpeg_quant_matrices);                          idct(&data[0]);
458                          stop_iquant_timer();                          stop_idct_timer();
459    
460                            /* Add this residual to the predicted block */
461                          start_timer();                          start_timer();
462                          idct(&data[i * 64]);                          add_residual(dst[i], &data[0], strides[i]);
463                          stop_idct_timer();                          stop_transfer_timer();
464                  }                  }
465          }          }
   
         if (dec->interlacing && pMB->field_dct) {  
                 next_block = stride;  
                 stride *= 2;  
466          }          }
467    
468          start_timer();  static void __inline
469          if (reduced_resolution) {  validate_vector(VECTOR * mv, unsigned int x_pos, unsigned int y_pos, const DECODER * dec)
470                  if (cbp & 32)  {
471                          add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride);          /* clip a vector to valid range
472                  if (cbp & 16)             prevents crashes if bitstream is broken
473                          add_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride);          */
474                  if (cbp & 8)          int shift = 5 + dec->quarterpel;
475                          add_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride);          int xborder_high = (int)(dec->mb_width - x_pos) << shift;
476                  if (cbp & 4)          int xborder_low = (-(int)x_pos-1) << shift;
477                          add_upsampled_8x8_16to8(pY_Cur + 16 + next_block, &data[3 * 64], stride);          int yborder_high = (int)(dec->mb_height - y_pos) << shift;
478                  if (cbp & 2)          int yborder_low = (-(int)y_pos-1) << shift;
479                          add_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2);  
480                  if (cbp & 1)  #define CHECK_MV(mv) \
481                          add_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2);          do { \
482          } else {          if ((mv).x > xborder_high) { \
483                  if (cbp & 32)                  DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", (mv).x, xborder_high, x_pos, y_pos); \
484                          transfer_16to8add(pY_Cur, &data[0 * 64], stride);                  (mv).x = xborder_high; \
485                  if (cbp & 16)          } else if ((mv).x < xborder_low) { \
486                          transfer_16to8add(pY_Cur + 8, &data[1 * 64], stride);                  DPRINTF(XVID_DEBUG_MV, "mv.x < min -- %d < %d, MB %d, %d", (mv).x, xborder_low, x_pos, y_pos); \
487                  if (cbp & 8)                  (mv).x = xborder_low; \
488                          transfer_16to8add(pY_Cur + next_block, &data[2 * 64], stride);          } \
489                  if (cbp & 4)          if ((mv).y > yborder_high) { \
490                          transfer_16to8add(pY_Cur + 8 + next_block, &data[3 * 64], stride);                  DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", (mv).y, yborder_high, x_pos, y_pos); \
491                  if (cbp & 2)                  (mv).y = yborder_high; \
492                          transfer_16to8add(pU_Cur, &data[4 * 64], stride2);          } else if ((mv).y < yborder_low) { \
493                  if (cbp & 1)                  DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", (mv).y, yborder_low, x_pos, y_pos); \
494                          transfer_16to8add(pV_Cur, &data[5 * 64], stride2);                  (mv).y = yborder_low; \
495          }          } \
496          stop_transfer_timer();          } while (0)
497    
498            CHECK_MV(mv[0]);
499            CHECK_MV(mv[1]);
500            CHECK_MV(mv[2]);
501            CHECK_MV(mv[3]);
502  }  }
503    
504  /* decode an inter macroblock */  /* decode an inter macroblock */
# Line 497  Line 538 
538                          mv[i] = pMB->mvs[i];                          mv[i] = pMB->mvs[i];
539          }          }
540    
541          for (i = 0; i < 4; i++) {          validate_vector(mv, x_pos, y_pos, dec);
                 /* 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;  
                         }  
                 }  
         }  
542    
543          start_timer();          start_timer();
544    
# Line 815  Line 831 
831                  mb_height = (dec->height + 31) / 32;                  mb_height = (dec->height + 31) / 32;
832          }          }
833    
834            if (!dec->is_edged[0]) {
835          start_timer();          start_timer();
836          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,
837                                          dec->width, dec->height, dec->bs_version);                                          dec->width, dec->height, dec->bs_version);
838                    dec->is_edged[0] = 1;
839          stop_edges_timer();          stop_edges_timer();
840            }
841    
842          if (gmc_warp) {          if (gmc_warp) {
843                  /* 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 1009  Line 1028 
1028  decoder_bf_interpolate_mbinter(DECODER * dec,  decoder_bf_interpolate_mbinter(DECODER * dec,
1029                                                                  IMAGE forward,                                                                  IMAGE forward,
1030                                                                  IMAGE backward,                                                                  IMAGE backward,
1031                                                                  const MACROBLOCK * pMB,                                                                  MACROBLOCK * pMB,
1032                                                                  const uint32_t x_pos,                                                                  const uint32_t x_pos,
1033                                                                  const uint32_t y_pos,                                                                  const uint32_t y_pos,
1034                                                                  Bitstream * bs,                                                                  Bitstream * bs,
# Line 1026  Line 1045 
1045          pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);          pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);
1046          pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);          pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);
1047    
1048            validate_vector(pMB->mvs, x_pos, y_pos, dec);
1049            validate_vector(pMB->b_mvs, x_pos, y_pos, dec);
1050    
1051          if (!direct) {          if (!direct) {
1052                  uv_dx = pMB->mvs[0].x;                  uv_dx = pMB->mvs[0].x;
1053                  uv_dy = pMB->mvs[0].y;                  uv_dy = pMB->mvs[0].y;
   
1054                  b_uv_dx = pMB->b_mvs[0].x;                  b_uv_dx = pMB->b_mvs[0].x;
1055                  b_uv_dy = pMB->b_mvs[0].y;                  b_uv_dy = pMB->b_mvs[0].y;
1056    
# Line 1042  Line 1063 
1063    
1064                  uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3];                  uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3];
1065                  uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3];                  uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3];
   
1066                  b_uv_dx = (b_uv_dx >> 1) + roundtab_79[b_uv_dx & 0x3];                  b_uv_dx = (b_uv_dx >> 1) + roundtab_79[b_uv_dx & 0x3];
1067                  b_uv_dy = (b_uv_dy >> 1) + roundtab_79[b_uv_dy & 0x3];                  b_uv_dy = (b_uv_dy >> 1) + roundtab_79[b_uv_dy & 0x3];
1068    
1069          } else {          } else {
                 if(dec->quarterpel) {  
                         uv_dx = (pMB->mvs[0].x / 2) + (pMB->mvs[1].x / 2) + (pMB->mvs[2].x / 2) + (pMB->mvs[3].x / 2);  
                         uv_dy = (pMB->mvs[0].y / 2) + (pMB->mvs[1].y / 2) + (pMB->mvs[2].y / 2) + (pMB->mvs[3].y / 2);  
                         b_uv_dx = (pMB->b_mvs[0].x / 2) + (pMB->b_mvs[1].x / 2) + (pMB->b_mvs[2].x / 2) + (pMB->b_mvs[3].x / 2);  
                         b_uv_dy = (pMB->b_mvs[0].y / 2) + (pMB->b_mvs[1].y / 2) + (pMB->b_mvs[2].y / 2) + (pMB->b_mvs[3].y / 2);  
                 } else {  
1070                          uv_dx = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x;                          uv_dx = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x;
1071                          uv_dy = pMB->mvs[0].y + pMB->mvs[1].y + pMB->mvs[2].y + pMB->mvs[3].y;                          uv_dy = pMB->mvs[0].y + pMB->mvs[1].y + pMB->mvs[2].y + pMB->mvs[3].y;
1072                          b_uv_dx = pMB->b_mvs[0].x + pMB->b_mvs[1].x + pMB->b_mvs[2].x + pMB->b_mvs[3].x;                          b_uv_dx = pMB->b_mvs[0].x + pMB->b_mvs[1].x + pMB->b_mvs[2].x + pMB->b_mvs[3].x;
1073                          b_uv_dy = pMB->b_mvs[0].y + pMB->b_mvs[1].y + pMB->b_mvs[2].y + pMB->b_mvs[3].y;                          b_uv_dy = pMB->b_mvs[0].y + pMB->b_mvs[1].y + pMB->b_mvs[2].y + pMB->b_mvs[3].y;
1074    
1075                    if (dec->quarterpel) {
1076                            uv_dx /= 2;
1077                            uv_dy /= 2;
1078                            b_uv_dx /= 2;
1079                            b_uv_dy /= 2;
1080                  }                  }
1081    
1082                  uv_dx = (uv_dx >> 3) + roundtab_76[uv_dx & 0xf];                  uv_dx = (uv_dx >> 3) + roundtab_76[uv_dx & 0xf];
# Line 1104  Line 1124 
1124    
1125          if(dec->quarterpel) {          if(dec->quarterpel) {
1126                  if(!direct) {                  if(!direct) {
1127                          interpolate16x16_quarterpel(dec->tmp.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64,                          interpolate16x16_add_quarterpel(dec->cur.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64,
1128                                                                                  dec->qtmp.y + 128, 16*x_pos, 16*y_pos,                                                                                  dec->qtmp.y + 128, 16*x_pos, 16*y_pos,
1129                                                                                  pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0);                                                                                  pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0);
1130                  } else {                  } else {
1131                          interpolate8x8_quarterpel(dec->tmp.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64,                          interpolate8x8_add_quarterpel(dec->cur.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64,
1132                                                                                  dec->qtmp.y + 128, 16*x_pos, 16*y_pos,                                                                                  dec->qtmp.y + 128, 16*x_pos, 16*y_pos,
1133                                                                                  pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0);                                                                                  pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0);
1134                          interpolate8x8_quarterpel(dec->tmp.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64,                          interpolate8x8_add_quarterpel(dec->cur.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64,
1135                                                                                  dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos,                                                                                  dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos,
1136                                                                                  pMB->b_mvs[1].x, pMB->b_mvs[1].y, stride, 0);                                                                                  pMB->b_mvs[1].x, pMB->b_mvs[1].y, stride, 0);
1137                          interpolate8x8_quarterpel(dec->tmp.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64,                          interpolate8x8_add_quarterpel(dec->cur.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64,
1138                                                                                  dec->qtmp.y + 128, 16*x_pos, 16*y_pos + 8,                                                                                  dec->qtmp.y + 128, 16*x_pos, 16*y_pos + 8,
1139                                                                                  pMB->b_mvs[2].x, pMB->b_mvs[2].y, stride, 0);                                                                                  pMB->b_mvs[2].x, pMB->b_mvs[2].y, stride, 0);
1140                          interpolate8x8_quarterpel(dec->tmp.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64,                          interpolate8x8_add_quarterpel(dec->cur.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64,
1141                                                                                  dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos + 8,                                                                                  dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos + 8,
1142                                                                                  pMB->b_mvs[3].x, pMB->b_mvs[3].y, stride, 0);                                                                                  pMB->b_mvs[3].x, pMB->b_mvs[3].y, stride, 0);
1143                  }                  }
1144          } else {          } else {
1145                  interpolate8x8_switch(dec->tmp.y, backward.y, 16 * x_pos, 16 * y_pos,                  interpolate8x8_add_switch(dec->cur.y, backward.y, 16 * x_pos, 16 * y_pos,
1146                                                          pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0);                                                          pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0);
1147                  interpolate8x8_switch(dec->tmp.y, backward.y, 16 * x_pos + 8,                  interpolate8x8_add_switch(dec->cur.y, backward.y, 16 * x_pos + 8,
1148                                                          16 * y_pos, pMB->b_mvs[1].x, pMB->b_mvs[1].y, stride, 0);                                                          16 * y_pos, pMB->b_mvs[1].x, pMB->b_mvs[1].y, stride, 0);
1149                  interpolate8x8_switch(dec->tmp.y, backward.y, 16 * x_pos,                  interpolate8x8_add_switch(dec->cur.y, backward.y, 16 * x_pos,
1150                                                          16 * y_pos + 8, pMB->b_mvs[2].x, pMB->b_mvs[2].y, stride, 0);                                                          16 * y_pos + 8, pMB->b_mvs[2].x, pMB->b_mvs[2].y, stride, 0);
1151                  interpolate8x8_switch(dec->tmp.y, backward.y, 16 * x_pos + 8,                  interpolate8x8_add_switch(dec->cur.y, backward.y, 16 * x_pos + 8,
1152                                                          16 * y_pos + 8, pMB->b_mvs[3].x, pMB->b_mvs[3].y, stride, 0);                                                          16 * y_pos + 8, pMB->b_mvs[3].x, pMB->b_mvs[3].y, stride, 0);
1153          }          }
1154    
1155          interpolate8x8_switch(dec->tmp.u, backward.u, 8 * x_pos, 8 * y_pos,          interpolate8x8_add_switch(dec->cur.u, backward.u, 8 * x_pos, 8 * y_pos,
1156                                                  b_uv_dx, b_uv_dy, stride2, 0);                                                  b_uv_dx, b_uv_dy, stride2, 0);
1157          interpolate8x8_switch(dec->tmp.v, backward.v, 8 * x_pos, 8 * y_pos,          interpolate8x8_add_switch(dec->cur.v, backward.v, 8 * x_pos, 8 * y_pos,
1158                                                  b_uv_dx, b_uv_dy, stride2, 0);                                                  b_uv_dx, b_uv_dy, stride2, 0);
1159    
         interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos,  
                                                 dec->cur.y + (16 * y_pos * stride) + 16 * x_pos,  
                                                 dec->tmp.y + (16 * y_pos * stride) + 16 * x_pos,  
                                                 stride, 1, 8);  
   
         interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8,  
                                                 dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8,  
                                                 dec->tmp.y + (16 * y_pos * stride) + 16 * x_pos + 8,  
                                                 stride, 1, 8);  
   
         interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos,  
                                                 dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos,  
                                                 dec->tmp.y + ((16 * y_pos + 8) * stride) + 16 * x_pos,  
                                                 stride, 1, 8);  
   
         interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8,  
                                                 dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8,  
                                                 dec->tmp.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8,  
                                                 stride, 1, 8);  
   
         interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos,  
                                                 dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos,  
                                                 dec->tmp.u + (8 * y_pos * stride2) + 8 * x_pos,  
                                                 stride2, 1, 8);  
   
         interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos,  
                                                 dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos,  
                                                 dec->tmp.v + (8 * y_pos * stride2) + 8 * x_pos,  
                                                 stride2, 1, 8);  
   
1160          stop_comp_timer();          stop_comp_timer();
1161    
1162          if (cbp)          if (cbp)
# Line 1215  Line 1205 
1205          uint32_t x, y;          uint32_t x, y;
1206          VECTOR mv;          VECTOR mv;
1207          const VECTOR zeromv = {0,0};          const VECTOR zeromv = {0,0};
         const int64_t TRB = dec->time_pp - dec->time_bp, TRD = dec->time_pp;  
1208          int i;          int i;
1209    
1210            if (!dec->is_edged[0]) {
1211          start_timer();          start_timer();
1212          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,
1213                                          dec->width, dec->height, dec->bs_version);                                          dec->width, dec->height, dec->bs_version);
1214                    dec->is_edged[0] = 1;
1215                    stop_edges_timer();
1216            }
1217    
1218            if (!dec->is_edged[1]) {
1219                    start_timer();
1220          image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height,          image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height,
1221                                          dec->width, dec->height, dec->bs_version);                                          dec->width, dec->height, dec->bs_version);
1222                    dec->is_edged[1] = 1;
1223          stop_edges_timer();          stop_edges_timer();
1224            }
1225    
1226          for (y = 0; y < dec->mb_height; y++) {          for (y = 0; y < dec->mb_height; y++) {
1227                  /* Initialize Pred Motion Vector */                  /* Initialize Pred Motion Vector */
# Line 1310  Line 1308 
1308    
1309                          case MODE_DIRECT_NONE_MV:                          case MODE_DIRECT_NONE_MV:
1310                                  for (i = 0; i < 4; i++) {                                  for (i = 0; i < 4; i++) {
1311                                          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;
1312                                          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;
1313                                                                          ? ((TRB - TRD) * last_mb->mvs[i].x) / TRD  
1314                                                                          : mb->mvs[i].x - last_mb->mvs[i].x);                                          mb->b_mvs[i].x = (mv.x)
1315                                          mb->mvs[i].y = (int32_t) ((TRB * last_mb->mvs[i].y) / TRD + mv.y);                                                  ?  mb->mvs[i].x - last_mb->mvs[i].x
1316                                          mb->b_mvs[i].y = (int32_t) ((mv.y == 0)                                                  : last_mb->mvs[i].x*(dec->time_bp - dec->time_pp)/dec->time_pp;
1317                                                                          ? ((TRB - TRD) * last_mb->mvs[i].y) / TRD                                          mb->b_mvs[i].y = (mv.y)
1318                                                                          : mb->mvs[i].y - last_mb->mvs[i].y);                                                  ? mb->mvs[i].y - last_mb->mvs[i].y
1319                                                    : last_mb->mvs[i].y*(dec->time_bp - dec->time_pp)/dec->time_pp;
1320                                  }                                  }
1321    
1322                                  decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0],                                  decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0],
# Line 1396  Line 1395 
1395          }          }
1396  }  }
1397    
   
1398  int  int
1399  decoder_decode(DECODER * dec,  decoder_decode(DECODER * dec,
1400                                  xvid_dec_frame_t * frame, xvid_dec_stats_t * stats)                                  xvid_dec_frame_t * frame, xvid_dec_stats_t * stats)
# Line 1547  Line 1545 
1545                  }                  }
1546    
1547                  image_swap(&dec->refn[0], &dec->refn[1]);                  image_swap(&dec->refn[0], &dec->refn[1]);
1548                    dec->is_edged[1] = dec->is_edged[0];
1549                  image_swap(&dec->cur, &dec->refn[0]);                  image_swap(&dec->cur, &dec->refn[0]);
1550                    dec->is_edged[0] = 0;
1551                  SWAP(MACROBLOCK *, dec->mbs, dec->last_mbs);                  SWAP(MACROBLOCK *, dec->mbs, dec->last_mbs);
1552                  dec->last_reduced_resolution = reduced_resolution;                  dec->last_reduced_resolution = reduced_resolution;
1553                  dec->last_coding_type = coding_type;                  dec->last_coding_type = coding_type;
# Line 1559  Line 1559 
1559    
1560                  if (dec->low_delay) {                  if (dec->low_delay) {
1561                          DPRINTF(XVID_DEBUG_ERROR, "warning: bvop found in low_delay==1 stream\n");                          DPRINTF(XVID_DEBUG_ERROR, "warning: bvop found in low_delay==1 stream\n");
1562                          dec->low_delay = 1;                          dec->low_delay = 0;
1563                  }                  }
1564    
1565                  if (dec->frames < 2) {                  if (dec->frames < 2) {

Legend:
Removed from v.1.56  
changed lines
  Added in v.1.67

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