📄 vtcdec.cpp
字号:
for (col=0; col<mzte_codec.m_iColors; col++){ noteProgress("Single-Quant Mode (Band by Band) - Spatial %d, SNR 0, "\ "Color %d",spa_lev,col); fflush(stderr); mzte_codec.m_iCurColor = col; if(spa_lev !=0 || col == 0){ wavelet_higher_bands_decode_SQ_band(col); if(decIQuantizeAC_spa(spa_lev,col)) errorHandler("decIQuantizeAC_spa"); } } } Void CVTCDecoder::TextureSpatialLayerSQ_dec(Int spa_lev,FILE *bitfile){ Int texture_spatial_layer_start_code,texture_spatial_layer_id; // Char fname[100]; // hjlee /*------- AC: Open and initialize bitstream file -------*/ if (mzte_codec.m_iSingleBitFile==0) { abort();#if 0 // wmay - this is bad - really bad sprintf(fname,mzte_codec.m_cBitFileAC,spa_lev,0); if ((bitfile=fopen(fname,"rb"))==NULL) errorHandler("Can't open file '%s' for reading.",fname); init_bit_packing_fp(bitfile,1);#endif } else init_bit_packing_fp(bitfile,0); /* header info */ texture_spatial_layer_start_code = get_X_bits(32); if (texture_spatial_layer_start_code != TEXTURE_SPATIAL_LAYER_START_CODE) errorHandler("Wrong texture_spatial_layer_start_code %x.", texture_spatial_layer_start_code); texture_spatial_layer_id = get_X_bits(5); if (texture_spatial_layer_id != spa_lev) errorHandler("Incorrect texture_spatial_layer_id"); mzte_codec.m_SPlayer[0].SNR_scalability_levels = 1; TextureSpatialLayerSQNSC_dec(spa_lev); align_byte(); if(mzte_codec.m_iSingleBitFile==0) fclose(bitfile);}Void CVTCDecoder::textureLayerSQ_Dec(FILE *bitfile){ Int col, err, spa_lev; SNR_IMAGE *snr_image; noteProgress("Decoding AC coefficients - Single-Quant Mode...."); /* added for compatability with MQ spatial layer flexability - ph 7/16 */ setSpatialLayerDimsSQ(0); // hjlee 0901 /*------- AC: Set spatial and SNR levels to zero -------*/ mzte_codec.m_iCurSpatialLev = 0; mzte_codec.m_iCurSNRLev = 0; for (col=0; col<mzte_codec.m_iColors; col++) { /* initialization of spatial dimensions for each color component */ setSpatialLevelAndDimensions(0, col); /* initialize AC coefficient info */ if ((err=ztqInitAC(1, col))) errorHandler("ztqInitAC"); snr_image=&(mzte_codec.m_SPlayer[col].SNRlayer.snr_image); } /*------- AC: Decode and inverse quantize all color components -------*/ if (mzte_codec.m_iScanDirection==0) /* tree-depth scan */ { /* Read quant value from bitstream */ for(col=0;col<mzte_codec.m_iColors;col++){ snr_image=&(mzte_codec.m_SPlayer[col].SNRlayer.snr_image); Get_Quant_and_Max(snr_image,0,col); // hjlee 0901 } /* losslessly decoding AC coefficients */ wavelet_higher_bands_decode_SQ_tree(); for (col=0; col<mzte_codec.m_iColors; col++) { /* Inverse quantize AC coefficients */ if ((err=decIQuantizeAC(col))) errorHandler("decIQuantizeAC"); } } else /* SQ band by band */ { /* added for compatability with MQ spatial layer flexability - ph 7/16 */ setSpatialLayerDimsSQ(1); // hjlee 0901 /* Assumes all three color components have the same number of SNR levels */ for (col=0; col<mzte_codec.m_iColors; col++) mzte_codec.m_SPlayer[col].SNR_scalability_levels = 1; /* Loop through spatial layers */ for (spa_lev=0; spa_lev<mzte_codec.m_iTargetSpatialLev/*mzte_codec.m_iSpatialLev*/; spa_lev++) { for (col=0; col<mzte_codec.m_iColors; col++) setSpatialLevelAndDimensions(spa_lev, col); /*----- AC: Set global spatial layer. -----*/ mzte_codec.m_iCurSpatialLev = spa_lev; /* Update spatial level coeff info if changing spatial levels. Do this for all color components */ if (mzte_codec.m_bStartCodeEnable) { TextureSpatialLayerSQ_dec(spa_lev,bitfile); } else TextureSpatialLayerSQNSC_dec(spa_lev); } } noteProgress("Completed decoding AC coefficients - Single-Quant Mode.");}Void CVTCDecoder::TextureSNRLayerMQ_decode(Int spa_lev, Int snr_lev,FILE *fp){ SNR_IMAGE *snr_image; Int col; Int texture_snr_layer_id; mzte_codec.m_iCurSpatialLev=spa_lev; if(mzte_codec.m_bStartCodeEnable){ noteProgress("Decoding Multi-Quant Mode Layer with SNR start code...."); /* header info */ if(get_X_bits(32) != texture_snr_layer_start_code) errorHandler("Error in decoding texture_snr_layer_start_code"); texture_snr_layer_id=get_X_bits(5); } else noteProgress("Decoding Multi-Quant Mode Layer without SNR start code...."); noteProgress("Multi-Quant Mode - Spatial %d, SNR %d", spa_lev,snr_lev); for(col=0; col < NCOL; col++) { /* Set global color variable */ mzte_codec.m_iCurColor = col; /* initialization of spatial dimensions for each color component */ setSpatialLevelAndDimensions(mzte_codec.m_iCurSpatialLev, col); snr_image=&(mzte_codec.m_SPlayer[col].SNRlayer.snr_image); Get_Quant_and_Max(snr_image,spa_lev,col); // hjlee 0901 updateResidMaxAndAssignSkips(col); noteDebug("resid_max=%d\n",snr_image->residual_max); } wavelet_higher_bands_decode_MQ(mzte_codec.m_iScanDirection); for(col=0; col < NCOL; col++) { /* Set global color variable */ mzte_codec.m_iCurColor = col; /* quantize and mark zerotree structure for AC coefficients */ if (decIQuantizeAC(col)) errorHandler("decQuantizeAndMarkAC"); noteDebug("max_root=%d max_valz=%d max_valnz=%d max_resi=%d", ROOT_MAX(col),VALZ_MAX(col),VALNZ_MAX(col), RESID_MAX(col)); /* Update states of ac coefficients */ if (decUpdateStateAC(col)) errorHandler("decUpdateStateAC"); }}#define SNR_INFINITY 99// hjlee 0901Void CVTCDecoder::textureLayerMQ_Dec(FILE *bitfile, Int target_spatial_levels, Int target_snr_levels, FILTER **wvtfilter){ Int err, spa_lev, snr_lev, snr_scalability_levels; Int texture_spatial_layer_start_code; Int texture_spatial_layer_id; Char fname[100];// hjlee 0901 /* added for spatial layer flexability - ph 7/16 */ getSpatialLayerDims(); // hjlee 0901 /*------- AC: Initialize QList Structure -------*/ if ((err=ztqQListInit())) errorHandler("Allocating memory for QList information.");// hjlee 0901 /* Initialize coeffs */ setSpatialLevelAndDimensions(0,0); if ((err=ztqInitAC(1,0))) errorHandler("ztqInitAC"); if (mzte_codec.m_lastWvtDecompInSpaLayer[0][1]<0) setSpatialLevelAndDimensions(1,1); else setSpatialLevelAndDimensions(0,1); if ((err=ztqInitAC(1,1))) errorHandler("ztqInitAC"); if (mzte_codec.m_lastWvtDecompInSpaLayer[0][2]<0) setSpatialLevelAndDimensions(1,2); else setSpatialLevelAndDimensions(0,2); if ((err=ztqInitAC(1,2))) errorHandler("ztqInitAC"); /* Loop through spatial layers */ target_spatial_levels=MIN(mzte_codec.m_iSpatialLev, target_spatial_levels); for (spa_lev=0; spa_lev<target_spatial_levels; spa_lev++) { /*----- AC: Set global spatial layer and SNR scalability level. -----*/ /* Assumes all three color components have the same number of SNR levels */ mzte_codec.m_iCurSpatialLev = spa_lev; mzte_codec.m_SPlayer[0].SNR_scalability_levels = SNR_INFINITY; snr_scalability_levels = mzte_codec.m_SPlayer[0].SNR_scalability_levels; /* Update spatial level coeff info if changing spatial levels. Do this for all color components. */ if (spa_lev != 0) { for (mzte_codec.m_iCurColor = 0; mzte_codec.m_iCurColor<mzte_codec.m_iColors; mzte_codec.m_iCurColor++) { setSpatialLevelAndDimensions(mzte_codec.m_iCurSpatialLev, mzte_codec.m_iCurColor);// hjlee 0901 if (mzte_codec.m_lastWvtDecompInSpaLayer[spa_lev-1][mzte_codec.m_iCurColor] >=0) spatialLayerChangeUpdate(mzte_codec.m_iCurColor); } } if (!mzte_codec.m_bStartCodeEnable) { snr_scalability_levels = get_X_bits(5); mzte_codec.m_SPlayer[0].SNR_scalability_levels = snr_scalability_levels; } /* Loop through SNR layers */ for (snr_lev=0; snr_lev<snr_scalability_levels; snr_lev++) { if (spa_lev==target_spatial_levels-1 && snr_lev==target_snr_levels) break; /*----- AC: Set global SNR layer -----*/ mzte_codec.m_iCurSNRLev = snr_lev; if (mzte_codec.m_bStartCodeEnable) { /*------- AC: Open and initialize bitstream file -------*/ if (mzte_codec.m_iSingleBitFile==0) { abort();#if 0 // this is bad - really bad code sprintf(fname,mzte_codec.m_cBitFileAC, mzte_codec.m_iCurSpatialLev,mzte_codec.m_iCurSNRLev);#endif if ((bitfile=fopen(fname,"rb"))==NULL) errorHandler("Can't open file '%s' for reading.",fname); /* initialize the buffer */ init_bit_packing_fp(bitfile,1); } else init_bit_packing_fp(bitfile,0); if (snr_lev==0) { /*------- AC: Read header info to bitstream file -------*/ texture_spatial_layer_start_code = get_X_bits(32); if (texture_spatial_layer_start_code != TEXTURE_SPATIAL_LAYER_START_CODE) errorHandler("Wrong texture_spatial_layer_start_code3 %x.", texture_spatial_layer_start_code); texture_spatial_layer_id = get_X_bits(5); if(texture_spatial_layer_id !=spa_lev) errorHandler("Incorrect texture_spatial_layer_id"); snr_scalability_levels = get_X_bits(5); mzte_codec.m_SPlayer[0].SNR_scalability_levels = snr_scalability_levels; align_byte(); /* byte alignment before start code */ } } /*------- AC: Decode and inverse quantize all color components ------*/ TextureSNRLayerMQ_decode(spa_lev, snr_lev, bitfile); if (mzte_codec.m_bStartCodeEnable){ align_byte(); /* byte alignment before start code */ if (mzte_codec.m_iSingleBitFile==0) fclose(bitfile); } } /* snr_lev */ } /* spa_lev */ /*------- AC: Free Qlist structure -------*/ ztqQListExit();}// hjlee 0901Void CVTCDecoder::TextureObjectLayer_dec_V1( Int target_spatial_levels, Int target_snr_levels, FILTER ***pwvtfilter){ FILE *bitfile; Int x,y,w,h,k; FILTER **wvtfilter; // hjlee 0901 UChar *inmask[3], *outmask[3]; Int nLevels[3], ret; Int Width[3], Height[3]; Int Nx[3], Ny[3]; Int usemask; Int useInt=1; PICTURE *Image; Int col,l; /*-------------------------------------------------*/ /*--------- DC (and overall header info) ----------*/ /*-------------------------------------------------*/ /*------- DC: Open and initialize bitstream file -------*/ if ((bitfile=fopen(m_cInBitsFile,"rb"))==NULL) errorHandler("Can't open file '%s' for reading.",m_cInBitsFile); /* initialize variables */ init_bit_packing_fp(bitfile,1); /*------- DC: Read header info from bitstream file -------*/ header_Dec_V1(pwvtfilter, &Image); // hjlee 0901 wvtfilter = *pwvtfilter; // hjlee 0901 /*--------------- CREATE DATA STRUCTURES -----------------*/ noteDetail("Creating and initializing data structures...."); mzte_codec.m_iColors = 3; mzte_codec.m_iBitDepth = 8; usemask = mzte_codec.m_iAlphaChannel = 0; useInt =1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -