[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.66, Sun Aug 15 11:28:38 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 271  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 285  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 363  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 391  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 416  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 429  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 459  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  static void __inline
443  validate_vector(VECTOR * mv, unsigned int x_pos, unsigned int y_pos, const DECODER * dec)  validate_vector(VECTOR * mv, unsigned int x_pos, unsigned int y_pos, const DECODER * dec)
444  {  {
445          /* clip a vector to valid range          /* clip a vector to valid range
446             prevents crashes if bitstream is broken             prevents crashes if bitstream is broken
447          */          */
448          int i;          int shift = 5 + dec->quarterpel;
449            int xborder_high = (int)(dec->mb_width - x_pos) << shift;
450          for (i = 0; i < 4; i++) {          int xborder_low = (-(int)x_pos-1) << shift;
451            int yborder_high = (int)(dec->mb_height - y_pos) << shift;
452                  int border = (int)(dec->mb_width - x_pos) << (5 + dec->quarterpel);          int yborder_low = (-(int)y_pos-1) << shift;
453                  if (mv[i].x > border) {  
454                          DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", mv[i].x, border, x_pos, y_pos);  #define CHECK_MV(mv) \
455                          mv[i].x = border;          do { \
456                  } else {          if ((mv).x > xborder_high) { \
457                          border = (-(int)x_pos-1) << (5 + dec->quarterpel);                  DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", (mv).x, xborder_high, x_pos, y_pos); \
458                          if (mv[i].x < border) {                  (mv).x = xborder_high; \
459                                  DPRINTF(XVID_DEBUG_MV, "mv.x < min -- %d < %d, MB %d, %d", mv[i].x, border, x_pos, y_pos);          } else if ((mv).x < xborder_low) { \
460                                  mv[i].x = border;                  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                  border = (int)(dec->mb_height - y_pos) << (5 + dec->quarterpel);                  DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", (mv).y, yborder_high, x_pos, y_pos); \
465                  if (mv[i].y >  border) {                  (mv).y = yborder_high; \
466                          DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", mv[i].y, border, x_pos, y_pos);          } else if ((mv).y < yborder_low) { \
467                          mv[i].y = border;                  DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", (mv).y, yborder_low, x_pos, y_pos); \
468                  } else {                  (mv).y = yborder_low; \
469                          border = (-(int)y_pos-1) << (5 + dec->quarterpel);          } \
470                          if (mv[i].y < border) {          } while (0)
471                                  DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", mv[i].y, border, x_pos, y_pos);  
472                                  mv[i].y = border;          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 */
# Line 510  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 522  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          validate_vector(mv, x_pos, y_pos, dec);          validate_vector(mv, x_pos, y_pos, dec);
505    
# Line 553  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 577  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 617  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 680  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 688  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 756  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 814  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 823  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 948  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 973  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 1160  Line 1085 
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 1255  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 1338  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 1402  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 1457  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 1508  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 1526  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 1549  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 1594  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.66  
changed lines
  Added in v.1.69

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