Ticket #286: source286.patch
File source286.patch, 10.5 KB (added by fbossen, 13 years ago) |
---|
-
source/Lib/TLibEncoder/TEncCu.h
115 115 /// CU encoding function 116 116 Void encodeCU ( TComDataCU* pcCU, Bool bForceTerminate = false ); 117 117 118 Void setBitCounter ( TComBitCounter* pcBitCounter ) { m_pcBitCounter = pcBitCounter; } 118 119 protected: 119 120 #if FINE_GRANULARITY_SLICES 120 121 Void finishCU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); -
source/Lib/TLibEncoder/TEncSlice.cpp
1073 1073 m_pcEntropyCoder->setEntropyCoder ( m_pppcRDSbacCoder[0][CI_CURR_BEST], pcSlice ); 1074 1074 #if OL_USE_WPP 1075 1075 m_pcEntropyCoder->setBitstream( &pcBitCounters[uiSubStrm] ); 1076 m_pcCuEncoder->setBitCounter( &pcBitCounters[uiSubStrm] ); 1077 m_pcBitCounter = &pcBitCounters[uiSubStrm]; 1076 1078 #else 1077 1079 m_pcEntropyCoder->setBitstream ( m_pcBitCounter ); 1078 1080 #endif … … 1085 1087 1086 1088 pppcRDSbacCoder->setBinCountingEnableFlag( false ); 1087 1089 #if FINE_GRANULARITY_SLICES 1088 if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits() + m_pc BitCounter->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3)1090 if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits() + m_pcEntropyCoder->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3) 1089 1091 { 1090 1092 #else 1091 uiBitsCoded += m_pc BitCounter->getNumberOfWrittenBits();1093 uiBitsCoded += m_pcEntropyCoder->getNumberOfWrittenBits(); 1092 1094 if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits() + uiBitsCoded ) >> 3 ) > m_pcCfg->getSliceArgument()) 1093 1095 { 1094 1096 #if TILES 1095 1097 if (uiCUAddr == rpcPic->getPicSym()->getCUOrderMap(uiStartCUAddr) && pcSlice->getSliceBits()==0) 1096 1098 { 1097 1099 // Could not fit even a single LCU within the slice under the defined byte-constraint. Display a warning message and code 1 LCU in the slice. 1098 fprintf(stdout,"\nSlice overflow warning! codedBits=%6d, limitBytes=%6d", m_pc BitCounter->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() );1100 fprintf(stdout,"\nSlice overflow warning! codedBits=%6d, limitBytes=%6d", m_pcEntropyCoder->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() ); 1099 1101 uiEncCUOrder++; 1100 1102 } 1101 1103 #else 1102 1104 if (uiCUAddr==uiStartCUAddr && pcSlice->getSliceBits()==0) 1103 1105 { 1104 1106 // Could not fit even a single LCU within the slice under the defined byte-constraint. Display a warning message and code 1 LCU in the slice. 1105 fprintf(stdout,"Slice overflow warning! codedBits=%6d, limitBytes=%6d\n", m_pc BitCounter->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() );1107 fprintf(stdout,"Slice overflow warning! codedBits=%6d, limitBytes=%6d\n", m_pcEntropyCoder->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() ); 1106 1108 uiCUAddr = uiCUAddr + 1; 1107 1109 } 1108 1110 #endif … … 1135 1137 #endif 1136 1138 #endif 1137 1139 #if !FINE_GRANULARITY_SLICES 1138 uiBitsCoded -= m_pc BitCounter->getNumberOfWrittenBits();1140 uiBitsCoded -= m_pcEntropyCoder->getNumberOfWrittenBits(); 1139 1141 #endif 1140 1142 pcSlice->setNextEntropySlice( true ); 1141 1143 break; … … 1178 1180 m_pcCuEncoder->compressCU( pcCU ); 1179 1181 m_pcCavlcCoder ->setAdaptFlag(true); 1180 1182 m_pcCuEncoder->encodeCU( pcCU ); 1181 1182 1183 #if FINE_GRANULARITY_SLICES 1183 if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits()+ m_pc BitCounter->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3)1184 if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits()+ m_pcEntropyCoder->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3) 1184 1185 { 1185 1186 #else 1186 uiBitsCoded += m_pc BitCounter->getNumberOfWrittenBits();1187 uiBitsCoded += m_pcEntropyCoder->getNumberOfWrittenBits(); 1187 1188 if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits() + uiBitsCoded ) >> 3 ) > m_pcCfg->getSliceArgument()) 1188 1189 { 1189 1190 #if TILES 1190 1191 if (uiCUAddr == rpcPic->getPicSym()->getCUOrderMap(uiStartCUAddr) && pcSlice->getSliceBits()==0) 1191 1192 { 1192 1193 // Could not fit even a single LCU within the slice under the defined byte-constraint. Display a warning message and code 1 LCU in the slice. 1193 fprintf(stdout,"\nSlice overflow warning! codedBits=%6d, limitBytes=%6d", m_pc BitCounter->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() );1194 fprintf(stdout,"\nSlice overflow warning! codedBits=%6d, limitBytes=%6d", m_pcEntropyCoder->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() ); 1194 1195 uiEncCUOrder++; 1195 1196 } 1196 1197 #else 1197 1198 if (uiCUAddr==uiStartCUAddr && pcSlice->getSliceBits()==0) 1198 1199 { 1199 1200 // Could not fit even a single LCU within the slice under the defined byte-constraint. Display a warning message and code 1 LCU in the slice. 1200 fprintf(stdout,"Slice overflow warning! codedBits=%6d, limitBytes=%6d\n", m_pc BitCounter->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() );1201 fprintf(stdout,"Slice overflow warning! codedBits=%6d, limitBytes=%6d\n", m_pcEntropyCoder->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() ); 1201 1202 uiCUAddr = uiCUAddr + 1; 1202 1203 } 1203 1204 #endif … … 1206 1207 break; 1207 1208 } 1208 1209 #if FINE_GRANULARITY_SLICES 1209 if (m_pcCfg->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE && pcSlice->getEntropySliceCounter()+ m_pc BitCounter->getNumberOfWrittenBits()> m_pcCfg->getEntropySliceArgument()&&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getEntropySliceCurEndCUAddr())1210 if (m_pcCfg->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE && pcSlice->getEntropySliceCounter()+ m_pcEntropyCoder->getNumberOfWrittenBits()> m_pcCfg->getEntropySliceArgument()&&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getEntropySliceCurEndCUAddr()) 1210 1211 { 1211 1212 1212 1213 #else … … 1216 1217 if (uiCUAddr == rpcPic->getPicSym()->getCUOrderMap(uiStartCUAddr)) 1217 1218 { 1218 1219 // Could not fit even a single LCU within the entropy slice under the defined bit/bin-constraint. Display a warning message and code 1 LCU in the entropy slice. 1219 fprintf(stdout,"\nEntropy Slice overflow warning! codedBits=%6d, limitBits=%6d", m_pc BitCounter->getNumberOfWrittenBits(), m_pcCfg->getEntropySliceArgument() );1220 fprintf(stdout,"\nEntropy Slice overflow warning! codedBits=%6d, limitBits=%6d", m_pcEntropyCoder->getNumberOfWrittenBits(), m_pcCfg->getEntropySliceArgument() ); 1220 1221 uiEncCUOrder++; 1221 1222 } 1222 1223 #else 1223 1224 if (uiCUAddr == uiStartCUAddr) 1224 1225 { 1225 1226 // Could not fit even a single LCU within the entropy slice under the defined bit/bin-constraint. Display a warning message and code 1 LCU in the entropy slice. 1226 fprintf(stdout,"Entropy Slice overflow warning! codedBits=%6d, limitBits=%6d\n", m_pc BitCounter->getNumberOfWrittenBits(), m_pcCfg->getEntropySliceArgument() );1227 fprintf(stdout,"Entropy Slice overflow warning! codedBits=%6d, limitBits=%6d\n", m_pcEntropyCoder->getNumberOfWrittenBits(), m_pcCfg->getEntropySliceArgument() ); 1227 1228 uiCUAddr = uiCUAddr + 1; 1228 1229 } 1229 1230 #endif 1230 1231 #endif 1231 1232 1232 1233 #if !FINE_GRANULARITY_SLICES 1233 uiBitsCoded -= m_pc BitCounter->getNumberOfWrittenBits();1234 uiBitsCoded -= m_pcEntropyCoder->getNumberOfWrittenBits(); 1234 1235 #endif 1235 1236 pcSlice->setNextEntropySlice( true ); 1236 1237 break; … … 1302 1303 #endif 1303 1304 1304 1305 #if OL_USE_WPP 1306 m_pcCuEncoder->setBitCounter( NULL ); 1307 m_pcBitCounter = NULL; 1305 1308 // Appropriate substream bitstream is switched later. 1306 1309 #else 1307 1310 // set bitstream -
source/Lib/TLibEncoder/TEncCu.cpp
1137 1137 m_pcEntropyCoder->encodeSliceFinish(); 1138 1138 } 1139 1139 #endif 1140 1141 Int numberOfWrittenBits = 0; 1142 if (m_pcBitCounter) 1143 { 1144 numberOfWrittenBits = m_pcEntropyCoder->getNumberOfWrittenBits(); 1145 } 1146 1140 1147 // Calculate slice end IF this CU puts us over slice bit size. 1141 1148 unsigned iGranularitySize = pcCU->getPic()->getNumPartInCU()>>(pcSlice->getPPS()->getSliceGranularity()<<1); 1142 1149 int iGranularityEnd = ((pcCU->getSCUAddr()+uiAbsPartIdx)/iGranularitySize)*iGranularitySize; … … 1145 1152 iGranularityEnd+=max(iGranularitySize,(pcCU->getPic()->getNumPartInCU()>>(uiDepth<<1))); 1146 1153 } 1147 1154 // Set slice end parameter 1148 if(pcSlice->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE&&!pcSlice->getFinalized()&&pcSlice->getSliceBits()+ m_pcBitCounter->getNumberOfWrittenBits()>pcSlice->getSliceArgument()<<3)1155 if(pcSlice->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE&&!pcSlice->getFinalized()&&pcSlice->getSliceBits()+numberOfWrittenBits>pcSlice->getSliceArgument()<<3) 1149 1156 { 1150 1157 pcSlice->setEntropySliceCurEndCUAddr(iGranularityEnd); 1151 1158 pcSlice->setSliceCurEndCUAddr(iGranularityEnd); … … 1164 1171 } 1165 1172 else 1166 1173 { 1167 if(pcSlice->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE&&!pcSlice->getFinalized()&&pcSlice->getEntropySliceCounter()+ m_pcBitCounter->getNumberOfWrittenBits()>pcSlice->getEntropySliceArgument())1174 if(pcSlice->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE&&!pcSlice->getFinalized()&&pcSlice->getEntropySliceCounter()+numberOfWrittenBits>pcSlice->getEntropySliceArgument()) 1168 1175 { 1169 1176 pcSlice->setEntropySliceCurEndCUAddr(iGranularityEnd); 1170 1177 return; … … 1172 1179 } 1173 1180 if(granularityBoundary) 1174 1181 { 1175 pcSlice->setSliceBits( (UInt)(pcSlice->getSliceBits() + m_pcBitCounter->getNumberOfWrittenBits()) );1182 pcSlice->setSliceBits( (UInt)(pcSlice->getSliceBits() + numberOfWrittenBits) ); 1176 1183 if(m_pcEncCfg->getUseSBACRD()) 1177 1184 { 1178 1185 TEncBinCABAC *pppcRDSbacCoder = (TEncBinCABAC *) m_pppcRDSbacCoder[0][CI_CURR_BEST]->getEncBinIf(); … … 1181 1188 } 1182 1189 else 1183 1190 { 1184 pcSlice->setEntropySliceCounter(pcSlice->getEntropySliceCounter()+ m_pcBitCounter->getNumberOfWrittenBits());1191 pcSlice->setEntropySliceCounter(pcSlice->getEntropySliceCounter()+numberOfWrittenBits); 1185 1192 } 1186 m_pcBitCounter->resetBits(); 1193 if (m_pcBitCounter) 1194 { 1195 m_pcEntropyCoder->resetBits(); 1196 } 1187 1197 } 1188 1198 } 1189 1199 #endif