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

📄 vtc_zte_ztscan_dec.cpp

📁 完整的RTP RTSP代码库
💻 CPP
📖 第 1 页 / 共 4 页
字号:
  cachb_decode_MQ_band()  mzte_ac_decoder_init()  mzte_ac_model_init()  mzte_ac_model_done()  mzte_ac_decoder_done()  Return Value  ------------  None.********************************************************/ Void CVTCDecoder::wavelet_higher_bands_decode_MQ(Int scanDirection){  noteDetail("Decoding AC band (wavelet_higher_bands_decode_MQ)....");  /* init arithmetic coder */  mzte_ac_decoder_init(&acd);    if (scanDirection==0)    cachb_decode_MQ_tree();  else    cachb_decode_MQ_band();  /* close arithmetic coder */  mzte_ac_decoder_done(&acd);}/**********************************************************************//***************       MQ BAND         ********************************//**********************************************************************//********************************************************  Function Name  -------------  static Void cachb_decode_MQ_band()  Arguments  ---------  None.  Description  -----------  Decode AC information for one color component.   Multiple quant, bandwise scan.  Functions Called  ----------------  clear_ZTR_D();  codeBlocks();  decode_pixel_MQ_band()  Return Value  ------------  None.********************************************************/ Void CVTCDecoder::cachb_decode_MQ_band(){  Int h,w;  Int ac_h,ac_w,ac_h2,ac_w2;  Int acH,acW,acH2,acW2;  Int layer, nCol;  Int n; /* layer index - for codeBlocks function */  Int k; /* block jump for the layer */  /* clear the ZTR_D type from the previous pass */  for (color=0; color<NCOL; ++color)  {          coeffinfo=mzte_codec.m_SPlayer[color].coeffinfo;    height=mzte_codec.m_SPlayer[color].height;    width=mzte_codec.m_SPlayer[color].width;    clear_ZTR_D(coeffinfo, width, height);  }  for (color=0; color<NCOL; ++color)    probModelInitMQ(color);   acH=mzte_codec.m_iDCHeight;  acW=mzte_codec.m_iDCWidth;  acH2=acH<<1;  acW2=acW<<1;  /* scan each coefficients in the spatial layer */  /* assume luma dimensions are >= chroma dimensions */  layer=0;  while(acH2<=mzte_codec.m_SPlayer[0].height 	&& acW2<=mzte_codec.m_SPlayer[0].width)  {    nCol = (layer==0) ? 1 : NCOL;    for (color=0; color < nCol; ++color)    {            SNR_IMAGE *snr_image;      noteProgress("  Coding Layer %d, Color %d", layer - (color!=0), color);      ac_h2=acH2;      ac_w2=acW2;      ac_h=acH;      ac_w=acW;      if (color)      {	ac_h2>>=1;	ac_w2>>=1;	ac_h>>=1;	ac_w>>=1;      }      snr_image=&(mzte_codec.m_SPlayer[color].SNRlayer.snr_image);      coeffinfo=mzte_codec.m_SPlayer[color].coeffinfo;      height=mzte_codec.m_SPlayer[color].height;      width=mzte_codec.m_SPlayer[color].width;      setProbModelsMQ(color);       /* Go through bands */      n = layer - (color>0);      k = 1<<n;      for(h=0;h<ac_h;h+=k)		for(w=ac_w;w<ac_w2;w+=k)		{		  /* LH */		  decodeMQBlocks(h,w,n);		  		  /* HL */		  h += ac_h;		  w -= ac_w;		  decodeMQBlocks(h,w,n);		  		  /* HH */		  w += ac_w;		  decodeMQBlocks(h,w,n);		  		  /* Set h back to where it started. w is already there */		  h -= ac_h;		}    }    /* update ranges */    acH=acH2;    acW=acW2;    acW2<<=1;    acH2<<=1;    layer++;  }  for (color=0; color<NCOL; ++color)    probModelFreeMQ(color);}/********************************************************  Function Name  -------------  static Void decode_pixel_MQ_band(Int h,Int w)  Arguments  ---------  Int h,Int w - position of a pixel in height and width    Description  -----------  Decoding the type and/or value of a coefficient, a  recursive function, multi quant mode.  Functions Called  ----------------  mzte_ac_decode_symbol()  mark_ZTR_D()  mag_sign_decode_MQ()  Return Value  ------------  None.********************************************************/ //Void CVTCDecoder::decode_pixel_MQ_band(Int h,Int w)Void CVTCDecoder::decode_pixel_MQ(Int h,Int w) // 1124{  Int zt_type;  /*~~~~~~~~~~~~~~~~~ zerotree descendent ~~~~~~~~~~~~~~~~~~~*/    if(coeffinfo[h][w].type==ZTR_D)    return;  /*~~~~~~~~~~~~~~ decode zero tree symbol ~~~~~~~~~~~~~~~~~~*/  if (IS_RESID(w,h,color))  {    zt_type=VAL; /* tmp assign. for next switch statement */  }  else  {    Int czt_type; /* what to put on bitstream */    Int l;    l=xy2wvtDecompLev(w,h);      zt_type = coeffinfo[h][w].type;#ifdef _SHAPE_    if(coeffinfo[h][w].mask==1) /* skip out-node */      {#endif      switch(coeffinfo[h][w].state)      {	case S_INIT:	  czt_type=mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_INIT]);	  coeffinfo[h][w].type=zt_type=czt_type;	  break;	case S_ZTR:	  czt_type=mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_ZTR]);	  coeffinfo[h][w].type=zt_type=czt_type;	  break;	case S_ZTR_D:	  czt_type=mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_ZTR_D]);	  coeffinfo[h][w].type=zt_type=czt_type;	  break;	case S_IZ:	  czt_type=mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_IZ]);	  coeffinfo[h][w].type=zt_type = czt_type ? VAL : IZ;	  break;	case S_LINIT: 	  czt_type=mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_LINIT]);	  coeffinfo[h][w].type=zt_type = czt_type ? VZTR : ZTR;	  break;	case S_LZTR:	  czt_type=mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_LZTR]);	  coeffinfo[h][w].type=zt_type = czt_type ? VZTR : ZTR;	  break;	case S_LZTR_D:	  czt_type=mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_LZTR_D]);	  coeffinfo[h][w].type=zt_type = czt_type ? VZTR : ZTR;	  break;	default:	  errorHandler("Invalid state (%d) in multi-quant encoding.", 		       coeffinfo[h][w].state);      }#ifdef _SHAPE_    }    else /* treat out-node as isolated zero for decoding purpose */    {      switch(coeffinfo[h][w].state)      {      case S_INIT:      case S_ZTR:      case S_ZTR_D:      case S_IZ:	zt_type = coeffinfo[h][w].type = IZ;	break;      case S_LINIT:       case S_LZTR:      case S_LZTR_D:	zt_type = coeffinfo[h][w].type = ZTR;	break;      default:	errorHandler("Invalid state (%d) in multi-quant encoding.", 		     coeffinfo[h][w].state);      }    }#endif  }  /*~~~~~~~~~~~~~~~~ mark ztr_d and encode magnitudes ~~~~~~~~~~~~~~~~~*/  switch(zt_type)  {    case ZTR:#ifdef _SHAPE_      if(coeffinfo[h][w].mask!=1)	return;#endif    case ZTR_D:      mark_ZTR_D(h,w);    case IZ:      coeffinfo[h][w].quantized_value=0;      return;    case VZTR:      mark_ZTR_D(h,w);    case VAL:#ifdef _SHAPE_      if(coeffinfo[h][w].mask==1) #endif	mag_sign_decode_MQ(h,w);      break;    default:      errorHandler("Invalid type in multi quant decoding.");       }}/**********************************************************************//***************       MQ TREE         ********************************//**********************************************************************//********************************************************  Function Name  -------------  static Void cachb_decode_MQ_tree()  Arguments  ---------  None.  Description  -----------  Decode AC information for one color component.   Multiple quant, treewise scan.  Functions Called  ----------------  clear_ZTR_D();  decode_pixel_MQ_tree()  Return Value  ------------  None.********************************************************/ Void CVTCDecoder::cachb_decode_MQ_tree(){  Int h,w, dc_h, dc_w;       /* clear the ZTR_D type from the previous pass */  for (color=0; color<NCOL; ++color)  {          coeffinfo=mzte_codec.m_SPlayer[color].coeffinfo;    height=mzte_codec.m_SPlayer[color].height;    width=mzte_codec.m_SPlayer[color].width;    clear_ZTR_D(coeffinfo, width, height);  }       for (color=0; color<NCOL; ++color)    probModelInitMQ(color);  /* ac_h, ac_w init */  dc_h=mzte_codec.m_iDCHeight;  dc_w=mzte_codec.m_iDCWidth;  for (h=0; h<dc_h; ++h)    for (w=0; w<dc_w; ++w)    {      for (color=0; color<NCOL; ++color)      {      	SNR_IMAGE *snr_image;	int tw,sw,sh,n;  // 1124		snr_image=&(mzte_codec.m_SPlayer[color].SNRlayer.snr_image);		coeffinfo=mzte_codec.m_SPlayer[color].coeffinfo;	height=mzte_codec.m_SPlayer[color].height;	width=mzte_codec.m_SPlayer[color].width;      	setProbModelsMQ(color);		/* LH */	n = 0;	for (tw=mzte_codec.m_iDCWidth; tw < width; tw<<=1)	{	  sh = h << n;	  sw = (w+dc_w) << n;	  decodeMQBlocks(sh,sw,n);	  n++;	}	/* HL */	n = 0;	for (tw=mzte_codec.m_iDCWidth; tw < width; tw<<=1)	{	  sh = (h+dc_h) << n;	  sw = w << n;	  decodeMQBlocks(sh,sw,n);	  n++;	}	/* HH */	n = 0;	for (tw=mzte_codec.m_iDCWidth; tw < width; tw<<=1)	{	  sh = (h+dc_h) << n;	  sw = (w+dc_w) << n;	  decodeMQBlocks(sh,sw,n);	  n++;	}#if 0	decode_pixel_MQ_tree(h,w+dc_w);      /* LH */	decode_pixel_MQ_tree(h+dc_h,w);      /* HL */	decode_pixel_MQ_tree(h+dc_h,w+dc_w); /* HH */#endif      }    }  for (color=0; color<NCOL; ++color)    probModelFreeMQ(color);}#if 0/********************************************************  Function Name  -------------  static Void decode_pixel_MQ_tree(Int h,Int w)  Arguments  ---------  Int h,Int w - position of a pixel in height and width    Description  -----------  Decoding the type and/or value of a coefficient, a  recursive function, multi quant mode.  Functions Called  ----------------  mzte_ac_decode_symbol()  mark_ZTR_D()  mag_sign_decode_MQ()  Return Value  ------------  None.********************************************************/ Void CVTCDecoder::decode_pixel_MQ_tree(Int h0,Int w0){  Int zt_type, h, w, k;  Int dcc[4]; /* Don't Code Children */  Int nSib; /* number siblings */  nSib = (h0<(mzte_codec.m_iDCHeight<<1) && w0<(mzte_codec.m_iDCWidth<<1)) ? 1 : 4;  /********************* CODE SIBLINGS *****************************/  for (k=0; k<nSib; ++k)  {    h = h0 + (k/2);    w = w0 + (k%2);    /* decode zero tree symbol */      if (IS_RESID(w,h,color))    {      zt_type=VAL;    }    else    {      Int czt_type; /* what to put on bitstream */      Int l;      l=xy2wvtDecompLev(w,h);        zt_type = coeffinfo[h][w].type;#ifdef _SHAPE_      if(coeffinfo[h][w].mask==1) /* skip out-node */        {#endif	switch(coeffinfo[h][w].state)	{	  case S_INIT:	    czt_type=mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_INIT]);	    coeffinfo[h][w].type=zt_type=czt_type;	    break;	  case S_ZTR:	    czt_type=mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_ZTR]);	    coeffinfo[h][w].type=zt_type=czt_type;	    break;	  case S_ZTR_D:	    czt_type=mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_ZTR_D]);	    coeffinfo[h][w].type=zt_type=czt_type;	    break;	  case S_IZ:	    czt_type=mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_IZ]);	    coeffinfo[h][w].type=zt_type = czt_type ? VAL : IZ;	    break;	  case S_LINIT: 	    czt_type=mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_LINIT]);	    coeffinfo[h][w].type=zt_type = czt_type ? VZTR : ZTR;	    break;	  case S_LZTR:	  czt_type=mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_LZTR]);	  coeffinfo[h][w].type=zt_type = czt_type ? VZTR : ZTR;	  break;	  case S_LZTR_D:	    czt_type=mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_LZTR_D]);	    coeffinfo[h][w].type=zt_type = czt_type ? VZTR : ZTR;	    break;	default:	  errorHandler("Invalid state (%d) in multi-quant encoding.", 		       coeffinfo[h][w].state);	}#ifdef _SHAPE_      }      else /* treat out-node as isolated zero for decoding purpose */      {	switch(coeffinfo[h][w].state)	  {	  case S_INIT:	  case S_ZTR:	  case S_ZTR_D:	  case S_IZ:	    zt_type = coeffinfo[h][w].type = IZ;	    break;	  case S_LINIT: 	  case S_LZTR:	  case S_LZTR_D:	    zt_type = coeffinfo[h][w].type = ZTR;	    break;	  default:	    errorHandler("Invalid state (%d) in multi-quant encoding.", 			 coeffinfo[h][w].state);	  }      }#endif          }    /* mark ztr_d and decode magnitudes */    switch(zt_type)    {      case ZTR:#ifdef _SHAPE_	if(coeffinfo[h][w].mask==1) { #endif	  dcc[k]=1;	  mark_ZTR_D(h,w); /* here it's just to zero out descendents */#ifdef _SHAPE_	}	else {	  dcc[k]=0;	}#endif

⌨️ 快捷键说明

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