Changeset 852 in 3DVCSoftware for branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecSbac.cpp
- Timestamp:
- 13 Feb 2014, 22:34:17 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecSbac.cpp
r833 r852 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2013, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 78 78 , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 79 79 , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 80 , m_cCUAMPSCModel ( 1, 1, NUM_CU_AMP_CTX , m_contextModels + m_numContextModels, m_numContextModels)81 80 , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 82 81 , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) … … 155 154 #endif 156 155 m_cCUPartSizeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PART_SIZE ); 157 m_cCUAMPSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CU_AMP_POS );158 156 m_cCUPredModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PRED_MODE ); 159 157 m_cCUIntraPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); … … 236 234 #endif 237 235 m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE ); 238 m_cCUAMPSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );239 236 m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE ); 240 237 m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE ); … … 906 903 if (eMode == SIZE_2NxN) 907 904 { 908 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0));905 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 )); 909 906 if (uiSymbol == 0) 910 907 { … … 915 912 else if (eMode == SIZE_Nx2N) 916 913 { 917 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0));914 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 )); 918 915 if (uiSymbol == 0) 919 916 { … … 2009 2006 if (uiCode == 0) 2010 2007 { 2011 ruiVal = 5;2008 ruiVal = 1; 2012 2009 } 2013 2010 else 2014 2011 { 2015 ruiVal = 1; 2016 } 2017 } 2018 } 2019 2020 inline Void copySaoOneLcuParam(SaoLcuParam* psDst, SaoLcuParam* psSrc) 2021 { 2022 Int i; 2023 psDst->partIdx = psSrc->partIdx; 2024 psDst->typeIdx = psSrc->typeIdx; 2025 if (psDst->typeIdx != -1) 2026 { 2027 psDst->subTypeIdx = psSrc->subTypeIdx ; 2028 psDst->length = psSrc->length; 2029 for (i=0;i<psDst->length;i++) 2030 { 2031 psDst->offset[i] = psSrc->offset[i]; 2032 } 2033 } 2034 else 2035 { 2036 psDst->length = 0; 2037 for (i=0;i<SAO_BO_LEN;i++) 2038 { 2039 psDst->offset[i] = 0; 2040 } 2041 } 2042 } 2043 2044 Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam, UInt compIdx) 2012 ruiVal = 2; 2013 } 2014 } 2015 } 2016 2017 Void TDecSbac::parseSaoSign(UInt& val) 2018 { 2019 m_pcTDecBinIf->decodeBinEP ( val ); 2020 } 2021 2022 Void TDecSbac::parseSAOBlkParam (SAOBlkParam& saoBlkParam 2023 , Bool* sliceEnabled 2024 , Bool leftMergeAvail 2025 , Bool aboveMergeAvail 2026 ) 2045 2027 { 2046 2028 UInt uiSymbol; 2047 static Int iTypeLength[MAX_NUM_SAO_TYPE] = 2048 { 2049 SAO_EO_LEN, 2050 SAO_EO_LEN, 2051 SAO_EO_LEN, 2052 SAO_EO_LEN, 2053 SAO_BO_LEN 2054 }; 2055 2056 if (compIdx==2) 2057 { 2058 uiSymbol = (UInt)( psSaoLcuParam->typeIdx + 1); 2059 } 2060 else 2061 { 2062 parseSaoTypeIdx(uiSymbol); 2063 } 2064 psSaoLcuParam->typeIdx = (Int)uiSymbol - 1; 2065 if (uiSymbol) 2066 { 2067 psSaoLcuParam->length = iTypeLength[psSaoLcuParam->typeIdx]; 2068 2069 Int bitDepth = compIdx ? g_bitDepthC : g_bitDepthY; 2070 Int offsetTh = 1 << min(bitDepth - 5,5); 2071 2072 if( psSaoLcuParam->typeIdx == SAO_BO ) 2073 { 2074 for(Int i=0; i< psSaoLcuParam->length; i++) 2075 { 2076 parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); 2077 psSaoLcuParam->offset[i] = uiSymbol; 2029 2030 Bool isLeftMerge = false; 2031 Bool isAboveMerge= false; 2032 2033 if(leftMergeAvail) 2034 { 2035 parseSaoMerge(uiSymbol); //sao_merge_left_flag 2036 isLeftMerge = (uiSymbol?true:false); 2037 } 2038 2039 if( aboveMergeAvail && !isLeftMerge) 2040 { 2041 parseSaoMerge(uiSymbol); //sao_merge_up_flag 2042 isAboveMerge = (uiSymbol?true:false); 2043 } 2044 2045 if(isLeftMerge || isAboveMerge) //merge mode 2046 { 2047 saoBlkParam[SAO_Y].modeIdc = saoBlkParam[SAO_Cb].modeIdc = saoBlkParam[SAO_Cr].modeIdc = SAO_MODE_MERGE; 2048 saoBlkParam[SAO_Y].typeIdc = saoBlkParam[SAO_Cb].typeIdc = saoBlkParam[SAO_Cr].typeIdc = (isLeftMerge)?SAO_MERGE_LEFT:SAO_MERGE_ABOVE; 2078 2049 } 2079 for(Int i=0; i< psSaoLcuParam->length; i++) 2080 { 2081 if (psSaoLcuParam->offset[i] != 0) 2082 { 2083 m_pcTDecBinIf->decodeBinEP ( uiSymbol); 2084 if (uiSymbol) 2050 else //new or off mode 2051 { 2052 for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++) 2053 { 2054 SAOOffset& ctbParam = saoBlkParam[compIdx]; 2055 2056 if(!sliceEnabled[compIdx]) 2085 2057 { 2086 psSaoLcuParam->offset[i] = -psSaoLcuParam->offset[i] ; 2087 } 2088 } 2089 } 2090 parseSaoUflc(5, uiSymbol ); 2091 psSaoLcuParam->subTypeIdx = uiSymbol; 2092 } 2093 else if( psSaoLcuParam->typeIdx < 4 ) 2094 { 2095 parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[0] = uiSymbol; 2096 parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[1] = uiSymbol; 2097 parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[2] = -(Int)uiSymbol; 2098 parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[3] = -(Int)uiSymbol; 2099 if (compIdx != 2) 2058 //off 2059 ctbParam.modeIdc = SAO_MODE_OFF; 2060 continue; 2061 } 2062 2063 //type 2064 if(compIdx == SAO_Y || compIdx == SAO_Cb) 2065 { 2066 parseSaoTypeIdx(uiSymbol); //sao_type_idx_luma or sao_type_idx_chroma 2067 2068 assert(uiSymbol ==0 || uiSymbol ==1 || uiSymbol ==2); 2069 2070 if(uiSymbol ==0) //OFF 2100 2071 { 2101 parseSaoUflc(2, uiSymbol ); 2102 psSaoLcuParam->subTypeIdx = uiSymbol; 2103 psSaoLcuParam->typeIdx += psSaoLcuParam->subTypeIdx; 2104 } 2072 ctbParam.modeIdc = SAO_MODE_OFF; 2105 2073 } 2106 } 2107 else 2108 { 2109 psSaoLcuParam->length = 0; 2110 } 2111 } 2112 2113 Void TDecSbac::parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp) 2114 { 2115 Int iAddr = pcCU->getAddr(); 2116 UInt uiSymbol; 2117 for (Int iCompIdx=0; iCompIdx<3; iCompIdx++) 2118 { 2119 pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; 2120 pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; 2121 pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx = 0; 2122 pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; 2123 pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[0] = 0; 2124 pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[1] = 0; 2125 pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[2] = 0; 2126 pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[3] = 0; 2127 2128 } 2129 if (pSaoParam->bSaoFlag[0] || pSaoParam->bSaoFlag[1] ) 2130 { 2131 if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft) 2132 { 2133 parseSaoMerge(uiSymbol); 2134 pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag = (Bool)uiSymbol; 2135 } 2136 if (pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag==0) 2137 { 2138 if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp) 2139 { 2140 parseSaoMerge(uiSymbol); 2141 pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag = (Bool)uiSymbol; 2142 } 2143 } 2144 } 2145 2146 for (Int iCompIdx=0; iCompIdx<3; iCompIdx++) 2147 { 2148 if ((iCompIdx == 0 && pSaoParam->bSaoFlag[0]) || (iCompIdx > 0 && pSaoParam->bSaoFlag[1]) ) 2149 { 2150 if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft) 2151 { 2152 pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag; 2153 } 2154 else 2155 { 2156 pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0; 2157 } 2158 2159 if (pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag==0) 2160 { 2161 if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp) 2162 { 2163 pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag; 2074 else if(uiSymbol == 1) //BO 2075 { 2076 ctbParam.modeIdc = SAO_MODE_NEW; 2077 ctbParam.typeIdc = SAO_TYPE_START_BO; 2078 } 2079 else //2, EO 2080 { 2081 ctbParam.modeIdc = SAO_MODE_NEW; 2082 ctbParam.typeIdc = SAO_TYPE_START_EO; 2083 } 2084 2085 } 2086 else //Cr, follow Cb SAO type 2087 { 2088 ctbParam.modeIdc = saoBlkParam[SAO_Cb].modeIdc; 2089 ctbParam.typeIdc = saoBlkParam[SAO_Cb].typeIdc; 2090 } 2091 2092 if(ctbParam.modeIdc == SAO_MODE_NEW) 2093 { 2094 Int offset[4]; 2095 for(Int i=0; i< 4; i++) 2096 { 2097 parseSaoMaxUvlc(uiSymbol, g_saoMaxOffsetQVal[compIdx] ); //sao_offset_abs 2098 offset[i] = (Int)uiSymbol; 2099 } 2100 2101 if(ctbParam.typeIdc == SAO_TYPE_START_BO) 2102 { 2103 for(Int i=0; i< 4; i++) 2104 { 2105 if(offset[i] != 0) 2106 { 2107 parseSaoSign(uiSymbol); //sao_offset_sign 2108 if(uiSymbol) 2109 { 2110 offset[i] = -offset[i]; 2111 } 2112 } 2113 } 2114 parseSaoUflc(NUM_SAO_BO_CLASSES_LOG2, uiSymbol ); //sao_band_position 2115 ctbParam.typeAuxInfo = uiSymbol; 2116 2117 for(Int i=0; i<4; i++) 2118 { 2119 ctbParam.offset[(ctbParam.typeAuxInfo+i)%MAX_NUM_SAO_CLASSES] = offset[i]; 2120 } 2121 2122 } 2123 else //EO 2124 { 2125 ctbParam.typeAuxInfo = 0; 2126 2127 if(compIdx == SAO_Y || compIdx == SAO_Cb) 2128 { 2129 parseSaoUflc(NUM_SAO_EO_TYPES_LOG2, uiSymbol ); //sao_eo_class_luma or sao_eo_class_chroma 2130 ctbParam.typeIdc += uiSymbol; 2164 2131 } 2165 2132 else 2166 2133 { 2167 pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0; 2168 } 2169 if (!pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag) 2170 { 2171 pSaoParam->saoLcuParam[2][iAddr].typeIdx = pSaoParam->saoLcuParam[1][iAddr].typeIdx; 2172 parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr]), iCompIdx); 2173 } 2174 else 2175 { 2176 copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-pSaoParam->numCuInWidth]); 2177 } 2178 } 2179 else 2180 { 2181 copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-1]); 2182 } 2183 } 2184 else 2185 { 2186 pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1; 2187 pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx = 0; 2134 ctbParam.typeIdc = saoBlkParam[SAO_Cb].typeIdc; 2135 } 2136 ctbParam.offset[SAO_CLASS_EO_FULL_VALLEY] = offset[0]; 2137 ctbParam.offset[SAO_CLASS_EO_HALF_VALLEY] = offset[1]; 2138 ctbParam.offset[SAO_CLASS_EO_PLAIN ] = 0; 2139 ctbParam.offset[SAO_CLASS_EO_HALF_PEAK ] = -offset[2]; 2140 ctbParam.offset[SAO_CLASS_EO_FULL_PEAK ] = -offset[3]; 2141 } 2142 } 2188 2143 } 2189 2144 } … … 2424 2379 #endif 2425 2380 2381 2382 2426 2383 //! \}
Note: See TracChangeset for help on using the changeset viewer.