📄 vtc_zte_ztscan_dec.cpp
字号:
setProbModelsSQ(color); // hjlee 0901 coeffinfo=mzte_codec.m_SPlayer[color].coeffinfo; /* scan each coefficients in the spatial layer */ k = 1<<n;//Modified by Sarnoff for error resilience, 3/5/99 if(mzte_codec.m_usErrResiDisable){ //no error resi case for(h=0;h<ac_h;h+=k) for(w=ac_w;w<ac_w2;w+=k) { /* LH */ decodeSQBlocks(h,w,n); /* HL */ h += ac_h; w -= ac_w; decodeSQBlocks(h,w,n); /* HH */ w += ac_w; decodeSQBlocks(h,w,n); /* Set h back to where it started. w is already there */ h -= ac_h; } } else{ //error resi case while (1) /* ph, 11/17/98 - removed: for(h=0;h<ac_h;h+=k) */ { /***** ph, 11/17/98 - check for error *****/ if (LTU>TU_max) { /* error */ return; } /* check that current TU and this function are ok */ get_TU_location(LTU); /* if color or band_height (spatial layer) are mismatched then leave */ if (TU_color!=color || band_height!=ac_h) return; /* color and spatial layer are correct test row. Set row of TU */ h = start_h; /*******************************************/ for(w=ac_w;w<ac_w2;w+=k) { /* LH */ decodeSQBlocks_ErrResi(h,w,n,color); if(n>0 && n<5) /* ph, 11/17/98 */ if (found_segment_error(color)==1) { /* found error */ } /* HL */ h += ac_h; w -= ac_w; decodeSQBlocks_ErrResi(h,w,n,color); if(n>0 && n<5) /* ph, 11/17/98 */ if (found_segment_error(color)==1) { /* found error */ } /* HH */ w += ac_w; decodeSQBlocks_ErrResi(h,w,n,color); if(n>0 && n<5) /* ph, 11/17/98 */ if (found_segment_error(color)==1) { /* found error */ } /* Set h back to where it started. w is already there */ h -= ac_h; /* ph, 11/19/98 - removed not needed */ } check_end_of_packet(); /* ph, 11/17/98 */ ++LTU; } }//End modified by Sarnoff for error resilience, 3/5/99} /******************************************************* The following single quant routines are for tree depth scan order.*******************************************************//******************************************************** Function Name ------------- Void wavelet_higher_bands_decode_SQ_tree() Arguments --------- None. Description ----------- Control program for decoding AC information for single quant mode. All colors decoded. Functions Called ---------------- cachb_decode_SQ_tree() 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_SQ_tree(){ noteDetail("Decoding AC band (wavelet_higher_bands_decode_SQ)...."); //Modified by Sarnoff for error resilience, 3/5/99 if(mzte_codec.m_usErrResiDisable){ /* init arithmetic coder */ mzte_ac_decoder_init(&acd); for (color=0; color<mzte_codec.m_iColors; color++) { probModelInitSQ(color); // hjlee 0901 }// cachb_decode_SQ(); // hjlee 0901 cachb_decode_SQ_tree(); for (color=0; color<mzte_codec.m_iColors; color++) /* close arithmetic coder */ probModelFreeSQ(color); mzte_ac_decoder_done(&acd); } else{ //error resi case /* init arithmetic coder */ init_arith_decoder_model(color); cachb_decode_SQ_tree(); close_arith_decoder_model(color); }//End modified by Sarnoff for error resilience, 3/5/99 noteDetail("Completed decoding AC band.");}/******************************************************** Function Name ------------- static Void cachb_decode_SQ() Arguments --------- None. Description ----------- Decode AC information for one color component. Single quant mode, tree-depth scan Functions Called ---------------- decode_pixel_SQ() Return Value ------------ None.********************************************************/ Void CVTCDecoder::cachb_decode_SQ_tree(){//Modified by Sarnoff for error resilience, 3/5/99 if(mzte_codec.m_usErrResiDisable){ //no error resi case Int h,w,dc_h,dc_w,dc_h2,dc_w2; dc_h=mzte_codec.m_iDCHeight; dc_w=mzte_codec.m_iDCWidth; dc_h2=dc_h<<1; dc_w2=dc_w<<1; for(h=0;h<dc_h;h++) for(w=0;w<dc_w;w++) // 1127 for (color=0; color<mzte_codec.m_iColors; color++) { SNR_IMAGE *snr_image; int tw,sw,sh,n; // 1127 snr_image=&(mzte_codec.m_SPlayer[color].SNRlayer.snr_image); height=mzte_codec.m_SPlayer[color].height; width=mzte_codec.m_SPlayer[color].width; setProbModelsSQ(color); // hjlee 0901 coeffinfo=mzte_codec.m_SPlayer[color].coeffinfo; /* LH */ n = 0; for (tw=mzte_codec.m_iDCWidth; tw < width; tw<<=1) { sh = h << n; sw = (w+dc_w) << n; decodeSQBlocks(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; decodeSQBlocks(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; decodeSQBlocks(sh,sw,n); n++; } } } else{ //error resilience case Int dc_h,dc_w; Int tw,sw,sh,n; dc_h=mzte_codec.m_iDCHeight; dc_w=mzte_codec.m_iDCWidth; /* rewrote for error resilience, bbc, 11/9/98 */ while(LTU<=TU_max){ get_TU_location(LTU); height=mzte_codec.m_SPlayer[TU_color].height; width=mzte_codec.m_SPlayer[TU_color].width; setProbModelsSQ(TU_color); coeffinfo=mzte_codec.m_SPlayer[TU_color].coeffinfo; color=TU_color; /* decoding one TU */ n = 0; for (tw=mzte_codec.m_iDCWidth; tw < width; tw<<=1){ sh = start_h << n; sw = start_w << n; decodeSQBlocks_ErrResi(sh,sw,n,TU_color); if(n>0 && n<5) found_segment_error(TU_color); n++; } check_end_of_packet(); /* error resilience code, bbc, 11/9/98 */ LTU++; } }//End modified by Sarnoff for error resilience, 3/5/99}/******************************************************** Function Name ------------- static Void decode_pixel_SQ(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. Functions Called ---------------- mag_sign_decode_SQ() mzte_ac_decode_symbol() decode_pixel_SQ() Return Value ------------ None.********************************************************/ // hjlee 0901Void CVTCDecoder::decode_pixel_SQ(Int h,Int w){ UChar zt_type; Int l; if(coeffinfo[h][w].type == ZTR_D) return; l=xy2wvtDecompLev(w,h); /* decode leave coefficients, value only */ if(IS_STATE_LEAF(coeffinfo[h][w].state)){ /* zero value. no sign */ /* Map leaf code word to type 0->ZTR, 1->VZTR */ coeffinfo[h][w].type = mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_LINIT]) ? VZTR : ZTR; if (coeffinfo[h][w].type==VZTR) mag_sign_decode_SQ(h,w); else coeffinfo[h][w].quantized_value = 0; return; } /* decode zero tree symbols */ coeffinfo[h][w].type=zt_type= mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_INIT]); /* code magnitude and sign */ switch(zt_type){ case IZ : break; case VZTR: mag_sign_decode_SQ(h,w); case ZTR: mark_ZTR_D(h,w); /* necessary for checking purpose bandwise scan */ return; case VAL: mag_sign_decode_SQ(h,w); break; default: errorHandler("Invalid zerotree symbol in single quant decode"); }#if 0 UChar zt_type; Int h, w, k; Int dcc[4]; /* Don't Code Children */ Int nSib; /* number siblings */ Int l; l=xy2wvtDecompLev(w0,h0); 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 leave coefficients, value only */ if(IS_STATE_LEAF(coeffinfo[h][w].state)){ /* zero value. no sign */#ifdef _SHAPE_ if(coeffinfo[h][w].mask==1) {#endif /* Map leaf code word to type 0->ZTR, 1->VZTR */ coeffinfo[h][w].type = mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_LINIT]) ? VZTR : ZTR; if (coeffinfo[h][w].type==VZTR) mag_sign_decode_SQ(h,w); else coeffinfo[h][w].quantized_value = 0;#ifdef _SHAPE_ } else coeffinfo[h][w].quantized_value = 0;#endif continue; } /* decode zero tree symbols */#ifdef _SHAPE_ if(coeffinfo[h][w].mask==1)#endif coeffinfo[h][w].type=zt_type= mzte_ac_decode_symbol(&acd,acm_type[l][CONTEXT_INIT]);#ifdef _SHAPE_ else coeffinfo[h][w].type=zt_type = IZ;#endif /* code magnitude and sign */ switch(zt_type){ case IZ : dcc[k]=0; break; case VZTR: mag_sign_decode_SQ(h,w); case ZTR: dcc[k]=1; break; case VAL: dcc[k]=0; mag_sign_decode_SQ(h,w); break; default: errorHandler("Invalid zerotree symbol in single quant decode"); } } /********************* CODE CHILDREN *****************************/ if (!IS_STATE_LEAF(coeffinfo[h0][w0].state)) { Int i, j; for (k=0; k<nSib; ++k) { if (dcc[k]==0) { h = h0 + (k/2); w = w0 + (k%2); /* scan children */ i=h<<1; j=w<<1; decode_pixel_SQ_tree(i,j); } } }#endif} /******************************************************** Function Name ------------- static Void mag_sign_decode_SQ(Int h,Int w) Arguments --------- Int h,Int w - position of a pixel Description ----------- Decode the value of a coefficient. Functions Called ---------------- mzte_ac_decode_symbol() Return Value ------------ None.********************************************************/ Void CVTCDecoder::mag_sign_decode_SQ(Int h,Int w){ Int value,v_sign; Int l; l=xy2wvtDecompLev(w,h); value=bitplane_decode(l,WVTDECOMP_NUMBITPLANES(color,l))+1; v_sign=mzte_ac_decode_symbol(&acd,acm_sign[l]); coeffinfo[h][w].quantized_value=(v_sign==0) ? value : -value;}/*********************************************************************//****************************** AC *********************************//************************** Multi quant ****************************//*********************************************************************/Int CVTCDecoder::bitplane_res_decode(Int l,Int max_bplane){ register Int i,val=0,k=0; for(i=max_bplane-1;i>=0;i--,k++) val+=mzte_ac_decode_symbol(&acd,&acm_bpres[l][k])<<i; return val;}/******************************************************** Function Name ------------- Void wavelet_higher_bands_decode_MQ(Int scanDirection) Arguments --------- Int scanDirection - 0 <=> tree, 1 <=> band Description ----------- Control program for decoding AC information for one color component. Multi quant mode. Functions Called ----------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -