[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.54, Sun Apr 11 09:41:27 2004 UTC revision 1.68, Sun Dec 5 13:56:13 2004 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"
51    
52  #include "bitstream/mbcoding.h"  #include "bitstream/mbcoding.h"
53  #include "prediction/mbprediction.h"  #include "prediction/mbprediction.h"
# Line 222  Line 222 
222          dec->time = dec->time_base = dec->last_time_base = 0;          dec->time = dec->time_base = dec->last_time_base = 0;
223          dec->low_delay = 0;          dec->low_delay = 0;
224          dec->packed_mode = 0;          dec->packed_mode = 0;
225            dec->time_inc_resolution = 1; /* until VOL header says otherwise */
226    
227          dec->fixed_dimensions = (dec->width > 0 && dec->height > 0);          dec->fixed_dimensions = (dec->width > 0 && dec->height > 0);
228    
# Line 269  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 283  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 338  Line 332 
332                  stop_coding_timer();                  stop_coding_timer();
333    
334                  start_timer();                  start_timer();
335                  add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors);                  add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors, dec->bs_version);
336                  stop_prediction_timer();                  stop_prediction_timer();
337    
338                  start_timer();                  start_timer();
# Line 361  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 389  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,
                                 const int reduced_resolution,  
374                                  const MACROBLOCK * pMB)                                  const MACROBLOCK * pMB)
375  {  {
376          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);  
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;
         const int stride2 = stride/2;  
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;
383          const quant_interFuncPtr dequant = dec->quant_type == 0 ? dequant_h263_inter : dequant_mpeg_inter;          typedef void (*get_inter_block_function_t)(
384                            Bitstream * bs,
385                            int16_t * block,
386                            int direction,
387                            const int quant,
388                            const uint16_t *matrix);
389            typedef void (*add_residual_function_t)(
390                            uint8_t *predicted_block,
391                            const int16_t *residual,
392                            int stride);
393    
394            const get_inter_block_function_t get_inter_block = (dec->quant_type == 0)
395                    ? (get_inter_block_function_t)get_inter_block_h263
396                    : (get_inter_block_function_t)get_inter_block_mpeg;
397    
398          for (i = 0; i < 6; i++) {          uint8_t *dst[6];
399            int strides[6];
400    
                 if (cbp & (1 << (5 - i))) {     /* coded */  
401    
402                          memset(block, 0, 64 * sizeof(int16_t)); /* clear */          if (dec->interlacing && pMB->field_dct) {
403                    next_block = stride;
404                    stride *= 2;
405            }
406    
407            dst[0] = pY_Cur;
408            dst[2] = pY_Cur + next_block;
409            dst[1] = dst[0] + 8;
410            dst[3] = dst[2] + 8;
411            dst[4] = pU_Cur;
412            dst[5] = pV_Cur;
413            strides[0] = strides[1] = strides[2] = strides[3] = stride;
414            strides[4] = stride/2;
415            strides[5] = stride/2;
416    
417            for (i = 0; i < 6; i++) {
418                    /* Process only coded blocks */
419                    if (cbp & (1 << (5 - i))) {
420    
421                            /* Clear the block */
422                            memset(&data[0], 0, 64*sizeof(int16_t));
423    
424                            /* Decode coeffs and dequantize on the fly */
425                          start_timer();                          start_timer();
426                          get_inter_block(bs, block, direction);                          get_inter_block(bs, &data[0], direction, iQuant, get_inter_matrix(dec->mpeg_quant_matrices));
427                          stop_coding_timer();                          stop_coding_timer();
428    
429                            /* iDCT */
430                          start_timer();                          start_timer();
431                          dequant(&data[i * 64], block, iQuant, dec->mpeg_quant_matrices);                          idct(&data[0]);
432                          stop_iquant_timer();                          stop_idct_timer();
433    
434                            /* Add this residual to the predicted block */
435                          start_timer();                          start_timer();
436                          idct(&data[i * 64]);                          transfer_16to8add(dst[i], &data[0], strides[i]);
437                          stop_idct_timer();                          stop_transfer_timer();
438                  }                  }
439          }          }
   
         if (dec->interlacing && pMB->field_dct) {  
                 next_block = stride;  
                 stride *= 2;  
440          }          }
441    
442          start_timer();  static void __inline
443          if (reduced_resolution) {  validate_vector(VECTOR * mv, unsigned int x_pos, unsigned int y_pos, const DECODER * dec)
444                  if (cbp & 32)  {
445                          add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride);          /* clip a vector to valid range
446                  if (cbp & 16)             prevents crashes if bitstream is broken
447                          add_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride);          */
448                  if (cbp & 8)          int shift = 5 + dec->quarterpel;
449                          add_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride);          int xborder_high = (int)(dec->mb_width - x_pos) << shift;
450                  if (cbp & 4)          int xborder_low = (-(int)x_pos-1) << shift;
451                          add_upsampled_8x8_16to8(pY_Cur + 16 + next_block, &data[3 * 64], stride);          int yborder_high = (int)(dec->mb_height - y_pos) << shift;
452                  if (cbp & 2)          int yborder_low = (-(int)y_pos-1) << shift;
453                          add_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2);  
454                  if (cbp & 1)  #define CHECK_MV(mv) \
455                          add_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2);          do { \
456          } else {          if ((mv).x > xborder_high) { \
457                  if (cbp & 32)                  DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", (mv).x, xborder_high, x_pos, y_pos); \
458                          transfer_16to8add(pY_Cur, &data[0 * 64], stride);                  (mv).x = xborder_high; \
459                  if (cbp & 16)          } else if ((mv).x < xborder_low) { \
460                          transfer_16to8add(pY_Cur + 8, &data[1 * 64], stride);                  DPRINTF(XVID_DEBUG_MV, "mv.x < min -- %d < %d, MB %d, %d", (mv).x, xborder_low, x_pos, y_pos); \
461                  if (cbp & 8)                  (mv).x = xborder_low; \
462                          transfer_16to8add(pY_Cur + next_block, &data[2 * 64], stride);          } \
463                  if (cbp & 4)          if ((mv).y > yborder_high) { \
464                          transfer_16to8add(pY_Cur + 8 + next_block, &data[3 * 64], stride);                  DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", (mv).y, yborder_high, x_pos, y_pos); \
465                  if (cbp & 2)                  (mv).y = yborder_high; \
466                          transfer_16to8add(pU_Cur, &data[4 * 64], stride2);          } else if ((mv).y < yborder_low) { \
467                  if (cbp & 1)                  DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", (mv).y, yborder_low, x_pos, y_pos); \
468                          transfer_16to8add(pV_Cur, &data[5 * 64], stride2);                  (mv).y = yborder_low; \
469          }          } \
470          stop_transfer_timer();          } 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 */
# Line 468  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 480  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 536  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 560  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 600  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 663  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 671  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 739  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 797  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 806  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]) {
761          start_timer();          start_timer();
762          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,
763                                          dec->width, dec->height, dec->bs_version);                                          dec->width, dec->height, dec->bs_version);
764                    dec->is_edged[0] = 1;
765          stop_edges_timer();          stop_edges_timer();
766            }
767    
768          if (gmc_warp) {          if (gmc_warp) {
769                  /* 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 928  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 953  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 1008  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 1025  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;
   
979                  b_uv_dx = pMB->b_mvs[0].x;                  b_uv_dx = pMB->b_mvs[0].x;
980                  b_uv_dy = pMB->b_mvs[0].y;                  b_uv_dy = pMB->b_mvs[0].y;
981    
# Line 1041  Line 988 
988    
989                  uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3];                  uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3];
990                  uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3];                  uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3];
   
991                  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];
992                  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];
993    
994          } 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 {  
995                          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;
996                          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;
997                          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;
998                          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;
999    
1000                    if (dec->quarterpel) {
1001                            uv_dx /= 2;
1002                            uv_dy /= 2;
1003                            b_uv_dx /= 2;
1004                            b_uv_dy /= 2;
1005                  }                  }
1006    
1007                  uv_dx = (uv_dx >> 3) + roundtab_76[uv_dx & 0xf];                  uv_dx = (uv_dx >> 3) + roundtab_76[uv_dx & 0xf];
# Line 1103  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, 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);  
   
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 1214  Line 1130 
1130          uint32_t x, y;          uint32_t x, y;
1131          VECTOR mv;          VECTOR mv;
1132          const VECTOR zeromv = {0,0};          const VECTOR zeromv = {0,0};
         const int64_t TRB = dec->time_pp - dec->time_bp, TRD = dec->time_pp;  
1133          int i;          int i;
1134    
1135            if (!dec->is_edged[0]) {
1136          start_timer();          start_timer();
1137          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,          image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height,
1138                                          dec->width, dec->height, dec->bs_version);                                          dec->width, dec->height, dec->bs_version);
1139                    dec->is_edged[0] = 1;
1140                    stop_edges_timer();
1141            }
1142    
1143            if (!dec->is_edged[1]) {
1144                    start_timer();
1145          image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height,          image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height,
1146                                          dec->width, dec->height, dec->bs_version);                                          dec->width, dec->height, dec->bs_version);
1147                    dec->is_edged[1] = 1;
1148          stop_edges_timer();          stop_edges_timer();
1149            }
1150    
1151          for (y = 0; y < dec->mb_height; y++) {          for (y = 0; y < dec->mb_height; y++) {
1152                  /* Initialize Pred Motion Vector */                  /* Initialize Pred Motion Vector */
# Line 1256  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 1309  Line 1233 
1233    
1234                          case MODE_DIRECT_NONE_MV:                          case MODE_DIRECT_NONE_MV:
1235                                  for (i = 0; i < 4; i++) {                                  for (i = 0; i < 4; i++) {
1236                                          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;
1237                                          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;
1238                                                                          ? ((TRB - TRD) * last_mb->mvs[i].x) / TRD  
1239                                                                          : mb->mvs[i].x - last_mb->mvs[i].x);                                          mb->b_mvs[i].x = (mv.x)
1240                                          mb->mvs[i].y = (int32_t) ((TRB * last_mb->mvs[i].y) / TRD + mv.y);                                                  ?  mb->mvs[i].x - last_mb->mvs[i].x
1241                                          mb->b_mvs[i].y = (int32_t) ((mv.y == 0)                                                  : last_mb->mvs[i].x*(dec->time_bp - dec->time_pp)/dec->time_pp;
1242                                                                          ? ((TRB - TRD) * last_mb->mvs[i].y) / TRD                                          mb->b_mvs[i].y = (mv.y)
1243                                                                          : mb->mvs[i].y - last_mb->mvs[i].y);                                                  ? mb->mvs[i].y - last_mb->mvs[i].y
1244                                                    : last_mb->mvs[i].y*(dec->time_bp - dec->time_pp)/dec->time_pp;
1245                                  }                                  }
1246    
1247                                  decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0],                                  decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0],
# 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 1360  Line 1285 
1285                                          xvid_dec_frame_t * frame, xvid_dec_stats_t * stats,                                          xvid_dec_frame_t * frame, xvid_dec_stats_t * stats,
1286                                          int coding_type, int quant)                                          int coding_type, int quant)
1287  {  {
1288            const int brightness = XVID_VERSION_MINOR(frame->version) >= 1 ? frame->brightness : 0;
1289    
1290          if (dec->cartoon_mode)          if (dec->cartoon_mode)
1291                  frame->general &= ~XVID_FILMEFFECT;                  frame->general &= ~XVID_FILMEFFECT;
1292    
1293          if ((frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) || frame->brightness!=0)          if ((frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) || brightness!=0)
1294                  && mbs != NULL) /* post process */                  && mbs != NULL) /* post process */
1295          {          {
1296                  /* note: image is stored to tmp */                  /* note: image is stored to tmp */
1297                  image_copy(&dec->tmp, img, dec->edged_width, dec->height);                  image_copy(&dec->tmp, img, dec->edged_width, dec->height);
1298                  image_postproc(&dec->postproc, &dec->tmp, dec->edged_width,                  image_postproc(&dec->postproc, &dec->tmp, dec->edged_width,
1299                                             mbs, dec->mb_width, dec->mb_height, dec->mb_width,                                             mbs, dec->mb_width, dec->mb_height, dec->mb_width,
1300                                             frame->general, frame->brightness, dec->frames, (coding_type == B_VOP));                                             frame->general, brightness, dec->frames, (coding_type == B_VOP));
1301                  img = &dec->tmp;                  img = &dec->tmp;
1302          }          }
1303    
# Line 1393  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 1401  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 1456  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=%lli,  time_pp=%i,  time_bp=%i\n",
# Line 1490  Line 1415 
1415                  goto repeat;                  goto repeat;
1416          }          }
1417    
1418            if(dec->frames == 0 && coding_type != I_VOP) {
1419                    /* 1st frame is not an i-vop */
1420                    goto repeat;
1421            }
1422    
1423          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 */
1424    
1425          /* packed_mode: special-N_VOP treament */          /* packed_mode: special-N_VOP treament */
# Line 1502  Line 1432 
1432          } else if (coding_type != B_VOP) {          } else if (coding_type != B_VOP) {
1433                  switch(coding_type) {                  switch(coding_type) {
1434                  case I_VOP :                  case I_VOP :
1435                          decoder_iframe(dec, &bs, reduced_resolution, quant, intra_dc_threshold);                          decoder_iframe(dec, &bs, quant, intra_dc_threshold);
1436                          break;                          break;
1437                  case P_VOP :                  case P_VOP :
1438                          decoder_pframe(dec, &bs, rounding, reduced_resolution, quant,                          decoder_pframe(dec, &bs, rounding, quant,
1439                                                  fcode_forward, intra_dc_threshold, NULL);                                                  fcode_forward, intra_dc_threshold, NULL);
1440                          break;                          break;
1441                  case S_VOP :                  case S_VOP :
1442                          decoder_pframe(dec, &bs, rounding, reduced_resolution, quant,                          decoder_pframe(dec, &bs, rounding, quant,
1443                                                  fcode_forward, intra_dc_threshold, &gmc_warp);                                                  fcode_forward, intra_dc_threshold, &gmc_warp);
1444                          break;                          break;
1445                  case N_VOP :                  case N_VOP :
# Line 1520  Line 1450 
1450                          break;                          break;
1451                  }                  }
1452    
                 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);  
                 }  
   
1453                  /* 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 */
1454                  if (!(dec->low_delay_default && dec->packed_mode)) {                  if (!(dec->low_delay_default && dec->packed_mode)) {
1455                          if (dec->low_delay) {                          if (dec->low_delay) {
# Line 1539  Line 1463 
1463                  }                  }
1464    
1465                  image_swap(&dec->refn[0], &dec->refn[1]);                  image_swap(&dec->refn[0], &dec->refn[1]);
1466                    dec->is_edged[1] = dec->is_edged[0];
1467                  image_swap(&dec->cur, &dec->refn[0]);                  image_swap(&dec->cur, &dec->refn[0]);
1468                    dec->is_edged[0] = 0;
1469                  SWAP(MACROBLOCK *, dec->mbs, dec->last_mbs);                  SWAP(MACROBLOCK *, dec->mbs, dec->last_mbs);
                 dec->last_reduced_resolution = reduced_resolution;  
1470                  dec->last_coding_type = coding_type;                  dec->last_coding_type = coding_type;
1471    
1472                  dec->frames++;                  dec->frames++;
# Line 1551  Line 1476 
1476    
1477                  if (dec->low_delay) {                  if (dec->low_delay) {
1478                          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");
1479                          dec->low_delay = 1;                          dec->low_delay = 0;
1480                  }                  }
1481    
1482                  if (dec->frames < 2) {                  if (dec->frames < 2) {

Legend:
Removed from v.1.54  
changed lines
  Added in v.1.68

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