[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.37.2.27, Sat Jan 11 14:59:23 2003 UTC revision 1.49, Wed Feb 19 21:59:30 2003 UTC
# Line 1  Line 1 
1  /**************************************************************************  /*****************************************************************************
2   *   *
3   *  XVID MPEG-4 VIDEO CODEC   *  XVID MPEG-4 VIDEO CODEC
4   *  -  Decoder main module  -   *  - Decoder Module -
5   *   *
6   *  This program is an implementation of a part of one or more MPEG-4   *  This file is part of XviD, a free MPEG-4 video encoder/decoder
  *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending  
  *  to use this software module in hardware or software products are  
  *  advised that its use may infringe existing patents or copyrights, and  
  *  any such use would be at such party's own risk.  The original  
  *  developer of this software module and his/her company, and subsequent  
  *  editors and their companies, will have no liability for use of this  
  *  software or modifications or derivatives thereof.  
7   *   *
8   *  This program is free software; you can redistribute it and/or modify   *  This program is free software; you can redistribute it and/or modify
9   *  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 26  Line 19 
19   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
20   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21   *   *
  *************************************************************************/  
   
 /**************************************************************************  
  *  
  *  History:  
  *  
  *  15.07.2002  fix a bug in B-frame decode at DIRECT mode  
  *              MinChen <chenm001@163.com>  
  *  10.07.2002  added BFRAMES_DEC_DEBUG support  
  *              Fix a little bug for low_delay flage  
  *              MinChen <chenm001@163.com>  
  *  28.06.2002  added basic resync support to iframe/pframe_decode()  
  *  22.06.2002  added primative N_VOP support  
  *                              #define BFRAMES_DEC now enables Minchen's bframe decoder  
  *  08.05.2002  add low_delay support for B_VOP decode  
  *              MinChen <chenm001@163.com>  
  *  05.05.2002  fix some B-frame decode problem  
  *  02.05.2002  add B-frame decode support(have some problem);  
  *              MinChen <chenm001@163.com>  
  *  22.04.2002  add some B-frame decode support;  chenm001 <chenm001@163.com>  
  *  29.03.2002  interlacing fix - compensated block wasn't being used when  
  *              reconstructing blocks, thus artifacts  
  *              interlacing speedup - used transfers to re-interlace  
  *              interlaced decoding should be as fast as progressive now  
  *  26.03.2002  interlacing support - moved transfers outside decode loop  
  *  26.12.2001  decoder_mbinter: dequant/idct moved within if(coded) block  
  *  22.12.2001  lock based interpolation  
  *  01.12.2001  inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>  
  *  
22   *  $Id$   *  $Id$
23   *   *
24   *************************************************************************/   ****************************************************************************/
25    
26  #include <stdio.h>  #include <stdio.h>
27  #include <stdlib.h>  #include <stdlib.h>
# Line 98  Line 62 
62  decoder_resize(DECODER * dec)  decoder_resize(DECODER * dec)
63  {  {
64          /* free existing */          /* free existing */
   
65          image_destroy(&dec->cur, dec->edged_width, dec->edged_height);          image_destroy(&dec->cur, dec->edged_width, dec->edged_height);
66          image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height);          image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height);
67          image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height);          image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height);
# Line 113  Line 76 
76                  xvid_free(dec->mbs);                  xvid_free(dec->mbs);
77    
78          /* realloc */          /* realloc */
   
79          dec->mb_width = (dec->width + 15) / 16;          dec->mb_width = (dec->width + 15) / 16;
80          dec->mb_height = (dec->height + 15) / 16;          dec->mb_height = (dec->height + 15) / 16;
81    
# Line 131  Line 93 
93                  return XVID_ERR_MEMORY;                  return XVID_ERR_MEMORY;
94          }          }
95    
96          // add by chenm001 <chenm001@163.com>          /* Support B-frame to reference last 2 frame */
         // for support B-frame to reference last 2 frame  
97          if (image_create(&dec->refn[1], dec->edged_width, dec->edged_height)) {          if (image_create(&dec->refn[1], dec->edged_width, dec->edged_height)) {
98                  image_destroy(&dec->cur, dec->edged_width, dec->edged_height);                  image_destroy(&dec->cur, dec->edged_width, dec->edged_height);
99                  image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height);                  image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height);
# Line 180  Line 141 
141          }          }
142          memset(dec->mbs, 0, sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height);          memset(dec->mbs, 0, sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height);
143    
144          // add by chenm001 <chenm001@163.com>          /* For skip MB flag */
         // for skip MB flag  
145          dec->last_mbs =          dec->last_mbs =
146                  xvid_malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height,                  xvid_malloc(sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height,
147                                          CACHE_LINE);                                          CACHE_LINE);
# Line 233  Line 193 
193    
194          init_timer();          init_timer();
195    
196          // add by chenm001 <chenm001@163.com>          /* For B-frame support (used to save reference frame's time */
         // for support B-frame to save reference frame's time  
197          dec->frames = 0;          dec->frames = 0;
198          dec->time = dec->time_base = dec->last_time_base = 0;          dec->time = dec->time_base = dec->last_time_base = 0;
199          dec->low_delay = 0;          dec->low_delay = 0;
# Line 255  Line 214 
214          xvid_free(dec->last_mbs);          xvid_free(dec->last_mbs);
215          xvid_free(dec->mbs);          xvid_free(dec->mbs);
216    
217          image_destroy(&dec->gmc, dec->edged_width, dec->edged_height);          /* image based GMC */          /* image based GMC */
218            image_destroy(&dec->gmc, dec->edged_width, dec->edged_height);
219    
220          image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height);          image_destroy(&dec->refn[0], dec->edged_width, dec->edged_height);
221          image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height);          image_destroy(&dec->refn[1], dec->edged_width, dec->edged_height);
# Line 277  Line 237 
237    
238    
239    
240  // decode an intra macroblock  /* decode an intra macroblock */
   
241  void  void
242  decoder_mbintra(DECODER * dec,  decoder_mbintra(DECODER * dec,
243                                  MACROBLOCK * pMB,                                  MACROBLOCK * pMB,
# Line 313  Line 272 
272                  pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);                  pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);
273          }          }
274    
275          memset(block, 0, 6 * 64 * sizeof(int16_t));     // clear          memset(block, 0, 6 * 64 * sizeof(int16_t));     /* clear */
276    
277          for (i = 0; i < 6; i++) {          for (i = 0; i < 6; i++) {
278                  uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4);                  uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4);
# Line 336  Line 295 
295                          dc_dif = dc_size ? get_dc_dif(bs, dc_size) : 0;                          dc_dif = dc_size ? get_dc_dif(bs, dc_size) : 0;
296    
297                          if (dc_size > 8) {                          if (dc_size > 8) {
298                                  BitstreamSkip(bs, 1);   // marker                                  BitstreamSkip(bs, 1);   /* marker */
299                          }                          }
300    
301                          block[i * 64 + 0] = dc_dif;                          block[i * 64 + 0] = dc_dif;
# Line 348  Line 307 
307                  }                  }
308    
309                  start_timer();                  start_timer();
310                  if (cbp & (1 << (5 - i)))       // coded                  if (cbp & (1 << (5 - i)))       /* coded */
311                  {                  {
312                          int direction = dec->alternate_vertical_scan ?                          int direction = dec->alternate_vertical_scan ?
313                                  2 : pMB->acpred_directions[i];                                  2 : pMB->acpred_directions[i];
# Line 405  Line 364 
364    
365    
366    
367  // decode an inter macroblock  /* decode an inter macroblock */
   
368  void  void
369  decoder_mbinter(DECODER * dec,  decoder_mbinter(DECODER * dec,
370                                  const MACROBLOCK * pMB,                                  const MACROBLOCK * pMB,
371                                  const uint32_t x_pos,                                  const uint32_t x_pos,
372                                  const uint32_t y_pos,                                  const uint32_t y_pos,
373                                  const uint32_t acpred_flag,                                  const uint32_t fcode,
374                                  const uint32_t cbp,                                  const uint32_t cbp,
375                                  Bitstream * bs,                                  Bitstream * bs,
376                                  const uint32_t quant,                                  const uint32_t quant,
377                                  const uint32_t rounding,                                  const uint32_t rounding,
378                                  const int reduced_resolution,                                  const int reduced_resolution)
                                 const int mcsel)  
379  {  {
380    
381          DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE);          DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE);
# Line 430  Line 387 
387          uint32_t i;          uint32_t i;
388          uint32_t iQuant = pMB->quant;          uint32_t iQuant = pMB->quant;
389          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
         uint8_t *pY_Ref, *pU_Ref, *pV_Ref;              /* ref for GMC is _not_ pRef itself */  
390    
391          int uv_dx, uv_dy;          int uv_dx, uv_dy;
392          VECTOR mv[4];   /* local copy of mvs */          VECTOR mv[4];   /* local copy of mvs */
# Line 451  Line 407 
407                          mv[i] = pMB->mvs[i];                          mv[i] = pMB->mvs[i];
408          }          }
409    
         if (mcsel) {  
                 mv[0].x = mv[0].y = mv[1].x = mv[1].y = mv[2].x = mv[2].y = mv[3].x = mv[3].y = 0;  
                         /* position in ref is same as the block, set vector to (0,0) */  
                 pY_Ref = dec->gmc.y;  
                 pU_Ref = dec->gmc.u;  
                 pV_Ref = dec->gmc.v;  
                         /* but reference itself isn't. It's warped... */  
                         /* Btw., this is too slow! For GMC it should simply be transfer_16to8add() */  
         } else {  
                 pY_Ref = dec->refn[0].y;  
                 pU_Ref = dec->refn[0].u;  
                 pV_Ref = dec->refn[0].v;  
         }  
   
410          if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) {          if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) {
411    
412                  uv_dx = mv[0].x / (1 + dec->quarterpel);                  uv_dx = mv[0].x / (1 + dec->quarterpel);
# Line 476  Line 418 
418                  start_timer();                  start_timer();
419                  if (reduced_resolution)                  if (reduced_resolution)
420                  {                  {
421                          interpolate32x32_switch(dec->cur.y, pY_Ref , 32*x_pos, 32*y_pos,                          interpolate32x32_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos,
422                                                                    mv[0].x, mv[0].y, stride,  rounding);                                                                    mv[0].x, mv[0].y, stride,  rounding);
423                          interpolate16x16_switch(dec->cur.u, pU_Ref , 16 * x_pos, 16 * y_pos,                          interpolate16x16_switch(dec->cur.u, dec->refn[0].u, 16 * x_pos, 16 * y_pos,
424                                                                    uv_dx, uv_dy, stride2, rounding);                                                                    uv_dx, uv_dy, stride2, rounding);
425                          interpolate16x16_switch(dec->cur.v, pV_Ref , 16 * x_pos, 16 * y_pos,                          interpolate16x16_switch(dec->cur.v, dec->refn[0].v, 16 * x_pos, 16 * y_pos,
426                                                                    uv_dx, uv_dy, stride2, rounding);                                                                    uv_dx, uv_dy, stride2, rounding);
427    
428                  }                  }
429                  else                  else
430                  {                  {
431                          if(dec->quarterpel) {                          if(dec->quarterpel) {
432                                  interpolate16x16_quarterpel(dec->cur.y, pY_Ref , dec->qtmp.y, dec->qtmp.y + 64,                                  interpolate16x16_quarterpel(dec->cur.y, dec->refn[0].y, dec->qtmp.y, dec->qtmp.y + 64,
433                                                                                          dec->qtmp.y + 128, 16*x_pos, 16*y_pos,                                                                                          dec->qtmp.y + 128, 16*x_pos, 16*y_pos,
434                                                                                          mv[0].x, mv[0].y, stride, rounding);                                                                                          mv[0].x, mv[0].y, stride, rounding);
435                          }                          }
436                          else {                          else {
437                                  interpolate16x16_switch(dec->cur.y, pY_Ref , 16*x_pos, 16*y_pos,                                  interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 16*x_pos, 16*y_pos,
438                                                                            mv[0].x, mv[0].y, stride, rounding);                                                                            mv[0].x, mv[0].y, stride, rounding);
439                          }                          }
440    
441                          interpolate8x8_switch(dec->cur.u, pU_Ref , 8 * x_pos, 8 * y_pos,                          interpolate8x8_switch(dec->cur.u, dec->refn[0].u, 8 * x_pos, 8 * y_pos,
442                                                                    uv_dx, uv_dy, stride2, rounding);                                                                    uv_dx, uv_dy, stride2, rounding);
443                          interpolate8x8_switch(dec->cur.v, pV_Ref , 8 * x_pos, 8 * y_pos,                          interpolate8x8_switch(dec->cur.v, dec->refn[0].v, 8 * x_pos, 8 * y_pos,
444                                                                    uv_dx, uv_dy, stride2, rounding);                                                                    uv_dx, uv_dy, stride2, rounding);
445                  }                  }
446                  stop_comp_timer();                  stop_comp_timer();
# Line 523  Line 465 
465                  start_timer();                  start_timer();
466                  if (reduced_resolution)                  if (reduced_resolution)
467                  {                  {
468                          interpolate16x16_switch(dec->cur.y, pY_Ref , 32*x_pos, 32*y_pos,                          interpolate16x16_switch(dec->cur.y, dec->refn[0].y, 32*x_pos, 32*y_pos,
469                                                                    mv[0].x, mv[0].y, stride,  rounding);                                                                    mv[0].x, mv[0].y, stride,  rounding);
470                          interpolate16x16_switch(dec->cur.y, pY_Ref , 32*x_pos + 16, 32*y_pos,                          interpolate16x16_switch(dec->cur.y, dec->refn[0].y , 32*x_pos + 16, 32*y_pos,
471                                                                    mv[1].x, mv[1].y, stride,  rounding);                                                                    mv[1].x, mv[1].y, stride,  rounding);
472                          interpolate16x16_switch(dec->cur.y, pY_Ref , 32*x_pos, 32*y_pos + 16,                          interpolate16x16_switch(dec->cur.y, dec->refn[0].y , 32*x_pos, 32*y_pos + 16,
473                                                                    mv[2].x, mv[2].y, stride,  rounding);                                                                    mv[2].x, mv[2].y, stride,  rounding);
474                          interpolate16x16_switch(dec->cur.y, pY_Ref , 32*x_pos + 16, 32*y_pos + 16,                          interpolate16x16_switch(dec->cur.y, dec->refn[0].y , 32*x_pos + 16, 32*y_pos + 16,
475                                                                    mv[3].x, mv[3].y, stride,  rounding);                                                                    mv[3].x, mv[3].y, stride,  rounding);
476                          interpolate16x16_switch(dec->cur.u, pU_Ref , 16 * x_pos, 16 * y_pos,                          interpolate16x16_switch(dec->cur.u, dec->refn[0].u , 16 * x_pos, 16 * y_pos,
477                                                                    uv_dx, uv_dy, stride2, rounding);                                                                    uv_dx, uv_dy, stride2, rounding);
478                          interpolate16x16_switch(dec->cur.v, pV_Ref , 16 * x_pos, 16 * y_pos,                          interpolate16x16_switch(dec->cur.v, dec->refn[0].v , 16 * x_pos, 16 * y_pos,
479                                                                    uv_dx, uv_dy, stride2, rounding);                                                                    uv_dx, uv_dy, stride2, rounding);
480    
481                          // set_block(pY_Cur, stride, 32, 32, 127);                          /* set_block(pY_Cur, stride, 32, 32, 127); */
482                  }                  }
483                  else                  else
484                  {                  {
485                          if(dec->quarterpel) {                          if(dec->quarterpel) {
486                                  interpolate8x8_quarterpel(dec->cur.y, pY_Ref , dec->qtmp.y, dec->qtmp.y + 64,                                  interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y , dec->qtmp.y, dec->qtmp.y + 64,
487                                                                                    dec->qtmp.y + 128, 16*x_pos, 16*y_pos,                                                                                    dec->qtmp.y + 128, 16*x_pos, 16*y_pos,
488                                                                                    mv[0].x, mv[0].y, stride,  rounding);                                                                                    mv[0].x, mv[0].y, stride,  rounding);
489                                  interpolate8x8_quarterpel(dec->cur.y, pY_Ref , dec->qtmp.y, dec->qtmp.y + 64,                                  interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y , dec->qtmp.y, dec->qtmp.y + 64,
490                                                                                    dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos,                                                                                    dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos,
491                                                                                    mv[1].x, mv[1].y, stride,  rounding);                                                                                    mv[1].x, mv[1].y, stride,  rounding);
492                                  interpolate8x8_quarterpel(dec->cur.y, pY_Ref , dec->qtmp.y, dec->qtmp.y + 64,                                  interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y , dec->qtmp.y, dec->qtmp.y + 64,
493                                                                                    dec->qtmp.y + 128, 16*x_pos, 16*y_pos + 8,                                                                                    dec->qtmp.y + 128, 16*x_pos, 16*y_pos + 8,
494                                                                                    mv[2].x, mv[2].y, stride,  rounding);                                                                                    mv[2].x, mv[2].y, stride,  rounding);
495                                  interpolate8x8_quarterpel(dec->cur.y, pY_Ref , dec->qtmp.y, dec->qtmp.y + 64,                                  interpolate8x8_quarterpel(dec->cur.y, dec->refn[0].y , dec->qtmp.y, dec->qtmp.y + 64,
496                                                                                    dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos + 8,                                                                                    dec->qtmp.y + 128, 16*x_pos + 8, 16*y_pos + 8,
497                                                                                    mv[3].x, mv[3].y, stride,  rounding);                                                                                    mv[3].x, mv[3].y, stride,  rounding);
498                          }                          }
499                          else {                          else {
500                                  interpolate8x8_switch(dec->cur.y, pY_Ref , 16*x_pos, 16*y_pos,                                  interpolate8x8_switch(dec->cur.y, dec->refn[0].y , 16*x_pos, 16*y_pos,
501                                                                            mv[0].x, mv[0].y, stride,  rounding);                                                                            mv[0].x, mv[0].y, stride,  rounding);
502                                  interpolate8x8_switch(dec->cur.y, pY_Ref , 16*x_pos + 8, 16*y_pos,                                  interpolate8x8_switch(dec->cur.y, dec->refn[0].y , 16*x_pos + 8, 16*y_pos,
503                                                                            mv[1].x, mv[1].y, stride,  rounding);                                                                            mv[1].x, mv[1].y, stride,  rounding);
504                                  interpolate8x8_switch(dec->cur.y, pY_Ref , 16*x_pos, 16*y_pos + 8,                                  interpolate8x8_switch(dec->cur.y, dec->refn[0].y , 16*x_pos, 16*y_pos + 8,
505                                                                            mv[2].x, mv[2].y, stride,  rounding);                                                                            mv[2].x, mv[2].y, stride,  rounding);
506                                  interpolate8x8_switch(dec->cur.y, pY_Ref , 16*x_pos + 8, 16*y_pos + 8,                                  interpolate8x8_switch(dec->cur.y, dec->refn[0].y , 16*x_pos + 8, 16*y_pos + 8,
507                                                                            mv[3].x, mv[3].y, stride,  rounding);                                                                            mv[3].x, mv[3].y, stride,  rounding);
508                          }                          }
509    
510                          interpolate8x8_switch(dec->cur.u, pU_Ref , 8 * x_pos, 8 * y_pos,                          interpolate8x8_switch(dec->cur.u, dec->refn[0].u , 8 * x_pos, 8 * y_pos,
511                                                                    uv_dx, uv_dy, stride2, rounding);                                                                    uv_dx, uv_dy, stride2, rounding);
512                          interpolate8x8_switch(dec->cur.v, pV_Ref , 8 * x_pos, 8 * y_pos,                          interpolate8x8_switch(dec->cur.v, dec->refn[0].v , 8 * x_pos, 8 * y_pos,
513                                                                    uv_dx, uv_dy, stride2, rounding);                                                                    uv_dx, uv_dy, stride2, rounding);
514                  }                  }
515                  stop_comp_timer();                  stop_comp_timer();
# Line 576  Line 518 
518          for (i = 0; i < 6; i++) {          for (i = 0; i < 6; i++) {
519                  int direction = dec->alternate_vertical_scan ? 2 : 0;                  int direction = dec->alternate_vertical_scan ? 2 : 0;
520    
521                  if (cbp & (1 << (5 - i)))       // coded                  if (cbp & (1 << (5 - i)))       /* coded */
522                  {                  {
523                          memset(&block[i * 64], 0, 64 * sizeof(int16_t));        // clear                          memset(&block[i * 64], 0, 64 * sizeof(int16_t));        /* clear */
524    
525                          start_timer();                          start_timer();
526                          get_inter_block(bs, &block[i * 64], direction);                          get_inter_block(bs, &block[i * 64], direction);
# Line 637  Line 579 
579          stop_transfer_timer();          stop_transfer_timer();
580  }  }
581    
582    static __inline int gmc_sanitize(int value, int quarterpel, int fcode)
583    {
584            int length = 1 << (fcode+4);
585    
586    /*      if (quarterpel) value *= 2; */
587    
588            if (value < -length)
589                    return -length;
590            else if (value >= length)
591                    return length-1;
592            else return value;
593    }
594    
595    
596    static void
597    decoder_mbgmc(DECODER * dec,
598                                    MACROBLOCK * const pMB,
599                                    const uint32_t x_pos,
600                                    const uint32_t y_pos,
601                                    const uint32_t fcode,
602                                    const uint32_t cbp,
603                                    Bitstream * bs,
604                                    const uint32_t quant,
605                                    const uint32_t rounding,
606                                    const int reduced_resolution)   /* no reduced res support */
607    {
608    
609            DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE);
610            DECLARE_ALIGNED_MATRIX(data, 6, 64, int16_t, CACHE_LINE);
611    
612            const uint32_t stride = dec->edged_width;
613            const uint32_t stride2 = stride / 2;
614            const uint32_t next_block = stride * (reduced_resolution ? 16 : 8);
615            uint32_t i;
616            const uint32_t iQuant = pMB->quant;
617            uint8_t *const pY_Cur=dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);
618            uint8_t *const pU_Cur=dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);
619            uint8_t *const pV_Cur=dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);
620    
621            pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = pMB->amv;
622    
623            start_timer();
624    
625    /* this is where the calculations are done */
626    
627            {
628                    pMB->amv = generate_GMCimageMB(&dec->gmc_data, &dec->refn[0], x_pos, y_pos,
629                                            stride, stride2, dec->quarterpel, rounding, &dec->cur);
630    
631                    pMB->amv.x = gmc_sanitize(pMB->amv.x, dec->quarterpel, fcode);
632                    pMB->amv.y = gmc_sanitize(pMB->amv.y, dec->quarterpel, fcode);
633            }
634            pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = pMB->amv;
635    
636    /*
637            transfer16x16_copy(pY_Cur, dec->gmc.y + (y_pos << 4)*stride + (x_pos  << 4), stride);
638            transfer8x8_copy(pU_Cur, dec->gmc.u + (y_pos << 3)*stride2 + (x_pos  << 3), stride2);
639            transfer8x8_copy(pV_Cur, dec->gmc.v + (y_pos << 3)*stride2 + (x_pos << 3), stride2);
640    */
641    
642    
643            stop_transfer_timer();
644    
645            if (!cbp) return;
646    
647            for (i = 0; i < 6; i++) {
648                    int direction = dec->alternate_vertical_scan ? 2 : 0;
649    
650                    if (cbp & (1 << (5 - i)))       /* coded */
651                    {
652                            memset(&block[i * 64], 0, 64 * sizeof(int16_t));        /* clear */
653    
654                            start_timer();
655                            get_inter_block(bs, &block[i * 64], direction);
656                            stop_coding_timer();
657    
658                            start_timer();
659                            if (dec->quant_type == 0) {
660                                    dequant_inter(&data[i * 64], &block[i * 64], iQuant);
661                            } else {
662                                    dequant4_inter(&data[i * 64], &block[i * 64], iQuant);
663                            }
664                            stop_iquant_timer();
665    
666                            start_timer();
667                            idct(&data[i * 64]);
668                            stop_idct_timer();
669                    }
670            }
671    
672    /* interlace + GMC is this possible ??? */
673    /*
674      if (dec->interlacing && pMB->field_dct) {
675              next_block = stride;
676              stride *= 2;
677      }
678    */
679            start_timer();
680            if (cbp & 32)
681                    transfer_16to8add(pY_Cur, &data[0 * 64], stride);
682            if (cbp & 16)
683                    transfer_16to8add(pY_Cur + 8, &data[1 * 64], stride);
684            if (cbp & 8)
685                    transfer_16to8add(pY_Cur + next_block, &data[2 * 64], stride);
686            if (cbp & 4)
687                    transfer_16to8add(pY_Cur + 8 + next_block, &data[3 * 64], stride);
688            if (cbp & 2)
689                    transfer_16to8add(pU_Cur, &data[4 * 64], stride2);
690            if (cbp & 1)
691                    transfer_16to8add(pV_Cur, &data[5 * 64], stride2);
692            stop_transfer_timer();
693    }
694    
695    
696  void  void
697  decoder_iframe(DECODER * dec,  decoder_iframe(DECODER * dec,
# Line 767  Line 822 
822    
823    
824    
 static __inline int gmc_sanitize(int value, int quarterpel, int fcode)  
 {  
         int length = 1 << (fcode+4);  
   
         if (quarterpel) value *= 2;  
   
         if (value < -length)  
                 return -length;  
         else if (value >= length)  
                 return length-1;  
         else return value;  
 }  
825    
826    
827  /* for P_VOP set gmc_warp to NULL */  /* for P_VOP set gmc_warp to NULL */
# Line 799  Line 842 
842          uint32_t mb_width = dec->mb_width;          uint32_t mb_width = dec->mb_width;
843          uint32_t mb_height = dec->mb_height;          uint32_t mb_height = dec->mb_height;
844    
         static int framecount=0;  
845          if (reduced_resolution)          if (reduced_resolution)
846          {          {
847                  mb_width = (dec->width + 31) / 32;                  mb_width = (dec->width + 31) / 32;
# Line 813  Line 855 
855    
856          if (gmc_warp)          if (gmc_warp)
857          {          {
858                  char filename[80];  
859                  sprintf(filename,"dGMC%05d.pgm",framecount);                  /* 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  
860                  if ( (dec->sprite_warping_accuracy != 3) || (dec->sprite_warping_points != 2) )                  if ( (dec->sprite_warping_accuracy != 3) || (dec->sprite_warping_points != 2) )
861                  {                  {
862                          fprintf(stderr,"Wrong GMC parameters acc=%d(-> 1/%d), %d!!!\n",                          fprintf(stderr,"Wrong GMC parameters acc=%d(-> 1/%d), %d!!!\n",
# Line 827  Line 868 
868                                  (2 << dec->sprite_warping_accuracy), gmc_warp,                                  (2 << dec->sprite_warping_accuracy), gmc_warp,
869                                  dec->width, dec->height, &dec->gmc_data);                                  dec->width, dec->height, &dec->gmc_data);
870    
871    /* image warping is done block-based  in decoder_mbgmc(), now */
872    /*
873                  generate_GMCimage(&dec->gmc_data, &dec->refn[0],                  generate_GMCimage(&dec->gmc_data, &dec->refn[0],
874                                          mb_width, mb_height,                                          mb_width, mb_height,
875                                          dec->edged_width, dec->edged_width/2,                                          dec->edged_width, dec->edged_width/2,
876                                          fcode, 0, 0,                                          fcode, dec->quarterpel, 0,
877                                          rounding, dec->mbs, &dec->gmc);                                          rounding, dec->mbs, &dec->gmc);
   
 /*  
                 sprintf(filename,"dGMC%05d.pgm",framecount);  
                 image_dump_yuvpgm(&dec->gmc,  
                                         dec->edged_width, dec->width, dec->height, filename);  
   
                 sprintf(filename,"dREF%05d.pgm",framecount);  
                 image_dump_yuvpgm(&dec->refn[0],  
                                         dec->edged_width, dec->width, dec->height, filename);  
                 sprintf(filename,"dCUR%05d.pgm",framecount);  
                 image_dump_yuvpgm(&dec->cur,  
                                         dec->edged_width, dec->width, dec->height, filename);  
                 framecount++;  
878  */  */
879          }          }
880    
# Line 855  Line 885 
885                  for (x = 0; x < mb_width; x++) {                  for (x = 0; x < mb_width; x++) {
886                          MACROBLOCK *mb;                          MACROBLOCK *mb;
887    
888                          // skip stuffing                          /* skip stuffing */
889                          while (BitstreamShowBits(bs, 10) == 1)                          while (BitstreamShowBits(bs, 10) == 1)
890                                  BitstreamSkip(bs, 10);                                  BitstreamSkip(bs, 10);
891    
# Line 870  Line 900 
900    
901                          DPRINTF(DPRINTF_MB, "macroblock (%i,%i) %08x", x, y, BitstreamShowBits(bs, 32));                          DPRINTF(DPRINTF_MB, "macroblock (%i,%i) %08x", x, y, BitstreamShowBits(bs, 32));
902    
903                          //if (!(dec->mb_skip[y*dec->mb_width + x]=BitstreamGetBit(bs)))         // not_coded                          /* if (!(dec->mb_skip[y*dec->mb_width + x]=BitstreamGetBit(bs))) */ /* not_coded */
904                          if (!(BitstreamGetBit(bs)))     // block _is_ coded                          if (!(BitstreamGetBit(bs)))     /* block _is_ coded */
905                          {                          {
906                                  uint32_t mcbpc;                                  uint32_t mcbpc;
907                                  uint32_t cbpc;                                  uint32_t cbpc;
# Line 879  Line 909 
909                                  uint32_t cbpy;                                  uint32_t cbpy;
910                                  uint32_t cbp;                                  uint32_t cbp;
911                                  uint32_t intra;                                  uint32_t intra;
912                                  int mcsel = 0;          // mcsel: '0'=local motion, '1'=GMC                                  int mcsel = 0;          /* mcsel: '0'=local motion, '1'=GMC */
913    
914                                  cp_mb++;                                  cp_mb++;
915                                  mcbpc = get_mcbpc_inter(bs);                                  mcbpc = get_mcbpc_inter(bs);
# Line 938  Line 968 
968                                          }                                          }
969                                  }                                  }
970    
971                                  if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) {                                  if (mcsel) {
972                                            decoder_mbgmc(dec, mb, x, y, fcode, cbp, bs, quant,
973                                                                    rounding, reduced_resolution);
974                                            continue;
975    
976                                          if (mcsel)                                  } else if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) {
                                         {  
                                                 mb->mvs[0] = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->amv;  
                                            /* already clipped to fcode */  
977    
978                                          } else if (dec->interlacing && mb->field_pred) {                                          if (dec->interlacing && mb->field_pred) {
979                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0],                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[0],
980                                                                                    fcode, bound);                                                                                    fcode, bound);
981                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[1],                                                  get_motion_vector(dec, bs, x, y, 0, &mb->mvs[1],
# Line 961  Line 991 
991                                          get_motion_vector(dec, bs, x, y, 1, &mb->mvs[1], fcode, bound);                                          get_motion_vector(dec, bs, x, y, 1, &mb->mvs[1], fcode, bound);
992                                          get_motion_vector(dec, bs, x, y, 2, &mb->mvs[2], fcode, bound);                                          get_motion_vector(dec, bs, x, y, 2, &mb->mvs[2], fcode, bound);
993                                          get_motion_vector(dec, bs, x, y, 3, &mb->mvs[3], fcode, bound);                                          get_motion_vector(dec, bs, x, y, 3, &mb->mvs[3], fcode, bound);
994                                  } else                  // MODE_INTRA, MODE_INTRA_Q                                  } else                  /* MODE_INTRA, MODE_INTRA_Q */
995                                  {                                  {
996                                          mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x =                                          mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x =
997                                                  0;                                                  0;
# Line 972  Line 1002 
1002                                          continue;                                          continue;
1003                                  }                                  }
1004    
1005                                  decoder_mbinter(dec, mb, x, y, acpred_flag, cbp, bs, quant,                                  decoder_mbinter(dec, mb, x, y, fcode, cbp, bs, quant,
1006                                                                  rounding, reduced_resolution, mcsel);                                                                  rounding, reduced_resolution);
1007    
1008                          }                          }
1009                          else if (gmc_warp)      /* a not coded S(GMC)-VOP macroblock */                          else if (gmc_warp)      /* a not coded S(GMC)-VOP macroblock */
1010                          {                          {
1011                                  mb->mode = MODE_NOT_CODED_GMC;                                  mb->mode = MODE_NOT_CODED_GMC;
                                 mb->mvs[0] = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->amv;  
1012    
1013                                  start_timer();                                  start_timer();
1014    
1015                                  transfer16x16_copy(dec->cur.y + (16*y)*dec->edged_width + (16*x),                                  decoder_mbgmc(dec, mb, x, y, fcode, 0x00, bs, quant,
1016                                                                   dec->gmc.y + (16*y)*dec->edged_width + (16*x),                                                                  rounding, reduced_resolution);
                                                                  dec->edged_width);  
   
                                 transfer8x8_copy(dec->cur.u + (8*y)*dec->edged_width/2 + (8*x),  
                                                                 dec->gmc.u + (8*y)*dec->edged_width/2 + (8*x),  
                                                                 dec->edged_width/2);  
   
                                 transfer8x8_copy(dec->cur.v + (8*y)*dec->edged_width/2 + (8*x),  
                                                                  dec->gmc.v + (8*y)*dec->edged_width/2 + (8*x),  
                                                                  dec->edged_width/2);  
1017    
1018                                  stop_transfer_timer();                                  stop_transfer_timer();
1019    
# Line 1009  Line 1029 
1029    
1030                                  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;
1031                                  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;
1032                                  // copy macroblock directly from ref to cur                                  /* copy macroblock directly from ref to cur */
1033    
1034                                  start_timer();                                  start_timer();
1035    
# Line 1057  Line 1077 
1077  }  }
1078    
1079    
1080  // add by MinChen <chenm001@163.com>  /* decode B-frame motion vector */
 // decode B-frame motion vector  
1081  void  void
1082  get_b_motion_vector(DECODER * dec,  get_b_motion_vector(DECODER * dec,
1083                                          Bitstream * bs,                                          Bitstream * bs,
# Line 1102  Line 1121 
1121  }  }
1122    
1123    
1124  // add by MinChen <chenm001@163.com>  /* decode an B-frame forward & backward inter macroblock */
 // decode an B-frame forward & backward inter macroblock  
1125  void  void
1126  decoder_bf_mbinter(DECODER * dec,  decoder_bf_mbinter(DECODER * dec,
1127                                     const MACROBLOCK * pMB,                                     const MACROBLOCK * pMB,
# Line 1187  Line 1205 
1205          for (i = 0; i < 6; i++) {          for (i = 0; i < 6; i++) {
1206                  int direction = dec->alternate_vertical_scan ? 2 : 0;                  int direction = dec->alternate_vertical_scan ? 2 : 0;
1207    
1208                  if (cbp & (1 << (5 - i)))       // coded                  if (cbp & (1 << (5 - i)))       /* coded */
1209                  {                  {
1210                          memset(&block[i * 64], 0, 64 * sizeof(int16_t));        // clear                          memset(&block[i * 64], 0, 64 * sizeof(int16_t));        /* clear */
1211    
1212                          start_timer();                          start_timer();
1213                          get_inter_block(bs, &block[i * 64], direction);                          get_inter_block(bs, &block[i * 64], direction);
# Line 1230  Line 1248 
1248          stop_transfer_timer();          stop_transfer_timer();
1249  }  }
1250    
1251  // add by MinChen <chenm001@163.com>  /* decode an B-frame direct &  inter macroblock */
 // decode an B-frame direct &  inter macroblock  
1252  void  void
1253  decoder_bf_interpolate_mbinter(DECODER * dec,  decoder_bf_interpolate_mbinter(DECODER * dec,
1254                                                             IMAGE forward,                                                             IMAGE forward,
# Line 1428  Line 1445 
1445          for (i = 0; i < 6; i++) {          for (i = 0; i < 6; i++) {
1446                  int direction = dec->alternate_vertical_scan ? 2 : 0;                  int direction = dec->alternate_vertical_scan ? 2 : 0;
1447    
1448                  if (cbp & (1 << (5 - i)))       // coded                  if (cbp & (1 << (5 - i)))       /* coded */
1449                  {                  {
1450                          memset(&block[i * 64], 0, 64 * sizeof(int16_t));        // clear                          memset(&block[i * 64], 0, 64 * sizeof(int16_t));        /* clear */
1451    
1452                          start_timer();                          start_timer();
1453                          get_inter_block(bs, &block[i * 64], direction);                          get_inter_block(bs, &block[i * 64], direction);
# Line 1472  Line 1489 
1489  }  }
1490    
1491    
1492  // add by MinChen <chenm001@163.com>  /* for decode B-frame dbquant */
 // for decode B-frame dbquant  
1493  int32_t __inline  int32_t __inline
1494  get_dbquant(Bitstream * bs)  get_dbquant(Bitstream * bs)
1495  {  {
1496          if (!BitstreamGetBit(bs))       // '0'          if (!BitstreamGetBit(bs))      /*  '0' */
1497                  return (0);                  return (0);
1498          else if (!BitstreamGetBit(bs))  // '10'          else if (!BitstreamGetBit(bs)) /* '10' */
1499                  return (-2);                  return (-2);
1500          else          else                           /* '11' */
1501                  return (2);                             // '11'                  return (2);
1502  }  }
1503    
1504  // add by MinChen <chenm001@163.com>  /*
1505  // for decode B-frame mb_type   * For decode B-frame mb_type
1506  // bit   ret_value   * bit   ret_value
1507  // 1        0   * 1        0
1508  // 01       1   * 01       1
1509  // 001      2   * 001      2
1510  // 0001     3   * 0001     3
1511     */
1512  int32_t __inline  int32_t __inline
1513  get_mbtype(Bitstream * bs)  get_mbtype(Bitstream * bs)
1514  {  {
# Line 1540  Line 1557 
1557  #endif  #endif
1558    
1559          for (y = 0; y < dec->mb_height; y++) {          for (y = 0; y < dec->mb_height; y++) {
1560                  // Initialize Pred Motion Vector                  /* Initialize Pred Motion Vector */
1561                  dec->p_fmv = dec->p_bmv = zeromv;                  dec->p_fmv = dec->p_bmv = zeromv;
1562                  for (x = 0; x < dec->mb_width; x++) {                  for (x = 0; x < dec->mb_width; x++) {
1563                          MACROBLOCK *mb = &dec->mbs[y * dec->mb_width + x];                          MACROBLOCK *mb = &dec->mbs[y * dec->mb_width + x];
# Line 1550  Line 1567 
1567                          mb->b_mvs[0] = mb->b_mvs[1] = mb->b_mvs[2] = mb->b_mvs[3] =                          mb->b_mvs[0] = mb->b_mvs[1] = mb->b_mvs[2] = mb->b_mvs[3] =
1568                          mb->mvs[0] = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = zeromv;                          mb->mvs[0] = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = zeromv;
1569    
1570                          // skip if the co-located P_VOP macroblock is not coded                          /*
1571                          // note: gmc+not_coded isn't skipped                           * skip if the co-located P_VOP macroblock is not coded
1572                             * if not codec in co-located S_VOP macroblock is _not_
1573                             * automatically skipped
1574                             */
1575    
1576                          if (last_mb->mode == MODE_NOT_CODED) {                          if (last_mb->mode == MODE_NOT_CODED) {
1577                                  //DEBUG2("Skip MB in B-frame at (X,Y)=!",x,y);                                  /* DEBUG2("Skip MB in B-frame at (X,Y)=!",x,y); */
1578                                  mb->cbp = 0;                                  mb->cbp = 0;
1579  #ifdef BFRAMES_DEC_DEBUG  #ifdef BFRAMES_DEC_DEBUG
1580                                  mb->mb_type = MODE_NOT_CODED;                                  mb->mb_type = MODE_NOT_CODED;
# Line 1562  Line 1582 
1582  #endif  #endif
1583                                  mb->mb_type = MODE_FORWARD;                                  mb->mb_type = MODE_FORWARD;
1584                                  mb->quant = last_mb->quant;                                  mb->quant = last_mb->quant;
1585                                  //mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = mb->mvs[0].x;                                  /*
1586                                  //mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = mb->mvs[0].y;                                    mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = mb->mvs[0].x;
1587                                      mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = mb->mvs[0].y;
1588                                    */
1589    
1590                                  decoder_bf_mbinter(dec, mb, x, y, mb->cbp, bs, mb->quant, 1);                                  decoder_bf_mbinter(dec, mb, x, y, mb->cbp, bs, mb->quant, 1);
1591                                  continue;                                  continue;
1592                          }                          }
1593    
1594                          if (!BitstreamGetBit(bs)) {     // modb=='0'                          if (!BitstreamGetBit(bs)) {     /* modb=='0' */
1595                                  const uint8_t modb2 = BitstreamGetBit(bs);                                  const uint8_t modb2 = BitstreamGetBit(bs);
1596    
1597                                  mb->mb_type = get_mbtype(bs);                                  mb->mb_type = get_mbtype(bs);
1598    
1599                                  if (!modb2) {   // modb=='00'                                  if (!modb2) {   /* modb=='00' */
1600                                          mb->cbp = BitstreamGetBits(bs, 6);                                          mb->cbp = BitstreamGetBits(bs, 6);
1601                                  } else {                                  } else {
1602                                          mb->cbp = 0;                                          mb->cbp = 0;
# Line 1595  Line 1617 
1617    
1618                          mb->quant = quant;                          mb->quant = quant;
1619                          mb->mode = MODE_INTER4V;                          mb->mode = MODE_INTER4V;
1620                          //DEBUG1("Switch bm_type=",mb->mb_type);                          /* DEBUG1("Switch bm_type=",mb->mb_type); */
1621    
1622  #ifdef BFRAMES_DEC_DEBUG  #ifdef BFRAMES_DEC_DEBUG
1623          BFRAME_DEBUG          BFRAME_DEBUG
# Line 1624  Line 1646 
1646                                                                                    / TRD                                                                                    / TRD
1647                                                                              : mb->mvs[i].y - last_mb->mvs[i].y);                                                                              : mb->mvs[i].y - last_mb->mvs[i].y);
1648                                          }                                          }
1649                                          //DEBUG("B-frame Direct!\n");                                          /* DEBUG("B-frame Direct!\n"); */
1650                                  }                                  }
1651                                  decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0],                                  decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0],
1652                                                                                             mb, x, y, bs);                                                                                             mb, x, y, bs);
# Line 1642  Line 1664 
1664    
1665                                  decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0],                                  decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0],
1666                                                                                             mb, x, y, bs);                                                                                             mb, x, y, bs);
1667                                  //DEBUG("B-frame Bidir!\n");                                  /* DEBUG("B-frame Bidir!\n"); */
1668                                  break;                                  break;
1669    
1670                          case MODE_BACKWARD:                          case MODE_BACKWARD:
# Line 1652  Line 1674 
1674    
1675                                  mb->mode = MODE_INTER;                                  mb->mode = MODE_INTER;
1676                                  decoder_bf_mbinter(dec, mb, x, y, mb->cbp, bs, quant, 0);                                  decoder_bf_mbinter(dec, mb, x, y, mb->cbp, bs, quant, 0);
1677                                  //DEBUG("B-frame Backward!\n");                                  /* DEBUG("B-frame Backward!\n"); */
1678                                  break;                                  break;
1679    
1680                          case MODE_FORWARD:                          case MODE_FORWARD:
# Line 1662  Line 1684 
1684    
1685                                  mb->mode = MODE_INTER;                                  mb->mode = MODE_INTER;
1686                                  decoder_bf_mbinter(dec, mb, x, y, mb->cbp, bs, quant, 1);                                  decoder_bf_mbinter(dec, mb, x, y, mb->cbp, bs, quant, 1);
1687                                  //DEBUG("B-frame Forward!\n");                                  /* DEBUG("B-frame Forward!\n"); */
1688                                  break;                                  break;
1689    
1690                          default:                          default:
1691                                  DPRINTF(DPRINTF_ERROR,"Not support B-frame mb_type = %i", mb->mb_type);                                  DPRINTF(DPRINTF_ERROR,"Not support B-frame mb_type = %i", mb->mb_type);
1692                          }                          }
1693                    } /* End of for */
                 }                                               // end of FOR  
1694          }          }
1695    
1696  #ifdef BFRAMES_DEC_DEBUG  #ifdef BFRAMES_DEC_DEBUG
1697          if (!first){          if (!first){
1698                  first=1;                  first=1;
# Line 1680  Line 1702 
1702  #endif  #endif
1703  }  }
1704    
1705  // swap two MACROBLOCK array  /* swap two MACROBLOCK array */
1706  void  void
1707  mb_swap(MACROBLOCK ** mb1,  mb_swap(MACROBLOCK ** mb1,
1708                  MACROBLOCK ** mb2)                  MACROBLOCK ** mb2)
# Line 1726  Line 1748 
1748          uint32_t fcode_backward;          uint32_t fcode_backward;
1749          uint32_t intra_dc_threshold;          uint32_t intra_dc_threshold;
1750          WARPPOINTS gmc_warp;          WARPPOINTS gmc_warp;
1751          uint32_t vop_type;          int vop_type;
1752          int success = 0;          int success = 0;
1753          int output = 0;          int output = 0;
1754          int seen_something = 0;          int seen_something = 0;
# Line 1754  Line 1776 
1776                  {                  {
1777                          stats->notify = output ? XVID_DEC_VOP : XVID_DEC_NOTHING;                          stats->notify = output ? XVID_DEC_VOP : XVID_DEC_NOTHING;
1778                          stats->data.vop.time_base = (int)dec->time_base;                          stats->data.vop.time_base = (int)dec->time_base;
1779                          stats->data.vop.time_increment = 0;     //XXX: todo                          stats->data.vop.time_increment = 0;     /* XXX: todo */
1780                  }                  }
1781    
1782                  emms();                  emms();
# Line 1765  Line 1787 
1787    
1788          BitstreamInit(&bs, frame->bitstream, frame->length);          BitstreamInit(&bs, frame->bitstream, frame->length);
1789    
1790          // XXX: 0x7f is only valid whilst decoding vfw xvid/divx5 avi's          /* XXX: 0x7f is only valid whilst decoding vfw xvid/divx5 avi's */
1791          if(dec->low_delay_default && frame->length == 1 && BitstreamShowBits(&bs, 8) == 0x7f)          if(dec->low_delay_default && frame->length == 1 && BitstreamShowBits(&bs, 8) == 0x7f)
1792          {          {
1793                  if (stats)                  if (stats)
# Line 1815  Line 1837 
1837                  goto repeat;                  goto repeat;
1838          }          }
1839    
1840          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 */
1841    
1842    
1843          /* packed_mode: special-N_VOP treament */          /* packed_mode: special-N_VOP treament */
# Line 1945  Line 1967 
1967          {          {
1968                  stats->notify = output ? XVID_DEC_VOP : XVID_DEC_NOTHING;                  stats->notify = output ? XVID_DEC_VOP : XVID_DEC_NOTHING;
1969                  stats->data.vop.time_base = (int)dec->time_base;                  stats->data.vop.time_base = (int)dec->time_base;
1970                  stats->data.vop.time_increment = 0;     //XXX: todo                  stats->data.vop.time_increment = 0;     /* XXX: todo */
1971          }          }
1972    
1973          emms();          emms();

Legend:
Removed from v.1.37.2.27  
changed lines
  Added in v.1.49

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