[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, Mon Mar 22 22:36:23 2004 UTC revision 1.66, Sun Aug 15 11:28:38 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 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 222  Line 223 
223          dec->time = dec->time_base = dec->last_time_base = 0;          dec->time = dec->time_base = dec->last_time_base = 0;
224          dec->low_delay = 0;          dec->low_delay = 0;
225          dec->packed_mode = 0;          dec->packed_mode = 0;
226            dec->time_inc_resolution = 1; /* until VOL header says otherwise */
227    
228          dec->fixed_dimensions = (dec->width > 0 && dec->height > 0);          dec->fixed_dimensions = (dec->width > 0 && dec->height > 0);
229    
# Line 338  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 389  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    
                 if (cbp & (1 << (5 - i))) {     /* coded */  
426    
427                          memset(block, 0, 64 * sizeof(int16_t)); /* clear */          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            for (i = 0; i < 6; i++) {
444                    /* Process only coded blocks */
445                    if (cbp & (1 << (5 - i))) {
446    
447                            /* 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                  }                  }
466          }          }
467    
468          if (dec->interlacing && pMB->field_dct) {  static void
469                  next_block = stride;  validate_vector(VECTOR * mv, unsigned int x_pos, unsigned int y_pos, const DECODER * dec)
470                  stride *= 2;  {
471            /* clip a vector to valid range
472               prevents crashes if bitstream is broken
473            */
474            int i;
475    
476            for (i = 0; i < 4; i++) {
477    
478                    int border = (int)(dec->mb_width - x_pos) << (5 + dec->quarterpel);
479                    if (mv[i].x > border) {
480                            DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", mv[i].x, border, x_pos, y_pos);
481                            mv[i].x = border;
482                    } else {
483                            border = (-(int)x_pos-1) << (5 + dec->quarterpel);
484                            if (mv[i].x < border) {
485                                    DPRINTF(XVID_DEBUG_MV, "mv.x < min -- %d < %d, MB %d, %d", mv[i].x, border, x_pos, y_pos);
486                                    mv[i].x = border;
487                            }
488          }          }
489    
490          start_timer();                  border = (int)(dec->mb_height - y_pos) << (5 + dec->quarterpel);
491          if (reduced_resolution) {                  if (mv[i].y >  border) {
492                  if (cbp & 32)                          DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", mv[i].y, border, x_pos, y_pos);
493                          add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride);                          mv[i].y = border;
                 if (cbp & 16)  
                         add_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride);  
                 if (cbp & 8)  
                         add_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride);  
                 if (cbp & 4)  
                         add_upsampled_8x8_16to8(pY_Cur + 16 + next_block, &data[3 * 64], stride);  
                 if (cbp & 2)  
                         add_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2);  
                 if (cbp & 1)  
                         add_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2);  
494          } else {          } else {
495                  if (cbp & 32)                          border = (-(int)y_pos-1) << (5 + dec->quarterpel);
496                          transfer_16to8add(pY_Cur, &data[0 * 64], stride);                          if (mv[i].y < border) {
497                  if (cbp & 16)                                  DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", mv[i].y, border, x_pos, y_pos);
498                          transfer_16to8add(pY_Cur + 8, &data[1 * 64], stride);                                  mv[i].y = border;
499                  if (cbp & 8)                          }
500                          transfer_16to8add(pY_Cur + next_block, &data[2 * 64], stride);                  }
                 if (cbp & 4)  
                         transfer_16to8add(pY_Cur + 8 + next_block, &data[3 * 64], stride);  
                 if (cbp & 2)  
                         transfer_16to8add(pU_Cur, &data[4 * 64], stride2);  
                 if (cbp & 1)  
                         transfer_16to8add(pV_Cur, &data[5 * 64], stride2);  
501          }          }
         stop_transfer_timer();  
502  }  }
503    
504  /* decode an inter macroblock */  /* decode an inter macroblock */
# Line 496  Line 538 
538                          mv[i] = pMB->mvs[i];                          mv[i] = pMB->mvs[i];
539          }          }
540    
541            validate_vector(mv, x_pos, y_pos, dec);
542    
543          start_timer();          start_timer();
544    
545          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 805 
805                  mv.y -= range;                  mv.y -= range;
806          }          }
807    
         /* 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);  
   
808          ret_mv->x = mv.x;          ret_mv->x = mv.x;
809          ret_mv->y = mv.y;          ret_mv->y = mv.y;
810  }  }
# Line 801  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 986  Line 1019 
1019          else if (mv_y > high)          else if (mv_y > high)
1020                  mv_y -= range;                  mv_y -= range;
1021    
   
         /* 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);  
   
1022          mv->x = mv_x;          mv->x = mv_x;
1023          mv->y = mv_y;          mv->y = mv_y;
1024  }  }
# 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 1361  Line 1360 
1360                                          xvid_dec_frame_t * frame, xvid_dec_stats_t * stats,                                          xvid_dec_frame_t * frame, xvid_dec_stats_t * stats,
1361                                          int coding_type, int quant)                                          int coding_type, int quant)
1362  {  {
1363            const int brightness = XVID_VERSION_MINOR(frame->version) >= 1 ? frame->brightness : 0;
1364    
1365          if (dec->cartoon_mode)          if (dec->cartoon_mode)
1366                  frame->general &= ~XVID_FILMEFFECT;                  frame->general &= ~XVID_FILMEFFECT;
1367    
1368          if (frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) && mbs != NULL)     /* post process */          if ((frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) || brightness!=0)
1369                    && mbs != NULL) /* post process */
1370          {          {
1371                  /* note: image is stored to tmp */                  /* note: image is stored to tmp */
1372                  image_copy(&dec->tmp, img, dec->edged_width, dec->height);                  image_copy(&dec->tmp, img, dec->edged_width, dec->height);
1373                  image_postproc(&dec->postproc, &dec->tmp, dec->edged_width,                  image_postproc(&dec->postproc, &dec->tmp, dec->edged_width,
1374                                             mbs, dec->mb_width, dec->mb_height, dec->mb_width,                                             mbs, dec->mb_width, dec->mb_height, dec->mb_width,
1375                                             frame->general, dec->frames, (coding_type == B_VOP));                                             frame->general, brightness, dec->frames, (coding_type == B_VOP));
1376                  img = &dec->tmp;                  img = &dec->tmp;
1377          }          }
1378    
# Line 1393  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 1490  Line 1491 
1491                  goto repeat;                  goto repeat;
1492          }          }
1493    
1494            if(dec->frames == 0 && coding_type != I_VOP) {
1495                    /* 1st frame is not an i-vop */
1496                    goto repeat;
1497            }
1498    
1499          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 */
1500    
1501          /* packed_mode: special-N_VOP treament */          /* packed_mode: special-N_VOP treament */
# Line 1539  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 1551  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.51  
changed lines
  Added in v.1.66

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