[cvs] / xvidcore / src / decoder.c Repository:
ViewVC logotype

Diff of /xvidcore/src/decoder.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.51.2.5, Fri Jun 4 11:54:41 2004 UTC revision 1.69, Sun Mar 27 03:59:41 2005 UTC
# Line 4  Line 4 
4   *  - Decoder Module -   *  - Decoder Module -
5   *   *
6   *  Copyright(C) 2002      MinChen <chenm001@163.com>   *  Copyright(C) 2002      MinChen <chenm001@163.com>
7   *               2002-2003 Peter Ross <pross@xvid.org>   *               2002-2004 Peter Ross <pross@xvid.org>
8   *   *
9   *  This program is free software ; you can redistribute it and/or modify   *  This program is free software ; you can redistribute it and/or modify
10   *  it under the terms of the GNU General Public License as published by   *  it under the terms of the GNU General Public License as published by
# Line 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 270  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 284  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 362  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 390  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 469  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 481  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 537  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 561  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 601  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 664  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 672  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 740  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 798  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 807  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 929  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 954  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 1009  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 1026  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 1042  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 1104  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 1217  Line 1132 
1132          const VECTOR zeromv = {0,0};          const VECTOR zeromv = {0,0};
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 1339  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 1361  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) && mbs != NULL)     /* post process */          if ((frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) || brightness!=0)
1294                    && 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, 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=%"
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 1507  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 1525  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 1544  Line 1469 
1469                  }                  }
1470    
1471                  image_swap(&dec->refn[0], &dec->refn[1]);                  image_swap(&dec->refn[0], &dec->refn[1]);
1472                    dec->is_edged[1] = dec->is_edged[0];
1473                  image_swap(&dec->cur, &dec->refn[0]);                  image_swap(&dec->cur, &dec->refn[0]);
1474                    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 1556  Line 1482 
1482    
1483                  if (dec->low_delay) {                  if (dec->low_delay) {
1484                          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");
1485                          dec->low_delay = 1;                          dec->low_delay = 0;
1486                  }                  }
1487    
1488                  if (dec->frames < 2) {                  if (dec->frames < 2) {
# Line 1591  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.51.2.5  
changed lines
  Added in v.1.69

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