/** Rescale coefficent for Scoeff prediction for luminance */ void ScoeffSRescale4x4(RESIDU *CurrResidu, const short W4x4_inter [6][16]) { int i8x8; for ( i8x8 = 0 ; i8x8 < 16 ; i8x8++ ) { /* each 4x4 sub-block of block */ int index = i8x8 << 4; rescale_4x4_residual(CurrResidu -> Qp, &CurrResidu -> LumaLevel [index], &CurrResidu -> LumaLevel [index], W4x4_inter); } }
/** This function permits to decode all intra chrominances in a MB. @param image_Cb Table of current frame. @param image_Cr Table of current frame. @param Block Data of the current macroblock. @param PicWidth Width in macroblocks of the current frame. @param pps PPS structure of the current video. @param macro Specifies the availability of the neighbouring macroblock. @param residu Structure which contains all the residu data of the current macroblock.. @param quantif Table which contains the quantization table. @param mb4x4_mode is the function vector for intra prediction */ void DecodeResidualChroma (unsigned char *image_Cb, unsigned char *image_Cr, const PPS *pps, const RESIDU *residu, const short PicWidthInPix, const W_TABLES *quantif) { short DC_coeff [4]; short AC_coeff [16]; //for Cb if ( residu -> Cbp & 0x30) { //Initialisation du QP int QPc = qP_tab [residu -> Qp + pps -> chroma_qp_index_offset]; ict_4x4_dc_chroma(&residu -> ChromaDCLevel_Cb [0], DC_coeff); rescale_4x4_dc_chr(QPc, DC_coeff, DC_coeff, quantif -> W4x4_Cb_inter); rescale_4x4_residual(QPc, &residu -> ChromaACLevel_Cb [0], AC_coeff, quantif -> W4x4_Cb_inter); AC_coeff [0] = DC_coeff [0]; ict_4x4_residual(AC_coeff, image_Cb, PicWidthInPix); rescale_4x4_residual(QPc, &residu -> ChromaACLevel_Cb [16], AC_coeff,quantif -> W4x4_Cb_inter); AC_coeff [0] = DC_coeff [1]; ict_4x4_residual(AC_coeff, &image_Cb[4],PicWidthInPix); rescale_4x4_residual(QPc, &residu -> ChromaACLevel_Cb [32], AC_coeff, quantif -> W4x4_Cb_inter); AC_coeff [0] = DC_coeff [2]; ict_4x4_residual(AC_coeff, &image_Cb[PicWidthInPix << 2],PicWidthInPix); rescale_4x4_residual(QPc, &residu -> ChromaACLevel_Cb [48], AC_coeff, quantif -> W4x4_Cb_inter); AC_coeff [0] = DC_coeff [3]; ict_4x4_residual(AC_coeff, &image_Cb[(1 + PicWidthInPix) << 2],PicWidthInPix); QPc = qP_tab [residu -> Qp + pps -> second_chroma_qp_index_offset]; ict_4x4_dc_chroma(&residu -> ChromaDCLevel_Cr [0], DC_coeff); rescale_4x4_dc_chr(QPc, DC_coeff, DC_coeff, quantif -> W4x4_Cr_inter); rescale_4x4_residual(QPc, &residu -> ChromaACLevel_Cr [0], AC_coeff, quantif -> W4x4_Cr_inter); AC_coeff [0] = DC_coeff [0]; ict_4x4_residual(AC_coeff, image_Cr,PicWidthInPix); rescale_4x4_residual(QPc, &residu -> ChromaACLevel_Cr [16], AC_coeff, quantif -> W4x4_Cr_inter); AC_coeff [0] = DC_coeff [1]; ict_4x4_residual(AC_coeff, &image_Cr[4],PicWidthInPix); rescale_4x4_residual(QPc, &residu -> ChromaACLevel_Cr [32], AC_coeff, quantif -> W4x4_Cr_inter); AC_coeff [0] = DC_coeff [2]; ict_4x4_residual(AC_coeff, &image_Cr[PicWidthInPix << 2],PicWidthInPix); rescale_4x4_residual(QPc, &residu -> ChromaACLevel_Cr [48], AC_coeff, quantif -> W4x4_Cr_inter); AC_coeff [0] = DC_coeff [3]; ict_4x4_residual(AC_coeff, &image_Cr[(1 + PicWidthInPix) << 2],PicWidthInPix); } }
/** Rescale coefficent for Scoeff prediction for chroma */ void ScoeffSRescaleChr4x4(RESIDU *CurrResidu, const PPS* Pps, const W_TABLES *Quantif) { short BaseDC_coeff [4]; short BqP = (short) (CurrResidu -> Qp + Pps -> chroma_qp_index_offset); short BQPc = qP_tab [BqP]; ict_4x4_dc_chroma(&CurrResidu -> ChromaDCLevel_Cb [0], BaseDC_coeff); rescale_4x4_dc_chr(BQPc, BaseDC_coeff, BaseDC_coeff, Quantif -> W4x4_Cb_inter); rescale_4x4_residual(BQPc, &CurrResidu -> ChromaACLevel_Cb [0], &CurrResidu -> ChromaACLevel_Cb [0], Quantif -> W4x4_Cb_inter); CurrResidu -> ChromaACLevel_Cb [0] = BaseDC_coeff [0]; rescale_4x4_residual(BQPc, &CurrResidu -> ChromaACLevel_Cb [16], &CurrResidu -> ChromaACLevel_Cb [16], Quantif -> W4x4_Cb_inter); CurrResidu -> ChromaACLevel_Cb [16] = BaseDC_coeff [1]; rescale_4x4_residual(BQPc, &CurrResidu -> ChromaACLevel_Cb [32], &CurrResidu -> ChromaACLevel_Cb [32], Quantif -> W4x4_Cb_inter); CurrResidu -> ChromaACLevel_Cb [32] = BaseDC_coeff [2]; rescale_4x4_residual(BQPc, &CurrResidu -> ChromaACLevel_Cb [48], &CurrResidu -> ChromaACLevel_Cb [48], Quantif -> W4x4_Cb_inter); CurrResidu -> ChromaACLevel_Cb [48] = BaseDC_coeff [3]; //Cr BqP = (short) (CurrResidu -> Qp + Pps -> second_chroma_qp_index_offset); BQPc = qP_tab [BqP]; ict_4x4_dc_chroma(&CurrResidu -> ChromaDCLevel_Cr [0], BaseDC_coeff); rescale_4x4_dc_chr(BQPc, BaseDC_coeff, BaseDC_coeff, Quantif -> W4x4_Cr_inter); rescale_4x4_residual(BQPc, &CurrResidu -> ChromaACLevel_Cr [0], &CurrResidu -> ChromaACLevel_Cr [0], Quantif -> W4x4_Cr_inter); CurrResidu -> ChromaACLevel_Cr [0] = BaseDC_coeff [0]; rescale_4x4_residual(BQPc, &CurrResidu -> ChromaACLevel_Cr [16], &CurrResidu -> ChromaACLevel_Cr [16], Quantif -> W4x4_Cr_inter); CurrResidu -> ChromaACLevel_Cr [16] = BaseDC_coeff [1]; rescale_4x4_residual(BQPc, &CurrResidu -> ChromaACLevel_Cr [32], &CurrResidu -> ChromaACLevel_Cr [32], Quantif -> W4x4_Cr_inter); CurrResidu -> ChromaACLevel_Cr [32] = BaseDC_coeff [2]; rescale_4x4_residual(BQPc, &CurrResidu -> ChromaACLevel_Cr [48], &CurrResidu -> ChromaACLevel_Cr [48], Quantif -> W4x4_Cr_inter); CurrResidu -> ChromaACLevel_Cr [48] = BaseDC_coeff [3]; }