[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.64, Mon Jul 26 19:32:28 2004 UTC revision 1.69, Sun Mar 27 03:59:41 2005 UTC
# Line 46  Line 46 
46  #include "dct/fdct.h"  #include "dct/fdct.h"
47  #include "utils/mem_transfer.h"  #include "utils/mem_transfer.h"
48  #include "image/interpolate8x8.h"  #include "image/interpolate8x8.h"
 #include "image/reduced.h"  
49  #include "image/font.h"  #include "image/font.h"
50  #include "image/qpel.h"  #include "image/qpel.h"
51    
# Line 62  Line 61 
61  #include "image/postprocessing.h"  #include "image/postprocessing.h"
62  #include "utils/mem_align.h"  #include "utils/mem_align.h"
63    
 #ifdef ARCH_IS_IA32  
 #define interpolate16x16_quarterpel new_interpolate16x16_quarterpel  
 #define interpolate8x8_quarterpel new_interpolate8x8_quarterpel  
 #endif  
   
64  static int  static int
65  decoder_resize(DECODER * dec)  decoder_resize(DECODER * dec)
66  {  {
# Line 276  Line 270 
270                                  Bitstream * bs,                                  Bitstream * bs,
271                                  const uint32_t quant,                                  const uint32_t quant,
272                                  const uint32_t intra_dc_threshold,                                  const uint32_t intra_dc_threshold,
273                                  const unsigned int bound,                                  const unsigned int bound)
                                 const int reduced_resolution)  
274  {  {
275    
276          DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE);
# Line 290  Line 283 
283          uint32_t iQuant = pMB->quant;          uint32_t iQuant = pMB->quant;
284          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
285    
         if (reduced_resolution) {  
                 pY_Cur = dec->cur.y + (y_pos << 5) * stride + (x_pos << 5);  
                 pU_Cur = dec->cur.u + (y_pos << 4) * stride2 + (x_pos << 4);  
                 pV_Cur = dec->cur.v + (y_pos << 4) * stride2 + (x_pos << 4);  
         }else{  
286                  pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);                  pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);
287                  pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);                  pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);
288                  pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);                  pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);
         }  
289    
290          memset(block, 0, 6 * 64 * sizeof(int16_t));     /* clear */          memset(block, 0, 6 * 64 * sizeof(int16_t));     /* clear */
291    
# Line 368  Line 355 
355          }          }
356    
357          start_timer();          start_timer();
   
         if (reduced_resolution)  
         {  
                 next_block*=2;  
                 copy_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride);  
                 copy_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride);  
                 copy_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride);  
                 copy_upsampled_8x8_16to8(pY_Cur + 16 + next_block, &data[3 * 64], stride);  
                 copy_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2);  
                 copy_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2);  
         }else{  
358                  transfer_16to8copy(pY_Cur, &data[0 * 64], stride);                  transfer_16to8copy(pY_Cur, &data[0 * 64], stride);
359                  transfer_16to8copy(pY_Cur + 8, &data[1 * 64], stride);                  transfer_16to8copy(pY_Cur + 8, &data[1 * 64], stride);
360                  transfer_16to8copy(pY_Cur + next_block, &data[2 * 64], stride);                  transfer_16to8copy(pY_Cur + next_block, &data[2 * 64], stride);
361                  transfer_16to8copy(pY_Cur + 8 + next_block, &data[3 * 64], stride);                  transfer_16to8copy(pY_Cur + 8 + next_block, &data[3 * 64], stride);
362                  transfer_16to8copy(pU_Cur, &data[4 * 64], stride2);                  transfer_16to8copy(pU_Cur, &data[4 * 64], stride2);
363                  transfer_16to8copy(pV_Cur, &data[5 * 64], stride2);                  transfer_16to8copy(pV_Cur, &data[5 * 64], stride2);
         }  
364          stop_transfer_timer();          stop_transfer_timer();
365  }  }
366    
# Line 396  Line 371 
371                                  uint8_t * pY_Cur,                                  uint8_t * pY_Cur,
372                                  uint8_t * pU_Cur,                                  uint8_t * pU_Cur,
373                                  uint8_t * pV_Cur,                                  uint8_t * pV_Cur,
                                 int reduced_resolution,  
374                                  const MACROBLOCK * pMB)                                  const MACROBLOCK * pMB)
375  {  {
376          DECLARE_ALIGNED_MATRIX(data, 1, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(data, 1, 64, int16_t, CACHE_LINE);
377    
378          int stride = dec->edged_width;          int stride = dec->edged_width;
379          int next_block = stride * (reduced_resolution ? 16 : 8);          int next_block = stride * 8;
380          int i;          int i;
381          const uint32_t iQuant = pMB->quant;          const uint32_t iQuant = pMB->quant;
382          const int direction = dec->alternate_vertical_scan ? 2 : 0;          const int direction = dec->alternate_vertical_scan ? 2 : 0;
# Line 421  Line 395 
395                  ? (get_inter_block_function_t)get_inter_block_h263                  ? (get_inter_block_function_t)get_inter_block_h263
396                  : (get_inter_block_function_t)get_inter_block_mpeg;                  : (get_inter_block_function_t)get_inter_block_mpeg;
397    
         const add_residual_function_t add_residual = (reduced_resolution)  
                 ? (add_residual_function_t)add_upsampled_8x8_16to8  
                 : (add_residual_function_t)transfer_16to8add;  
   
398          uint8_t *dst[6];          uint8_t *dst[6];
399          int strides[6];          int strides[6];
400    
# Line 434  Line 404 
404                  stride *= 2;                  stride *= 2;
405          }          }
406    
         reduced_resolution = !!reduced_resolution;  
407          dst[0] = pY_Cur;          dst[0] = pY_Cur;
408          dst[2] = pY_Cur + next_block;          dst[2] = pY_Cur + next_block;
409          dst[1] = dst[0] + (8<<reduced_resolution);          dst[1] = dst[0] + 8;
410          dst[3] = dst[2] + (8<<reduced_resolution);          dst[3] = dst[2] + 8;
411          dst[4] = pU_Cur;          dst[4] = pU_Cur;
412          dst[5] = pV_Cur;          dst[5] = pV_Cur;
413          strides[0] = strides[1] = strides[2] = strides[3] = stride;          strides[0] = strides[1] = strides[2] = strides[3] = stride;
# Line 464  Line 433 
433    
434                          /* Add this residual to the predicted block */                          /* Add this residual to the predicted block */
435                          start_timer();                          start_timer();
436                          add_residual(dst[i], &data[0], strides[i]);                          transfer_16to8add(dst[i], &data[0], strides[i]);
437                          stop_transfer_timer();                          stop_transfer_timer();
438                  }                  }
439          }          }
440  }  }
441    
442    static void __inline
443    validate_vector(VECTOR * mv, unsigned int x_pos, unsigned int y_pos, const DECODER * dec)
444    {
445            /* clip a vector to valid range
446               prevents crashes if bitstream is broken
447            */
448            int shift = 5 + dec->quarterpel;
449            int xborder_high = (int)(dec->mb_width - x_pos) << shift;
450            int xborder_low = (-(int)x_pos-1) << shift;
451            int yborder_high = (int)(dec->mb_height - y_pos) << shift;
452            int yborder_low = (-(int)y_pos-1) << shift;
453    
454    #define CHECK_MV(mv) \
455            do { \
456            if ((mv).x > xborder_high) { \
457                    DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", (mv).x, xborder_high, x_pos, y_pos); \
458                    (mv).x = xborder_high; \
459            } else if ((mv).x < xborder_low) { \
460                    DPRINTF(XVID_DEBUG_MV, "mv.x < min -- %d < %d, MB %d, %d", (mv).x, xborder_low, x_pos, y_pos); \
461                    (mv).x = xborder_low; \
462            } \
463            if ((mv).y > yborder_high) { \
464                    DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", (mv).y, yborder_high, x_pos, y_pos); \
465                    (mv).y = yborder_high; \
466            } else if ((mv).y < yborder_low) { \
467                    DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", (mv).y, yborder_low, x_pos, y_pos); \
468                    (mv).y = yborder_low; \
469            } \
470            } while (0)
471    
472            CHECK_MV(mv[0]);
473            CHECK_MV(mv[1]);
474            CHECK_MV(mv[2]);
475            CHECK_MV(mv[3]);
476    }
477    
478  /* decode an inter macroblock */  /* decode an inter macroblock */
479  static void  static void
480  decoder_mbinter(DECODER * dec,  decoder_mbinter(DECODER * dec,
# Line 479  Line 484 
484                                  const uint32_t cbp,                                  const uint32_t cbp,
485                                  Bitstream * bs,                                  Bitstream * bs,
486                                  const uint32_t rounding,                                  const uint32_t rounding,
                                 const int reduced_resolution,  
487                                  const int ref)                                  const int ref)
488  {  {
489          uint32_t stride = dec->edged_width;          uint32_t stride = dec->edged_width;
# Line 491  Line 495 
495          int uv_dx, uv_dy;          int uv_dx, uv_dy;
496          VECTOR mv[4];   /* local copy of mvs */          VECTOR mv[4];   /* local copy of mvs */
497    
         if (reduced_resolution) {  
                 pY_Cur = dec->cur.y + (y_pos << 5) * stride + (x_pos << 5);  
                 pU_Cur = dec->cur.u + (y_pos << 4) * stride2 + (x_pos << 4);  
                 pV_Cur = dec->cur.v + (y_pos << 4) * stride2 + (x_pos << 4);  
                 for (i = 0; i < 4; i++) {  
                         mv[i].x = RRV_MV_SCALEUP(pMB->mvs[i].x);  
                         mv[i].y = RRV_MV_SCALEUP(pMB->mvs[i].y);  
                 }  
         } else {  
498                  pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);                  pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);
499                  pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);                  pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);
500                  pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);                  pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);
501                  for (i = 0; i < 4; i++)                  for (i = 0; i < 4; i++)
502                          mv[i] = pMB->mvs[i];                          mv[i] = pMB->mvs[i];
         }  
503    
504          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;  
                         }  
                 }  
         }  
505    
506          start_timer();          start_timer();
507    
# Line 547  Line 516 
516                  uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3];                  uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3];
517                  uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3];                  uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3];
518    
519                  if (reduced_resolution)                  if (dec->quarterpel)
                         interpolate32x32_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos,  
                                                                         mv[0].x, mv[0].y, stride, rounding);  
                 else if (dec->quarterpel)  
520                          interpolate16x16_quarterpel(dec->cur.y, dec->refn[ref].y, dec->qtmp.y, dec->qtmp.y + 64,                          interpolate16x16_quarterpel(dec->cur.y, dec->refn[ref].y, dec->qtmp.y, dec->qtmp.y + 64,
521                                                                          dec->qtmp.y + 128, 16*x_pos, 16*y_pos,                                                                          dec->qtmp.y + 128, 16*x_pos, 16*y_pos,
522                                                                                          mv[0].x, mv[0].y, stride, rounding);                                                                                          mv[0].x, mv[0].y, stride, rounding);
# Line 571  Line 537 
537                  uv_dx = (uv_dx >> 3) + roundtab_76[uv_dx & 0xf];                  uv_dx = (uv_dx >> 3) + roundtab_76[uv_dx & 0xf];
538                  uv_dy = (uv_dy >> 3) + roundtab_76[uv_dy & 0xf];                  uv_dy = (uv_dy >> 3) + roundtab_76[uv_dy & 0xf];
539    
540                  if (reduced_resolution) {                  if (dec->quarterpel) {
                         interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos,  
                                                                 mv[0].x, mv[0].y, stride, rounding);  
                         interpolate16x16_switch(dec->cur.y, dec->refn[0].y , 32*x_pos + 16, 32*y_pos,  
                                                                 mv[1].x, mv[1].y, stride, rounding);  
                         interpolate16x16_switch(dec->cur.y, dec->refn[0].y , 32*x_pos, 32*y_pos + 16,  
                                                                 mv[2].x, mv[2].y, stride, rounding);  
                         interpolate16x16_switch(dec->cur.y, dec->refn[0].y , 32*x_pos + 16, 32*y_pos + 16,  
                                                                 mv[3].x, mv[3].y, stride, rounding);  
                         interpolate16x16_switch(dec->cur.u, dec->refn[0].u , 16 * x_pos, 16 * y_pos,  
                                                                 uv_dx, uv_dy, stride2, rounding);  
                         interpolate16x16_switch(dec->cur.v, dec->refn[0].v , 16 * x_pos, 16 * y_pos,  
                                                                 uv_dx, uv_dy, stride2, rounding);  
   
                 } else if (dec->quarterpel) {  
541                          interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y , dec->qtmp.y, dec->qtmp.y + 64,                          interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y , dec->qtmp.y, dec->qtmp.y + 64,
542                                                                          dec->qtmp.y + 128, 16*x_pos, 16*y_pos,                                                                          dec->qtmp.y + 128, 16*x_pos, 16*y_pos,
543                                                                          mv[0].x, mv[0].y, stride, rounding);                                                                          mv[0].x, mv[0].y, stride, rounding);
# Line 611  Line 563 
563          }          }
564    
565          /* chroma */          /* chroma */
         if (reduced_resolution) {  
                 interpolate16x16_switch(dec->cur.u, dec->refn[0].u, 16 * x_pos, 16 * y_pos,  
                                                                 uv_dx, uv_dy, stride2, rounding);  
                 interpolate16x16_switch(dec->cur.v, dec->refn[0].v, 16 * x_pos, 16 * y_pos,  
                                                                 uv_dx, uv_dy, stride2, rounding);  
         } else {  
566                  interpolate8x8_switch(dec->cur.u, dec->refn[ref].u, 8 * x_pos, 8 * y_pos,                  interpolate8x8_switch(dec->cur.u, dec->refn[ref].u, 8 * x_pos, 8 * y_pos,
567                                                                  uv_dx, uv_dy, stride2, rounding);                                                                  uv_dx, uv_dy, stride2, rounding);
568                  interpolate8x8_switch(dec->cur.v, dec->refn[ref].v, 8 * x_pos, 8 * y_pos,                  interpolate8x8_switch(dec->cur.v, dec->refn[ref].v, 8 * x_pos, 8 * y_pos,
569                                                                  uv_dx, uv_dy, stride2, rounding);                                                                  uv_dx, uv_dy, stride2, rounding);
         }  
570    
571          stop_comp_timer();          stop_comp_timer();
572    
573          if (cbp)          if (cbp)
574                  decoder_mb_decode(dec, cbp, bs, pY_Cur, pU_Cur, pV_Cur,                  decoder_mb_decode(dec, cbp, bs, pY_Cur, pU_Cur, pV_Cur, pMB);
                                                         reduced_resolution, pMB);  
575  }  }
576    
577  static void  static void
# Line 674  Line 618 
618          stop_transfer_timer();          stop_transfer_timer();
619    
620          if (cbp)          if (cbp)
621                  decoder_mb_decode(dec, cbp, bs, pY_Cur, pU_Cur, pV_Cur, 0, pMB);                  decoder_mb_decode(dec, cbp, bs, pY_Cur, pU_Cur, pV_Cur, pMB);
622    
623  }  }
624    
# Line 682  Line 626 
626  static void  static void
627  decoder_iframe(DECODER * dec,  decoder_iframe(DECODER * dec,
628                                  Bitstream * bs,                                  Bitstream * bs,
                                 int reduced_resolution,  
629                                  int quant,                                  int quant,
630                                  int intra_dc_threshold)                                  int intra_dc_threshold)
631  {  {
632          uint32_t bound;          uint32_t bound;
633          uint32_t x, y;          uint32_t x, y;
634          uint32_t mb_width = dec->mb_width;          const uint32_t mb_width = dec->mb_width;
635          uint32_t mb_height = dec->mb_height;          const uint32_t mb_height = dec->mb_height;
   
         if (reduced_resolution) {  
                 mb_width = (dec->width + 31) / 32;  
                 mb_height = (dec->height + 31) / 32;  
         }  
636    
637          bound = 0;          bound = 0;
638    
# Line 750  Line 688 
688                          }                          }
689    
690                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,
691                                                          intra_dc_threshold, bound, reduced_resolution);                                                          intra_dc_threshold, bound);
692    
693                  }                  }
694                  if(dec->out_frm)                  if(dec->out_frm)
# Line 808  Line 746 
746  decoder_pframe(DECODER * dec,  decoder_pframe(DECODER * dec,
747                                  Bitstream * bs,                                  Bitstream * bs,
748                                  int rounding,                                  int rounding,
                                 int reduced_resolution,  
749                                  int quant,                                  int quant,
750                                  int fcode,                                  int fcode,
751                                  int intra_dc_threshold,                                  int intra_dc_threshold,
# Line 817  Line 754 
754          uint32_t x, y;          uint32_t x, y;
755          uint32_t bound;          uint32_t bound;
756          int cp_mb, st_mb;          int cp_mb, st_mb;
757          uint32_t mb_width = dec->mb_width;          const uint32_t mb_width = dec->mb_width;
758          uint32_t mb_height = dec->mb_height;          const uint32_t mb_height = dec->mb_height;
   
         if (reduced_resolution) {  
                 mb_width = (dec->width + 31) / 32;  
                 mb_height = (dec->height + 31) / 32;  
         }  
759    
760          if (!dec->is_edged[0]) {          if (!dec->is_edged[0]) {
761                  start_timer();                  start_timer();
# Line 942  Line 874 
874                                          mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = 0;                                          mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = 0;
875                                          mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y =     0;                                          mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y =     0;
876                                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,                                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant,
877                                                                          intra_dc_threshold, bound, reduced_resolution);                                                                          intra_dc_threshold, bound);
878                                          continue;                                          continue;
879                                  }                                  }
880    
881                                  decoder_mbinter(dec, mb, x, y, cbp, bs,                                  decoder_mbinter(dec, mb, x, y, cbp, bs, rounding, 0);
                                                                 rounding, reduced_resolution, 0);  
882    
883                          } else if (gmc_warp) {  /* a not coded S(GMC)-VOP macroblock */                          } else if (gmc_warp) {  /* a not coded S(GMC)-VOP macroblock */
884                                  mb->mode = MODE_NOT_CODED_GMC;                                  mb->mode = MODE_NOT_CODED_GMC;
# Line 967  Line 898 
898                                  mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = 0;                                  mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = 0;
899    
900                                  decoder_mbinter(dec, mb, x, y, 0, bs,                                  decoder_mbinter(dec, mb, x, y, 0, bs,
901                                                                  rounding, reduced_resolution, 0);                                                                  rounding, 0);
902    
903                                  if(dec->out_frm && cp_mb > 0) {                                  if(dec->out_frm && cp_mb > 0) {
904                                          output_slice(&dec->cur, dec->edged_width,dec->width,dec->out_frm,st_mb,y,cp_mb);                                          output_slice(&dec->cur, dec->edged_width,dec->width,dec->out_frm,st_mb,y,cp_mb);
# Line 1022  Line 953 
953  decoder_bf_interpolate_mbinter(DECODER * dec,  decoder_bf_interpolate_mbinter(DECODER * dec,
954                                                                  IMAGE forward,                                                                  IMAGE forward,
955                                                                  IMAGE backward,                                                                  IMAGE backward,
956                                                                  const MACROBLOCK * pMB,                                                                  MACROBLOCK * pMB,
957                                                                  const uint32_t x_pos,                                                                  const uint32_t x_pos,
958                                                                  const uint32_t y_pos,                                                                  const uint32_t y_pos,
959                                                                  Bitstream * bs,                                                                  Bitstream * bs,
# Line 1039  Line 970 
970          pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);          pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);
971          pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);          pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);
972    
973            validate_vector(pMB->mvs, x_pos, y_pos, dec);
974            validate_vector(pMB->b_mvs, x_pos, y_pos, dec);
975    
976          if (!direct) {          if (!direct) {
977                  uv_dx = pMB->mvs[0].x;                  uv_dx = pMB->mvs[0].x;
978                  uv_dy = pMB->mvs[0].y;                  uv_dy = pMB->mvs[0].y;
# Line 1115  Line 1049 
1049    
1050          if(dec->quarterpel) {          if(dec->quarterpel) {
1051                  if(!direct) {                  if(!direct) {
1052                          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,
1053                                                                                  dec->qtmp.y + 128, 16*x_pos, 16*y_pos,                                                                                  dec->qtmp.y + 128, 16*x_pos, 16*y_pos,
1054                                                                                  pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0);                                                                                  pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0);
1055                  } else {                  } else {
1056                          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,
1057                                                                                  dec->qtmp.y + 128, 16*x_pos, 16*y_pos,                                                                                  dec->qtmp.y + 128, 16*x_pos, 16*y_pos,
1058                                                                                  pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0);                                                                                  pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0);
1059                          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,
1060                                                                                  dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos,                                                                                  dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos,
1061                                                                                  pMB->b_mvs[1].x, pMB->b_mvs[1].y, stride, 0);                                                                                  pMB->b_mvs[1].x, pMB->b_mvs[1].y, stride, 0);
1062                          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,
1063                                                                                  dec->qtmp.y + 128, 16*x_pos, 16*y_pos + 8,                                                                                  dec->qtmp.y + 128, 16*x_pos, 16*y_pos + 8,
1064                                                                                  pMB->b_mvs[2].x, pMB->b_mvs[2].y, stride, 0);                                                                                  pMB->b_mvs[2].x, pMB->b_mvs[2].y, stride, 0);
1065                          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,
1066                                                                                  dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos + 8,                                                                                  dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos + 8,
1067                                                                                  pMB->b_mvs[3].x, pMB->b_mvs[3].y, stride, 0);                                                                                  pMB->b_mvs[3].x, pMB->b_mvs[3].y, stride, 0);
1068                  }                  }
1069          } else {          } else {
1070                  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,
1071                                                          pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0);                                                          pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0);
1072                  interpolate8x8_switch(dec->tmp.y, backward.y, 16 * x_pos + 8,                  interpolate8x8_add_switch(dec->cur.y, backward.y, 16 * x_pos + 8,
1073                                                          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);
1074                  interpolate8x8_switch(dec->tmp.y, backward.y, 16 * x_pos,                  interpolate8x8_add_switch(dec->cur.y, backward.y, 16 * x_pos,
1075                                                          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);
1076                  interpolate8x8_switch(dec->tmp.y, backward.y, 16 * x_pos + 8,                  interpolate8x8_add_switch(dec->cur.y, backward.y, 16 * x_pos + 8,
1077                                                          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);
1078          }          }
1079    
1080          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,
1081                                                  b_uv_dx, b_uv_dy, stride2, 0);                                                  b_uv_dx, b_uv_dy, stride2, 0);
1082          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,
1083                                                  b_uv_dx, b_uv_dy, stride2, 0);                                                  b_uv_dx, b_uv_dy, stride2, 0);
1084    
         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, 0, 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, 0, 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, 0, 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, 0, 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, 0, 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, 0, 8);  
   
1085          stop_comp_timer();          stop_comp_timer();
1086    
1087          if (cbp)          if (cbp)
1088                  decoder_mb_decode(dec, cbp, bs, pY_Cur, pU_Cur, pV_Cur, 0, pMB);                  decoder_mb_decode(dec, cbp, bs, pY_Cur, pU_Cur, pV_Cur, pMB);
1089  }  }
1090    
1091  /* for decode B-frame dbquant */  /* for decode B-frame dbquant */
# Line 1276  Line 1180 
1180                          if (last_mb->mode == MODE_NOT_CODED) {                          if (last_mb->mode == MODE_NOT_CODED) {
1181                                  mb->cbp = 0;                                  mb->cbp = 0;
1182                                  mb->mode = MODE_FORWARD;                                  mb->mode = MODE_FORWARD;
1183                                  decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 0, 1);                                  decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 1);
1184                                  continue;                                  continue;
1185                          }                          }
1186    
# Line 1359  Line 1263 
1263                                  get_b_motion_vector(bs, &mb->mvs[0], fcode_backward, dec->p_bmv, dec, x, y);                                  get_b_motion_vector(bs, &mb->mvs[0], fcode_backward, dec->p_bmv, dec, x, y);
1264                                  dec->p_bmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] =     mb->mvs[0];                                  dec->p_bmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] =     mb->mvs[0];
1265    
1266                                  decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 0, 0);                                  decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 0);
1267                                  break;                                  break;
1268    
1269                          case MODE_FORWARD:                          case MODE_FORWARD:
1270                                  get_b_motion_vector(bs, &mb->mvs[0], fcode_forward, dec->p_fmv, dec, x, y);                                  get_b_motion_vector(bs, &mb->mvs[0], fcode_forward, dec->p_fmv, dec, x, y);
1271                                  dec->p_fmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] =     mb->mvs[0];                                  dec->p_fmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] =     mb->mvs[0];
1272    
1273                                  decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 0, 1);                                  decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 1);
1274                                  break;                                  break;
1275    
1276                          default:                          default:
# Line 1416  Line 1320 
1320          }          }
1321  }  }
1322    
   
1323  int  int
1324  decoder_decode(DECODER * dec,  decoder_decode(DECODER * dec,
1325                                  xvid_dec_frame_t * frame, xvid_dec_stats_t * stats)                                  xvid_dec_frame_t * frame, xvid_dec_stats_t * stats)
# Line 1424  Line 1327 
1327    
1328          Bitstream bs;          Bitstream bs;
1329          uint32_t rounding;          uint32_t rounding;
         uint32_t reduced_resolution;  
1330          uint32_t quant = 2;          uint32_t quant = 2;
1331          uint32_t fcode_forward;          uint32_t fcode_forward;
1332          uint32_t fcode_backward;          uint32_t fcode_backward;
# Line 1479  Line 1381 
1381    
1382  repeat:  repeat:
1383    
1384          coding_type = BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution,          coding_type = BitstreamReadHeaders(&bs, dec, &rounding,
1385                          &quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, &gmc_warp);                          &quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, &gmc_warp);
1386    
1387          DPRINTF(XVID_DEBUG_HEADER, "coding_type=%i,  packed=%i,  time=%lli,  time_pp=%i,  time_bp=%i\n",          DPRINTF(XVID_DEBUG_HEADER, "coding_type=%i,  packed=%i,  time=%"
1388    #if defined(_MSC_VER)
1389        "I64"
1390    #else
1391        "ll"
1392    #endif
1393        "i,  time_pp=%i,  time_bp=%i\n",
1394                                                          coding_type,    dec->packed_mode, dec->time, dec->time_pp, dec->time_bp);                                                          coding_type,    dec->packed_mode, dec->time, dec->time_pp, dec->time_bp);
1395    
1396          if (coding_type == -1) { /* nothing */          if (coding_type == -1) { /* nothing */
# Line 1530  Line 1438 
1438          } else if (coding_type != B_VOP) {          } else if (coding_type != B_VOP) {
1439                  switch(coding_type) {                  switch(coding_type) {
1440                  case I_VOP :                  case I_VOP :
1441                          decoder_iframe(dec, &bs, reduced_resolution, quant, intra_dc_threshold);                          decoder_iframe(dec, &bs, quant, intra_dc_threshold);
1442                          break;                          break;
1443                  case P_VOP :                  case P_VOP :
1444                          decoder_pframe(dec, &bs, rounding, reduced_resolution, quant,                          decoder_pframe(dec, &bs, rounding, quant,
1445                                                  fcode_forward, intra_dc_threshold, NULL);                                                  fcode_forward, intra_dc_threshold, NULL);
1446                          break;                          break;
1447                  case S_VOP :                  case S_VOP :
1448                          decoder_pframe(dec, &bs, rounding, reduced_resolution, quant,                          decoder_pframe(dec, &bs, rounding, quant,
1449                                                  fcode_forward, intra_dc_threshold, &gmc_warp);                                                  fcode_forward, intra_dc_threshold, &gmc_warp);
1450                          break;                          break;
1451                  case N_VOP :                  case N_VOP :
# Line 1548  Line 1456 
1456                          break;                          break;
1457                  }                  }
1458    
                 if (reduced_resolution) {  
                         image_deblock_rrv(&dec->cur, dec->edged_width, dec->mbs,  
                                 (dec->width + 31) / 32, (dec->height + 31) / 32, dec->mb_width,  
                                 16, 0);  
                 }  
   
1459                  /* note: for packed_mode, output is performed when the special-N_VOP is decoded */                  /* note: for packed_mode, output is performed when the special-N_VOP is decoded */
1460                  if (!(dec->low_delay_default && dec->packed_mode)) {                  if (!(dec->low_delay_default && dec->packed_mode)) {
1461                          if (dec->low_delay) {                          if (dec->low_delay) {
# Line 1571  Line 1473 
1473                  image_swap(&dec->cur, &dec->refn[0]);                  image_swap(&dec->cur, &dec->refn[0]);
1474                  dec->is_edged[0] = 0;                  dec->is_edged[0] = 0;
1475                  SWAP(MACROBLOCK *, dec->mbs, dec->last_mbs);                  SWAP(MACROBLOCK *, dec->mbs, dec->last_mbs);
                 dec->last_reduced_resolution = reduced_resolution;  
1476                  dec->last_coding_type = coding_type;                  dec->last_coding_type = coding_type;
1477    
1478                  dec->frames++;                  dec->frames++;
# Line 1616  Line 1517 
1517    
1518  done :  done :
1519    
1520          /* low_delay_default mode: if we've gotten here without outputting anything,    /* if we reach here without outputing anything _and_
1521             then output the recently decoded frame, or print an error message  */       the calling application has specified low_delay_default,
1522         we *must* output something.
1523         this always occurs on the first call to decode() call
1524         when bframes are present in the bitstream. it may also
1525         occur if no vops  were seen in the bitstream
1526    
1527         if packed_mode is enabled, then we output the recently
1528         decoded frame (the very first ivop). otherwise we have
1529         nothing to display, and therefore output a black screen.
1530      */
1531          if (dec->low_delay_default && output == 0) {          if (dec->low_delay_default && output == 0) {
1532                  if (dec->packed_mode && seen_something) {                  if (dec->packed_mode && seen_something) {
                         /* output the recently decoded frame */  
1533                          decoder_output(dec, &dec->refn[0], dec->last_mbs, frame, stats, dec->last_coding_type, quant);                          decoder_output(dec, &dec->refn[0], dec->last_mbs, frame, stats, dec->last_coding_type, quant);
1534                  } else {                  } else {
1535                          image_clear(&dec->cur, dec->width, dec->height, dec->edged_width, 0, 128, 128);                          image_clear(&dec->cur, dec->width, dec->height, dec->edged_width, 0, 128, 128);
                         image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16,  
                                 "warning: nothing to output");  
                         image_printf(&dec->cur, dec->edged_width, dec->height, 16, 64,  
                                 "bframe decoder lag");  
   
1536                          decoder_output(dec, &dec->cur, NULL, frame, stats, P_VOP, quant);                          decoder_output(dec, &dec->cur, NULL, frame, stats, P_VOP, quant);
1537                          if (stats) stats->type = XVID_TYPE_NOTHING;                          if (stats) stats->type = XVID_TYPE_NOTHING;
1538                  }                  }

Legend:
Removed from v.1.64  
changed lines
  Added in v.1.69

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