⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parseblock.cpp

📁 This code is based on mpeg_play, available from: http://bmrc.berkeley.edu/frame/research/mpeg/
💻 CPP
📖 第 1 页 / 共 2 页
字号:
              vid_stream->mblock.past_intra_addr > 1) {	    DCT_dc_cb_past = diff;	  } else {	    DCT_dc_cb_past += diff;	  }	  *reconptr++ = DCT_dc_cb_past;	}#else      /* We test 5 first; a result of the mixup of Cr and Cb */        coeff = diff;        if (n == 5) {          if (vid_stream->mblock.mb_address -              vid_stream->mblock.past_intra_addr > 1) {            coeff += 1024;          } else {            coeff += DCT_dc_cr_past;          }          DCT_dc_cr_past = coeff;        } else {          if (vid_stream->mblock.mb_address -              vid_stream->mblock.past_intra_addr > 1) {            coeff += 1024;          } else {            coeff += DCT_dc_cb_past;          }          DCT_dc_cb_past = coeff;        }#endif      }      #ifndef USE_ATI      *reconptr = coeff;#ifdef USE_MMX      if ( mmx_available ) {        *reconptr <<= 4;      }#endif /* USE_MMX */#endif /* USE_ATI */      pos = 0;      coeffCount = (coeff != 0);      i = 0;       if (vid_stream->picture.code_type != 4) {        qscale = vid_stream->slice.quant_scale;        iqmatrixptr = vid_stream->intra_quant_matrix[0];            while(1) {                DECODE_DCT_COEFF_NEXT(run, level);	  if (run >= END_OF_BLOCK) break;          i = i + run + 1;          pos = zigzag_direct[i&0x3f];          /* quantizes and oddifies each coefficient */          if (level < 0) {            coeff = ((level<<1) * qscale *                      ((int) (iqmatrixptr[pos]))) / 16;             coeff += (1 - (coeff & 1));          } else {            coeff = ((level<<1) * qscale *                      ((int) (*(iqmatrixptr+pos)))) >> 4;             coeff -= (1 - (coeff & 1));          }#ifdef USE_ATI	  *reconptr++ = run;	  *reconptr++ = coeff;#else#ifdef USE_MMX          if ( mmx_available )            coeff *= 16;#endif#ifdef QUANT_CHECK          printf ("coeff: %d\n", coeff);#endif          reconptr[pos] = coeff;          coeffCount++;#endif /* USE_ATI */        }#ifdef QUANT_CHECK	printf ("\n");#endif#ifdef USE_ATI	/* mark end of block */	*reconptr++ = 0xFFFFFFFF;#endif#ifdef ANALYSIS         {          extern unsigned int *mbCoeffPtr;          mbCoeffPtr[pos]++;        }#endif        flush_bits(2);	goto end;      }    } else { /* non-intra-coded macroblock */      niqmatrixptr = vid_stream->non_intra_quant_matrix[0];      qscale = vid_stream->slice.quant_scale;      DECODE_DCT_COEFF_FIRST(run, level);      i = run;      pos = zigzag_direct[i&0x3f];        /* quantizes and oddifies each coefficient */      if (level < 0) {        coeff = (((level<<1) - 1) * qscale *                  ((int) (niqmatrixptr[pos]))) / 16; 	if ((coeff & 1) == 0) {coeff = coeff + 1;}      } else {        coeff = (((level<<1) + 1) * qscale *                  ((int) (*(niqmatrixptr+pos)))) >> 4; 	coeff = (coeff-1) | 1; /* equivalent to: if ((coeff&1)==0) coeff = coeff - 1; */      }#ifdef USE_ATI      *reconptr++ = run;      *reconptr++ = coeff;#else#ifdef USE_MMX      if ( mmx_available )        coeff *= 16;#endif      reconptr[pos] = coeff;      if (coeff) {          coeffCount = 1;      }#endif /* USE_ATI */      if (vid_stream->picture.code_type != 4) {            while(1) {                DECODE_DCT_COEFF_NEXT(run, level);          if (run >= END_OF_BLOCK) {	       	break;          }          i = i+run+1;          pos = zigzag_direct[i&0x3f];          if (level < 0) {            coeff = (((level<<1) - 1) * qscale *                      ((int) (niqmatrixptr[pos]))) / 16;             if ((coeff & 1) == 0) {coeff = coeff + 1;}          } else {            coeff = (((level<<1) + 1) * qscale *                      ((int) (*(niqmatrixptr+pos)))) >> 4;             coeff = (coeff-1) | 1; /* equivalent to: if ((coeff&1)==0) coeff = coeff - 1; */          }#ifdef USE_ATI	  *reconptr++ = run;	  *reconptr++ = coeff;#else#ifdef USE_MMX          if ( mmx_available )            coeff *= 16;#endif          reconptr[pos] = coeff;          coeffCount++;#endif /* USE_ATI */        } /* end while */#ifdef USE_ATI	/* mark end of block */	*reconptr++ = 0xFFFFFFFF; #endif#ifdef ANALYSIS        {          extern unsigned int *mbCoeffPtr;          mbCoeffPtr[pos]++;        }#endif        flush_bits(2);        goto end;      } /* end if (vid_stream->picture.code_type != 4) */    }      end:#ifdef USE_ATI    return;#else    if( ! vid_stream->_skipFrame || (vid_stream->picture.code_type != B_TYPE) )    {        if( coeffCount == 1 )        {#ifdef USE_MMX          if ( mmx_available )            IDCT_mmx(reconptr);          else            j_rev_dct_sparse (reconptr, pos);#else          j_rev_dct_sparse (reconptr, pos);#endif        }        else        {#ifdef FLOATDCT          if (qualityFlag)          {            float_idct(reconptr);          }          else#endif#ifdef USE_MMX          if ( mmx_available )            IDCT_mmx(reconptr);          else            j_rev_dct(reconptr);#else            j_rev_dct(reconptr);#endif        }    }#ifdef USE_MMX    if ( mmx_available ) {      __asm__ ("emms");    }#endif#endif}    #undef DCT_recon #undef DCT_dc_y_past #undef DCT_dc_cr_past #undef DCT_dc_cb_past /* *-------------------------------------------------------------- * * ParseAwayBlock -- * *    Parses off block values, throwing them away. *      Used with grayscale dithering. * * Results: *    None. * * Side effects: *      None. * *-------------------------------------------------------------- */void ParseAwayBlock( int n, VidStream* vid_stream ){  unsigned int diff;  unsigned int size, run;  int level;  if (vid_stream->buf_length < 100)    correct_underflow(vid_stream);  if (vid_stream->mblock.mb_intra) {    /* If the block is a luminance block... */    if (n < 4) {      /* Parse and decode size of first coefficient. */      DecodeDCTDCSizeLum(size);      /* Parse first coefficient. */      if (size != 0) {        get_bitsn(size, diff);      }    }    /* Otherwise, block is chrominance block... */    else {      /* Parse and decode size of first coefficient. */      DecodeDCTDCSizeChrom(size);      /* Parse first coefficient. */      if (size != 0) {        get_bitsn(size, diff);      }    }  }  /* Otherwise, block is not intracoded... */  else {    /* Decode and set first coefficient. */    DECODE_DCT_COEFF_FIRST(run, level);  }  /* If picture is not D type (i.e. I, P, or B)... */  if (vid_stream->picture.code_type != 4) {    /* While end of macroblock has not been reached... */    while (1) {      /* Get the dct_coeff_next */      DECODE_DCT_COEFF_NEXT(run, level);      if (run >= END_OF_BLOCK) break;    }    /* End_of_block */    flush_bits(2);  }}/* EOF */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -