HEVC学习(二十七) —— 变换编码之二
来源:互联网 发布:金字塔期货软件官网 编辑:程序博客网 时间:2024/05/16 10:24
//! 用于significant_coeff_flag的上下文推导过程的模式选择 draft 9.3.3.1.4Int TComTrQuant::calcPatternSigCtx( const UInt* sigCoeffGroupFlag, UInt posXCG, UInt posYCG, Int width, Int height ){ if( width == 4 && height == 4 ) return -1; //!< 不满足计算pattern的条件 UInt sigRight = 0; UInt sigLower = 0; /* **x a ** **b */ width >>= 2; height >>= 2; if( posXCG < width - 1 ) //!< draft (9-17) { sigRight = (sigCoeffGroupFlag[ posYCG * width + posXCG + 1 ] != 0); //!< coded_sub_block_flag[xS+1][yS] } if (posYCG < height - 1 ) //!< draft (9-18) { sigLower = (sigCoeffGroupFlag[ (posYCG + 1 ) * width + posXCG ] != 0); //!< (coded_sub_block_flag[xS][yS+1] << 1) } return sigRight + (sigLower<<1); //!< draft (9-17) (9-18)}
//! Derivation process of ctxIdxInc for the syntax element significant_coeff_flag (draft 9.3.3.1.4)Int TComTrQuant::getSigCtxInc ( Int patternSigCtx, UInt scanIdx, Int posX, Int posY, Int log2BlockSize, Int width ,Int height ,TextType textureType ){ const Int ctxIndMap[16] = { 0, 1, 4, 5, 2, 3, 4, 5, 6, 6, 8, 8, 7, 7, 8, 8 }; //!< Table 9-39 Specification of ctxIdxMap[i] if( posX + posY == 0 ) //!< draft (9-16) { return 0; } if ( log2BlockSize == 2 ) //!< draft (9-15) { return ctxIndMap[ 4 * posY + posX ]; } //! draft (9-24)、(9-25)、(9-26)、(9-27) Int offset = log2BlockSize == 3 ? (scanIdx==SCAN_DIAG ? 9 : 15) : (textureType == TEXT_LUMA ? 21 : 12); Int posXinSubset = posX-((posX>>2)<<2); //!< xP = xC & 3 Int posYinSubset = posY-((posY>>2)<<2); //!< yP = yC & 3 Int cnt = 0; if(patternSigCtx==0) //!< prevCsbf == 0 { cnt = posXinSubset+posYinSubset<=2 ? (posXinSubset+posYinSubset==0 ? 2 : 1) : 0; //!< draft (9-19) } else if(patternSigCtx==1) //!< prevCsbf == 1 { cnt = posYinSubset<=1 ? (posYinSubset==0 ? 2 : 1) : 0; //!< draft (9-20) } else if(patternSigCtx==2) //!< prevCsbf == 2 { cnt = posXinSubset<=1 ? (posXinSubset==0 ? 2 : 1) : 0; //!< draft (9-21) } else { cnt = 2; //!< draft (9-22) } return (( textureType == TEXT_LUMA && ((posX>>2) + (posY>>2)) > 0 ) ? 3 : 0) + offset + cnt; //!< draft (9-23)}