Changeset 916 in SHVCSoftware for branches/SHM-upgrade/source/Lib/TLibDecoder
- Timestamp:
- 12 Nov 2014, 08:09:17 (10 years ago)
- Location:
- branches/SHM-upgrade/source/Lib/TLibDecoder
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-upgrade/source/Lib/TLibDecoder/AnnexBread.cpp
r595 r916 42 42 #include <vector> 43 43 #include "AnnexBread.h" 44 #if RExt__DECODER_DEBUG_BIT_STATISTICS 45 #include "TLibCommon/TComCodingStatistics.h" 46 #endif 44 47 45 48 using namespace std; … … 56 59 * be correct at this point. 57 60 */ 58 static void61 static Void 59 62 _byteStreamNALUnit( 60 63 InputByteStream& bs, … … 70 73 * 0x00000001. 71 74 */ 75 #if RExt__DECODER_DEBUG_BIT_STATISTICS 76 TComCodingStatistics::SStat &statBits=TComCodingStatistics::GetStatisticEP(STATS__NAL_UNIT_PACKING); 77 #endif 72 78 while ((bs.eofBeforeNBytes(24/8) || bs.peekBytes(24/8) != 0x000001) 73 79 && (bs.eofBeforeNBytes(32/8) || bs.peekBytes(32/8) != 0x00000001)) 74 80 { 75 81 uint8_t leading_zero_8bits = bs.readByte(); 82 #if RExt__DECODER_DEBUG_BIT_STATISTICS 83 statBits.bits+=8; statBits.count++; 84 #endif 76 85 assert(leading_zero_8bits == 0); 77 86 stats.m_numLeadingZero8BitsBytes++; … … 89 98 { 90 99 uint8_t zero_byte = bs.readByte(); 100 #if RExt__DECODER_DEBUG_BIT_STATISTICS 101 statBits.bits+=8; statBits.count++; 102 #endif 91 103 assert(zero_byte == 0); 92 104 stats.m_numZeroByteBytes++; … … 100 112 /* NB, (1) guarantees that the next three bytes are 0x00 00 01 */ 101 113 uint32_t start_code_prefix_one_3bytes = bs.readBytes(24/8); 114 #if RExt__DECODER_DEBUG_BIT_STATISTICS 115 statBits.bits+=24; statBits.count+=3; 116 #endif 102 117 assert(start_code_prefix_one_3bytes == 0x000001); 103 118 stats.m_numStartCodePrefixBytes += 3; … … 117 132 */ 118 133 /* NB, (unsigned)x > 2 implies n!=0 && n!=1 */ 119 while (bs.eofBeforeNBytes(24/8) || bs.peekBytes(24/8) > 2) 134 #if RExt__DECODER_DEBUG_BIT_STATISTICS 135 TComCodingStatistics::SStat &bodyStats=TComCodingStatistics::GetStatisticEP(STATS__NAL_UNIT_TOTAL_BODY); 136 #endif 137 while (bs.eofBeforeNBytes(24/8) || bs.peekBytes(24/8) > 2) 120 138 { 139 #if RExt__DECODER_DEBUG_BIT_STATISTICS 140 uint8_t thebyte=bs.readByte();bodyStats.bits+=8;bodyStats.count++; 141 nalUnit.push_back(thebyte); 142 #else 121 143 nalUnit.push_back(bs.readByte()); 144 #endif 122 145 } 123 146 124 147 /* 5. When the current position in the byte stream is: 125 148 * - not at the end of the byte stream (as determined by unspecified means) … … 141 164 { 142 165 uint8_t trailing_zero_8bits = bs.readByte(); 166 #if RExt__DECODER_DEBUG_BIT_STATISTICS 167 statBits.bits+=8; statBits.count++; 168 #endif 143 169 assert(trailing_zero_8bits == 0); 144 170 stats.m_numTrailingZero8BitsBytes++; -
branches/SHM-upgrade/source/Lib/TLibDecoder/AnnexBread.h
r713 r916 39 39 #pragma once 40 40 41 #ifndef __ANNEXBREAD__ 42 #define __ANNEXBREAD__ 43 41 44 #include <stdint.h> 42 45 #include <istream> … … 72 75 * modified externally to this class 73 76 */ 74 void reset()77 Void reset() 75 78 { 76 79 m_NumFutureBytes = 0; … … 154 157 } 155 158 159 #if RExt__DECODER_DEBUG_BIT_STATISTICS 160 UInt GetNumBufferedBytes() const { return m_NumFutureBytes; } 161 #endif 162 156 163 private: 157 164 UInt m_NumFutureBytes; /* number of valid bytes in m_FutureBytes */ … … 185 192 186 193 //! \} 194 195 #endif -
branches/SHM-upgrade/source/Lib/TLibDecoder/NALread.cpp
r815 r916 45 45 #include "TLibCommon/NAL.h" 46 46 #include "TLibCommon/TComBitStream.h" 47 #if RExt__DECODER_DEBUG_BIT_STATISTICS 48 #include "TLibCommon/TComCodingStatistics.h" 49 #endif 47 50 48 51 using namespace std; … … 50 53 //! \ingroup TLibDecoder 51 54 //! \{ 52 static void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, TComInputBitstream *bitstream, Bool isVclNalUnit)55 static Void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, TComInputBitstream *bitstream, Bool isVclNalUnit) 53 56 { 54 57 UInt zeroCount = 0; … … 66 69 it_read++; 67 70 zeroCount = 0; 71 #if RExt__DECODER_DEBUG_BIT_STATISTICS 72 TComCodingStatistics::IncrementStatisticEP(STATS__EMULATION_PREVENTION_3_BYTES, 8, 0); 73 #endif 68 74 if (it_read == nalUnitBuf.end()) 69 75 { … … 76 82 } 77 83 assert(zeroCount == 0); 78 84 79 85 if (isVclNalUnit) 80 86 { 81 87 // Remove cabac_zero_word from payload if present 82 88 Int n = 0; 83 89 84 90 while (it_write[-1] == 0x00) 85 91 { … … 87 93 n++; 88 94 } 89 95 90 96 if (n > 0) 91 97 { 92 printf("\nDetected %d instances of cabac_zero_word ", n/2);98 printf("\nDetected %d instances of cabac_zero_word\n", n/2); 93 99 } 94 100 } … … 111 117 #endif 112 118 nalu.m_temporalId = bs.read(3) - 1; // nuh_temporal_id_plus1 119 #if RExt__DECODER_DEBUG_BIT_STATISTICS 120 TComCodingStatistics::IncrementStatisticEP(STATS__NAL_UNIT_HEADER_BITS, 1+6+6+3, 0); 121 #endif 113 122 114 123 if ( nalu.m_temporalId ) … … 143 152 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N 144 153 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R 145 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N 146 ); 154 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N ); 147 155 #else 148 156 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_R … … 156 164 * a bitstream 157 165 */ 158 void read(InputNALUnit& nalu, vector<uint8_t>& nalUnitBuf)166 Void read(InputNALUnit& nalu, vector<uint8_t>& nalUnitBuf) 159 167 { 160 168 /* perform anti-emulation prevention */ 161 169 TComInputBitstream *pcBitstream = new TComInputBitstream(NULL); 162 170 convertPayloadToRBSP(nalUnitBuf, pcBitstream, (nalUnitBuf[0] & 64) == 0); 163 171 164 172 nalu.m_Bitstream = new TComInputBitstream(&nalUnitBuf); 165 173 nalu.m_Bitstream->setEmulationPreventionByteLocation(pcBitstream->getEmulationPreventionByteLocation()); -
branches/SHM-upgrade/source/Lib/TLibDecoder/NALread.h
r595 r916 39 39 #pragma once 40 40 41 #ifndef __NALREAD__ 42 #define __NALREAD__ 43 41 44 #include "TLibCommon/TypeDef.h" 42 45 #include "TLibCommon/TComBitStream.h" … … 58 61 }; 59 62 60 void read(InputNALUnit& nalu, std::vector<uint8_t>& nalUnitBuf);63 Void read(InputNALUnit& nalu, std::vector<uint8_t>& nalUnitBuf); 61 64 62 65 //! \} 66 67 #endif -
branches/SHM-upgrade/source/Lib/TLibDecoder/SEIread.cpp
r912 r916 32 32 */ 33 33 34 /** 34 /** 35 35 \file SEIread.cpp 36 \brief reading fun ctionality for SEI messages36 \brief reading funtionality for SEI messages 37 37 */ 38 38 … … 43 43 #include "SyntaxElementParser.h" 44 44 #include "SEIread.h" 45 #include "TLibCommon/TComPicYuv.h" 46 #include <iomanip> 47 45 48 46 49 //! \ingroup TLibDecoder 47 50 //! \{ 48 51 52 49 53 #if ENC_DEC_TRACE 50 54 Void xTraceSEIHeader() … … 55 59 Void xTraceSEIMessageType(SEI::PayloadType payloadType) 56 60 { 57 switch (payloadType) 58 { 59 case SEI::DECODED_PICTURE_HASH: 60 fprintf( g_hTrace, "=========== Decoded picture hash SEI message ===========\n"); 61 break; 62 case SEI::USER_DATA_UNREGISTERED: 63 fprintf( g_hTrace, "=========== User Data Unregistered SEI message ===========\n"); 64 break; 65 case SEI::ACTIVE_PARAMETER_SETS: 66 fprintf( g_hTrace, "=========== Active Parameter sets SEI message ===========\n"); 67 break; 68 case SEI::BUFFERING_PERIOD: 69 fprintf( g_hTrace, "=========== Buffering period SEI message ===========\n"); 70 break; 71 case SEI::PICTURE_TIMING: 72 fprintf( g_hTrace, "=========== Picture timing SEI message ===========\n"); 73 break; 74 case SEI::RECOVERY_POINT: 75 fprintf( g_hTrace, "=========== Recovery point SEI message ===========\n"); 76 break; 77 case SEI::FRAME_PACKING: 78 fprintf( g_hTrace, "=========== Frame Packing Arrangement SEI message ===========\n"); 79 break; 80 case SEI::DISPLAY_ORIENTATION: 81 fprintf( g_hTrace, "=========== Display Orientation SEI message ===========\n"); 82 break; 83 case SEI::TEMPORAL_LEVEL0_INDEX: 84 fprintf( g_hTrace, "=========== Temporal Level Zero Index SEI message ===========\n"); 85 break; 86 case SEI::REGION_REFRESH_INFO: 87 fprintf( g_hTrace, "=========== Gradual Decoding Refresh Information SEI message ===========\n"); 88 break; 89 case SEI::DECODING_UNIT_INFO: 90 fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n"); 91 break; 92 case SEI::TONE_MAPPING_INFO: 93 fprintf( g_hTrace, "===========Tone Mapping Info SEI message ===========\n"); 94 break; 95 #if P0050_KNEE_FUNCTION_SEI 96 case SEI::KNEE_FUNCTION_INFO: 97 fprintf( g_hTrace, "=========== Knee Function Information SEI message ===========\n"); 98 break; 99 #endif 100 #if Q0074_COLOUR_REMAPPING_SEI 101 case SEI::COLOUR_REMAPPING_INFO: 102 fprintf( g_hTrace, "===========Colour Remapping Information SEI message ===========\n"); 103 break; 104 #endif 105 case SEI::SOP_DESCRIPTION: 106 fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n"); 107 break; 108 case SEI::SCALABLE_NESTING: 109 fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n"); 110 break; 111 #if SVC_EXTENSION 112 #if LAYERS_NOT_PRESENT_SEI 113 case SEI::LAYERS_NOT_PRESENT: 114 fprintf( g_hTrace, "=========== Layers Present SEI message ===========\n"); 115 break; 116 #endif 117 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 118 case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: 119 fprintf( g_hTrace, "=========== Inter Layer Constrained Tile Sets SEI message ===========\n"); 120 break; 121 #endif 122 #if SUB_BITSTREAM_PROPERTY_SEI 123 case SEI::SUB_BITSTREAM_PROPERTY: 124 fprintf( g_hTrace, "=========== Sub-bitstream property SEI message ===========\n"); 125 break; 126 #endif 127 #if O0164_MULTI_LAYER_HRD 128 case SEI::BSP_NESTING: 129 fprintf( g_hTrace, "=========== Bitstream parition nesting SEI message ===========\n"); 130 break; 131 case SEI::BSP_INITIAL_ARRIVAL_TIME: 132 fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n"); 133 break; 134 #if !REMOVE_BSP_HRD_SEI 135 case SEI::BSP_HRD: 136 fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n"); 137 break; 138 #endif 139 #endif 140 #if Q0078_ADD_LAYER_SETS 141 case SEI::OUTPUT_LAYER_SET_NESTING: 142 fprintf(g_hTrace, "=========== Output layer set nesting SEI message ===========\n"); 143 break; 144 case SEI::VPS_REWRITING: 145 fprintf(g_hTrace, "=========== VPS rewriting SEI message ===========\n"); 146 break; 147 #endif 148 #if Q0096_OVERLAY_SEI 149 case SEI::OVERLAY_INFO: 150 fprintf( g_hTrace, "=========== Overlay Information SEI message ===========\n"); 151 break; 152 #endif 153 #endif //SVC_EXTENSION 154 default: 155 fprintf( g_hTrace, "=========== Unknown SEI message ===========\n"); 156 break; 157 } 158 } 159 #endif 61 fprintf( g_hTrace, "=========== %s SEI message ===========\n", SEI::getSEIMessageString(payloadType)); 62 } 63 #endif 64 65 Void SEIReader::sei_read_code(std::ostream *pOS, UInt uiLength, UInt& ruiCode, const Char *pSymbolName) 66 { 67 READ_CODE(uiLength, ruiCode, pSymbolName); 68 if (pOS) (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; 69 } 70 71 Void SEIReader::sei_read_uvlc(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName) 72 { 73 READ_UVLC(ruiCode, pSymbolName); 74 if (pOS) (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; 75 } 76 77 Void SEIReader::sei_read_svlc(std::ostream *pOS, Int& ruiCode, const Char *pSymbolName) 78 { 79 READ_SVLC(ruiCode, pSymbolName); 80 if (pOS) (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; 81 } 82 83 Void SEIReader::sei_read_flag(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName) 84 { 85 READ_FLAG(ruiCode, pSymbolName); 86 if (pOS) (*pOS) << " " << std::setw(55) << pSymbolName << ": " << (ruiCode?1:0) << "\n"; 87 } 88 89 static inline Void output_sei_message_header(SEI &sei, std::ostream *pDecodedMessageOutputStream, UInt payloadSize) 90 { 91 if (pDecodedMessageOutputStream) 92 { 93 std::string seiMessageHdr(SEI::getSEIMessageString(sei.payloadType())); seiMessageHdr+=" SEI message"; 94 (*pDecodedMessageOutputStream) << std::setfill('-') << std::setw(seiMessageHdr.size()) << "-" << std::setfill(' ') << "\n" << seiMessageHdr << "\n"; 95 } 96 } 97 98 #undef READ_CODE 99 #undef READ_SVLC 100 #undef READ_UVLC 101 #undef READ_FLAG 102 160 103 161 104 /** … … 163 106 */ 164 107 #if LAYERS_NOT_PRESENT_SEI 165 void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps)166 #else 167 void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps)108 Void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 109 #else 110 Void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 168 111 #endif 169 112 { … … 174 117 { 175 118 #if LAYERS_NOT_PRESENT_SEI 176 xReadSEImessage(seis, nalUnitType, vps, sps );177 #else 178 xReadSEImessage(seis, nalUnitType, sps );119 xReadSEImessage(seis, nalUnitType, vps, sps, pDecodedMessageOutputStream); 120 #else 121 xReadSEImessage(seis, nalUnitType, sps, pDecodedMessageOutputStream); 179 122 #endif 180 123 /* SEI messages are an integer number of bytes, something has failed … … 184 127 185 128 UInt rbspTrailingBits; 186 READ_CODE(8, rbspTrailingBits, "rbsp_trailing_bits");129 sei_read_code(NULL, 8, rbspTrailingBits, "rbsp_trailing_bits"); 187 130 assert(rbspTrailingBits == 0x80); 188 131 } … … 190 133 #if O0164_MULTI_LAYER_HRD 191 134 #if LAYERS_NOT_PRESENT_SEI 192 Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting *nestingSei, const SEIBspNesting *bspNestingSei)193 #else 194 Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting *nestingSei)135 Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream, const SEIScalableNesting *nestingSei, const SEIBspNesting *bspNestingSei) 136 #else 137 Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream, const SEIScalableNesting *nestingSei) 195 138 #endif 196 139 #else 197 140 #if LAYERS_NOT_PRESENT_SEI 198 Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps )199 #else 200 Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps )141 Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 142 #else 143 Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 201 144 #endif 202 145 #endif … … 210 153 do 211 154 { 212 READ_CODE (8, val, "payload_type");155 sei_read_code(NULL, 8, val, "payload_type"); 213 156 payloadType += val; 214 157 } while (val==0xFF); … … 217 160 do 218 161 { 219 READ_CODE (8, val, "payload_size");162 sei_read_code(NULL, 8, val, "payload_size"); 220 163 payloadSize += val; 221 164 } while (val==0xFF); … … 242 185 case SEI::USER_DATA_UNREGISTERED: 243 186 sei = new SEIuserDataUnregistered; 244 xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize );187 xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream); 245 188 break; 246 189 case SEI::ACTIVE_PARAMETER_SETS: 247 sei = new SEIActiveParameterSets; 248 xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize );249 break; 190 sei = new SEIActiveParameterSets; 191 xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize, pDecodedMessageOutputStream); 192 break; 250 193 case SEI::DECODING_UNIT_INFO: 251 194 if (!sps) … … 255 198 else 256 199 { 257 sei = new SEIDecodingUnitInfo; 200 sei = new SEIDecodingUnitInfo; 258 201 #if VPS_VUI_BSP_HRD_PARAMS 259 xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps );260 #else 261 xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps );262 #endif 263 } 264 break; 202 xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps, pDecodedMessageOutputStream); 203 #else 204 xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, pDecodedMessageOutputStream); 205 #endif 206 } 207 break; 265 208 case SEI::BUFFERING_PERIOD: 266 209 if (!sps) … … 272 215 sei = new SEIBufferingPeriod; 273 216 #if VPS_VUI_BSP_HRD_PARAMS 274 xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps );275 #else 276 xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps );217 xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps, pDecodedMessageOutputStream); 218 #else 219 xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, pDecodedMessageOutputStream); 277 220 #endif 278 221 } … … 287 230 sei = new SEIPictureTiming; 288 231 #if VPS_VUI_BSP_HRD_PARAMS 289 xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, nestingSei, bspNestingSei, vps );290 #else 291 xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps );232 xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, nestingSei, bspNestingSei, vps, pDecodedMessageOutputStream); 233 #else 234 xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, pDecodedMessageOutputStream); 292 235 #endif 293 236 } … … 295 238 case SEI::RECOVERY_POINT: 296 239 sei = new SEIRecoveryPoint; 297 xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize );240 xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize, pDecodedMessageOutputStream); 298 241 break; 299 242 case SEI::FRAME_PACKING: 300 243 sei = new SEIFramePacking; 301 xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize); 244 xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream); 245 break; 246 case SEI::SEGM_RECT_FRAME_PACKING: 247 sei = new SEISegmentedRectFramePacking; 248 xParseSEISegmentedRectFramePacking((SEISegmentedRectFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream); 302 249 break; 303 250 case SEI::DISPLAY_ORIENTATION: 304 251 sei = new SEIDisplayOrientation; 305 xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize );252 xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize, pDecodedMessageOutputStream); 306 253 break; 307 254 case SEI::TEMPORAL_LEVEL0_INDEX: 308 255 sei = new SEITemporalLevel0Index; 309 xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize );256 xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize, pDecodedMessageOutputStream); 310 257 break; 311 258 case SEI::REGION_REFRESH_INFO: 312 259 sei = new SEIGradualDecodingRefreshInfo; 313 xParseSEIGradualDecodingRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize); 260 xParseSEIRegionRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize, pDecodedMessageOutputStream); 261 break; 262 case SEI::NO_DISPLAY: 263 sei = new SEINoDisplay; 264 xParseSEINoDisplay((SEINoDisplay&) *sei, payloadSize, pDecodedMessageOutputStream); 314 265 break; 315 266 case SEI::TONE_MAPPING_INFO: 316 267 sei = new SEIToneMappingInfo; 317 xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize); 318 break; 319 #if P0050_KNEE_FUNCTION_SEI 268 xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream); 269 break; 270 case SEI::SOP_DESCRIPTION: 271 sei = new SEISOPDescription; 272 xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize, pDecodedMessageOutputStream); 273 break; 274 case SEI::SCALABLE_NESTING: 275 sei = new SEIScalableNesting; 276 #if LAYERS_NOT_PRESENT_SEI 277 xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, vps, sps, pDecodedMessageOutputStream); 278 #else 279 xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps, pDecodedMessageOutputStream); 280 #endif 281 break; 282 case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS: 283 sei = new SEITempMotionConstrainedTileSets; 284 xParseSEITempMotionConstraintsTileSets((SEITempMotionConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream); 285 break; 286 case SEI::TIME_CODE: 287 sei = new SEITimeCode; 288 xParseSEITimeCode((SEITimeCode&) *sei, payloadSize, pDecodedMessageOutputStream); 289 break; 290 case SEI::CHROMA_SAMPLING_FILTER_HINT: 291 sei = new SEIChromaSamplingFilterHint; 292 xParseSEIChromaSamplingFilterHint((SEIChromaSamplingFilterHint&) *sei, payloadSize/*, sps*/, pDecodedMessageOutputStream); 293 //} 294 break; 320 295 case SEI::KNEE_FUNCTION_INFO: 321 296 sei = new SEIKneeFunctionInfo; 322 xParseSEIKneeFunctionInfo((SEIKneeFunctionInfo&) *sei, payloadSize); 323 break; 324 #endif 297 xParseSEIKneeFunctionInfo((SEIKneeFunctionInfo&) *sei, payloadSize, pDecodedMessageOutputStream); 298 break; 299 case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: 300 sei = new SEIMasteringDisplayColourVolume; 301 xParseSEIMasteringDisplayColourVolume((SEIMasteringDisplayColourVolume&) *sei, payloadSize, pDecodedMessageOutputStream); 302 break; 325 303 #if Q0074_COLOUR_REMAPPING_SEI 326 304 case SEI::COLOUR_REMAPPING_INFO: 327 305 sei = new SEIColourRemappingInfo; 328 xParseSEIColourRemappingInfo((SEIColourRemappingInfo&) *sei, payloadSize); 329 break; 330 #endif 331 case SEI::SOP_DESCRIPTION: 332 sei = new SEISOPDescription; 333 xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize); 334 break; 335 case SEI::SCALABLE_NESTING: 336 sei = new SEIScalableNesting; 337 #if LAYERS_NOT_PRESENT_SEI 338 xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, vps, sps); 339 #else 340 xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps); 341 #endif 342 break; 306 xParseSEIColourRemappingInfo((SEIColourRemappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream); 307 break; 308 #endif 343 309 #if SVC_EXTENSION 344 310 #if LAYERS_NOT_PRESENT_SEI … … 351 317 { 352 318 sei = new SEILayersNotPresent; 353 xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps );319 xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps, pDecodedMessageOutputStream); 354 320 } 355 321 break; … … 358 324 case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: 359 325 sei = new SEIInterLayerConstrainedTileSets; 360 xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize );326 xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream); 361 327 break; 362 328 #endif … … 365 331 sei = new SEISubBitstreamProperty; 366 332 #if OLS_IDX_CHK 367 xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, vps );368 #else 369 xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei );333 xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, vps, pDecodedMessageOutputStream); 334 #else 335 xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, pDecodedMessageOutputStream); 370 336 #endif 371 337 break; … … 375 341 sei = new SEIBspNesting; 376 342 #if LAYERS_NOT_PRESENT_SEI 377 xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, vps, sps, *nestingSei );378 #else 379 xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, sps, *nestingSei );343 xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, vps, sps, *nestingSei, pDecodedMessageOutputStream); 344 #else 345 xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, sps, *nestingSei, pDecodedMessageOutputStream); 380 346 #endif 381 347 break; 382 348 case SEI::BSP_INITIAL_ARRIVAL_TIME: 383 349 sei = new SEIBspInitialArrivalTime; 384 xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, vps, sps, *nestingSei, *bspNestingSei );350 xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, vps, sps, *nestingSei, *bspNestingSei, pDecodedMessageOutputStream); 385 351 break; 386 352 #if !REMOVE_BSP_HRD_SEI 387 353 case SEI::BSP_HRD: 388 354 sei = new SEIBspHrd; 389 xParseSEIBspHrd((SEIBspHrd&) *sei, sps, *nestingSei );355 xParseSEIBspHrd((SEIBspHrd&) *sei, sps, *nestingSei, pDecodedMessageOutputStream); 390 356 break; 391 357 #endif … … 395 361 sei = new SEIOutputLayerSetNesting; 396 362 #if LAYERS_NOT_PRESENT_SEI 397 xParseSEIOutputLayerSetNesting((SEIOutputLayerSetNesting&)*sei, nalUnitType, vps, sps );398 #else 399 xParseSEIOutputLayerSetNesting((SEIOutputLayerSetNesting&)*sei, nalUnitType, sps );363 xParseSEIOutputLayerSetNesting((SEIOutputLayerSetNesting&)*sei, nalUnitType, vps, sps, pDecodedMessageOutputStream); 364 #else 365 xParseSEIOutputLayerSetNesting((SEIOutputLayerSetNesting&)*sei, nalUnitType, sps, pDecodedMessageOutputStream); 400 366 #endif 401 367 break; 402 368 case SEI::VPS_REWRITING: 403 369 sei = new SEIVPSRewriting; 404 xParseSEIVPSRewriting((SEIVPSRewriting&)*sei );370 xParseSEIVPSRewriting((SEIVPSRewriting&)*sei, pDecodedMessageOutputStream); 405 371 break; 406 372 #endif … … 408 374 case SEI::TMVP_CONSTRAINTS: 409 375 sei = new SEITMVPConstrains; 410 xParseSEITMVPConstraints((SEITMVPConstrains&) *sei, payloadSize );376 xParseSEITMVPConstraints((SEITMVPConstrains&) *sei, payloadSize, pDecodedMessageOutputStream); 411 377 break; 412 378 #endif … … 414 380 case SEI::FRAME_FIELD_INFO: 415 381 sei = new SEIFrameFieldInfo; 416 xParseSEIFrameFieldInfo ((SEIFrameFieldInfo&) *sei, payloadSize );382 xParseSEIFrameFieldInfo ((SEIFrameFieldInfo&) *sei, payloadSize, pDecodedMessageOutputStream); 417 383 break; 418 384 #endif … … 420 386 case SEI::OVERLAY_INFO: 421 387 sei = new SEIOverlayInfo; 422 xParseSEIOverlayInfo((SEIOverlayInfo&) *sei, payloadSize );388 xParseSEIOverlayInfo((SEIOverlayInfo&) *sei, payloadSize, pDecodedMessageOutputStream); 423 389 break; 424 390 #endif … … 429 395 { 430 396 UInt seiByte; 431 READ_CODE (8, seiByte, "unknown prefix SEI payload byte");397 sei_read_code (NULL, 8, seiByte, "unknown prefix SEI payload byte"); 432 398 } 433 399 printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType); 400 if (pDecodedMessageOutputStream) 401 { 402 (*pDecodedMessageOutputStream) << "Unknown prefix SEI message (payloadType = " << payloadType << ") was found!\n"; 403 } 404 break; 434 405 } 435 406 } … … 440 411 case SEI::USER_DATA_UNREGISTERED: 441 412 sei = new SEIuserDataUnregistered; 442 xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize );413 xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream); 443 414 break; 444 415 case SEI::DECODED_PICTURE_HASH: 445 416 sei = new SEIDecodedPictureHash; 446 xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize );417 xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize, pDecodedMessageOutputStream); 447 418 break; 448 419 default: … … 450 421 { 451 422 UInt seiByte; 452 READ_CODE (8, seiByte, "unknown suffix SEI payload byte");423 sei_read_code( NULL, 8, seiByte, "unknown suffix SEI payload byte"); 453 424 } 454 425 printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType); 455 } 456 } 426 if (pDecodedMessageOutputStream) 427 { 428 (*pDecodedMessageOutputStream) << "Unknown suffix SEI message (payloadType = " << payloadType << ") was found!\n"; 429 } 430 break; 431 } 432 } 433 457 434 if (sei != NULL) 458 435 { … … 473 450 { 474 451 UInt reservedPayloadExtensionData; 475 READ_CODE (1, reservedPayloadExtensionData, "reserved_payload_extension_data");452 sei_read_code ( pDecodedMessageOutputStream, 1, reservedPayloadExtensionData, "reserved_payload_extension_data"); 476 453 } 477 454 … … 488 465 { 489 466 UInt reservedPayloadExtensionData; 490 READ_FLAG (reservedPayloadExtensionData, "reserved_payload_extension_data");467 sei_read_flag ( 0, reservedPayloadExtensionData, "reserved_payload_extension_data"); 491 468 } 492 469 493 470 UInt dummy; 494 READ_FLAG (dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--;471 sei_read_flag( 0, dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--; 495 472 while (payloadBitsRemaining) 496 473 { 497 READ_FLAG (dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--;474 sei_read_flag( 0, dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--; 498 475 } 499 476 } … … 505 482 } 506 483 507 #if P0138_USE_ALT_CPB_PARAMS_FLAG508 /**509 * Check if SEI message contains payload extension510 */511 Bool SEIReader::xPayloadExtensionPresent()512 {513 Int payloadBitsRemaining = getBitstream()->getNumBitsLeft();514 Bool payloadExtensionPresent = false;515 516 if (payloadBitsRemaining > 8)517 {518 payloadExtensionPresent = true;519 }520 else521 {522 Int finalBits = getBitstream()->peekBits(payloadBitsRemaining);523 while (payloadBitsRemaining && (finalBits & 1) == 0)524 {525 payloadBitsRemaining--;526 finalBits >>= 1;527 }528 payloadBitsRemaining--;529 if (payloadBitsRemaining > 0)530 {531 payloadExtensionPresent = true;532 }533 }534 535 return payloadExtensionPresent;536 }537 #endif538 539 484 /** 540 485 * parse bitstream bs and unpack a user_data_unregistered SEI message 541 486 * of payloasSize bytes into sei. 542 487 */ 543 Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize) 544 { 545 assert(payloadSize >= 16); 488 489 Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 490 { 491 assert(payloadSize >= ISO_IEC_11578_LEN); 546 492 UInt val; 547 548 for (UInt i = 0; i < 16; i++) 549 { 550 READ_CODE (8, val, "uuid_iso_iec_11578"); 493 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 494 495 for (UInt i = 0; i < ISO_IEC_11578_LEN; i++) 496 { 497 sei_read_code( pDecodedMessageOutputStream, 8, val, "uuid_iso_iec_11578"); 551 498 sei.uuid_iso_iec_11578[i] = val; 552 499 } 553 500 554 sei.userDataLength = payloadSize - 16;501 sei.userDataLength = payloadSize - ISO_IEC_11578_LEN; 555 502 if (!sei.userDataLength) 556 503 { … … 562 509 for (UInt i = 0; i < sei.userDataLength; i++) 563 510 { 564 READ_CODE (8, val, "user_data" );511 sei_read_code( pDecodedMessageOutputStream, 8, val, "user_data" ); 565 512 sei.userData[i] = val; 566 513 } … … 571 518 * of payloadSize bytes into sei. 572 519 */ 573 Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt /*payloadSize*/) 574 { 520 Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 521 { 522 UInt bytesRead = 0; 523 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 524 575 525 UInt val; 576 READ_CODE (8, val, "hash_type"); 577 sei.method = static_cast<SEIDecodedPictureHash::Method>(val); 578 for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++) 579 { 580 if(SEIDecodedPictureHash::MD5 == sei.method) 581 { 582 for (UInt i = 0; i < 16; i++) 583 { 584 READ_CODE(8, val, "picture_md5"); 585 sei.digest[yuvIdx][i] = val; 586 } 587 } 588 else if(SEIDecodedPictureHash::CRC == sei.method) 589 { 590 READ_CODE(16, val, "picture_crc"); 591 sei.digest[yuvIdx][0] = val >> 8 & 0xFF; 592 sei.digest[yuvIdx][1] = val & 0xFF; 593 } 594 else if(SEIDecodedPictureHash::CHECKSUM == sei.method) 595 { 596 READ_CODE(32, val, "picture_checksum"); 597 sei.digest[yuvIdx][0] = (val>>24) & 0xff; 598 sei.digest[yuvIdx][1] = (val>>16) & 0xff; 599 sei.digest[yuvIdx][2] = (val>>8) & 0xff; 600 sei.digest[yuvIdx][3] = val & 0xff; 601 } 602 } 603 } 604 Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt /*payloadSize*/) 526 sei_read_code( pDecodedMessageOutputStream, 8, val, "hash_type"); 527 sei.method = static_cast<SEIDecodedPictureHash::Method>(val); bytesRead++; 528 529 const Char *traceString="\0"; 530 switch (sei.method) 531 { 532 case SEIDecodedPictureHash::MD5: traceString="picture_md5"; break; 533 case SEIDecodedPictureHash::CRC: traceString="picture_crc"; break; 534 case SEIDecodedPictureHash::CHECKSUM: traceString="picture_checksum"; break; 535 default: assert(false); break; 536 } 537 538 if (pDecodedMessageOutputStream) (*pDecodedMessageOutputStream) << " " << std::setw(55) << traceString << ": " << std::hex << std::setfill('0'); 539 540 sei.m_digest.hash.clear(); 541 for(;bytesRead < payloadSize; bytesRead++) 542 { 543 sei_read_code( NULL, 8, val, traceString); 544 sei.m_digest.hash.push_back((UChar)val); 545 if (pDecodedMessageOutputStream) (*pDecodedMessageOutputStream) << std::setw(2) << val; 546 } 547 548 if (pDecodedMessageOutputStream) (*pDecodedMessageOutputStream) << std::dec << std::setfill(' ') << "\n"; 549 } 550 551 Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 605 552 { 606 553 UInt val; 607 READ_CODE(4, val, "active_video_parameter_set_id"); sei.activeVPSId = val; 608 READ_FLAG( val, "self_contained_cvs_flag"); sei.m_selfContainedCvsFlag = val ? true : false; 609 READ_FLAG( val, "no_parameter_set_update_flag"); sei.m_noParameterSetUpdateFlag = val ? true : false; 610 READ_UVLC( val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; 554 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 555 556 sei_read_code( pDecodedMessageOutputStream, 4, val, "active_video_parameter_set_id"); sei.activeVPSId = val; 557 sei_read_flag( pDecodedMessageOutputStream, val, "self_contained_cvs_flag"); sei.m_selfContainedCvsFlag = (val != 0); 558 sei_read_flag( pDecodedMessageOutputStream, val, "no_parameter_set_update_flag"); sei.m_noParameterSetUpdateFlag = (val != 0); 559 sei_read_uvlc( pDecodedMessageOutputStream, val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; 611 560 612 561 sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1); … … 616 565 for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++) 617 566 { 618 READ_UVLC(val, "active_seq_parameter_set_id"); sei.activeSeqParameterSetId[i] = val;567 sei_read_uvlc( pDecodedMessageOutputStream, val, "active_seq_parameter_set_id[i]"); sei.activeSeqParameterSetId[i] = val; 619 568 } 620 569 #if R0247_SEI_ACTIVE 621 570 for (Int i=1; i < (sei.numSpsIdsMinus1 + 1); i++) 622 571 { 623 READ_UVLC(val, "layer_sps_idx"); sei.layerSpsIdx[i] = val; 624 } 625 #endif 626 xParseByteAlign(); 572 sei_read_uvlc( pDecodedMessageOutputStream, val, "layer_sps_idx"); sei.layerSpsIdx[i] = val; 573 } 574 #endif 627 575 } 628 576 629 577 #if VPS_VUI_BSP_HRD_PARAMS 630 Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps)631 #else 632 Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps)578 Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps,std::ostream *pDecodedMessageOutputStream) 579 #else 580 Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 633 581 #endif 634 582 { 635 583 UInt val; 636 READ_UVLC(val, "decoding_unit_idx"); 584 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 585 sei_read_uvlc( pDecodedMessageOutputStream, val, "decoding_unit_idx"); 637 586 sei.m_decodingUnitIdx = val; 638 587 … … 674 623 hrd = vui->getHrdParameters(); 675 624 } 676 #else 677 TComVUI *vui = sps->getVuiParameters(); 678 TComHrd *hrd = vui->getHrdParameters(); 679 #endif 625 680 626 if(hrd->getSubPicCpbParamsInPicTimingSEIFlag()) 681 627 { 682 READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay");628 sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay_increment"); 683 629 sei.m_duSptCpbRemovalDelay = val; 684 630 } … … 687 633 sei.m_duSptCpbRemovalDelay = 0; 688 634 } 689 READ_FLAG( val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = val ? true : false;635 sei_read_flag( pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0); 690 636 if(sei.m_dpbOutputDuDelayPresentFlag) 691 637 { 692 READ_CODE(hrd->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay");638 sei_read_code( pDecodedMessageOutputStream, hrd->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); 693 639 sei.m_picSptDpbOutputDuDelay = val; 694 640 } 695 xParseByteAlign(); 641 #else 642 TComVUI *vui = sps->getVuiParameters(); 643 644 if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag()) 645 { 646 sei_read_code( pDecodedMessageOutputStream, ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay_increment"); 647 sei.m_duSptCpbRemovalDelay = val; 648 } 649 else 650 { 651 sei.m_duSptCpbRemovalDelay = 0; 652 } 653 sei_read_flag( pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0); 654 if(sei.m_dpbOutputDuDelayPresentFlag) 655 { 656 sei_read_code( pDecodedMessageOutputStream, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); 657 sei.m_picSptDpbOutputDuDelay = val; 658 } 659 #endif 696 660 } 697 661 698 662 #if VPS_VUI_BSP_HRD_PARAMS 699 Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps)700 #else 701 Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps)663 Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps, std::ostream *pDecodedMessageOutputStream) 664 #else 665 Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 702 666 #endif 703 667 { … … 747 711 #endif 748 712 749 READ_UVLC( code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; 713 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 714 715 sei_read_uvlc( pDecodedMessageOutputStream, code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; 750 716 if( !pHRD->getSubPicCpbParamsPresentFlag() ) 751 717 { 752 READ_FLAG(code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code;718 sei_read_flag( pDecodedMessageOutputStream, code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code; 753 719 } 754 720 if( sei.m_rapCpbParamsPresentFlag ) 755 721 { 756 READ_CODE( pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; 757 READ_CODE( pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; 758 } 722 sei_read_code( pDecodedMessageOutputStream, pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; 723 sei_read_code( pDecodedMessageOutputStream, pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; 724 } 725 759 726 //read splicing flag and cpb_removal_delay_delta 760 READ_FLAG( code, "concatenation_flag");727 sei_read_flag( pDecodedMessageOutputStream, code, "concatenation_flag"); 761 728 sei.m_concatenationFlag = code; 762 READ_CODE(( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" );729 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" ); 763 730 sei.m_auCpbRemovalDelayDelta = code + 1; 731 764 732 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) 765 733 { … … 769 737 for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ ) 770 738 { 771 READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay" );739 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_delay":"nal_initial_cpb_removal_delay" ); 772 740 sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code; 773 READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay_offset" );741 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_offset":"vcl_initial_cpb_removal_offset" ); 774 742 sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code; 775 743 if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag ) 776 744 { 777 READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay" );745 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_delay":"vcl_initial_alt_cpb_removal_delay" ); 778 746 sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code; 779 READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay_offset" );747 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_offset":"vcl_initial_alt_cpb_removal_offset" ); 780 748 sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code; 781 749 } … … 789 757 if (xPayloadExtensionPresent()) 790 758 { 791 READ_FLAG (code, "use_alt_cpb_params_flag");759 sei_read_flag( pDecodedMessageOutputStream, code, "use_alt_cpb_params_flag"); 792 760 sei.m_useAltCpbParamsFlag = code; 793 761 sei.m_useAltCpbParamsFlagPresent = true; 794 762 } 795 763 #endif 796 797 xParseByteAlign(); 798 } 764 } 765 799 766 #if VPS_VUI_BSP_HRD_PARAMS 800 Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps)801 #else 802 Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps)767 Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps, std::ostream *pDecodedMessageOutputStream) 768 #else 769 Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 803 770 #endif 804 771 { … … 851 818 TComHRD *hrd = vui->getHrdParameters(); 852 819 #endif 820 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 853 821 854 822 if( vui->getFrameFieldInfoPresentFlag() ) 855 823 { 856 READ_CODE(4, code, "pic_struct" ); sei.m_picStruct = code;857 READ_CODE( 2, code, "source_scan_type" ); sei.m_sourceScanType= code;858 READ_FLAG( code, "duplicate_flag" ); sei.m_duplicateFlag = ( code == 1 ? true : false);824 sei_read_code( pDecodedMessageOutputStream, 4, code, "pic_struct" ); sei.m_picStruct = code; 825 sei_read_code( pDecodedMessageOutputStream, 2, code, "source_scan_type" ); sei.m_sourceScanType = code; 826 sei_read_flag( pDecodedMessageOutputStream, code, "duplicate_flag" ); sei.m_duplicateFlag = (code == 1); 859 827 } 860 828 861 829 if( hrd->getCpbDpbDelaysPresentFlag()) 862 830 { 863 READ_CODE(( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" );831 sei_read_code( pDecodedMessageOutputStream, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" ); 864 832 sei.m_auCpbRemovalDelay = code + 1; 865 READ_CODE(( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" );833 sei_read_code( pDecodedMessageOutputStream, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" ); 866 834 sei.m_picDpbOutputDelay = code; 867 835 868 836 if(hrd->getSubPicCpbParamsPresentFlag()) 869 837 { 870 READ_CODE(hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" );838 sei_read_code( pDecodedMessageOutputStream, hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" ); 871 839 sei.m_picDpbOutputDuDelay = code; 872 840 } 841 873 842 if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) 874 843 { 875 READ_UVLC(code, "num_decoding_units_minus1");844 sei_read_uvlc( pDecodedMessageOutputStream, code, "num_decoding_units_minus1"); 876 845 sei.m_numDecodingUnitsMinus1 = code; 877 READ_FLAG(code, "du_common_cpb_removal_delay_flag" );846 sei_read_flag( pDecodedMessageOutputStream, code, "du_common_cpb_removal_delay_flag" ); 878 847 sei.m_duCommonCpbRemovalDelayFlag = code; 879 848 if( sei.m_duCommonCpbRemovalDelayFlag ) 880 849 { 881 READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_minus1" );850 sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_increment_minus1" ); 882 851 sei.m_duCommonCpbRemovalDelayMinus1 = code; 883 852 } … … 895 864 for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ ) 896 865 { 897 READ_UVLC( code, "num_nalus_in_du_minus1");866 sei_read_uvlc( pDecodedMessageOutputStream, code, "num_nalus_in_du_minus1[i]"); 898 867 sei.m_numNalusInDuMinus1[ i ] = code; 899 868 if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) ) 900 869 { 901 READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1" );870 sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1[i]" ); 902 871 sei.m_duCpbRemovalDelayMinus1[ i ] = code; 903 872 } … … 905 874 } 906 875 } 907 xParseByteAlign(); 908 } 909 Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt /*payloadSize*/)876 } 877 878 Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 910 879 { 911 880 Int iCode; 912 881 UInt uiCode; 913 READ_SVLC( iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; 914 READ_FLAG( uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; 915 READ_FLAG( uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; 916 xParseByteAlign(); 917 } 918 Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt /*payloadSize*/) 882 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 883 884 sei_read_svlc( pDecodedMessageOutputStream, iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; 885 sei_read_flag( pDecodedMessageOutputStream, uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; 886 sei_read_flag( pDecodedMessageOutputStream, uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; 887 } 888 889 Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 919 890 { 920 891 UInt val; 921 READ_UVLC( val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; 922 READ_FLAG( val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; 892 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 893 894 sei_read_uvlc( pDecodedMessageOutputStream, val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; 895 sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; 923 896 924 897 if ( !sei.m_arrangementCancelFlag ) 925 898 { 926 READ_CODE(7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val;899 sei_read_code( pDecodedMessageOutputStream, 7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val; 927 900 assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) ); 928 READ_FLAG( val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; 929 930 READ_CODE( 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; 931 READ_FLAG( val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; 932 READ_FLAG( val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; 933 READ_FLAG( val, "field_views_flag" ); sei.m_fieldViewsFlag = val; 934 READ_FLAG( val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; 935 READ_FLAG( val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; 936 READ_FLAG( val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; 901 902 sei_read_flag( pDecodedMessageOutputStream, val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; 903 904 sei_read_code( pDecodedMessageOutputStream, 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; 905 sei_read_flag( pDecodedMessageOutputStream, val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; 906 sei_read_flag( pDecodedMessageOutputStream, val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; 907 sei_read_flag( pDecodedMessageOutputStream, val, "field_views_flag" ); sei.m_fieldViewsFlag = val; 908 sei_read_flag( pDecodedMessageOutputStream, val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; 909 sei_read_flag( pDecodedMessageOutputStream, val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; 910 sei_read_flag( pDecodedMessageOutputStream, val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; 937 911 938 912 if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) 939 913 { 940 READ_CODE( 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; 941 READ_CODE( 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; 942 READ_CODE( 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; 943 READ_CODE( 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; 944 } 945 946 READ_CODE( 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; 947 READ_FLAG( val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = val ? true : false; 948 } 949 READ_FLAG( val, "upsampled_aspect_ratio" ); sei.m_upsampledAspectRatio = val; 950 951 xParseByteAlign(); 952 } 953 954 Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt /*payloadSize*/) 914 sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; 915 sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; 916 sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; 917 sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; 918 } 919 920 sei_read_code( pDecodedMessageOutputStream, 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; 921 sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = (val != 0); 922 } 923 sei_read_flag( pDecodedMessageOutputStream, val, "upsampled_aspect_ratio_flag" ); sei.m_upsampledAspectRatio = val; 924 } 925 926 Void SEIReader::xParseSEISegmentedRectFramePacking(SEISegmentedRectFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 955 927 { 956 928 UInt val; 957 READ_FLAG( val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; 958 if( !sei.cancelFlag ) 959 { 960 READ_FLAG( val, "hor_flip" ); sei.horFlip = val; 961 READ_FLAG( val, "ver_flip" ); sei.verFlip = val; 962 READ_CODE( 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; 963 READ_FLAG( val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; 964 } 965 xParseByteAlign(); 966 } 967 968 Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt /*payloadSize*/) 929 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 930 sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; 931 if( !sei.m_arrangementCancelFlag ) 932 { 933 sei_read_code( pDecodedMessageOutputStream, 2, val, "segmented_rect_content_interpretation_type" ); sei.m_contentInterpretationType = val; 934 sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_persistence" ); sei.m_arrangementPersistenceFlag = val; 935 } 936 } 937 938 Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 969 939 { 970 940 UInt val; 971 READ_CODE ( 8, val, "tl0_idx" ); sei.tl0Idx = val; 972 READ_CODE ( 8, val, "rap_idx" ); sei.rapIdx = val; 973 xParseByteAlign(); 974 } 975 976 Void SEIReader::xParseSEIGradualDecodingRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt /*payloadSize*/) 941 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 942 sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; 943 if( !sei.cancelFlag ) 944 { 945 sei_read_flag( pDecodedMessageOutputStream, val, "hor_flip" ); sei.horFlip = val; 946 sei_read_flag( pDecodedMessageOutputStream, val, "ver_flip" ); sei.verFlip = val; 947 sei_read_code( pDecodedMessageOutputStream, 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; 948 sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; 949 } 950 } 951 952 Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 977 953 { 978 954 UInt val; 979 READ_FLAG( val, "gdr_foreground_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; 980 xParseByteAlign(); 981 } 982 983 Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt /*payloadSize*/) 955 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 956 sei_read_code( pDecodedMessageOutputStream, 8, val, "temporal_sub_layer_zero_idx" ); sei.tl0Idx = val; 957 sei_read_code( pDecodedMessageOutputStream, 8, val, "irap_pic_id" ); sei.rapIdx = val; 958 } 959 960 Void SEIReader::xParseSEIRegionRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 961 { 962 UInt val; 963 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 964 sei_read_flag( pDecodedMessageOutputStream, val, "refreshed_region_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; 965 } 966 967 Void SEIReader::xParseSEINoDisplay(SEINoDisplay& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 968 { 969 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 970 sei.m_noDisplay = true; 971 } 972 973 Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 984 974 { 985 975 Int i; 986 976 UInt val; 987 READ_UVLC( val, "tone_map_id" ); sei.m_toneMapId = val; 988 READ_FLAG( val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; 977 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 978 sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_id" ); sei.m_toneMapId = val; 979 sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; 989 980 990 981 if ( !sei.m_toneMapCancelFlag ) 991 982 { 992 READ_FLAG( val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val;993 READ_CODE(8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val;994 READ_CODE(8, val, "target_bit_depth" ); sei.m_targetBitDepth = val;995 READ_UVLC( val, "model_id" ); sei.m_modelId = val;983 sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val; 984 sei_read_code( pDecodedMessageOutputStream, 8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val; 985 sei_read_code( pDecodedMessageOutputStream, 8, val, "target_bit_depth" ); sei.m_targetBitDepth = val; 986 sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_model_id" ); sei.m_modelId = val; 996 987 switch(sei.m_modelId) 997 988 { 998 989 case 0: 999 990 { 1000 READ_CODE(32, val, "min_value" ); sei.m_minValue = val;1001 READ_CODE(32, val, "max_value" ); sei.m_maxValue = val;991 sei_read_code( pDecodedMessageOutputStream, 32, val, "min_value" ); sei.m_minValue = val; 992 sei_read_code( pDecodedMessageOutputStream, 32, val, "max_value" ); sei.m_maxValue = val; 1002 993 break; 1003 994 } 1004 995 case 1: 1005 996 { 1006 READ_CODE(32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val;1007 READ_CODE(32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val;997 sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val; 998 sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val; 1008 999 break; 1009 1000 } … … 1014 1005 for(i = 0; i < num; i++) 1015 1006 { 1016 READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval" );1007 sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval[i]" ); 1017 1008 sei.m_startOfCodedInterval[i] = val; 1018 1009 } … … 1022 1013 case 3: 1023 1014 { 1024 READ_CODE(16, val, "num_pivots" ); sei.m_numPivots = val;1015 sei_read_code( pDecodedMessageOutputStream, 16, val, "num_pivots" ); sei.m_numPivots = val; 1025 1016 sei.m_codedPivotValue.resize(sei.m_numPivots); 1026 1017 sei.m_targetPivotValue.resize(sei.m_numPivots); 1027 1018 for(i = 0; i < sei.m_numPivots; i++ ) 1028 1019 { 1029 READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value" );1020 sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value[i]" ); 1030 1021 sei.m_codedPivotValue[i] = val; 1031 READ_CODE( ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value" );1022 sei_read_code( pDecodedMessageOutputStream, ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value[i]" ); 1032 1023 sei.m_targetPivotValue[i] = val; 1033 1024 } … … 1036 1027 case 4: 1037 1028 { 1038 READ_CODE(8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedIdc = val;1029 sei_read_code( pDecodedMessageOutputStream, 8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedIdc = val; 1039 1030 if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO 1040 1031 { 1041 READ_CODE(32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val;1042 } 1043 READ_CODE(8, val, "exposure_index_idc" ); sei.m_exposureIndexIdc = val;1032 sei_read_code( pDecodedMessageOutputStream, 32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val; 1033 } 1034 sei_read_code( pDecodedMessageOutputStream, 8, val, "exposure_index_idc" ); sei.m_exposureIndexIdc = val; 1044 1035 if( sei.m_exposureIndexIdc == 255) //Extended_ISO 1045 1036 { 1046 READ_CODE(32, val, "exposure_index_value" ); sei.m_exposureIndexValue = val;1047 } 1048 READ_FLAG(val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val;1049 READ_CODE(16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val;1050 READ_CODE(16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val;1051 READ_CODE(32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val;1052 READ_CODE(32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val;1053 READ_CODE( 16, val, "nominal_black_level_luma_code_value" );sei.m_nominalBlackLevelLumaCodeValue = val;1054 READ_CODE( 16, val, "nominal_white_level_luma_code_value" );sei.m_nominalWhiteLevelLumaCodeValue= val;1055 READ_CODE( 16, val, "extended_white_level_luma_code_value" );sei.m_extendedWhiteLevelLumaCodeValue = val;1037 sei_read_code( pDecodedMessageOutputStream, 32, val, "exposure_index_value" ); sei.m_exposureIndexValue = val; 1038 } 1039 sei_read_flag( pDecodedMessageOutputStream, val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val; 1040 sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val; 1041 sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val; 1042 sei_read_code( pDecodedMessageOutputStream, 32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val; 1043 sei_read_code( pDecodedMessageOutputStream, 32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val; 1044 sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_black_level_code_value" ); sei.m_nominalBlackLevelLumaCodeValue = val; 1045 sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_white_level_code_value" ); sei.m_nominalWhiteLevelLumaCodeValue= val; 1046 sei_read_code( pDecodedMessageOutputStream, 16, val, "extended_white_level_code_value" ); sei.m_extendedWhiteLevelLumaCodeValue = val; 1056 1047 break; 1057 1048 } … … 1062 1053 } 1063 1054 }//switch model id 1064 }// if(!sei.m_toneMapCancelFlag) 1065 1066 xParseByteAlign(); 1067 } 1068 1069 #if P0050_KNEE_FUNCTION_SEI 1070 Void SEIReader::xParseSEIKneeFunctionInfo(SEIKneeFunctionInfo& sei, UInt /*payloadSize*/){ 1055 }// if(!sei.m_toneMapCancelFlag) 1056 } 1057 1058 Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 1059 { 1060 Int iCode; 1061 UInt uiCode; 1062 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1063 1064 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; 1065 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; 1066 for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) 1067 { 1068 sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "sop_vcl_nut[i]" ); sei.m_sopDescVclNaluType[i] = uiCode; 1069 sei_read_code( pDecodedMessageOutputStream, 3, sei.m_sopDescTemporalId[i], "sop_temporal_id[i]" ); sei.m_sopDescTemporalId[i] = uiCode; 1070 if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) 1071 { 1072 sei_read_uvlc( pDecodedMessageOutputStream, sei.m_sopDescStRpsIdx[i], "sop_short_term_rps_idx[i]" ); sei.m_sopDescStRpsIdx[i] = uiCode; 1073 } 1074 if (i > 0) 1075 { 1076 sei_read_svlc( pDecodedMessageOutputStream, iCode, "sop_poc_delta[i]" ); sei.m_sopDescPocDelta[i] = iCode; 1077 } 1078 } 1079 } 1080 1081 #if LAYERS_NOT_PRESENT_SEI 1082 Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 1083 #else 1084 Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 1085 #endif 1086 { 1087 UInt uiCode; 1088 SEIMessages seis; 1089 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1090 1091 sei_read_flag( pDecodedMessageOutputStream, uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; 1092 sei_read_flag( pDecodedMessageOutputStream, uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; 1093 if (sei.m_nestingOpFlag) 1094 { 1095 sei_read_flag( pDecodedMessageOutputStream, uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode; 1096 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode; 1097 for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++) 1098 { 1099 sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_max_temporal_id_plus1[i]" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode; 1100 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_op_idx[i]" ); sei.m_nestingOpIdx[i] = uiCode; 1101 } 1102 } 1103 else 1104 { 1105 sei_read_flag( pDecodedMessageOutputStream, uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode; 1106 if (!sei.m_allLayersFlag) 1107 { 1108 sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode; 1109 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode; 1110 for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) 1111 { 1112 sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "nesting_layer_id[i]" ); sei.m_nestingLayerId[i] = uiCode; 1113 } 1114 } 1115 } 1116 1117 // byte alignment 1118 while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) 1119 { 1120 UInt code; 1121 sei_read_flag( pDecodedMessageOutputStream, code, "nesting_zero_bit" ); 1122 } 1123 1124 sei.m_callerOwnsSEIs = false; 1125 1126 // read nested SEI messages 1127 do { 1128 #if O0164_MULTI_LAYER_HRD 1129 #if LAYERS_NOT_PRESENT_SEI 1130 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream, &sei); 1131 #else 1132 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream, &sei); 1133 #endif 1134 #else 1135 #if LAYERS_NOT_PRESENT_SEI 1136 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream); 1137 #else 1138 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream); 1139 #endif 1140 #endif 1141 } while (m_pcBitstream->getNumBitsLeft() > 8); 1142 1143 if (pDecodedMessageOutputStream) (*pDecodedMessageOutputStream) << "End of scalable nesting SEI message\n"; 1144 } 1145 1146 Void SEIReader::xParseSEITempMotionConstraintsTileSets(SEITempMotionConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 1147 { 1148 UInt code; 1149 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1150 sei_read_flag( pDecodedMessageOutputStream, code, "mc_all_tiles_exact_sample_value_match_flag"); sei.m_mc_all_tiles_exact_sample_value_match_flag = (code != 0); 1151 sei_read_flag( pDecodedMessageOutputStream, code, "each_tile_one_tile_set_flag"); sei.m_each_tile_one_tile_set_flag = (code != 0); 1152 1153 if(!sei.m_each_tile_one_tile_set_flag) 1154 { 1155 sei_read_flag( pDecodedMessageOutputStream, code, "limited_tile_set_display_flag"); sei.m_limited_tile_set_display_flag = (code != 0); 1156 sei_read_uvlc( pDecodedMessageOutputStream, code, "num_sets_in_message_minus1"); sei.setNumberOfTileSets(code + 1); 1157 1158 if(sei.getNumberOfTileSets() != 0) 1159 { 1160 for(Int i = 0; i < sei.getNumberOfTileSets(); i++) 1161 { 1162 sei_read_uvlc( pDecodedMessageOutputStream, code, "mcts_id"); sei.tileSetData(i).m_mcts_id = code; 1163 1164 if(sei.m_limited_tile_set_display_flag) 1165 { 1166 sei_read_flag( pDecodedMessageOutputStream, code, "display_tile_set_flag"); sei.tileSetData(i).m_display_tile_set_flag = (code != 1); 1167 } 1168 1169 sei_read_uvlc( pDecodedMessageOutputStream, code, "num_tile_rects_in_set_minus1"); sei.tileSetData(i).setNumberOfTileRects(code + 1); 1170 1171 for(Int j=0; j<sei.tileSetData(i).getNumberOfTileRects(); j++) 1172 { 1173 sei_read_uvlc( pDecodedMessageOutputStream, code, "top_left_tile_index"); sei.tileSetData(i).topLeftTileIndex(j) = code; 1174 sei_read_uvlc( pDecodedMessageOutputStream, code, "bottom_right_tile_index"); sei.tileSetData(i).bottomRightTileIndex(j) = code; 1175 } 1176 1177 if(!sei.m_mc_all_tiles_exact_sample_value_match_flag) 1178 { 1179 sei_read_flag( pDecodedMessageOutputStream, code, "exact_sample_value_match_flag"); sei.tileSetData(i).m_exact_sample_value_match_flag = (code != 0); 1180 } 1181 sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_level_idc_present_flag"); sei.tileSetData(i).m_mcts_tier_level_idc_present_flag = (code != 0); 1182 1183 if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag) 1184 { 1185 sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_flag"); sei.tileSetData(i).m_mcts_tier_flag = (code != 0); 1186 sei_read_code( pDecodedMessageOutputStream, 8, code, "mcts_level_idc"); sei.tileSetData(i).m_mcts_level_idc = code; 1187 } 1188 } 1189 } 1190 } 1191 else 1192 { 1193 sei_read_flag( pDecodedMessageOutputStream, code, "max_mcs_tier_level_idc_present_flag"); sei.m_max_mcs_tier_level_idc_present_flag = code; 1194 if(sei.m_max_mcs_tier_level_idc_present_flag) 1195 { 1196 sei_read_flag( pDecodedMessageOutputStream, code, "max_mcts_tier_flag"); sei.m_max_mcts_tier_flag = code; 1197 sei_read_code( pDecodedMessageOutputStream, 8, code, "max_mcts_level_idc"); sei.m_max_mcts_level_idc = code; 1198 } 1199 } 1200 } 1201 1202 Void SEIReader::xParseSEITimeCode(SEITimeCode& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 1203 { 1204 UInt code; 1205 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1206 sei_read_code( pDecodedMessageOutputStream, 2, code, "num_clock_ts"); sei.numClockTs = code; 1207 for(Int i = 0; i < sei.numClockTs; i++) 1208 { 1209 TComSEITimeSet currentTimeSet; 1210 sei_read_flag( pDecodedMessageOutputStream, code, "clock_time_stamp_flag[i]"); currentTimeSet.clockTimeStampFlag = code; 1211 if(currentTimeSet.clockTimeStampFlag) 1212 { 1213 sei_read_flag( pDecodedMessageOutputStream, code, "nuit_field_based_flag"); currentTimeSet.numUnitFieldBasedFlag = code; 1214 sei_read_code( pDecodedMessageOutputStream, 5, code, "counting_type"); currentTimeSet.countingType = code; 1215 sei_read_flag( pDecodedMessageOutputStream, code, "full_timestamp_flag"); currentTimeSet.fullTimeStampFlag = code; 1216 sei_read_flag( pDecodedMessageOutputStream, code, "discontinuity_flag"); currentTimeSet.discontinuityFlag = code; 1217 sei_read_flag( pDecodedMessageOutputStream, code, "cnt_dropped_flag"); currentTimeSet.cntDroppedFlag = code; 1218 sei_read_code( pDecodedMessageOutputStream, 9, code, "n_frames"); currentTimeSet.numberOfFrames = code; 1219 if(currentTimeSet.fullTimeStampFlag) 1220 { 1221 sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code; 1222 sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code; 1223 sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code; 1224 } 1225 else 1226 { 1227 sei_read_flag( pDecodedMessageOutputStream, code, "seconds_flag"); currentTimeSet.secondsFlag = code; 1228 if(currentTimeSet.secondsFlag) 1229 { 1230 sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code; 1231 sei_read_flag( pDecodedMessageOutputStream, code, "minutes_flag"); currentTimeSet.minutesFlag = code; 1232 if(currentTimeSet.minutesFlag) 1233 { 1234 sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code; 1235 sei_read_flag( pDecodedMessageOutputStream, code, "hours_flag"); currentTimeSet.hoursFlag = code; 1236 if(currentTimeSet.hoursFlag) 1237 sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code; 1238 } 1239 } 1240 } 1241 sei_read_code( pDecodedMessageOutputStream, 5, code, "time_offset_length"); currentTimeSet.timeOffsetLength = code; 1242 if(currentTimeSet.timeOffsetLength > 0) 1243 { 1244 sei_read_code( pDecodedMessageOutputStream, currentTimeSet.timeOffsetLength, code, "time_offset_value"); 1245 if((code & (1 << (currentTimeSet.timeOffsetLength-1))) == 0) 1246 { 1247 currentTimeSet.timeOffsetValue = code; 1248 } 1249 else 1250 { 1251 code &= (1<< (currentTimeSet.timeOffsetLength-1)) - 1; 1252 currentTimeSet.timeOffsetValue = ~code + 1; 1253 } 1254 } 1255 } 1256 sei.timeSetArray[i] = currentTimeSet; 1257 } 1258 } 1259 1260 Void SEIReader::xParseSEIChromaSamplingFilterHint(SEIChromaSamplingFilterHint& sei, UInt payloadSize/*, TComSPS* sps*/, std::ostream *pDecodedMessageOutputStream) 1261 { 1262 UInt uiCode; 1263 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1264 1265 sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "ver_chroma_filter_idc"); sei.m_verChromaFilterIdc = uiCode; 1266 sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "hor_chroma_filter_idc"); sei.m_horChromaFilterIdc = uiCode; 1267 sei_read_flag( pDecodedMessageOutputStream, uiCode, "ver_filtering_process_flag"); sei.m_verFilteringProcessFlag = uiCode; 1268 if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1) 1269 { 1270 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "target_format_idc"); sei.m_targetFormatIdc = uiCode; 1271 if(sei.m_verChromaFilterIdc == 1) 1272 { 1273 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_vertical_filters"); sei.m_numVerticalFilters = uiCode; 1274 if(sei.m_numVerticalFilters > 0) 1275 { 1276 sei.m_verTapLengthMinus1 = (Int*)malloc(sei.m_numVerticalFilters * sizeof(Int)); 1277 sei.m_verFilterCoeff = (Int**)malloc(sei.m_numVerticalFilters * sizeof(Int*)); 1278 for(Int i = 0; i < sei.m_numVerticalFilters; i ++) 1279 { 1280 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ver_tap_length_minus_1"); sei.m_verTapLengthMinus1[i] = uiCode; 1281 sei.m_verFilterCoeff[i] = (Int*)malloc(sei.m_verTapLengthMinus1[i] * sizeof(Int)); 1282 for(Int j = 0; j < sei.m_verTapLengthMinus1[i]; j ++) 1283 { 1284 sei_read_svlc( pDecodedMessageOutputStream, sei.m_verFilterCoeff[i][j], "ver_filter_coeff"); 1285 } 1286 } 1287 } 1288 } 1289 if(sei.m_horChromaFilterIdc == 1) 1290 { 1291 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_horizontal_filters"); sei.m_numHorizontalFilters = uiCode; 1292 if(sei.m_numHorizontalFilters > 0) 1293 { 1294 sei.m_horTapLengthMinus1 = (Int*)malloc(sei.m_numHorizontalFilters * sizeof(Int)); 1295 sei.m_horFilterCoeff = (Int**)malloc(sei.m_numHorizontalFilters * sizeof(Int*)); 1296 for(Int i = 0; i < sei.m_numHorizontalFilters; i ++) 1297 { 1298 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "hor_tap_length_minus_1"); sei.m_horTapLengthMinus1[i] = uiCode; 1299 sei.m_horFilterCoeff[i] = (Int*)malloc(sei.m_horTapLengthMinus1[i] * sizeof(Int)); 1300 for(Int j = 0; j < sei.m_horTapLengthMinus1[i]; j ++) 1301 { 1302 sei_read_svlc( pDecodedMessageOutputStream, sei.m_horFilterCoeff[i][j], "hor_filter_coeff"); 1303 } 1304 } 1305 } 1306 } 1307 } 1308 } 1309 1310 Void SEIReader::xParseSEIKneeFunctionInfo(SEIKneeFunctionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 1311 { 1071 1312 Int i; 1072 1313 UInt val; 1073 READ_UVLC( val, "knee_function_id" ); sei.m_kneeId = val; 1074 READ_FLAG( val, "knee_function_cancel_flag" ); sei.m_kneeCancelFlag = val; 1314 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1315 1316 sei_read_uvlc( pDecodedMessageOutputStream, val, "knee_function_id" ); sei.m_kneeId = val; 1317 sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_cancel_flag" ); sei.m_kneeCancelFlag = val; 1075 1318 if ( !sei.m_kneeCancelFlag ) 1076 1319 { 1077 READ_FLAG( val, "knee_function_persistence_flag" ); sei.m_kneePersistenceFlag = val; 1078 READ_FLAG( val, "mapping_flag" ); sei.m_kneeMappingFlag = val; 1079 READ_CODE( 32, val, "input_d_range" ); sei.m_kneeInputDrange = val; 1080 READ_CODE( 32, val, "input_disp_luminance" ); sei.m_kneeInputDispLuminance = val; 1081 READ_CODE( 32, val, "output_d_range" ); sei.m_kneeOutputDrange = val; 1082 READ_CODE( 32, val, "output_disp_luminance" ); sei.m_kneeOutputDispLuminance = val; 1083 READ_UVLC( val, "num_knee_points_minus1" ); sei.m_kneeNumKneePointsMinus1 = val; 1320 sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_persistence_flag" ); sei.m_kneePersistenceFlag = val; 1321 sei_read_code( pDecodedMessageOutputStream, 32, val, "input_d_range" ); sei.m_kneeInputDrange = val; 1322 sei_read_code( pDecodedMessageOutputStream, 32, val, "input_disp_luminance" ); sei.m_kneeInputDispLuminance = val; 1323 sei_read_code( pDecodedMessageOutputStream, 32, val, "output_d_range" ); sei.m_kneeOutputDrange = val; 1324 sei_read_code( pDecodedMessageOutputStream, 32, val, "output_disp_luminance" ); sei.m_kneeOutputDispLuminance = val; 1325 sei_read_uvlc( pDecodedMessageOutputStream, val, "num_knee_points_minus1" ); sei.m_kneeNumKneePointsMinus1 = val; 1084 1326 assert( sei.m_kneeNumKneePointsMinus1 > 0 ); 1085 1327 sei.m_kneeInputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); … … 1087 1329 for(i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ ) 1088 1330 { 1089 READ_CODE( 10, val, "input_knee_point" ); sei.m_kneeInputKneePoint[i] = val; 1090 READ_CODE( 10, val, "output_knee_point" ); sei.m_kneeOutputKneePoint[i] = val; 1091 } 1092 } 1093 } 1094 #endif 1331 sei_read_code( pDecodedMessageOutputStream, 10, val, "input_knee_point" ); sei.m_kneeInputKneePoint[i] = val; 1332 sei_read_code( pDecodedMessageOutputStream, 10, val, "output_knee_point" ); sei.m_kneeOutputKneePoint[i] = val; 1333 } 1334 } 1335 } 1336 1337 Void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 1338 { 1339 UInt code; 1340 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1341 1342 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[0]" ); sei.values.primaries[0][0] = code; 1343 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[0]" ); sei.values.primaries[0][1] = code; 1344 1345 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[1]" ); sei.values.primaries[1][0] = code; 1346 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[1]" ); sei.values.primaries[1][1] = code; 1347 1348 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[2]" ); sei.values.primaries[2][0] = code; 1349 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[2]" ); sei.values.primaries[2][1] = code; 1350 1351 1352 sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_x" ); sei.values.whitePoint[0] = code; 1353 sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_y" ); sei.values.whitePoint[1] = code; 1354 1355 sei_read_code( pDecodedMessageOutputStream, 32, code, "max_display_mastering_luminance" ); sei.values.maxLuminance = code; 1356 sei_read_code( pDecodedMessageOutputStream, 32, code, "min_display_mastering_luminance" ); sei.values.minLuminance = code; 1357 } 1095 1358 1096 1359 #if Q0074_COLOUR_REMAPPING_SEI 1097 Void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& sei, UInt /*payloadSize*/ )1360 Void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& sei, UInt /*payloadSize*/, std::ostream *pDecodedMessageOutputStream) 1098 1361 { 1099 1362 UInt uiVal; 1100 1363 Int iVal; 1101 1364 1102 READ_UVLC(uiVal, "colour_remap_id" ); sei.m_colourRemapId = uiVal;1103 READ_FLAG(uiVal, "colour_remap_cancel_flag" ); sei.m_colourRemapCancelFlag = uiVal;1365 sei_read_uvlc( pDecodedMessageOutputStream, uiVal, "colour_remap_id" ); sei.m_colourRemapId = uiVal; 1366 sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_cancel_flag" ); sei.m_colourRemapCancelFlag = uiVal; 1104 1367 if( !sei.m_colourRemapCancelFlag ) 1105 1368 { 1106 READ_FLAG(uiVal, "colour_remap_persistence_flag" ); sei.m_colourRemapPersistenceFlag = uiVal;1107 READ_FLAG(uiVal, "colour_remap_video_signal_info_present_flag" ); sei.m_colourRemapVideoSignalInfoPresentFlag = uiVal;1369 sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_persistence_flag" ); sei.m_colourRemapPersistenceFlag = uiVal; 1370 sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_video_signal_info_present_flag" ); sei.m_colourRemapVideoSignalInfoPresentFlag = uiVal; 1108 1371 if ( sei.m_colourRemapVideoSignalInfoPresentFlag ) 1109 1372 { 1110 READ_FLAG(uiVal, "colour_remap_full_range_flag" ); sei.m_colourRemapFullRangeFlag = uiVal;1111 READ_CODE(8, uiVal, "colour_remap_primaries" ); sei.m_colourRemapPrimaries = uiVal;1112 READ_CODE(8, uiVal, "colour_remap_transfer_function" ); sei.m_colourRemapTransferFunction = uiVal;1113 READ_CODE(8, uiVal, "colour_remap_matrix_coefficients" ); sei.m_colourRemapMatrixCoefficients = uiVal;1114 } 1115 READ_CODE(8, uiVal, "colour_remap_input_bit_depth" ); sei.m_colourRemapInputBitDepth = uiVal;1116 READ_CODE(8, uiVal, "colour_remap_bit_depth" ); sei.m_colourRemapBitDepth = uiVal;1373 sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_full_range_flag" ); sei.m_colourRemapFullRangeFlag = uiVal; 1374 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_primaries" ); sei.m_colourRemapPrimaries = uiVal; 1375 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_transfer_function" ); sei.m_colourRemapTransferFunction = uiVal; 1376 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_matrix_coefficients" ); sei.m_colourRemapMatrixCoefficients = uiVal; 1377 } 1378 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_input_bit_depth" ); sei.m_colourRemapInputBitDepth = uiVal; 1379 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_bit_depth" ); sei.m_colourRemapBitDepth = uiVal; 1117 1380 1118 1381 for( Int c=0 ; c<3 ; c++ ) 1119 1382 { 1120 READ_CODE(8, uiVal, "pre_lut_num_val_minus1[c]" ); sei.m_preLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal;1383 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "pre_lut_num_val_minus1[c]" ); sei.m_preLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; 1121 1384 sei.m_preLutCodedValue[c].resize(sei.m_preLutNumValMinus1[c]+1); 1122 1385 sei.m_preLutTargetValue[c].resize(sei.m_preLutNumValMinus1[c]+1); … … 1124 1387 for ( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) 1125 1388 { 1126 READ_CODE((( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" ); sei.m_preLutCodedValue[c][i] = uiVal;1127 READ_CODE((( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLutTargetValue[c][i] = uiVal;1389 sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" ); sei.m_preLutCodedValue[c][i] = uiVal; 1390 sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLutTargetValue[c][i] = uiVal; 1128 1391 } 1129 1392 else // pre_lut_num_val_minus1[c] == 0 … … 1136 1399 } 1137 1400 1138 READ_FLAG(uiVal, "colour_remap_matrix_present_flag" ); sei.m_colourRemapMatrixPresentFlag = uiVal;1401 sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_matrix_present_flag" ); sei.m_colourRemapMatrixPresentFlag = uiVal; 1139 1402 if( sei.m_colourRemapMatrixPresentFlag ) 1140 1403 { 1141 READ_CODE(4, uiVal, "log2_matrix_denom" ); sei.m_log2MatrixDenom = uiVal;1404 sei_read_code( pDecodedMessageOutputStream, 4, uiVal, "log2_matrix_denom" ); sei.m_log2MatrixDenom = uiVal; 1142 1405 for ( Int c=0 ; c<3 ; c++ ) 1143 1406 for ( Int i=0 ; i<3 ; i++ ) 1144 1407 { 1145 READ_SVLC(iVal, "colour_remap_coeffs[c][i]" ); sei.m_colourRemapCoeffs[c][i] = iVal;1408 sei_read_svlc( pDecodedMessageOutputStream, iVal, "colour_remap_coeffs[c][i]" ); sei.m_colourRemapCoeffs[c][i] = iVal; 1146 1409 } 1147 1410 } … … 1155 1418 for( Int c=0 ; c<3 ; c++ ) 1156 1419 { 1157 READ_CODE(8, uiVal, "post_lut_num_val_minus1[c]" ); sei.m_postLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal;1420 sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "post_lut_num_val_minus1[c]" ); sei.m_postLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; 1158 1421 sei.m_postLutCodedValue[c].resize(sei.m_postLutNumValMinus1[c]+1); 1159 1422 sei.m_postLutTargetValue[c].resize(sei.m_postLutNumValMinus1[c]+1); … … 1161 1424 for ( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) 1162 1425 { 1163 READ_CODE((( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" ); sei.m_postLutCodedValue[c][i] = uiVal;1164 READ_CODE((( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLutTargetValue[c][i] = uiVal;1426 sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" ); sei.m_postLutCodedValue[c][i] = uiVal; 1427 sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLutTargetValue[c][i] = uiVal; 1165 1428 } 1166 1429 else … … 1173 1436 } 1174 1437 } 1175 1176 xParseByteAlign(); 1177 } 1178 #endif 1179 1180 Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize) 1181 { 1182 Int iCode; 1183 UInt uiCode; 1184 1185 READ_UVLC( uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; 1186 READ_UVLC( uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; 1187 for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) 1188 { 1189 READ_CODE( 6, uiCode, "sop_desc_vcl_nalu_type" ); sei.m_sopDescVclNaluType[i] = uiCode; 1190 READ_CODE( 3, sei.m_sopDescTemporalId[i], "sop_desc_temporal_id" ); sei.m_sopDescTemporalId[i] = uiCode; 1191 if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) 1192 { 1193 READ_UVLC( sei.m_sopDescStRpsIdx[i], "sop_desc_st_rps_idx" ); sei.m_sopDescStRpsIdx[i] = uiCode; 1194 } 1195 if (i > 0) 1196 { 1197 READ_SVLC( iCode, "sop_desc_poc_delta" ); sei.m_sopDescPocDelta[i] = iCode; 1198 } 1199 } 1200 1201 xParseByteAlign(); 1202 } 1203 1204 #if Q0189_TMVP_CONSTRAINTS 1205 Void SEIReader::xParseSEITMVPConstraints (SEITMVPConstrains& sei, UInt payloadSize) 1206 { 1207 UInt uiCode; 1208 READ_UVLC( uiCode, "prev_pics_not_used_flag" ); sei.prev_pics_not_used_flag = uiCode; 1209 READ_UVLC( uiCode, "no_intra_layer_col_pic_flag" ); sei.no_intra_layer_col_pic_flag = uiCode; 1210 xParseByteAlign(); 1211 } 1212 #endif 1213 1214 #if Q0247_FRAME_FIELD_INFO 1215 Void SEIReader::xParseSEIFrameFieldInfo (SEIFrameFieldInfo& sei, UInt payloadSize) 1216 { 1217 UInt code; 1218 READ_CODE( 4, code, "ffinfo_pic_struct" ); sei.m_ffinfo_picStruct = code; 1219 READ_CODE( 2, code, "ffinfo_source_scan_type" ); sei.m_ffinfo_sourceScanType = code; 1220 READ_FLAG( code, "ffinfo_duplicate_flag" ); sei.m_ffinfo_duplicateFlag = ( code == 1 ? true : false ); 1221 xParseByteAlign(); 1222 } 1223 #endif 1224 1225 #if LAYERS_NOT_PRESENT_SEI 1226 Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps) 1227 #else 1228 Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps) 1229 #endif 1230 { 1231 UInt uiCode; 1232 SEIMessages seis; 1233 1234 READ_FLAG( uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; 1235 READ_FLAG( uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; 1236 if (sei.m_nestingOpFlag) 1237 { 1238 READ_FLAG( uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode; 1239 READ_UVLC( uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode; 1240 for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++) 1241 { 1242 READ_CODE( 3, uiCode, "nesting_max_temporal_id_plus1" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode; 1243 READ_UVLC( uiCode, "nesting_op_idx" ); sei.m_nestingOpIdx[i] = uiCode; 1244 } 1245 } 1246 else 1247 { 1248 READ_FLAG( uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode; 1249 if (!sei.m_allLayersFlag) 1250 { 1251 READ_CODE( 3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode; 1252 READ_UVLC( uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode; 1253 for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) 1254 { 1255 READ_CODE( 6, uiCode, "nesting_layer_id" ); sei.m_nestingLayerId[i] = uiCode; 1256 } 1257 } 1258 } 1259 1260 // byte alignment 1261 while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) 1262 { 1263 UInt code; 1264 READ_FLAG( code, "nesting_zero_bit" ); 1265 } 1266 1267 sei.m_callerOwnsSEIs = false; 1268 1269 // read nested SEI messages 1270 do { 1271 #if O0164_MULTI_LAYER_HRD 1272 #if LAYERS_NOT_PRESENT_SEI 1273 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &sei); 1274 #else 1275 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, &sei); 1276 #endif 1277 #else 1278 #if LAYERS_NOT_PRESENT_SEI 1279 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps); 1280 #else 1281 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps); 1282 #endif 1283 #endif 1284 } while (m_pcBitstream->getNumBitsLeft() > 8); 1285 1286 } 1287 1288 Void SEIReader::xParseByteAlign() 1289 { 1290 UInt code; 1291 if( m_pcBitstream->getNumBitsRead() % 8 != 0 ) 1292 { 1293 READ_FLAG( code, "bit_equal_to_one" ); assert( code == 1 ); 1294 } 1295 while( m_pcBitstream->getNumBitsRead() % 8 != 0 ) 1296 { 1297 READ_FLAG( code, "bit_equal_to_zero" ); assert( code == 0 ); 1298 } 1299 } 1438 } 1439 #endif 1440 1300 1441 1301 1442 #if SVC_EXTENSION 1302 1443 #if LAYERS_NOT_PRESENT_SEI 1303 Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps )1444 Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps, std::ostream *pDecodedMessageOutputStream) 1304 1445 { 1305 1446 UInt uiCode; 1306 1447 UInt i = 0; 1307 1448 1308 READ_UVLC(uiCode, "lp_sei_active_vps_id" ); sei.m_activeVpsId = uiCode;1449 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "lp_sei_active_vps_id" ); sei.m_activeVpsId = uiCode; 1309 1450 assert(vps->getVPSId() == sei.m_activeVpsId); 1310 1451 sei.m_vpsMaxLayers = vps->getMaxLayers(); 1311 1452 for (; i < sei.m_vpsMaxLayers; i++) 1312 1453 { 1313 READ_FLAG(uiCode, "layer_not_present_flag" ); sei.m_layerNotPresentFlag[i] = uiCode ? true : false;1454 sei_read_flag( pDecodedMessageOutputStream, uiCode, "layer_not_present_flag" ); sei.m_layerNotPresentFlag[i] = uiCode ? true : false; 1314 1455 } 1315 1456 for (; i < MAX_LAYERS; i++) … … 1317 1458 sei.m_layerNotPresentFlag[i] = false; 1318 1459 } 1319 xParseByteAlign(); 1320 } 1321 #endif 1460 } 1461 #endif 1462 1322 1463 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 1323 Void SEIReader::xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize )1464 Void SEIReader::xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 1324 1465 { 1325 1466 UInt uiCode; 1326 1467 1327 READ_FLAG(uiCode, "il_all_tiles_exact_sample_value_match_flag" ); sei.m_ilAllTilesExactSampleValueMatchFlag = uiCode;1328 READ_FLAG(uiCode, "il_one_tile_per_tile_set_flag" ); sei.m_ilOneTilePerTileSetFlag = uiCode;1468 sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_all_tiles_exact_sample_value_match_flag" ); sei.m_ilAllTilesExactSampleValueMatchFlag = uiCode; 1469 sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_one_tile_per_tile_set_flag" ); sei.m_ilOneTilePerTileSetFlag = uiCode; 1329 1470 if( !sei.m_ilOneTilePerTileSetFlag ) 1330 1471 { 1331 READ_UVLC(uiCode, "il_num_sets_in_message_minus1" ); sei.m_ilNumSetsInMessageMinus1 = uiCode;1472 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_num_sets_in_message_minus1" ); sei.m_ilNumSetsInMessageMinus1 = uiCode; 1332 1473 if( sei.m_ilNumSetsInMessageMinus1 ) 1333 1474 { 1334 READ_FLAG(uiCode, "skipped_tile_set_present_flag" ); sei.m_skippedTileSetPresentFlag = uiCode;1475 sei_read_flag( pDecodedMessageOutputStream, uiCode, "skipped_tile_set_present_flag" ); sei.m_skippedTileSetPresentFlag = uiCode; 1335 1476 } 1336 1477 else … … 1341 1482 for( UInt i = 0; i < numSignificantSets; i++ ) 1342 1483 { 1343 READ_UVLC(uiCode, "ilcts_id" ); sei.m_ilctsId[i] = uiCode;1344 READ_UVLC(uiCode, "il_num_tile_rects_in_set_minus1" ) ;sei.m_ilNumTileRectsInSetMinus1[i] = uiCode;1484 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ilcts_id" ); sei.m_ilctsId[i] = uiCode; 1485 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_num_tile_rects_in_set_minus1" ) ;sei.m_ilNumTileRectsInSetMinus1[i] = uiCode; 1345 1486 for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ ) 1346 1487 { 1347 READ_UVLC(uiCode, "il_top_left_tile_index" ); sei.m_ilTopLeftTileIndex[i][j] = uiCode;1348 READ_UVLC(uiCode, "il_bottom_right_tile_index" ); sei.m_ilBottomRightTileIndex[i][j] = uiCode;1349 } 1350 READ_CODE(2, uiCode, "ilc_idc" ); sei.m_ilcIdc[i] = uiCode;1488 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_top_left_tile_index" ); sei.m_ilTopLeftTileIndex[i][j] = uiCode; 1489 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_bottom_right_tile_index" ); sei.m_ilBottomRightTileIndex[i][j] = uiCode; 1490 } 1491 sei_read_code( pDecodedMessageOutputStream, 2, uiCode, "ilc_idc" ); sei.m_ilcIdc[i] = uiCode; 1351 1492 if( sei.m_ilAllTilesExactSampleValueMatchFlag ) 1352 1493 { 1353 READ_FLAG(uiCode, "il_exact_sample_value_match_flag" ); sei.m_ilExactSampleValueMatchFlag[i] = uiCode;1494 sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_exact_sample_value_match_flag" ); sei.m_ilExactSampleValueMatchFlag[i] = uiCode; 1354 1495 } 1355 1496 } … … 1357 1498 else 1358 1499 { 1359 READ_CODE( 2, uiCode, "all_tiles_ilc_idc" ); sei.m_allTilesIlcIdc = uiCode; 1360 } 1361 1362 xParseByteAlign(); 1363 } 1364 #endif 1500 sei_read_code( pDecodedMessageOutputStream, 2, uiCode, "all_tiles_ilc_idc" ); sei.m_allTilesIlcIdc = uiCode; 1501 } 1502 } 1503 #endif 1504 1365 1505 #if SUB_BITSTREAM_PROPERTY_SEI 1366 1506 #if OLS_IDX_CHK 1367 Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, TComVPS *vps )1368 #else 1369 Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei )1507 Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, TComVPS *vps, std::ostream *pDecodedMessageOutputStream) 1508 #else 1509 Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, std::ostream *pDecodedMessageOutputStream) 1370 1510 #endif 1371 1511 { 1372 1512 UInt uiCode; 1373 READ_CODE(4, uiCode, "active_vps_id" ); sei.m_activeVpsId = uiCode;1374 READ_UVLC(uiCode, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreams = uiCode + 1;1513 sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "active_vps_id" ); sei.m_activeVpsId = uiCode; 1514 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreams = uiCode + 1; 1375 1515 1376 1516 for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ ) 1377 1517 { 1378 READ_CODE(2, uiCode, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = uiCode;1379 READ_UVLC(uiCode, "output_layer_set_idx_to_vps[i]" );1518 sei_read_code( pDecodedMessageOutputStream, 2, uiCode, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = uiCode; 1519 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "output_layer_set_idx_to_vps[i]" ); 1380 1520 #if OLS_IDX_CHK 1381 1521 // The value of output_layer_set_idx_to_vps[ i ] shall be in the range of 0 to NumOutputLayerSets − 1, inclusive. … … 1383 1523 #endif 1384 1524 sei.m_outputLayerSetIdxToVps[i] = uiCode; 1385 READ_CODE( 3, uiCode, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = uiCode; 1386 READ_CODE( 16, uiCode, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = uiCode; 1387 READ_CODE( 16, uiCode, "max_bit_rate[i]" ); sei.m_maxBitRate[i] = uiCode; 1388 } 1389 xParseByteAlign(); 1525 sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = uiCode; 1526 sei_read_code( pDecodedMessageOutputStream, 16, uiCode, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = uiCode; 1527 sei_read_code( pDecodedMessageOutputStream, 16, uiCode, "max_bit_rate[i]" ); sei.m_maxBitRate[i] = uiCode; 1528 } 1390 1529 } 1391 1530 #endif … … 1393 1532 #if O0164_MULTI_LAYER_HRD 1394 1533 #if LAYERS_NOT_PRESENT_SEI 1395 Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei )1396 #else 1397 Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting &nestingSei )1534 Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, std::ostream *pDecodedMessageOutputStream) 1535 #else 1536 Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting &nestingSei, std::ostream *pDecodedMessageOutputStream) 1398 1537 #endif 1399 1538 { 1400 1539 UInt uiCode; 1401 READ_UVLC(uiCode, "bsp_idx" ); sei.m_bspIdx = uiCode;1540 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bsp_idx" ); sei.m_bspIdx = uiCode; 1402 1541 1403 1542 // byte alignment … … 1405 1544 { 1406 1545 UInt code; 1407 READ_FLAG(code, "bsp_nesting_zero_bit" );1546 sei_read_flag( pDecodedMessageOutputStream, code, "bsp_nesting_zero_bit" ); 1408 1547 } 1409 1548 … … 1413 1552 #if NESTING_SEI_EXTENSIBILITY 1414 1553 Int numSeiMessages = 0; 1415 READ_UVLC(uiCode, "num_seis_in_bsp_minus1" ); assert( uiCode <= MAX_SEIS_IN_BSP_NESTING );1554 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_seis_in_bsp_minus1" ); assert( uiCode <= MAX_SEIS_IN_BSP_NESTING ); 1416 1555 numSeiMessages = uiCode; 1417 1556 for(Int i = 0; i < numSeiMessages; i++) 1418 1557 { 1419 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &nestingSei, &sei);1558 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream, &nestingSei, &sei); 1420 1559 } 1421 1560 #else 1422 1561 do { 1423 1562 #if LAYERS_NOT_PRESENT_SEI 1424 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &nestingSei, &sei);1425 #else 1426 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, &nestingSei);1563 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream, &nestingSei, &sei); 1564 #else 1565 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream, &nestingSei); 1427 1566 #endif 1428 1567 } while (m_pcBitstream->getNumBitsLeft() > 8); … … 1430 1569 } 1431 1570 1432 Void SEIReader::xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei )1571 Void SEIReader::xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei, std::ostream *pDecodedMessageOutputStream) 1433 1572 { 1434 1573 assert(vps->getVpsVuiPresentFlag()); … … 1463 1602 for(UInt i = 0; i < maxValues; i++) 1464 1603 { 1465 READ_CODE(syntaxElemLen[i], uiCode, "nal_initial_arrival_delay[i]" ); sei.m_nalInitialArrivalDelay[i] = uiCode;1604 sei_read_code( pDecodedMessageOutputStream, syntaxElemLen[i], uiCode, "nal_initial_arrival_delay[i]" ); sei.m_nalInitialArrivalDelay[i] = uiCode; 1466 1605 } 1467 1606 } … … 1470 1609 for(UInt i = 0; i < maxValues; i++) 1471 1610 { 1472 READ_CODE(syntaxElemLen[i], uiCode, "vcl_initial_arrival_delay[i]" ); sei.m_vclInitialArrivalDelay[i] = uiCode;1611 sei_read_code( pDecodedMessageOutputStream, syntaxElemLen[i], uiCode, "vcl_initial_arrival_delay[i]" ); sei.m_vclInitialArrivalDelay[i] = uiCode; 1473 1612 } 1474 1613 } … … 1503 1642 for(UInt i = 0; i < schedCombCnt; i++) 1504 1643 { 1505 READ_CODE(len, uiCode, "nal_initial_arrival_delay" ); sei.m_nalInitialArrivalDelay[i] = uiCode;1644 sei_read_code( pDecodedMessageOutputStream, len, uiCode, "nal_initial_arrival_delay" ); sei.m_nalInitialArrivalDelay[i] = uiCode; 1506 1645 } 1507 1646 } … … 1514 1653 for(UInt i = 0; i < schedCombCnt; i++) 1515 1654 { 1516 READ_CODE(len, uiCode, "vcl_initial_arrival_delay" ); sei.m_vclInitialArrivalDelay[i] = uiCode;1655 sei_read_code( pDecodedMessageOutputStream, len, uiCode, "vcl_initial_arrival_delay" ); sei.m_vclInitialArrivalDelay[i] = uiCode; 1517 1656 } 1518 1657 } … … 1521 1660 1522 1661 #if !REMOVE_BSP_HRD_SEI 1523 Void SEIReader::xParseSEIBspHrd(SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei )1662 Void SEIReader::xParseSEIBspHrd(SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei, std::ostream *pDecodedMessageOutputStream) 1524 1663 { 1525 1664 UInt uiCode; 1526 READ_UVLC(uiCode, "sei_num_bsp_hrd_parameters_minus1" ); sei.m_seiNumBspHrdParametersMinus1 = uiCode;1665 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sei_num_bsp_hrd_parameters_minus1" ); sei.m_seiNumBspHrdParametersMinus1 = uiCode; 1527 1666 for (UInt i = 0; i <= sei.m_seiNumBspHrdParametersMinus1; i++) 1528 1667 { 1529 1668 if (i > 0) 1530 1669 { 1531 READ_FLAG(uiCode, "sei_bsp_cprms_present_flag" ); sei.m_seiBspCprmsPresentFlag[i] = uiCode;1670 sei_read_flag( pDecodedMessageOutputStream, uiCode, "sei_bsp_cprms_present_flag" ); sei.m_seiBspCprmsPresentFlag[i] = uiCode; 1532 1671 } 1533 1672 xParseHrdParameters(sei.hrd, i==0 ? 1 : sei.m_seiBspCprmsPresentFlag[i], nestingSei.m_nestingMaxTemporalIdPlus1[0]-1); … … 1536 1675 { 1537 1676 UInt lsIdx = nestingSei.m_nestingOpIdx[h]; 1538 READ_UVLC(uiCode, "num_sei_bitstream_partitions_minus1[i]"); sei.m_seiNumBitstreamPartitionsMinus1[lsIdx] = uiCode;1677 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_sei_bitstream_partitions_minus1[i]"); sei.m_seiNumBitstreamPartitionsMinus1[lsIdx] = uiCode; 1539 1678 #if HRD_BPB 1540 1679 Int chkPart=0; … … 1560 1699 { 1561 1700 #endif 1562 READ_FLAG(uiCode, "sei_layer_in_bsp_flag[lsIdx][i][j]" ); sei.m_seiLayerInBspFlag[lsIdx][i][j] = uiCode;1701 sei_read_flag( pDecodedMessageOutputStream, uiCode, "sei_layer_in_bsp_flag[lsIdx][i][j]" ); sei.m_seiLayerInBspFlag[lsIdx][i][j] = uiCode; 1563 1702 } 1564 1703 #if !HRD_BPB … … 1588 1727 #endif 1589 1728 1590 READ_UVLC(uiCode, "sei_num_bsp_sched_combinations_minus1[i]"); sei.m_seiNumBspSchedCombinationsMinus1[lsIdx] = uiCode;1729 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sei_num_bsp_sched_combinations_minus1[i]"); sei.m_seiNumBspSchedCombinationsMinus1[lsIdx] = uiCode; 1591 1730 for (i = 0; i <= sei.m_seiNumBspSchedCombinationsMinus1[lsIdx]; i++) 1592 1731 { 1593 1732 for (UInt j = 0; j <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; j++) 1594 1733 { 1595 READ_UVLC(uiCode, "sei_bsp_comb_hrd_idx[lsIdx][i][j]"); sei.m_seiBspCombHrdIdx[lsIdx][i][j] = uiCode;1734 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sei_bsp_comb_hrd_idx[lsIdx][i][j]"); sei.m_seiBspCombHrdIdx[lsIdx][i][j] = uiCode; 1596 1735 #if HRD_BPB 1597 1736 assert(uiCode <= sei.m_seiNumBspHrdParametersMinus1); 1598 1737 #endif 1599 READ_UVLC(uiCode, "sei_bsp_comb_sched_idx[lsIdx][i][j]"); sei.m_seiBspCombScheddx[lsIdx][i][j] = uiCode;1738 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sei_bsp_comb_sched_idx[lsIdx][i][j]"); sei.m_seiBspCombScheddx[lsIdx][i][j] = uiCode; 1600 1739 #if HRD_BPB 1601 1740 assert(uiCode <= sei.hrd->getCpbCntMinus1( sps->getMaxTLayers()-1 )); … … 1608 1747 #endif 1609 1748 1610 Void SEIReader::xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 )1749 Void SEIReader::xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1, std::ostream *pDecodedMessageOutputStream) 1611 1750 { 1612 1751 UInt uiCode; 1613 1752 if( commonInfPresentFlag ) 1614 1753 { 1615 READ_FLAG(uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false );1616 READ_FLAG(uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false );1754 sei_read_flag( pDecodedMessageOutputStream, uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); 1755 sei_read_flag( pDecodedMessageOutputStream, uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); 1617 1756 if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) 1618 1757 { 1619 READ_FLAG(uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false );1758 sei_read_flag( pDecodedMessageOutputStream, uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); 1620 1759 if( hrd->getSubPicCpbParamsPresentFlag() ) 1621 1760 { 1622 READ_CODE(8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode );1623 READ_CODE(5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode );1624 READ_FLAG(uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false );1625 READ_CODE(5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode );1626 } 1627 READ_CODE(4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode );1628 READ_CODE(4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode );1761 sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); 1762 sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); 1763 sei_read_flag( pDecodedMessageOutputStream, uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); 1764 sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); 1765 } 1766 sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); 1767 sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); 1629 1768 if( hrd->getSubPicCpbParamsPresentFlag() ) 1630 1769 { 1631 READ_CODE(4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode );1632 } 1633 READ_CODE(5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode );1634 READ_CODE(5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode );1635 READ_CODE(5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode );1770 sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); 1771 } 1772 sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); 1773 sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); 1774 sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); 1636 1775 } 1637 1776 } … … 1639 1778 for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) 1640 1779 { 1641 READ_FLAG(uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false );1780 sei_read_flag( pDecodedMessageOutputStream, uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); 1642 1781 if( !hrd->getFixedPicRateFlag( i ) ) 1643 1782 { 1644 READ_FLAG(uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false );1783 sei_read_flag( pDecodedMessageOutputStream, uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); 1645 1784 } 1646 1785 else … … 1652 1791 if( hrd->getFixedPicRateWithinCvsFlag( i ) ) 1653 1792 { 1654 READ_UVLC(uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode );1793 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); 1655 1794 } 1656 1795 else 1657 1796 { 1658 READ_FLAG(uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false );1797 sei_read_flag( pDecodedMessageOutputStream, uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); 1659 1798 } 1660 1799 if (!hrd->getLowDelayHrdFlag( i )) 1661 1800 { 1662 READ_UVLC(uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode );1801 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); 1663 1802 } 1664 1803 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) … … 1669 1808 for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) 1670 1809 { 1671 READ_UVLC(uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode );1672 READ_UVLC(uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode );1810 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); 1811 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); 1673 1812 if( hrd->getSubPicCpbParamsPresentFlag() ) 1674 1813 { 1675 READ_UVLC(uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode );1676 READ_UVLC(uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode );1814 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); 1815 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); 1677 1816 } 1678 READ_FLAG(uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false );1817 sei_read_flag( pDecodedMessageOutputStream, uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); 1679 1818 } 1680 1819 } … … 1687 1826 1688 1827 #if LAYERS_NOT_PRESENT_SEI 1689 Void SEIReader::xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps )1690 #else 1691 Void SEIReader::xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComSPS *sps )1828 Void SEIReader::xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 1829 #else 1830 Void SEIReader::xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 1692 1831 #endif 1693 1832 { … … 1695 1834 SEIMessages seis; 1696 1835 1697 READ_FLAG(uiCode, "ols_flag"); sei.m_olsFlag = uiCode;1698 READ_UVLC(uiCode, "num_ols_indices_minus1"); sei.m_numOlsIndicesMinus1 = uiCode;1836 sei_read_flag( pDecodedMessageOutputStream, uiCode, "ols_flag"); sei.m_olsFlag = uiCode; 1837 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_ols_indices_minus1"); sei.m_numOlsIndicesMinus1 = uiCode; 1699 1838 1700 1839 for (Int i = 0; i <= sei.m_numOlsIndicesMinus1; i++) 1701 1840 { 1702 READ_UVLC(uiCode, "ols_idx[i]"); sei.m_olsIdx[i] = uiCode;1841 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ols_idx[i]"); sei.m_olsIdx[i] = uiCode; 1703 1842 } 1704 1843 … … 1707 1846 { 1708 1847 UInt code; 1709 READ_FLAG(code, "ols_nesting_zero_bit");1848 sei_read_flag( pDecodedMessageOutputStream, code, "ols_nesting_zero_bit"); 1710 1849 } 1711 1850 … … 1716 1855 #if O0164_MULTI_LAYER_HRD 1717 1856 #if LAYERS_NOT_PRESENT_SEI 1718 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps );1719 #else 1720 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps );1857 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream); 1858 #else 1859 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream); 1721 1860 #endif 1722 1861 #else 1723 1862 #if LAYERS_NOT_PRESENT_SEI 1724 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps );1725 #else 1726 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps );1863 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream); 1864 #else 1865 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream); 1727 1866 #endif 1728 1867 #endif … … 1731 1870 } 1732 1871 1733 Void SEIReader::xParseSEIVPSRewriting(SEIVPSRewriting &sei )1872 Void SEIReader::xParseSEIVPSRewriting(SEIVPSRewriting &sei, std::ostream *pDecodedMessageOutputStream ) 1734 1873 { 1735 1874 } … … 1738 1877 1739 1878 #if Q0096_OVERLAY_SEI 1740 Void SEIReader::xParseSEIOverlayInfo(SEIOverlayInfo& sei, UInt /*payloadSize*/){ 1879 Void SEIReader::xParseSEIOverlayInfo(SEIOverlayInfo& sei, UInt /*payloadSize*/, std::ostream *pDecodedMessageOutputStream) 1880 { 1741 1881 Int i, j; 1742 1882 UInt val; 1743 READ_FLAG(val, "overlay_info_cancel_flag" ); sei.m_overlayInfoCancelFlag = val;1883 sei_read_flag( pDecodedMessageOutputStream, val, "overlay_info_cancel_flag" ); sei.m_overlayInfoCancelFlag = val; 1744 1884 if ( !sei.m_overlayInfoCancelFlag ) 1745 1885 { 1746 READ_UVLC(val, "overlay_content_aux_id_minus128" ); sei.m_overlayContentAuxIdMinus128 = val;1747 READ_UVLC(val, "overlay_label_aux_id_minus128" ); sei.m_overlayLabelAuxIdMinus128 = val;1748 READ_UVLC(val, "overlay_alpha_aux_id_minus128" ); sei.m_overlayAlphaAuxIdMinus128 = val;1749 READ_UVLC(val, "overlay_element_label_value_length_minus8" ); sei.m_overlayElementLabelValueLengthMinus8 = val;1750 READ_UVLC(val, "num_overlays_minus1" ); sei.m_numOverlaysMinus1 = val;1886 sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_content_aux_id_minus128" ); sei.m_overlayContentAuxIdMinus128 = val; 1887 sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_label_aux_id_minus128" ); sei.m_overlayLabelAuxIdMinus128 = val; 1888 sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_alpha_aux_id_minus128" ); sei.m_overlayAlphaAuxIdMinus128 = val; 1889 sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_element_label_value_length_minus8" ); sei.m_overlayElementLabelValueLengthMinus8 = val; 1890 sei_read_uvlc( pDecodedMessageOutputStream, val, "num_overlays_minus1" ); sei.m_numOverlaysMinus1 = val; 1751 1891 1752 1892 assert( sei.m_numOverlaysMinus1 < MAX_OVERLAYS ); … … 1763 1903 for ( i=0 ; i<=sei.m_numOverlaysMinus1 ; i++ ) 1764 1904 { 1765 READ_UVLC(val, "overlay_idx" ); sei.m_overlayIdx[i] = val;1766 READ_FLAG(val, "language_overlay_present_flag" ); sei.m_languageOverlayPresentFlag[i] = val;1767 READ_CODE(6, val, "overlay_content_layer_id"); sei.m_overlayContentLayerId[i] = val;1768 READ_FLAG(val, "overlay_label_present_flag" ); sei.m_overlayLabelPresentFlag[i] = val;1905 sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_idx" ); sei.m_overlayIdx[i] = val; 1906 sei_read_flag( pDecodedMessageOutputStream, val, "language_overlay_present_flag" ); sei.m_languageOverlayPresentFlag[i] = val; 1907 sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_content_layer_id"); sei.m_overlayContentLayerId[i] = val; 1908 sei_read_flag( pDecodedMessageOutputStream, val, "overlay_label_present_flag" ); sei.m_overlayLabelPresentFlag[i] = val; 1769 1909 if ( sei.m_overlayLabelPresentFlag[i] ) 1770 1910 { 1771 READ_CODE(6, val, "overlay_label_layer_id"); sei.m_overlayLabelLayerId[i] = val;1772 } 1773 READ_FLAG(val, "overlay_alpha_present_flag" ); sei.m_overlayAlphaPresentFlag[i] = val;1911 sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_label_layer_id"); sei.m_overlayLabelLayerId[i] = val; 1912 } 1913 sei_read_flag( pDecodedMessageOutputStream, val, "overlay_alpha_present_flag" ); sei.m_overlayAlphaPresentFlag[i] = val; 1774 1914 if ( sei.m_overlayAlphaPresentFlag[i] ) 1775 1915 { 1776 READ_CODE(6, val, "overlay_alpha_layer_id"); sei.m_overlayAlphaLayerId[i] = val;1916 sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_alpha_layer_id"); sei.m_overlayAlphaLayerId[i] = val; 1777 1917 } 1778 1918 if ( sei.m_overlayLabelPresentFlag[i] ) 1779 1919 { 1780 READ_UVLC(val, "num_overlay_elements_minus1"); sei.m_numOverlayElementsMinus1[i] = val;1920 sei_read_uvlc( pDecodedMessageOutputStream, val, "num_overlay_elements_minus1"); sei.m_numOverlayElementsMinus1[i] = val; 1781 1921 assert( sei.m_numOverlayElementsMinus1[i] < MAX_OVERLAY_ELEMENTS ); 1782 1922 sei.m_overlayElementLabelMin[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); … … 1784 1924 for ( j=0 ; j<=sei.m_numOverlayElementsMinus1[i] ; j++ ) 1785 1925 { 1786 READ_CODE(sei.m_overlayElementLabelValueLengthMinus8 + 8, val, "overlay_element_label_min"); sei.m_overlayElementLabelMin[i][j] = val;1787 READ_CODE(sei.m_overlayElementLabelValueLengthMinus8 + 8, val, "overlay_element_label_max"); sei.m_overlayElementLabelMax[i][j] = val;1926 sei_read_code( pDecodedMessageOutputStream, sei.m_overlayElementLabelValueLengthMinus8 + 8, val, "overlay_element_label_min"); sei.m_overlayElementLabelMin[i][j] = val; 1927 sei_read_code( pDecodedMessageOutputStream, sei.m_overlayElementLabelValueLengthMinus8 + 8, val, "overlay_element_label_max"); sei.m_overlayElementLabelMax[i][j] = val; 1788 1928 } 1789 1929 } … … 1797 1937 while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) 1798 1938 { 1799 READ_FLAG(val, "overlay_zero_bit" );1939 sei_read_flag( pDecodedMessageOutputStream, val, "overlay_zero_bit" ); 1800 1940 assert( val==0 ); 1801 1941 } … … 1835 1975 } 1836 1976 } 1837 READ_FLAG( val, "overlay_info_persistence_flag" ); sei.m_overlayInfoPersistenceFlag = val; 1838 } 1839 xParseByteAlign(); 1840 } 1841 #endif 1977 sei_read_flag( pDecodedMessageOutputStream, val, "overlay_info_persistence_flag" ); sei.m_overlayInfoPersistenceFlag = val; 1978 } 1979 } 1980 #endif 1981 1982 #if P0138_USE_ALT_CPB_PARAMS_FLAG 1983 /** 1984 * Check if SEI message contains payload extension 1985 */ 1986 Bool SEIReader::xPayloadExtensionPresent() 1987 { 1988 Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); 1989 Bool payloadExtensionPresent = false; 1990 1991 if (payloadBitsRemaining > 8) 1992 { 1993 payloadExtensionPresent = true; 1994 } 1995 else 1996 { 1997 Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); 1998 while (payloadBitsRemaining && (finalBits & 1) == 0) 1999 { 2000 payloadBitsRemaining--; 2001 finalBits >>= 1; 2002 } 2003 payloadBitsRemaining--; 2004 if (payloadBitsRemaining > 0) 2005 { 2006 payloadExtensionPresent = true; 2007 } 2008 } 2009 2010 return payloadExtensionPresent; 2011 } 2012 #endif 2013 2014 #if Q0189_TMVP_CONSTRAINTS 2015 Void SEIReader::xParseSEITMVPConstraints (SEITMVPConstrains& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 2016 { 2017 UInt uiCode; 2018 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "prev_pics_not_used_flag" ); sei.prev_pics_not_used_flag = uiCode; 2019 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "no_intra_layer_col_pic_flag" ); sei.no_intra_layer_col_pic_flag = uiCode; 2020 } 2021 #endif 2022 2023 #if Q0247_FRAME_FIELD_INFO 2024 Void SEIReader::xParseSEIFrameFieldInfo (SEIFrameFieldInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 2025 { 2026 UInt code; 2027 sei_read_code( pDecodedMessageOutputStream, 4, code, "ffinfo_pic_struct" ); sei.m_ffinfo_picStruct = code; 2028 sei_read_code( pDecodedMessageOutputStream, 2, code, "ffinfo_source_scan_type" ); sei.m_ffinfo_sourceScanType = code; 2029 sei_read_flag( pDecodedMessageOutputStream, code, "ffinfo_duplicate_flag" ); sei.m_ffinfo_duplicateFlag = ( code == 1 ? true : false ); 2030 } 2031 #endif 2032 1842 2033 1843 2034 #endif //SVC_EXTENSION -
branches/SHM-upgrade/source/Lib/TLibDecoder/SEIread.h
r912 r916 57 57 virtual ~SEIReader() {}; 58 58 #if LAYERS_NOT_PRESENT_SEI 59 Void parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps );59 Void parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 60 60 #else 61 Void parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps );61 Void parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 62 62 #endif 63 63 protected: 64 64 #if O0164_MULTI_LAYER_HRD 65 65 #if LAYERS_NOT_PRESENT_SEI 66 Void xReadSEImessage (SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting *nestingSei=NULL, const SEIBspNesting *bspNestingSei=NULL);66 Void xReadSEImessage (SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream, const SEIScalableNesting *nestingSei=NULL, const SEIBspNesting *bspNestingSei=NULL); 67 67 #else 68 Void xReadSEImessage (SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting *nestingSei=NULL);68 Void xReadSEImessage (SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, , std::ostream *pDecodedMessageOutputStream, const SEIScalableNesting *nestingSei=NULL); 69 69 #endif 70 70 #else 71 71 #if LAYERS_NOT_PRESENT_SEI 72 Void xReadSEImessage (SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps);72 Void xReadSEImessage (SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 73 73 #else 74 Void xReadSEImessage (SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps);74 Void xReadSEImessage (SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 75 75 #endif 76 #endif 77 Void xParseSEIuserDataUnregistered (SEIuserDataUnregistered &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 78 Void xParseSEIActiveParameterSets (SEIActiveParameterSets &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 79 Void xParseSEIDecodedPictureHash (SEIDecodedPictureHash& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 80 #if VPS_VUI_BSP_HRD_PARAMS 81 Void xParseSEIDecodingUnitInfo (SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps, std::ostream *pDecodedMessageOutputStream); 82 Void xParseSEIBufferingPeriod (SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps, std::ostream *pDecodedMessageOutputStream); 83 Void xParseSEIPictureTiming (SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps, std::ostream *pDecodedMessageOutputStream); 84 #else 85 Void xParseSEIDecodingUnitInfo (SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 86 Void xParseSEIBufferingPeriod (SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 87 Void xParseSEIPictureTiming (SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 88 #endif 89 Void xParseSEIRecoveryPoint (SEIRecoveryPoint& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 90 Void xParseSEIFramePacking (SEIFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 91 Void xParseSEISegmentedRectFramePacking (SEISegmentedRectFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 92 Void xParseSEIDisplayOrientation (SEIDisplayOrientation &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 93 Void xParseSEITemporalLevel0Index (SEITemporalLevel0Index &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 94 Void xParseSEIRegionRefreshInfo (SEIGradualDecodingRefreshInfo &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 95 Void xParseSEINoDisplay (SEINoDisplay &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 96 Void xParseSEIToneMappingInfo (SEIToneMappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 97 Void xParseSEISOPDescription (SEISOPDescription &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 98 #if !LAYERS_NOT_PRESENT_SEI 99 Void xParseSEIScalableNesting (SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 100 #endif 101 Void xParseSEITempMotionConstraintsTileSets (SEITempMotionConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 102 Void xParseSEITimeCode (SEITimeCode& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 103 Void xParseSEIChromaSamplingFilterHint (SEIChromaSamplingFilterHint& sei, UInt payloadSize/*,TComSPS* */, std::ostream *pDecodedMessageOutputStream); 104 Void xParseSEIKneeFunctionInfo (SEIKneeFunctionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 105 Void xParseSEIMasteringDisplayColourVolume (SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 106 107 Void sei_read_code(std::ostream *pOS, UInt uiLength, UInt& ruiCode, const Char *pSymbolName); 108 Void sei_read_uvlc(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName); 109 Void sei_read_svlc(std::ostream *pOS, Int& ruiCode, const Char *pSymbolName); 110 Void sei_read_flag(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName); 111 112 #if Q0074_COLOUR_REMAPPING_SEI 113 Void xParseSEIColourRemappingInfo (SEIColourRemappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 114 #endif 115 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 116 Void xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 117 #endif 118 #if SUB_BITSTREAM_PROPERTY_SEI 119 #if OLS_IDX_CHK 120 Void xParseSEISubBitstreamProperty (SEISubBitstreamProperty &sei, TComVPS *vps, std::ostream *pDecodedMessageOutputStream); 121 #else 122 Void xParseSEISubBitstreamProperty (SEISubBitstreamProperty &sei, std::ostream *pDecodedMessageOutputStream); 123 #endif 124 #endif 125 #if LAYERS_NOT_PRESENT_SEI 126 Void xParseSEILayersNotPresent (SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps ,std::ostream *pDecodedMessageOutputStream); 127 Void xParseSEIScalableNesting (SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 128 #endif 129 #if O0164_MULTI_LAYER_HRD 130 #if LAYERS_NOT_PRESENT_SEI 131 Void xParseSEIBspNesting (SEIBspNesting &sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, std::ostream *pDecodedMessageOutputStream); 132 #else 133 Void xParseSEIBspNesting (SEIBspNesting &sei, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting &nestingSei ,std::ostream *pDecodedMessageOutputStream); 134 #endif 135 Void xParseSEIBspInitialArrivalTime (SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei, std::ostream *pDecodedMessageOutputStream); 136 #if !REMOVE_BSP_HRD_SEI 137 Void xParseSEIBspHrd(SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei, std::ostream *pDecodedMessageOutputStream); 138 #endif 139 Void xParseHrdParameters (TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1, std::ostream *pDecodedMessageOutputStream); 140 #endif 141 #if Q0078_ADD_LAYER_SETS 142 #if LAYERS_NOT_PRESENT_SEI 143 Void xParseSEIOutputLayerSetNesting (SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 144 #else 145 Void xParseSEIOutputLayerSetNesting (SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 146 #endif 147 Void xParseSEIVPSRewriting (SEIVPSRewriting &sei, std::ostream *pDecodedMessageOutputStream); 148 #endif 149 150 #if Q0189_TMVP_CONSTRAINTS 151 Void xParseSEITMVPConstraints (SEITMVPConstrains& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 152 #endif 153 #if Q0247_FRAME_FIELD_INFO 154 Void xParseSEIFrameFieldInfo (SEIFrameFieldInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 155 #endif 156 #if Q0096_OVERLAY_SEI 157 Void xParseSEIOverlayInfo (SEIOverlayInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 76 158 #endif 77 159 #if P0138_USE_ALT_CPB_PARAMS_FLAG 78 160 Bool xPayloadExtensionPresent (); 79 161 #endif 80 Void xParseSEIuserDataUnregistered (SEIuserDataUnregistered &sei, UInt payloadSize);81 Void xParseSEIActiveParameterSets (SEIActiveParameterSets &sei, UInt payloadSize);82 Void xParseSEIDecodedPictureHash (SEIDecodedPictureHash& sei, UInt payloadSize);83 #if VPS_VUI_BSP_HRD_PARAMS84 Void xParseSEIDecodingUnitInfo (SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps);85 Void xParseSEIBufferingPeriod (SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps);86 Void xParseSEIPictureTiming (SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps);87 #else88 Void xParseSEIDecodingUnitInfo (SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps);89 Void xParseSEIBufferingPeriod (SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps);90 Void xParseSEIPictureTiming (SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps);91 #endif92 Void xParseSEIRecoveryPoint (SEIRecoveryPoint& sei, UInt payloadSize);93 Void xParseSEIFramePacking (SEIFramePacking& sei, UInt payloadSize);94 Void xParseSEIDisplayOrientation (SEIDisplayOrientation &sei, UInt payloadSize);95 Void xParseSEITemporalLevel0Index (SEITemporalLevel0Index &sei, UInt payloadSize);96 Void xParseSEIGradualDecodingRefreshInfo (SEIGradualDecodingRefreshInfo &sei, UInt payloadSize);97 Void xParseSEIToneMappingInfo (SEIToneMappingInfo& sei, UInt payloadSize);98 #if P0050_KNEE_FUNCTION_SEI99 Void xParseSEIKneeFunctionInfo (SEIKneeFunctionInfo& sei, UInt payloadSize);100 #endif101 #if Q0074_COLOUR_REMAPPING_SEI102 Void xParseSEIColourRemappingInfo (SEIColourRemappingInfo& sei, UInt payloadSize);103 #endif104 Void xParseSEISOPDescription (SEISOPDescription &sei, UInt payloadSize);105 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI106 Void xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize);107 #endif108 #if SUB_BITSTREAM_PROPERTY_SEI109 #if OLS_IDX_CHK110 Void xParseSEISubBitstreamProperty (SEISubBitstreamProperty &sei, TComVPS *vps);111 #else112 Void xParseSEISubBitstreamProperty (SEISubBitstreamProperty &sei);113 #endif114 #endif115 #if LAYERS_NOT_PRESENT_SEI116 Void xParseSEILayersNotPresent (SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps);117 Void xParseSEIScalableNesting (SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps);118 #else119 Void xParseSEIScalableNesting (SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps);120 #endif121 #if O0164_MULTI_LAYER_HRD122 #if LAYERS_NOT_PRESENT_SEI123 Void xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei);124 #else125 Void xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting &nestingSei);126 #endif127 Void xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei);128 #if !REMOVE_BSP_HRD_SEI129 Void xParseSEIBspHrd(SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei);130 #endif131 Void xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1);132 #endif133 #if Q0078_ADD_LAYER_SETS134 #if LAYERS_NOT_PRESENT_SEI135 Void xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps);136 #else137 Void xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComSPS *sps);138 #endif139 Void xParseSEIVPSRewriting(SEIVPSRewriting &sei);140 #endif141 142 #if Q0189_TMVP_CONSTRAINTS143 Void xParseSEITMVPConstraints (SEITMVPConstrains& sei, UInt payloadSize);144 #endif145 #if Q0247_FRAME_FIELD_INFO146 Void xParseSEIFrameFieldInfo (SEIFrameFieldInfo& sei, UInt payloadSize);147 #endif148 #if Q0096_OVERLAY_SEI149 Void xParseSEIOverlayInfo (SEIOverlayInfo& sei, UInt payloadSize);150 #endif151 Void xParseByteAlign();152 162 }; 153 163 -
branches/SHM-upgrade/source/Lib/TLibDecoder/SyntaxElementParser.cpp
r912 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 48 48 Void SyntaxElementParser::xReadCodeTr (UInt length, UInt& rValue, const Char *pSymbolName) 49 49 { 50 #if RExt__DECODER_DEBUG_BIT_STATISTICS 51 xReadCode (length, rValue, pSymbolName); 52 #else 50 53 xReadCode (length, rValue); 54 #endif 51 55 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 52 56 if (length < 10) 53 57 { 54 fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue ); 58 fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue ); 55 59 } 56 60 else … … 63 67 Void SyntaxElementParser::xReadUvlcTr (UInt& rValue, const Char *pSymbolName) 64 68 { 69 #if RExt__DECODER_DEBUG_BIT_STATISTICS 70 xReadUvlc (rValue, pSymbolName); 71 #else 65 72 xReadUvlc (rValue); 66 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 67 fprintf( g_hTrace, "%-50s ue(v) : %u\n", pSymbolName, rValue ); 73 #endif 74 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 75 fprintf( g_hTrace, "%-50s ue(v) : %u\n", pSymbolName, rValue ); 68 76 fflush ( g_hTrace ); 69 77 } … … 71 79 Void SyntaxElementParser::xReadSvlcTr (Int& rValue, const Char *pSymbolName) 72 80 { 73 xReadSvlc(rValue); 74 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 75 fprintf( g_hTrace, "%-50s se(v) : %d\n", pSymbolName, rValue ); 81 #if RExt__DECODER_DEBUG_BIT_STATISTICS 82 xReadSvlc (rValue, pSymbolName); 83 #else 84 xReadSvlc (rValue); 85 #endif 86 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 87 fprintf( g_hTrace, "%-50s se(v) : %d\n", pSymbolName, rValue ); 76 88 fflush ( g_hTrace ); 77 89 } … … 79 91 Void SyntaxElementParser::xReadFlagTr (UInt& rValue, const Char *pSymbolName) 80 92 { 81 xReadFlag(rValue); 82 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 83 fprintf( g_hTrace, "%-50s u(1) : %d\n", pSymbolName, rValue ); 93 #if RExt__DECODER_DEBUG_BIT_STATISTICS 94 xReadFlag (rValue, pSymbolName); 95 #else 96 xReadFlag (rValue); 97 #endif 98 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 99 fprintf( g_hTrace, "%-50s u(1) : %d\n", pSymbolName, rValue ); 84 100 fflush ( g_hTrace ); 85 101 } … … 101 117 // Protected member functions 102 118 // ==================================================================================================================== 103 119 #if RExt__DECODER_DEBUG_BIT_STATISTICS 120 Void SyntaxElementParser::xReadCode (UInt uiLength, UInt& ruiCode, const Char *pSymbolName) 121 #else 104 122 Void SyntaxElementParser::xReadCode (UInt uiLength, UInt& ruiCode) 123 #endif 105 124 { 106 125 assert ( uiLength > 0 ); 107 126 m_pcBitstream->read (uiLength, ruiCode); 108 } 109 127 #if RExt__DECODER_DEBUG_BIT_STATISTICS 128 TComCodingStatistics::IncrementStatisticEP(pSymbolName, uiLength, ruiCode); 129 #endif 130 } 131 132 #if RExt__DECODER_DEBUG_BIT_STATISTICS 133 Void SyntaxElementParser::xReadUvlc( UInt& ruiVal, const Char *pSymbolName) 134 #else 110 135 Void SyntaxElementParser::xReadUvlc( UInt& ruiVal) 136 #endif 111 137 { 112 138 UInt uiVal = 0; … … 114 140 UInt uiLength; 115 141 m_pcBitstream->read( 1, uiCode ); 142 #if RExt__DECODER_DEBUG_BIT_STATISTICS 143 UInt totalLen=1; 144 #endif 116 145 117 146 if( 0 == uiCode ) … … 128 157 129 158 uiVal += (1 << uiLength)-1; 159 #if RExt__DECODER_DEBUG_BIT_STATISTICS 160 totalLen+=uiLength+uiLength; 161 #endif 130 162 } 131 163 132 164 ruiVal = uiVal; 133 } 134 165 #if RExt__DECODER_DEBUG_BIT_STATISTICS 166 TComCodingStatistics::IncrementStatisticEP(pSymbolName, Int(totalLen), ruiVal); 167 #endif 168 } 169 170 #if RExt__DECODER_DEBUG_BIT_STATISTICS 171 Void SyntaxElementParser::xReadSvlc( Int& riVal, const Char *pSymbolName) 172 #else 135 173 Void SyntaxElementParser::xReadSvlc( Int& riVal) 174 #endif 136 175 { 137 176 UInt uiBits = 0; 138 177 m_pcBitstream->read( 1, uiBits ); 178 #if RExt__DECODER_DEBUG_BIT_STATISTICS 179 UInt totalLen=1; 180 #endif 139 181 if( 0 == uiBits ) 140 182 { … … 151 193 uiBits += (1 << uiLength); 152 194 riVal = ( uiBits & 1) ? -(Int)(uiBits>>1) : (Int)(uiBits>>1); 195 #if RExt__DECODER_DEBUG_BIT_STATISTICS 196 totalLen+=uiLength+uiLength; 197 #endif 153 198 } 154 199 else … … 156 201 riVal = 0; 157 202 } 158 } 159 203 #if RExt__DECODER_DEBUG_BIT_STATISTICS 204 TComCodingStatistics::IncrementStatisticEP(pSymbolName, Int(totalLen), riVal); 205 #endif 206 } 207 208 #if RExt__DECODER_DEBUG_BIT_STATISTICS 209 Void SyntaxElementParser::xReadFlag (UInt& ruiCode, const Char *pSymbolName) 210 #else 160 211 Void SyntaxElementParser::xReadFlag (UInt& ruiCode) 212 #endif 161 213 { 162 214 m_pcBitstream->read( 1, ruiCode ); 215 #if RExt__DECODER_DEBUG_BIT_STATISTICS 216 TComCodingStatistics::IncrementStatisticEP(pSymbolName, 1, Int(ruiCode)); 217 #endif 163 218 } 164 219 -
branches/SHM-upgrade/source/Lib/TLibDecoder/SyntaxElementParser.h
r912 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 57 57 #else 58 58 59 #if RExt__DECODER_DEBUG_BIT_STATISTICS 60 61 #define READ_CODE(length, code, name) xReadCode ( length, code, name ) 62 #define READ_UVLC( code, name) xReadUvlc ( code, name ) 63 #define READ_SVLC( code, name) xReadSvlc ( code, name ) 64 #define READ_FLAG( code, name) xReadFlag ( code, name ) 65 #if Q0096_OVERLAY_SEI 66 #define READ_STRING(bufSize, code, length, name) xReadStringTr ( bufSize, code, length, name ) 67 #endif 68 69 #else 70 59 71 #define READ_CODE(length, code, name) xReadCode ( length, code ) 60 72 #define READ_UVLC( code, name) xReadUvlc ( code ) … … 63 75 #if Q0096_OVERLAY_SEI 64 76 #define READ_STRING(bufSize, code, length, name) xReadString ( bufSize, code, length ) 77 #endif 65 78 #endif 66 79 … … 84 97 virtual ~SyntaxElementParser() {}; 85 98 99 #if RExt__DECODER_DEBUG_BIT_STATISTICS 100 Void xReadCode ( UInt length, UInt& val, const Char *pSymbolName ); 101 Void xReadUvlc ( UInt& val, const Char *pSymbolName ); 102 Void xReadSvlc ( Int& val, const Char *pSymbolName ); 103 Void xReadFlag ( UInt& val, const Char *pSymbolName ); 104 #if Q0096_OVERLAY_SEI 105 Void xReadStringTr(UInt bufSize, UChar *pValue, UInt& rLength, const Char *pSymbolName); 106 #endif 107 #else 86 108 Void xReadCode ( UInt length, UInt& val ); 87 109 Void xReadUvlc ( UInt& val ); … … 90 112 #if Q0096_OVERLAY_SEI 91 113 Void xReadString (UInt bufSize, UChar *val, UInt& length); 114 #endif 92 115 #endif 93 116 #if ENC_DEC_TRACE -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecBinCoder.h
r595 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 36 36 */ 37 37 38 #ifndef __TDEC _BIN_CODER__39 #define __TDEC _BIN_CODER__38 #ifndef __TDECBINCODER__ 39 #define __TDECBINCODER__ 40 40 41 41 #include "TLibCommon/ContextModel.h" 42 42 #include "TLibCommon/TComBitStream.h" 43 44 #if RExt__DECODER_DEBUG_BIT_STATISTICS 45 class TComCodingStatisticsClassType; 46 #endif 43 47 44 48 //! \ingroup TLibDecoder … … 55 59 virtual Void finish () = 0; 56 60 61 #if RExt__DECODER_DEBUG_BIT_STATISTICS 62 virtual Void decodeBin ( UInt& ruiBin, ContextModel& rcCtxModel, const class TComCodingStatisticsClassType &whichStat ) = 0; 63 virtual Void decodeBinEP ( UInt& ruiBin , const class TComCodingStatisticsClassType &whichStat ) = 0; 64 virtual Void decodeBinsEP ( UInt& ruiBins, Int numBins , const class TComCodingStatisticsClassType &whichStat ) = 0; 65 #else 57 66 virtual Void decodeBin ( UInt& ruiBin, ContextModel& rcCtxModel ) = 0; 58 67 virtual Void decodeBinEP ( UInt& ruiBin ) = 0; 59 68 virtual Void decodeBinsEP ( UInt& ruiBins, Int numBins ) = 0; 69 #endif 70 71 virtual Void align () = 0; 72 60 73 virtual Void decodeBinTrm ( UInt& ruiBin ) = 0; 61 62 virtual Void xReadPCMCode ( UInt uiLength, UInt& ruiCode) 74 75 virtual Void xReadPCMCode ( UInt uiLength, UInt& ruiCode) = 0; 63 76 64 77 virtual ~TDecBinIf() {} 65 78 66 virtual Void copyState ( TDecBinIf* pcTDecBinIf ) = 0; 67 virtual TDecBinCABAC* getTDecBinCABAC () { return 0; } 79 virtual Void copyState ( const TDecBinIf* pcTDecBinIf ) = 0; 80 virtual TDecBinCABAC* getTDecBinCABAC () { return 0; } 81 virtual const TDecBinCABAC* getTDecBinCABAC () const { return 0; } 68 82 }; 69 83 -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecBinCoderCABAC.cpp
r595 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 37 37 38 38 #include "TDecBinCoderCABAC.h" 39 #include "TLibCommon/Debug.h" 40 #if RExt__DECODER_DEBUG_BIT_STATISTICS 41 #include "TLibCommon/TComCodingStatistics.h" 42 #endif 39 43 40 44 //! \ingroup TLibDecoder … … 66 70 { 67 71 assert( m_pcTComBitstream->getNumBitsUntilByteAligned() == 0 ); 72 #if RExt__DECODER_DEBUG_BIT_STATISTICS 73 TComCodingStatistics::UpdateCABACStat(STATS__CABAC_INITIALISATION, 512, 510, 0); 74 #endif 68 75 m_uiRange = 510; 69 76 m_bitsNeeded = -8; … … 88 95 */ 89 96 Void 90 TDecBinCABAC::copyState( TDecBinIf* pcTDecBinIf )91 { 92 TDecBinCABAC* pcTDecBinCABAC = pcTDecBinIf->getTDecBinCABAC();97 TDecBinCABAC::copyState( const TDecBinIf* pcTDecBinIf ) 98 { 99 const TDecBinCABAC* pcTDecBinCABAC = pcTDecBinIf->getTDecBinCABAC(); 93 100 m_uiRange = pcTDecBinCABAC->m_uiRange; 94 101 m_uiValue = pcTDecBinCABAC->m_uiValue; … … 97 104 98 105 99 Void 100 TDecBinCABAC::decodeBin( UInt& ruiBin, ContextModel &rcCtxModel ) 101 { 106 107 #if RExt__DECODER_DEBUG_BIT_STATISTICS 108 Void TDecBinCABAC::decodeBin( UInt& ruiBin, ContextModel &rcCtxModel, const TComCodingStatisticsClassType &whichStat ) 109 #else 110 Void TDecBinCABAC::decodeBin( UInt& ruiBin, ContextModel &rcCtxModel ) 111 #endif 112 { 113 #ifdef DEBUG_CABAC_BINS 114 const UInt startingRange = m_uiRange; 115 #endif 116 102 117 UInt uiLPS = TComCABACTables::sm_aucLPSTable[ rcCtxModel.getState() ][ ( m_uiRange >> 6 ) - 4 ]; 103 118 m_uiRange -= uiLPS; 104 119 UInt scaledRange = m_uiRange << 7; 105 120 106 121 if( m_uiValue < scaledRange ) 107 122 { 108 123 // MPS path 109 124 ruiBin = rcCtxModel.getMps(); 125 #if RExt__DECODER_DEBUG_BIT_STATISTICS 126 TComCodingStatistics::UpdateCABACStat(whichStat, m_uiRange+uiLPS, m_uiRange, Int(ruiBin)); 127 #endif 110 128 rcCtxModel.updateMPS(); 111 112 if ( scaledRange >= ( 256 << 7 ) ) 113 { 114 return; 115 } 116 117 m_uiRange = scaledRange >> 6; 118 m_uiValue += m_uiValue; 119 120 if ( ++m_bitsNeeded == 0 ) 121 { 122 m_bitsNeeded = -8; 123 m_uiValue += m_pcTComBitstream->readByte(); 129 130 if ( scaledRange < ( 256 << 7 ) ) 131 { 132 m_uiRange = scaledRange >> 6; 133 m_uiValue += m_uiValue; 134 135 if ( ++m_bitsNeeded == 0 ) 136 { 137 m_bitsNeeded = -8; 138 m_uiValue += m_pcTComBitstream->readByte(); 139 } 124 140 } 125 141 } … … 127 143 { 128 144 // LPS path 145 ruiBin = 1 - rcCtxModel.getMps(); 146 #if RExt__DECODER_DEBUG_BIT_STATISTICS 147 TComCodingStatistics::UpdateCABACStat(whichStat, m_uiRange+uiLPS, uiLPS, Int(ruiBin)); 148 #endif 129 149 Int numBits = TComCABACTables::sm_aucRenormTable[ uiLPS >> 3 ]; 130 150 m_uiValue = ( m_uiValue - scaledRange ) << numBits; 131 151 m_uiRange = uiLPS << numBits; 132 ruiBin = 1 - rcCtxModel.getMps();133 152 rcCtxModel.updateLPS(); 134 153 135 154 m_bitsNeeded += numBits; 136 155 137 156 if ( m_bitsNeeded >= 0 ) 138 157 { … … 141 160 } 142 161 } 143 } 144 145 Void 146 TDecBinCABAC::decodeBinEP( UInt& ruiBin ) 147 { 162 163 #ifdef DEBUG_CABAC_BINS 164 if ((g_debugCounter + debugCabacBinWindow) >= debugCabacBinTargetLine) 165 std::cout << g_debugCounter << ": coding bin value " << ruiBin << ", range = [" << startingRange << "->" << m_uiRange << "]\n"; 166 167 if (g_debugCounter >= debugCabacBinTargetLine) 168 { 169 Char breakPointThis; 170 breakPointThis = 7; 171 } 172 if (g_debugCounter >= (debugCabacBinTargetLine + debugCabacBinWindow)) exit(0); 173 g_debugCounter++; 174 #endif 175 } 176 177 178 #if RExt__DECODER_DEBUG_BIT_STATISTICS 179 Void TDecBinCABAC::decodeBinEP( UInt& ruiBin, const TComCodingStatisticsClassType &whichStat ) 180 #else 181 Void TDecBinCABAC::decodeBinEP( UInt& ruiBin ) 182 #endif 183 { 184 if (m_uiRange == 256) 185 { 186 #if RExt__DECODER_DEBUG_BIT_STATISTICS 187 decodeAlignedBinsEP(ruiBin, 1, whichStat); 188 #else 189 decodeAlignedBinsEP(ruiBin, 1); 190 #endif 191 return; 192 } 193 148 194 m_uiValue += m_uiValue; 149 195 150 196 if ( ++m_bitsNeeded >= 0 ) 151 197 { … … 153 199 m_uiValue += m_pcTComBitstream->readByte(); 154 200 } 155 201 156 202 ruiBin = 0; 157 203 UInt scaledRange = m_uiRange << 7; … … 161 207 m_uiValue -= scaledRange; 162 208 } 163 } 164 209 #if RExt__DECODER_DEBUG_BIT_STATISTICS 210 TComCodingStatistics::IncrementStatisticEP(whichStat, 1, Int(ruiBin)); 211 #endif 212 } 213 214 #if RExt__DECODER_DEBUG_BIT_STATISTICS 215 Void TDecBinCABAC::decodeBinsEP( UInt& ruiBin, Int numBins, const TComCodingStatisticsClassType &whichStat ) 216 #else 165 217 Void TDecBinCABAC::decodeBinsEP( UInt& ruiBin, Int numBins ) 166 { 218 #endif 219 { 220 if (m_uiRange == 256) 221 { 222 #if RExt__DECODER_DEBUG_BIT_STATISTICS 223 decodeAlignedBinsEP(ruiBin, numBins, whichStat); 224 #else 225 decodeAlignedBinsEP(ruiBin, numBins); 226 #endif 227 return; 228 } 229 167 230 UInt bins = 0; 168 231 #if RExt__DECODER_DEBUG_BIT_STATISTICS 232 Int origNumBins=numBins; 233 #endif 169 234 while ( numBins > 8 ) 170 235 { 171 236 m_uiValue = ( m_uiValue << 8 ) + ( m_pcTComBitstream->readByte() << ( 8 + m_bitsNeeded ) ); 172 237 173 238 UInt scaledRange = m_uiRange << 15; 174 239 for ( Int i = 0; i < 8; i++ ) … … 184 249 numBins -= 8; 185 250 } 186 251 187 252 m_bitsNeeded += numBins; 188 253 m_uiValue <<= numBins; 189 254 190 255 if ( m_bitsNeeded >= 0 ) 191 256 { … … 193 258 m_bitsNeeded -= 8; 194 259 } 195 260 196 261 UInt scaledRange = m_uiRange << ( numBins + 7 ); 197 262 for ( Int i = 0; i < numBins; i++ ) … … 205 270 } 206 271 } 207 272 208 273 ruiBin = bins; 274 #if RExt__DECODER_DEBUG_BIT_STATISTICS 275 TComCodingStatistics::IncrementStatisticEP(whichStat, origNumBins, Int(ruiBin)); 276 #endif 277 } 278 279 Void TDecBinCABAC::align() 280 { 281 #if RExt__DECODER_DEBUG_BIT_STATISTICS 282 TComCodingStatistics::UpdateCABACStat(STATS__CABAC_EP_BIT_ALIGNMENT, m_uiRange, 256, 0); 283 #endif 284 m_uiRange = 256; 285 } 286 287 #if RExt__DECODER_DEBUG_BIT_STATISTICS 288 Void TDecBinCABAC::decodeAlignedBinsEP( UInt& ruiBins, Int numBins, const class TComCodingStatisticsClassType &whichStat ) 289 #else 290 Void TDecBinCABAC::decodeAlignedBinsEP( UInt& ruiBins, Int numBins ) 291 #endif 292 { 293 Int binsRemaining = numBins; 294 ruiBins = 0; 295 296 assert(m_uiRange == 256); //aligned decode only works when range = 256 297 298 while (binsRemaining > 0) 299 { 300 const UInt binsToRead = std::min<UInt>(binsRemaining, 8); //read bytes if able to take advantage of the system's byte-read function 301 const UInt binMask = (1 << binsToRead) - 1; 302 303 //The MSB of m_uiValue is known to be 0 because range is 256. Therefore: 304 // > The comparison against the symbol range of 128 is simply a test on the next-most-significant bit 305 // > "Subtracting" the symbol range if the decoded bin is 1 simply involves clearing that bit. 306 // 307 //As a result, the required bins are simply the <binsToRead> next-most-significant bits of m_uiValue 308 //(m_uiValue is stored MSB-aligned in a 16-bit buffer - hence the shift of 15) 309 // 310 // m_uiValue = |0|V|V|V|V|V|V|V|V|B|B|B|B|B|B|B| (V = usable bit, B = potential buffered bit (buffer refills when m_bitsNeeded >= 0)) 311 // 312 const UInt newBins = (m_uiValue >> (15 - binsToRead)) & binMask; 313 314 ruiBins = (ruiBins << binsToRead) | newBins; 315 m_uiValue = (m_uiValue << binsToRead) & 0x7FFF; 316 317 binsRemaining -= binsToRead; 318 m_bitsNeeded += binsToRead; 319 320 if (m_bitsNeeded >= 0) 321 { 322 m_uiValue |= m_pcTComBitstream->readByte() << m_bitsNeeded; 323 m_bitsNeeded -= 8; 324 } 325 } 326 327 #if RExt__DECODER_DEBUG_BIT_STATISTICS 328 TComCodingStatistics::IncrementStatisticEP(whichStat, numBins, Int(ruiBins)); 329 #endif 209 330 } 210 331 … … 217 338 { 218 339 ruiBin = 1; 340 #if RExt__DECODER_DEBUG_BIT_STATISTICS 341 TComCodingStatistics::UpdateCABACStat(STATS__CABAC_TRM_BITS, m_uiRange+2, 2, ruiBin); 342 TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS, -m_bitsNeeded, 0); 343 #endif 219 344 } 220 345 else 221 346 { 222 347 ruiBin = 0; 348 #if RExt__DECODER_DEBUG_BIT_STATISTICS 349 TComCodingStatistics::UpdateCABACStat(STATS__CABAC_TRM_BITS, m_uiRange+2, m_uiRange, ruiBin); 350 #endif 223 351 if ( scaledRange < ( 256 << 7 ) ) 224 352 { 225 353 m_uiRange = scaledRange >> 6; 226 354 m_uiValue += m_uiValue; 227 355 228 356 if ( ++m_bitsNeeded == 0 ) 229 357 { 230 358 m_bitsNeeded = -8; 231 m_uiValue += m_pcTComBitstream->readByte(); 359 m_uiValue += m_pcTComBitstream->readByte(); 232 360 } 233 361 } … … 244 372 assert ( uiLength > 0 ); 245 373 m_pcTComBitstream->read (uiLength, ruiCode); 374 #if RExt__DECODER_DEBUG_BIT_STATISTICS 375 TComCodingStatistics::IncrementStatisticEP(STATS__CABAC_PCM_CODE_BITS, uiLength, ruiCode); 376 #endif 246 377 } 247 378 //! \} -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecBinCoderCABAC.h
r595 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 36 36 */ 37 37 38 #ifndef __TDEC _BIN_CODER_CABAC__39 #define __TDEC _BIN_CODER_CABAC__38 #ifndef __TDECBINCODERCABAC__ 39 #define __TDECBINCODERCABAC__ 40 40 41 41 #include "TLibCommon/TComCABACTables.h" … … 50 50 TDecBinCABAC (); 51 51 virtual ~TDecBinCABAC(); 52 52 53 53 Void init ( TComInputBitstream* pcTComBitstream ); 54 54 Void uninit (); 55 55 56 56 Void start (); 57 57 Void finish (); 58 58 59 #if RExt__DECODER_DEBUG_BIT_STATISTICS 60 Void decodeBin ( UInt& ruiBin, ContextModel& rcCtxModel, const class TComCodingStatisticsClassType &whichStat ); 61 Void decodeBinEP ( UInt& ruiBin , const class TComCodingStatisticsClassType &whichStat ); 62 Void decodeBinsEP ( UInt& ruiBin, Int numBins , const class TComCodingStatisticsClassType &whichStat ); 63 Void decodeAlignedBinsEP( UInt& ruiBins, Int numBins , const class TComCodingStatisticsClassType &whichStat ); 64 #else 59 65 Void decodeBin ( UInt& ruiBin, ContextModel& rcCtxModel ); 60 66 Void decodeBinEP ( UInt& ruiBin ); 61 67 Void decodeBinsEP ( UInt& ruiBin, Int numBins ); 68 Void decodeAlignedBinsEP( UInt& ruiBins, Int numBins ); 69 #endif 70 71 Void align (); 72 62 73 Void decodeBinTrm ( UInt& ruiBin ); 63 74 64 75 Void xReadPCMCode ( UInt uiLength, UInt& ruiCode ); 65 66 Void copyState ( TDecBinIf* pcTDecBinIf ); 67 TDecBinCABAC* getTDecBinCABAC() { return this; } 76 77 Void copyState ( const TDecBinIf* pcTDecBinIf ); 78 TDecBinCABAC* getTDecBinCABAC() { return this; } 79 const TDecBinCABAC* getTDecBinCABAC() const { return this; } 68 80 69 81 private: -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecCAVLC.cpp
r914 r916 39 39 #include "SEIread.h" 40 40 #include "TDecSlice.h" 41 #include "TLibCommon/TComChromaFormat.h" 42 #if RExt__DECODER_DEBUG_BIT_STATISTICS 43 #include "TLibCommon/TComCodingStatistics.h" 44 #endif 41 45 #if Q0048_CGS_3D_ASYMLUT 42 46 #include "../TLibCommon/TCom3DAsymLUT.h" … … 82 86 // ==================================================================================================================== 83 87 84 void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx )88 Void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx ) 85 89 { 86 90 UInt code; … … 178 182 } 179 183 180 Void TDecCavlc::parsePPS(TComPPS* pcPPS181 184 #if Q0048_CGS_3D_ASYMLUT 182 , TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID 183 #endif 184 ) 185 Void TDecCavlc::parsePPS(TComPPS* pcPPS, TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID) 186 #else 187 Void TDecCavlc::parsePPS(TComPPS* pcPPS) 188 #endif 189 185 190 { 186 191 #if ENC_DEC_TRACE … … 200 205 201 206 READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag" ); pcPPS->setDependentSliceSegmentsEnabledFlag ( uiCode == 1 ); 207 202 208 READ_FLAG( uiCode, "output_flag_present_flag" ); pcPPS->setOutputFlagPresentFlag( uiCode==1 ); 203 209 204 210 READ_CODE(3, uiCode, "num_extra_slice_header_bits"); pcPPS->setNumExtraSliceHeaderBits(uiCode); 211 205 212 READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode ); 206 213 … … 231 238 } 232 239 READ_SVLC( iCode, "pps_cb_qp_offset"); 233 pcPPS->set ChromaCbQpOffset(iCode);234 assert( pcPPS->get ChromaCbQpOffset() >= -12 );235 assert( pcPPS->get ChromaCbQpOffset() <= 12 );240 pcPPS->setQpOffset(COMPONENT_Cb, iCode); 241 assert( pcPPS->getQpOffset(COMPONENT_Cb) >= -12 ); 242 assert( pcPPS->getQpOffset(COMPONENT_Cb) <= 12 ); 236 243 237 244 READ_SVLC( iCode, "pps_cr_qp_offset"); 238 pcPPS->setChromaCrQpOffset(iCode); 239 assert( pcPPS->getChromaCrQpOffset() >= -12 ); 240 assert( pcPPS->getChromaCrQpOffset() <= 12 ); 245 pcPPS->setQpOffset(COMPONENT_Cr, iCode); 246 assert( pcPPS->getQpOffset(COMPONENT_Cr) >= -12 ); 247 assert( pcPPS->getQpOffset(COMPONENT_Cr) <= 12 ); 248 249 assert(MAX_NUM_COMPONENT<=3); 241 250 242 251 READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" ); … … 259 268 READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setTileUniformSpacingFlag( uiCode == 1 ); 260 269 261 if( !pcPPS->getTileUniformSpacingFlag()) 262 { 263 std::vector<Int> columnWidth(pcPPS->getNumTileColumnsMinus1()); 264 for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++) 265 { 266 READ_UVLC( uiCode, "column_width_minus1" ); 267 columnWidth[i] = uiCode+1; 268 } 269 pcPPS->setTileColumnWidth(columnWidth); 270 271 std::vector<Int> rowHeight (pcPPS->getTileNumRowsMinus1()); 272 for(UInt i=0; i<pcPPS->getTileNumRowsMinus1(); i++) 273 { 274 READ_UVLC( uiCode, "row_height_minus1" ); 275 rowHeight[i] = uiCode + 1; 276 } 277 pcPPS->setTileRowHeight(rowHeight); 278 } 279 280 if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getTileNumRowsMinus1() !=0) 270 const UInt tileColumnsMinus1 = pcPPS->getNumTileColumnsMinus1(); 271 const UInt tileRowsMinus1 = pcPPS->getNumTileRowsMinus1(); 272 273 if ( !pcPPS->getTileUniformSpacingFlag()) 274 { 275 if (tileColumnsMinus1 > 0) 276 { 277 std::vector<Int> columnWidth(tileColumnsMinus1); 278 for(UInt i = 0; i < tileColumnsMinus1; i++) 279 { 280 READ_UVLC( uiCode, "column_width_minus1" ); 281 columnWidth[i] = uiCode+1; 282 } 283 pcPPS->setTileColumnWidth(columnWidth); 284 } 285 286 if (tileRowsMinus1 > 0) 287 { 288 std::vector<Int> rowHeight (tileRowsMinus1); 289 for(UInt i = 0; i < tileRowsMinus1; i++) 290 { 291 READ_UVLC( uiCode, "row_height_minus1" ); 292 rowHeight[i] = uiCode + 1; 293 } 294 pcPPS->setTileRowHeight(rowHeight); 295 } 296 } 297 298 if ((tileColumnsMinus1 + tileRowsMinus1) != 0) 281 299 { 282 300 READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false ); … … 295 313 } 296 314 } 297 #if !R0042_PROFILE_INDICATION 298 #if SCALINGLIST_INFERRING 299 if( pcPPS->getLayerId() > 0 ) 300 { 301 READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); 302 pcPPS->setInferScalingListFlag( uiCode ); 303 } 304 305 if( pcPPS->getInferScalingListFlag() ) 306 { 307 READ_UVLC( uiCode, "pps_scaling_list_ref_layer_id" ); pcPPS->setScalingListRefLayerId( uiCode ); 308 309 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive 310 assert( pcPPS->getScalingListRefLayerId() <= 62 ); 311 312 pcPPS->setScalingListPresentFlag( false ); 313 } 314 else 315 { 316 #endif 317 #endif 318 319 READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); 320 321 if(pcPPS->getScalingListPresentFlag ()) 322 { 323 parseScalingList( pcPPS->getScalingList() ); 324 } 325 #if !R0042_PROFILE_INDICATION 326 #if SCALINGLIST_INFERRING 327 } 328 #endif 329 #endif 315 READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); 316 if(pcPPS->getScalingListPresentFlag ()) 317 { 318 parseScalingList( pcPPS->getScalingList() ); 319 } 330 320 331 321 READ_FLAG( uiCode, "lists_modification_present_flag"); … … 338 328 pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); 339 329 340 #if !R0042_PROFILE_INDICATION341 READ_FLAG( uiCode, "pps_extension_flag");342 #else343 330 READ_FLAG( uiCode, "pps_extension_present_flag"); 344 #endif 345 346 #if !R0042_PROFILE_INDICATION 347 #if POC_RESET_INFO_INFERENCE 348 pcPPS->setExtensionFlag( uiCode ? true : false ); 349 350 if( pcPPS->getExtensionFlag() ) 351 #else 352 if (uiCode) 353 #endif 354 { 355 #if P0166_MODIFIED_PPS_EXTENSION 356 UInt ppsExtensionTypeFlag[8]; 357 for (UInt i = 0; i < 8; i++) 358 { 359 READ_FLAG( ppsExtensionTypeFlag[i], "pps_extension_type_flag" ); 360 } 361 #if !POC_RESET_IDC 362 if (ppsExtensionTypeFlag[1]) 363 { 364 #else 365 if( ppsExtensionTypeFlag[0] ) 366 { 367 READ_FLAG( uiCode, "poc_reset_info_present_flag" ); 368 pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); 369 #if REF_REGION_OFFSET 370 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); 371 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 372 { 373 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); 374 READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); pcPPS->setScaledRefLayerOffsetPresentFlag( i, uiCode ); 375 if (uiCode) 376 { 377 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); 378 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 379 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 380 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 381 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 382 #if P0312_VERT_PHASE_ADJ 383 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); 384 #endif 385 } 386 READ_FLAG( uiCode, "ref_region_offset_present_flag" ); pcPPS->setRefRegionOffsetPresentFlag( i, uiCode ); 387 if (uiCode) 388 { 389 Window& refWindow = pcPPS->getRefLayerWindow(i); 390 READ_SVLC( iCode, "ref_region_left_offset" ); refWindow.setWindowLeftOffset (iCode << 1); 391 READ_SVLC( iCode, "ref_region_top_offset" ); refWindow.setWindowTopOffset (iCode << 1); 392 READ_SVLC( iCode, "ref_region_right_offset" ); refWindow.setWindowRightOffset (iCode << 1); 393 READ_SVLC( iCode, "ref_region_bottom_offset" ); refWindow.setWindowBottomOffset(iCode << 1); 394 } 395 #if R0209_GENERIC_PHASE 396 READ_FLAG( uiCode, "resample_phase_set_present_flag" ); pcPPS->setResamplePhaseSetPresentFlag( i, uiCode ); 397 if (uiCode) 398 { 399 READ_UVLC( uiCode, "phase_hor_luma" ); pcPPS->setPhaseHorLuma ( i, uiCode ); 400 READ_UVLC( uiCode, "phase_ver_luma" ); pcPPS->setPhaseVerLuma ( i, uiCode ); 401 READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); pcPPS->setPhaseHorChroma (i, uiCode - 8); 402 READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); pcPPS->setPhaseVerChroma (i, uiCode - 8); 403 } 404 #endif 405 } 406 #else 407 #if MOVE_SCALED_OFFSET_TO_PPS 408 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); 409 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 410 { 411 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); 412 #if O0098_SCALED_REF_LAYER_ID 413 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); 414 #endif 415 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 416 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 417 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 418 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 419 #if P0312_VERT_PHASE_ADJ 420 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); 421 #endif 422 } 423 #endif 424 #endif 425 #if Q0048_CGS_3D_ASYMLUT 426 READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); 427 pcPPS->setCGSFlag( uiCode ); 428 if( pcPPS->getCGSFlag() ) 429 { 430 xParse3DAsymLUT( pc3DAsymLUT ); 431 pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() ); 432 pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() ); 433 } 434 #endif 435 #endif 436 } 437 #if POC_RESET_INFO_INFERENCE 438 else // Extension type 0 absent 439 { 440 pcPPS->setPocResetInfoPresentFlag( false ); 441 } 442 #endif 443 if (ppsExtensionTypeFlag[7]) 444 { 445 #endif 446 447 while ( xMoreRbspData() ) 448 { 449 READ_FLAG( uiCode, "pps_extension_data_flag"); 450 } 451 #if P0166_MODIFIED_PPS_EXTENSION 452 } 453 #endif 454 } 455 #if POC_RESET_INFO_INFERENCE 456 if( !pcPPS->getExtensionFlag() ) 457 { 458 pcPPS->setPocResetInfoPresentFlag( false ); 459 } 460 #endif 461 #else 331 332 #if SVC_EXTENSION 462 333 pcPPS->setExtensionFlag( uiCode ? true : false ); 463 334 if( pcPPS->getExtensionFlag() ) 464 { 465 READ_FLAG( uiCode, "pps_range_extension_flag" ); 466 assert(uiCode == 0); 467 READ_FLAG( uiCode, "pps_multilayer_extension_flag" ); 468 assert(uiCode == 1); 469 READ_CODE(6, uiCode, "pps_extension_6bits"); 470 assert(uiCode == 0); 471 472 READ_FLAG( uiCode, "poc_reset_info_present_flag" ); 473 pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); 335 #else 336 if (uiCode) 337 #endif 338 { 339 Bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]; 340 for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) 341 { 342 READ_FLAG( uiCode, "pps_extension_flag[]" ); 343 pps_extension_flags[i] = uiCode!=0; 344 } 345 346 Bool bSkipTrailingExtensionBits=false; 347 for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. 348 { 349 if (pps_extension_flags[i]) 350 { 351 switch (PPSExtensionFlagIndex(i)) 352 { 353 case PPS_EXT__REXT: 354 assert(!bSkipTrailingExtensionBits); 355 356 if (pcPPS->getUseTransformSkip()) 357 { 358 READ_UVLC( uiCode, "log2_transform_skip_max_size_minus2"); 359 pcPPS->setTransformSkipLog2MaxSize(uiCode+2); 360 } 361 362 READ_FLAG( uiCode, "cross_component_prediction_flag"); 363 pcPPS->setUseCrossComponentPrediction(uiCode != 0); 364 365 READ_FLAG( uiCode, "chroma_qp_adjustment_enabled_flag"); 366 if (uiCode == 0) 367 { 368 pcPPS->clearChromaQpAdjTable(); 369 pcPPS->setMaxCuChromaQpAdjDepth(0); 370 } 371 else 372 { 373 READ_UVLC(uiCode, "diff_cu_chroma_qp_adjustment_depth"); pcPPS->setMaxCuChromaQpAdjDepth(uiCode); 374 UInt tableSizeMinus1 = 0; 375 READ_UVLC(tableSizeMinus1, "chroma_qp_adjustment_table_size_minus1"); 376 /* skip zero index */ 377 for (Int chromaQpAdjustmentIndex = 1; chromaQpAdjustmentIndex <= (tableSizeMinus1 + 1); chromaQpAdjustmentIndex++) 378 { 379 Int cbOffset; 380 Int crOffset; 381 READ_SVLC(cbOffset, "cb_qp_adjustnemt[i]"); 382 READ_SVLC(crOffset, "cr_qp_adjustnemt[i]"); 383 pcPPS->setChromaQpAdjTableAt(chromaQpAdjustmentIndex, cbOffset, crOffset); 384 } 385 assert(pcPPS->getChromaQpAdjTableSize() == tableSizeMinus1 + 1); 386 } 387 388 READ_UVLC( uiCode, "sao_luma_bit_shift"); 389 pcPPS->setSaoOffsetBitShift(CHANNEL_TYPE_LUMA, uiCode); 390 READ_UVLC( uiCode, "sao_chroma_bit_shift"); 391 pcPPS->setSaoOffsetBitShift(CHANNEL_TYPE_CHROMA, uiCode); 392 break; 393 394 #if SVC_EXTENSION 395 case PPS_EXT__MLAYER: 396 READ_FLAG( uiCode, "poc_reset_info_present_flag" ); 397 pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); 474 398 475 399 #if SCALINGLIST_INFERRING 476 READ_FLAG( uiCode, "pps_infer_scaling_list_flag" );477 pcPPS->setInferScalingListFlag( uiCode );478 479 if( pcPPS->getInferScalingListFlag() )480 {481 READ_UVLC( uiCode, "pps_scaling_list_ref_layer_id" );482 pcPPS->setScalingListRefLayerId( uiCode );483 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive484 assert( pcPPS->getScalingListRefLayerId() <= 62 );485 pcPPS->setScalingListPresentFlag( false );486 }400 READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); 401 pcPPS->setInferScalingListFlag( uiCode ); 402 403 if( pcPPS->getInferScalingListFlag() ) 404 { 405 READ_UVLC( uiCode, "pps_scaling_list_ref_layer_id" ); 406 pcPPS->setScalingListRefLayerId( uiCode ); 407 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive 408 assert( pcPPS->getScalingListRefLayerId() <= 62 ); 409 pcPPS->setScalingListPresentFlag( false ); 410 } 487 411 #endif 488 412 489 413 #if REF_REGION_OFFSET 490 READ_UVLC( uiCode, "num_ref_loc_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode);491 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)492 {493 READ_CODE( 6, uiCode, "ref_loc_offset_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode );494 READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); pcPPS->setScaledRefLayerOffsetPresentFlag( i, uiCode );495 if (uiCode)496 {497 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i);498 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1);499 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1);500 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1);501 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1);414 READ_UVLC( uiCode, "num_ref_loc_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); 415 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 416 { 417 READ_CODE( 6, uiCode, "ref_loc_offset_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); 418 READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); pcPPS->setScaledRefLayerOffsetPresentFlag( i, uiCode ); 419 if (uiCode) 420 { 421 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); 422 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 423 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 424 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 425 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 502 426 #if P0312_VERT_PHASE_ADJ 503 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode);504 #endif 505 }506 READ_FLAG( uiCode, "ref_region_offset_present_flag" ); pcPPS->setRefRegionOffsetPresentFlag( i, uiCode );507 if (uiCode)508 {509 Window& refWindow = pcPPS->getRefLayerWindow(i);510 READ_SVLC( iCode, "ref_region_left_offset" ); refWindow.setWindowLeftOffset (iCode << 1);511 READ_SVLC( iCode, "ref_region_top_offset" ); refWindow.setWindowTopOffset (iCode << 1);512 READ_SVLC( iCode, "ref_region_right_offset" ); refWindow.setWindowRightOffset (iCode << 1);513 READ_SVLC( iCode, "ref_region_bottom_offset" ); refWindow.setWindowBottomOffset(iCode << 1);514 }427 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); 428 #endif 429 } 430 READ_FLAG( uiCode, "ref_region_offset_present_flag" ); pcPPS->setRefRegionOffsetPresentFlag( i, uiCode ); 431 if (uiCode) 432 { 433 Window& refWindow = pcPPS->getRefLayerWindow(i); 434 READ_SVLC( iCode, "ref_region_left_offset" ); refWindow.setWindowLeftOffset (iCode << 1); 435 READ_SVLC( iCode, "ref_region_top_offset" ); refWindow.setWindowTopOffset (iCode << 1); 436 READ_SVLC( iCode, "ref_region_right_offset" ); refWindow.setWindowRightOffset (iCode << 1); 437 READ_SVLC( iCode, "ref_region_bottom_offset" ); refWindow.setWindowBottomOffset(iCode << 1); 438 } 515 439 #if R0209_GENERIC_PHASE 516 READ_FLAG( uiCode, "resample_phase_set_present_flag" ); pcPPS->setResamplePhaseSetPresentFlag( i, uiCode );517 if (uiCode)518 {519 READ_UVLC( uiCode, "phase_hor_luma" ); pcPPS->setPhaseHorLuma ( i, uiCode );520 READ_UVLC( uiCode, "phase_ver_luma" ); pcPPS->setPhaseVerLuma ( i, uiCode );521 READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); pcPPS->setPhaseHorChroma (i, uiCode - 8);522 READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); pcPPS->setPhaseVerChroma (i, uiCode - 8);523 }524 #endif 525 }440 READ_FLAG( uiCode, "resample_phase_set_present_flag" ); pcPPS->setResamplePhaseSetPresentFlag( i, uiCode ); 441 if (uiCode) 442 { 443 READ_UVLC( uiCode, "phase_hor_luma" ); pcPPS->setPhaseHorLuma ( i, uiCode ); 444 READ_UVLC( uiCode, "phase_ver_luma" ); pcPPS->setPhaseVerLuma ( i, uiCode ); 445 READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); pcPPS->setPhaseHorChroma (i, uiCode - 8); 446 READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); pcPPS->setPhaseVerChroma (i, uiCode - 8); 447 } 448 #endif 449 } 526 450 #else 527 451 #if MOVE_SCALED_OFFSET_TO_PPS 528 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode);529 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)530 {531 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i);452 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); 453 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 454 { 455 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); 532 456 #if O0098_SCALED_REF_LAYER_ID 533 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode );534 #endif 535 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1);536 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1);537 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1);538 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1);457 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); 458 #endif 459 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 460 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 461 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 462 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 539 463 #if P0312_VERT_PHASE_ADJ 540 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode);541 #endif 542 }464 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); 465 #endif 466 } 543 467 #endif 544 468 #endif 545 469 #if Q0048_CGS_3D_ASYMLUT 546 READ_FLAG( uiCode , "colour_mapping_enabled_flag" );547 pcPPS->setCGSFlag( uiCode );548 if( pcPPS->getCGSFlag() )549 {470 READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); 471 pcPPS->setCGSFlag( uiCode ); 472 if( pcPPS->getCGSFlag() ) 473 { 550 474 #if R0157_RESTRICT_PPSID_FOR_CGS_LUT 551 // when pps_pic_parameter_set_id greater than or equal to 8, colour_mapping_enabled_flag shall be equal to 0 552 assert( pcPPS->getPPSId() < 8 ); 553 #endif 554 xParse3DAsymLUT( pc3DAsymLUT ); 555 pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() ); 556 pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() ); 557 } 558 #endif 559 } 560 #endif 561 475 // when pps_pic_parameter_set_id greater than or equal to 8, colour_mapping_enabled_flag shall be equal to 0 476 assert( pcPPS->getPPSId() < 8 ); 477 #endif 478 xParse3DAsymLUT( pc3DAsymLUT ); 479 pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() ); 480 pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() ); 481 } 482 #endif 483 break; 484 #endif 485 default: 486 bSkipTrailingExtensionBits=true; 487 break; 488 } 489 } 490 } 491 if (bSkipTrailingExtensionBits) 492 { 493 while ( xMoreRbspData() ) 494 { 495 READ_FLAG( uiCode, "pps_extension_data_flag"); 496 } 497 } 498 } 562 499 } 563 500 … … 622 559 READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); 623 560 } 561 624 562 TimingInfo *timingInfo = pcVUI->getTimingInfo(); 625 563 READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); … … 639 577 READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); 640 578 } 579 641 580 READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); 642 581 if( pcVUI->getHrdParametersPresentFlag() ) … … 645 584 } 646 585 } 586 647 587 READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); 648 588 if (pcVUI->getBitstreamRestrictionFlag()) … … 707 647 hrd->setFixedPicRateWithinCvsFlag( i, true ); 708 648 } 649 709 650 hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present 710 651 hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present 652 711 653 if( hrd->getFixedPicRateWithinCvsFlag( i ) ) 712 654 { … … 721 663 READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); 722 664 } 665 723 666 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) 724 667 { 725 668 if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || 726 ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )669 ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) 727 670 { 728 671 for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) … … 742 685 } 743 686 744 #if SVC_EXTENSION && !SPS_DPB_PARAMS745 Void TDecCavlc::parseSPS(TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager)746 #else747 687 Void TDecCavlc::parseSPS(TComSPS* pcSPS) 748 #endif749 688 { 750 689 #if ENC_DEC_TRACE … … 752 691 #endif 753 692 754 #if R0042_PROFILE_INDICATION755 UInt uiTmp = 0;756 Bool bMultiLayerExtSpsFlag;757 #endif758 693 UInt uiCode; 759 694 READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); 695 760 696 #if SVC_EXTENSION 697 UInt uiTmp = 0; 698 761 699 if(pcSPS->getLayerId() == 0) 762 700 { 763 701 #endif 764 765 702 READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); 703 assert(uiCode <= 6); 766 704 #if SVC_EXTENSION 767 705 } 768 #if R0042_PROFILE_INDICATION769 706 else 770 707 { 771 708 READ_CODE( 3, uiCode, "sps_ext_or_max_sub_layers_minus1" ); uiTmp = uiCode; 772 709 } 773 #endif 774 #if !SPS_DPB_PARAMS 775 if(pcSPS->getLayerId() != 0) 776 { 777 pcSPS->setMaxTLayers ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers() ); 778 } 779 #endif 780 #endif 781 710 711 Bool V1CompatibleSPSFlag = !( pcSPS->getLayerId() != 0 && uiTmp == 7 ); 712 713 if( V1CompatibleSPSFlag ) 714 { 715 #endif 716 READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); 717 parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 782 718 #if SVC_EXTENSION 783 #if R0042_PROFILE_INDICATION 784 bMultiLayerExtSpsFlag = ( pcSPS->getLayerId() != 0 && uiTmp == 7 ); 785 #endif 786 #endif 787 788 #if SVC_EXTENSION 789 #if !R0042_PROFILE_INDICATION 790 if(pcSPS->getLayerId() == 0) 791 #else 792 if(!bMultiLayerExtSpsFlag) 793 #endif 794 { 795 #endif 796 READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); 797 #if SVC_EXTENSION 798 } 799 #if !SPS_DPB_PARAMS 800 else 801 { 802 pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() ); 803 } 804 #endif 805 #endif 806 807 #if !Q0177_SPS_TEMP_NESTING_FIX //This part is not needed anymore as it is already covered by implementation in TDecTop::xActivateParameterSets() 719 } 720 #else 808 721 if ( pcSPS->getMaxTLayers() == 1 ) 809 722 { 810 723 // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 811 #if SVC_EXTENSION812 #if !SPS_DPB_PARAMS813 assert( pcSPS->getTemporalIdNestingFlag() == true );814 #endif815 #else816 724 assert( uiCode == 1 ); 817 #endif 818 } 819 #endif 820 821 #ifdef SPS_PTL_FIX 822 #if !R0042_PROFILE_INDICATION 823 if ( pcSPS->getLayerId() == 0) 824 #else 825 if(!bMultiLayerExtSpsFlag) 826 #endif 827 { 828 parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 829 } 830 #else 831 parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 725 } 832 726 #endif 833 727 … … 835 729 assert(uiCode <= 15); 836 730 837 #if REPN_FORMAT_IN_VPS 838 #if !R0042_PROFILE_INDICATION 839 if( pcSPS->getLayerId() > 0 ) 840 #else 841 if( bMultiLayerExtSpsFlag) 842 #endif 731 #if SVC_EXTENSION 732 if( !V1CompatibleSPSFlag ) 843 733 { 844 734 READ_FLAG( uiCode, "update_rep_format_flag" ); 845 735 pcSPS->setUpdateRepFormatFlag( uiCode ? true : false ); 846 #if R0042_PROFILE_INDICATION847 if( bMultiLayerExtSpsFlag && uiCode)736 737 if( pcSPS->getUpdateRepFormatFlag() ) 848 738 { 849 739 READ_CODE(8, uiCode, "sps_rep_format_idx"); 850 740 pcSPS->setUpdateRepFormatIndex(uiCode); 851 741 } 852 #endif853 742 } 854 743 else 855 744 { 856 #if REP_FORMAT_FIX857 745 pcSPS->setUpdateRepFormatFlag( false ); 858 #else 859 pcSPS->setUpdateRepFormatFlag( true ); 860 #endif 861 } 862 863 #if R0042_PROFILE_INDICATION 864 if( !bMultiLayerExtSpsFlag ) 865 { 866 #else 867 #if O0096_REP_FORMAT_INDEX 868 if( pcSPS->getLayerId() == 0 ) 869 #else 870 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 871 #endif 872 #endif 873 { 874 #endif 875 #if AUXILIARY_PICTURES 876 READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); 877 #else 878 READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); 879 #endif 880 assert(uiCode <= 3); 881 // in the first version we only support chroma_format_idc equal to 1 (4:2:0), so separate_colour_plane_flag cannot appear in the bitstream 882 assert (uiCode == 1); 883 if( uiCode == 3 ) 884 { 885 READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); 886 } 887 888 READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); 889 READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); 746 #endif 747 READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); 748 assert(uiCode <= 3); 749 750 if( pcSPS->getChromaFormatIdc() == CHROMA_444 ) 751 { 752 READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); 753 } 754 755 READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); 756 READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); 757 READ_FLAG( uiCode, "conformance_window_flag"); 758 if (uiCode != 0) 759 { 760 Window &conf = pcSPS->getConformanceWindow(); 890 761 #if REPN_FORMAT_IN_VPS 891 } 892 #if O0096_REP_FORMAT_INDEX 893 #if !R0042_PROFILE_INDICATION 894 else if ( pcSPS->getUpdateRepFormatFlag() ) 895 { 896 READ_CODE(8, uiCode, "update_rep_format_index"); 897 pcSPS->setUpdateRepFormatIndex(uiCode); 898 } 899 #endif 900 #endif 901 #endif 902 903 #if R0156_CONF_WINDOW_IN_REP_FORMAT 904 #if REPN_FORMAT_IN_VPS 905 #if !R0042_PROFILE_INDICATION 906 #if O0096_REP_FORMAT_INDEX 907 if( pcSPS->getLayerId() == 0 ) 908 #else 909 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 910 #endif 911 #endif 912 { 913 #endif 914 #endif 915 READ_FLAG( uiCode, "conformance_window_flag"); 916 if (uiCode != 0) 917 { 918 Window &conf = pcSPS->getConformanceWindow(); 919 #if REPN_FORMAT_IN_VPS 920 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); 921 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); 922 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); 923 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); 924 #else 925 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 926 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 927 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 928 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 929 #endif 930 } 931 #if R0156_CONF_WINDOW_IN_REP_FORMAT 932 #if REPN_FORMAT_IN_VPS 933 } 934 #endif 935 #endif 936 937 #if REPN_FORMAT_IN_VPS 938 #if !R0042_PROFILE_INDICATION 939 #if O0096_REP_FORMAT_INDEX 940 if( pcSPS->getLayerId() == 0 ) 941 #else 942 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 943 #endif 944 #endif 945 { 946 #endif 947 READ_UVLC( uiCode, "bit_depth_luma_minus8" ); 948 assert(uiCode <= 6); 949 pcSPS->setBitDepthY( uiCode + 8 ); 950 pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); 951 952 READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); 953 assert(uiCode <= 6); 954 pcSPS->setBitDepthC( uiCode + 8 ); 955 pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); 956 #if REPN_FORMAT_IN_VPS 957 } 958 #endif 959 #if R0042_PROFILE_INDICATION 960 } 961 #endif 762 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); 763 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); 764 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); 765 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); 766 #else 767 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 768 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 769 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 770 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 771 #endif 772 } 773 774 READ_UVLC( uiCode, "bit_depth_luma_minus8" ); 775 #if O0043_BEST_EFFORT_DECODING 776 const UInt forceDecodeBitDepth = pcSPS->getForceDecodeBitDepth(); 777 g_bitDepthInStream[CHANNEL_TYPE_LUMA] = 8 + uiCode; 778 if (forceDecodeBitDepth != 0) 779 { 780 uiCode = forceDecodeBitDepth - 8; 781 } 782 #endif 783 assert(uiCode <= 8); 784 785 pcSPS->setBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode); 786 #if O0043_BEST_EFFORT_DECODING 787 pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*(g_bitDepthInStream[CHANNEL_TYPE_LUMA]-8)) ); 788 #else 789 pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*uiCode) ); 790 #endif 791 792 READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); 793 #if O0043_BEST_EFFORT_DECODING 794 g_bitDepthInStream[CHANNEL_TYPE_CHROMA] = 8 + uiCode; 795 if (forceDecodeBitDepth != 0) 796 { 797 uiCode = forceDecodeBitDepth - 8; 798 } 799 #endif 800 assert(uiCode <= 8); 801 pcSPS->setBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode); 802 #if O0043_BEST_EFFORT_DECODING 803 pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*(g_bitDepthInStream[CHANNEL_TYPE_CHROMA]-8)) ); 804 #else 805 pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*uiCode) ); 806 #endif 807 808 #if SVC_EXTENSION 809 } 810 #endif 811 962 812 963 813 READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); 964 814 assert(uiCode <= 12); 965 815 966 #if SPS_DPB_PARAMS 967 #if !R0042_PROFILE_INDICATION 968 if( pcSPS->getLayerId() == 0 ) 969 { 970 #else 971 if( !bMultiLayerExtSpsFlag ) 972 { 973 #endif 974 #endif 975 UInt subLayerOrderingInfoPresentFlag; 976 READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); 977 978 for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) 979 { 980 READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); 981 pcSPS->setMaxDecPicBuffering( uiCode + 1, i); 982 READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" ); 983 pcSPS->setNumReorderPics(uiCode, i); 984 READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); 985 pcSPS->setMaxLatencyIncrease( uiCode, i ); 986 987 if (!subLayerOrderingInfoPresentFlag) 988 { 989 for (i++; i <= pcSPS->getMaxTLayers()-1; i++) 990 { 991 pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); 992 pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); 993 pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); 994 } 995 break; 996 } 997 } 998 #if SPS_DPB_PARAMS 816 #if SVC_EXTENSION 817 if( V1CompatibleSPSFlag ) 818 { 819 #endif 820 UInt subLayerOrderingInfoPresentFlag; 821 READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); 822 823 for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) 824 { 825 READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); 826 pcSPS->setMaxDecPicBuffering( uiCode + 1, i); 827 READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" ); 828 pcSPS->setNumReorderPics(uiCode, i); 829 READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); 830 pcSPS->setMaxLatencyIncrease( uiCode, i ); 831 832 if (!subLayerOrderingInfoPresentFlag) 833 { 834 for (i++; i <= pcSPS->getMaxTLayers()-1; i++) 835 { 836 pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); 837 pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); 838 pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); 839 } 840 break; 841 } 842 } 843 #if SVC_EXTENSION 999 844 } 1000 845 #endif … … 1004 849 READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); 1005 850 pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); 1006 851 1007 852 if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) 1008 853 { 1009 854 assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); 1010 855 } 1011 856 1012 857 Int maxCUDepthDelta = uiCode; 1013 858 pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); … … 1022 867 1023 868 Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); 1024 pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); 869 pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth + getMaxCUDepthOffset(pcSPS->getChromaFormatIdc(), pcSPS->getQuadtreeTULog2MinSize()) ); 870 1025 871 READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); 1026 1027 872 if(pcSPS->getScalingListFlag()) 1028 873 { 1029 #if SCALINGLIST_INFERRING 1030 #if !R0042_PROFILE_INDICATION 1031 if( pcSPS->getLayerId() > 0 ) 1032 #else 1033 if( bMultiLayerExtSpsFlag ) 1034 #endif 874 #if SVC_EXTENSION 875 if( !V1CompatibleSPSFlag ) 1035 876 { 1036 877 READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setInferScalingListFlag( uiCode ); … … 1049 890 { 1050 891 #endif 1051 1052 1053 1054 1055 1056 #if S CALINGLIST_INFERRING892 READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); 893 if(pcSPS->getScalingListPresentFlag ()) 894 { 895 parseScalingList( pcSPS->getScalingList() ); 896 } 897 #if SVC_EXTENSION 1057 898 } 1058 899 #endif … … 1064 905 if( pcSPS->getUsePCM() ) 1065 906 { 1066 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepth Luma (1 + uiCode );1067 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepth Chroma (1 + uiCode );907 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_LUMA, 1 + uiCode ); 908 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_CHROMA, 1 + uiCode ); 1068 909 READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); 1069 910 READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); … … 1097 938 } 1098 939 READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); 940 1099 941 READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); 1100 942 … … 1106 948 } 1107 949 1108 READ_FLAG( uiCode, "sps_extension_ flag");950 READ_FLAG( uiCode, "sps_extension_present_flag"); 1109 951 1110 952 #if SVC_EXTENSION … … 1112 954 1113 955 if( pcSPS->getExtensionFlag() ) 1114 { 1115 #if !R0042_PROFILE_INDICATION 1116 #if O0142_CONDITIONAL_SPS_EXTENSION 1117 UInt spsExtensionTypeFlag[8]; 1118 for (UInt i = 0; i < 8; i++) 1119 { 1120 READ_FLAG( spsExtensionTypeFlag[i], "sps_extension_type_flag" ); 1121 } 1122 if (spsExtensionTypeFlag[1]) 1123 { 1124 parseSPSExtension( pcSPS ); 1125 } 1126 if (spsExtensionTypeFlag[7]) 1127 { 1128 #else 1129 parseSPSExtension( pcSPS ); 1130 READ_FLAG( uiCode, "sps_extension2_flag"); 1131 if(uiCode) 1132 { 1133 #endif 956 #else 957 if (uiCode) 958 #endif 959 { 960 Bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS]; 961 for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) 962 { 963 READ_FLAG( uiCode, "sps_extension_flag[]" ); 964 sps_extension_flags[i] = uiCode!=0; 965 } 966 967 Bool bSkipTrailingExtensionBits=false; 968 for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. 969 { 970 if (sps_extension_flags[i]) 971 { 972 switch (SPSExtensionFlagIndex(i)) 973 { 974 case SPS_EXT__REXT: 975 assert(!bSkipTrailingExtensionBits); 976 977 READ_FLAG( uiCode, "transform_skip_rotation_enabled_flag"); pcSPS->setUseResidualRotation (uiCode != 0); 978 READ_FLAG( uiCode, "transform_skip_context_enabled_flag"); pcSPS->setUseSingleSignificanceMapContext (uiCode != 0); 979 READ_FLAG( uiCode, "residual_dpcm_implicit_enabled_flag"); pcSPS->setUseResidualDPCM(RDPCM_SIGNAL_IMPLICIT, (uiCode != 0)); 980 READ_FLAG( uiCode, "residual_dpcm_explicit_enabled_flag"); pcSPS->setUseResidualDPCM(RDPCM_SIGNAL_EXPLICIT, (uiCode != 0)); 981 READ_FLAG( uiCode, "extended_precision_processing_flag"); pcSPS->setUseExtendedPrecision (uiCode != 0); 982 READ_FLAG( uiCode, "intra_smoothing_disabled_flag"); pcSPS->setDisableIntraReferenceSmoothing (uiCode != 0); 983 READ_FLAG( uiCode, "high_precision_prediction_weighting_flag"); pcSPS->setUseHighPrecisionPredictionWeighting (uiCode != 0); 984 READ_FLAG( uiCode, "golomb_rice_parameter_adaptation_flag"); pcSPS->setUseGolombRiceParameterAdaptation (uiCode != 0); 985 READ_FLAG( uiCode, "cabac_bypass_alignment_enabled_flag"); pcSPS->setAlignCABACBeforeBypass (uiCode != 0); 986 break; 987 #if SVC_EXTENSION 988 case SPS_EXT__MLAYER: 989 parseSPSExtension( pcSPS ); 990 break; 991 #endif 992 default: 993 bSkipTrailingExtensionBits=true; 994 break; 995 } 996 } 997 } 998 if (bSkipTrailingExtensionBits) 999 { 1134 1000 while ( xMoreRbspData() ) 1135 1001 { … … 1137 1003 } 1138 1004 } 1139 } 1140 #else 1141 READ_FLAG( uiCode, "sps_range_extension_flag" ); 1142 assert(uiCode == 0); 1143 READ_FLAG( uiCode, "sps_multilayer_extension_flag" ); 1144 assert(uiCode == 1); 1145 READ_CODE(6, uiCode, "sps_extension_6bits"); 1146 assert(uiCode == 0); 1147 parseSPSExtension( pcSPS ); 1148 } 1149 #endif 1150 #else 1151 if (uiCode) 1152 { 1153 while ( xMoreRbspData() ) 1154 { 1155 READ_FLAG( uiCode, "sps_extension_data_flag"); 1156 } 1157 } 1158 #endif 1159 } 1160 1161 #if SVC_EXTENSION 1162 Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) 1163 { 1164 UInt uiCode; 1165 // more syntax elements to be parsed here 1166 1167 READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); 1168 // Vertical MV component restriction is not used in SHVC CTC 1169 assert( uiCode == 0 ); 1170 1171 #if !MOVE_SCALED_OFFSET_TO_PPS 1172 if( pcSPS->getLayerId() > 0 ) 1173 { 1174 Int iCode; 1175 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); 1176 for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) 1177 { 1178 Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); 1179 #if O0098_SCALED_REF_LAYER_ID 1180 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); 1181 #endif 1182 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 1183 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 1184 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 1185 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 1186 #if P0312_VERT_PHASE_ADJ 1187 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcSPS->setVertPhasePositionEnableFlag( pcSPS->getScaledRefLayerId(i), uiCode); 1188 #endif 1189 } 1190 } 1191 #endif 1192 } 1193 #endif 1005 } 1006 } 1194 1007 1195 1008 Void TDecCavlc::parseVPS(TComVPS* pcVPS) … … 1216 1029 READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); 1217 1030 #endif 1218 READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER);1031 READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER); 1219 1032 READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); 1220 1033 assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); … … 1292 1105 READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); 1293 1106 } 1107 1294 1108 READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); 1295 1109 … … 1356 1170 1357 1171 return; 1172 } 1173 1174 Void TDecCavlc::parseSliceHeader (TComSlice* pcSlice, ParameterSetManagerDecoder *parameterSetManager) 1175 { 1176 UInt uiCode; 1177 Int iCode; 1178 1179 #if ENC_DEC_TRACE 1180 xTraceSliceHeader(pcSlice); 1181 #endif 1182 TComPPS* pps = NULL; 1183 TComSPS* sps = NULL; 1184 1185 UInt firstSliceSegmentInPic; 1186 READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); 1187 if( pcSlice->getRapPicFlag()) 1188 { 1189 READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already 1190 pcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); 1191 } 1192 READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); pcSlice->setPPSId(uiCode); 1193 pps = parameterSetManager->getPrefetchedPPS(uiCode); 1194 //!KS: need to add error handling code here, if PPS is not available 1195 assert(pps!=0); 1196 sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); 1197 //!KS: need to add error handling code here, if SPS is not available 1198 assert(sps!=0); 1199 pcSlice->setSPS(sps); 1200 pcSlice->setPPS(pps); 1201 1202 const ChromaFormat chFmt = sps->getChromaFormatIdc(); 1203 const UInt numValidComp=getNumberValidComponents(chFmt); 1204 const Bool bChroma=(chFmt!=CHROMA_400); 1205 1206 if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) 1207 { 1208 READ_FLAG( uiCode, "dependent_slice_segment_flag" ); pcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); 1209 } 1210 else 1211 { 1212 pcSlice->setDependentSliceSegmentFlag(false); 1213 } 1214 #if REPN_FORMAT_IN_VPS 1215 Int numCTUs = ((pcSlice->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((pcSlice->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); 1216 #else 1217 Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); 1218 #endif 1219 UInt sliceSegmentAddress = 0; 1220 Int bitsSliceSegmentAddress = 0; 1221 while(numCTUs>(1<<bitsSliceSegmentAddress)) 1222 { 1223 bitsSliceSegmentAddress++; 1224 } 1225 1226 if(!firstSliceSegmentInPic) 1227 { 1228 READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); 1229 } 1230 //set uiCode to equal slice start address (or dependent slice start address) 1231 pcSlice->setSliceSegmentCurStartCtuTsAddr( sliceSegmentAddress );// this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet. 1232 pcSlice->setSliceSegmentCurEndCtuTsAddr(numCTUs); // Set end as the last CTU of the picture. 1233 1234 if (!pcSlice->getDependentSliceSegmentFlag()) 1235 { 1236 pcSlice->setSliceCurStartCtuTsAddr(sliceSegmentAddress); // this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet. 1237 pcSlice->setSliceCurEndCtuTsAddr(numCTUs); 1238 } 1239 1240 #if Q0142_POC_LSB_NOT_PRESENT 1241 #if SHM_FIX7 1242 Int iPOClsb = 0; 1243 #endif 1244 #endif 1245 1246 if(!pcSlice->getDependentSliceSegmentFlag()) 1247 { 1248 #if SVC_EXTENSION 1249 #if POC_RESET_FLAG 1250 Int iBits = 0; 1251 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1252 { 1253 READ_FLAG(uiCode, "poc_reset_flag"); pcSlice->setPocResetFlag( uiCode ? true : false ); 1254 iBits++; 1255 } 1256 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1257 { 1258 #if DISCARDABLE_PIC_RPS 1259 READ_FLAG(uiCode, "discardable_flag"); pcSlice->setDiscardableFlag( uiCode ? true : false ); 1260 #else 1261 READ_FLAG(uiCode, "discardable_flag"); // ignored 1262 #endif 1263 iBits++; 1264 } 1265 #if O0149_CROSS_LAYER_BLA_FLAG 1266 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1267 { 1268 READ_FLAG(uiCode, "cross_layer_bla_flag"); pcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); 1269 iBits++; 1270 } 1271 #endif 1272 for (; iBits < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 1273 { 1274 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 1275 } 1276 #else 1277 #if CROSS_LAYER_BLA_FLAG_FIX 1278 Int iBits = 0; 1279 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1280 #else 1281 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) 1282 #endif 1283 { 1284 READ_FLAG(uiCode, "discardable_flag"); // ignored 1285 #if NON_REF_NAL_TYPE_DISCARDABLE 1286 pcSlice->setDiscardableFlag( uiCode ? true : false ); 1287 if (uiCode) 1288 { 1289 assert(pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && 1290 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && 1291 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && 1292 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && 1293 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); 1294 } 1295 #endif 1296 #if CROSS_LAYER_BLA_FLAG_FIX 1297 iBits++; 1298 #endif 1299 } 1300 #if CROSS_LAYER_BLA_FLAG_FIX 1301 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1302 { 1303 READ_FLAG(uiCode, "cross_layer_bla_flag"); pcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); 1304 iBits++; 1305 } 1306 for ( ; iBits < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 1307 #else 1308 for (Int i = 1; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 1309 #endif 1310 { 1311 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 1312 } 1313 #endif 1314 #else //SVC_EXTENSION 1315 for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 1316 { 1317 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 1318 } 1319 #endif //SVC_EXTENSION 1320 1321 READ_UVLC ( uiCode, "slice_type" ); pcSlice->setSliceType((SliceType)uiCode); 1322 if( pps->getOutputFlagPresentFlag() ) 1323 { 1324 READ_FLAG( uiCode, "pic_output_flag" ); pcSlice->setPicOutputFlag( uiCode ? true : false ); 1325 } 1326 else 1327 { 1328 pcSlice->setPicOutputFlag( true ); 1329 } 1330 1331 if( pcSlice->getIdrPicFlag() ) 1332 { 1333 pcSlice->setPOC(0); 1334 TComReferencePictureSet* rps = pcSlice->getLocalRPS(); 1335 rps->setNumberOfNegativePictures(0); 1336 rps->setNumberOfPositivePictures(0); 1337 rps->setNumberOfLongtermPictures(0); 1338 rps->setNumberOfPictures(0); 1339 pcSlice->setRPS(rps); 1340 } 1341 #if N0065_LAYER_POC_ALIGNMENT 1342 #if O0062_POC_LSB_NOT_PRESENT_FLAG 1343 if( ( pcSlice->getLayerId() > 0 && !pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdInVps(pcSlice->getLayerId())) ) || !pcSlice->getIdrPicFlag() ) 1344 #else 1345 if( pcSlice->getLayerId() > 0 || !pcSlice->getIdrPicFlag() ) 1346 #endif 1347 #else 1348 else 1349 #endif 1350 { 1351 READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); 1352 #if POC_RESET_IDC_DECODER 1353 pcSlice->setPicOrderCntLsb( uiCode ); 1354 #endif 1355 #if SVC_EXTENSION 1356 iPOClsb = uiCode; 1357 #else 1358 Int iPOClsb = uiCode; 1359 #endif 1360 Int iPrevPOC = pcSlice->getPrevTid0POC(); 1361 Int iMaxPOClsb = 1<< sps->getBitsForPOC(); 1362 Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); 1363 Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; 1364 Int iPOCmsb; 1365 if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) 1366 { 1367 iPOCmsb = iPrevPOCmsb + iMaxPOClsb; 1368 } 1369 else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) 1370 { 1371 iPOCmsb = iPrevPOCmsb - iMaxPOClsb; 1372 } 1373 else 1374 { 1375 iPOCmsb = iPrevPOCmsb; 1376 } 1377 if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 1378 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 1379 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 1380 { 1381 // For BLA picture types, POCmsb is set to 0. 1382 iPOCmsb = 0; 1383 } 1384 pcSlice->setPOC (iPOCmsb+iPOClsb); 1385 1386 #if N0065_LAYER_POC_ALIGNMENT 1387 } 1388 #if POC_RESET_IDC_DECODER 1389 else 1390 { 1391 pcSlice->setPicOrderCntLsb( 0 ); 1392 } 1393 #endif 1394 if( !pcSlice->getIdrPicFlag() ) 1395 { 1396 #endif 1397 TComReferencePictureSet* rps; 1398 rps = pcSlice->getLocalRPS(); 1399 pcSlice->setRPS(rps); 1400 READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); 1401 if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header 1402 { 1403 parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); 1404 } 1405 else // use reference to short-term reference picture set in PPS 1406 { 1407 Int numBits = 0; 1408 while ((1 << numBits) < pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) 1409 { 1410 numBits++; 1411 } 1412 if (numBits > 0) 1413 { 1414 READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); 1415 } 1416 else 1417 { 1418 uiCode = 0; 1419 1420 } 1421 *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); 1422 } 1423 if(sps->getLongTermRefsPresent()) 1424 { 1425 Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); 1426 UInt numOfLtrp = 0; 1427 UInt numLtrpInSPS = 0; 1428 if (pcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) 1429 { 1430 READ_UVLC( uiCode, "num_long_term_sps"); 1431 numLtrpInSPS = uiCode; 1432 numOfLtrp += numLtrpInSPS; 1433 rps->setNumberOfLongtermPictures(numOfLtrp); 1434 } 1435 Int bitsForLtrpInSPS = 0; 1436 while (pcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) 1437 { 1438 bitsForLtrpInSPS++; 1439 } 1440 READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); 1441 numOfLtrp += uiCode; 1442 rps->setNumberOfLongtermPictures(numOfLtrp); 1443 Int maxPicOrderCntLSB = 1 << pcSlice->getSPS()->getBitsForPOC(); 1444 Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0; 1445 for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) 1446 { 1447 Int pocLsbLt; 1448 if (k < numLtrpInSPS) 1449 { 1450 uiCode = 0; 1451 if (bitsForLtrpInSPS > 0) 1452 { 1453 READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); 1454 } 1455 Int usedByCurrFromSPS=pcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); 1456 1457 pocLsbLt = pcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); 1458 rps->setUsed(j,usedByCurrFromSPS); 1459 } 1460 else 1461 { 1462 READ_CODE(pcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; 1463 READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); 1464 } 1465 READ_FLAG(uiCode,"delta_poc_msb_present_flag"); 1466 Bool mSBPresentFlag = uiCode ? true : false; 1467 if(mSBPresentFlag) 1468 { 1469 READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); 1470 Bool deltaFlag = false; 1471 // First LTRP || First LTRP from SH 1472 if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) 1473 { 1474 deltaFlag = true; 1475 } 1476 if(deltaFlag) 1477 { 1478 deltaPocMSBCycleLT = uiCode; 1479 } 1480 else 1481 { 1482 deltaPocMSBCycleLT = uiCode + prevDeltaMSB; 1483 } 1484 1485 Int pocLTCurr = pcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB 1486 - iPOClsb + pocLsbLt; 1487 rps->setPOC (j, pocLTCurr); 1488 rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLTCurr); 1489 rps->setCheckLTMSBPresent(j,true); 1490 } 1491 else 1492 { 1493 rps->setPOC (j, pocLsbLt); 1494 rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLsbLt); 1495 rps->setCheckLTMSBPresent(j,false); 1496 1497 // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present 1498 if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) 1499 { 1500 deltaPocMSBCycleLT = 0; 1501 } 1502 } 1503 prevDeltaMSB = deltaPocMSBCycleLT; 1504 } 1505 offset += rps->getNumberOfLongtermPictures(); 1506 rps->setNumberOfPictures(offset); 1507 } 1508 #if DPB_CONSTRAINTS 1509 if(pcSlice->getVPS()->getVpsExtensionFlag()==1) 1510 { 1511 #if Q0078_ADD_LAYER_SETS 1512 for (Int ii = 1; ii < (pcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++) // prevent assert error when num_add_layer_sets > 0 1513 #else 1514 for (Int ii=1; ii< pcSlice->getVPS()->getNumOutputLayerSets(); ii++ ) 1515 #endif 1516 { 1517 Int layerSetIdxForOutputLayerSet = pcSlice->getVPS()->getOutputLayerSetIdx( ii ); 1518 Int chkAssert=0; 1519 for(Int kk = 0; kk < pcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++) 1520 { 1521 if(pcSlice->getLayerId() == pcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk)) 1522 { 1523 chkAssert=1; 1524 } 1525 } 1526 if(chkAssert) 1527 { 1528 // There may be something wrong here (layer id assumed to be layer idx?) 1529 assert(rps->getNumberOfNegativePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 1530 assert(rps->getNumberOfPositivePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); 1531 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 1532 } 1533 } 1534 1535 1536 } 1537 if(pcSlice->getLayerId() == 0) 1538 { 1539 assert(rps->getNumberOfNegativePictures() <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1) ); 1540 assert(rps->getNumberOfPositivePictures() <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures()); 1541 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1)); 1542 } 1543 #endif 1544 if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 1545 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 1546 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 1547 { 1548 // In the case of BLA picture types, rps data is read from slice header but ignored 1549 rps = pcSlice->getLocalRPS(); 1550 rps->setNumberOfNegativePictures(0); 1551 rps->setNumberOfPositivePictures(0); 1552 rps->setNumberOfLongtermPictures(0); 1553 rps->setNumberOfPictures(0); 1554 pcSlice->setRPS(rps); 1555 } 1556 if (pcSlice->getSPS()->getTMVPFlagsPresent()) 1557 { 1558 READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); 1559 pcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); 1560 } 1561 else 1562 { 1563 pcSlice->setEnableTMVPFlag(false); 1564 } 1565 } 1566 1567 #if SVC_EXTENSION 1568 pcSlice->setActiveNumILRRefIdx(0); 1569 if((pcSlice->getLayerId() > 0) && !(pcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (pcSlice->getNumILRRefIdx() > 0) ) 1570 { 1571 READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); 1572 pcSlice->setInterLayerPredEnabledFlag(uiCode); 1573 if( pcSlice->getInterLayerPredEnabledFlag()) 1574 { 1575 if(pcSlice->getNumILRRefIdx() > 1) 1576 { 1577 Int numBits = 1; 1578 while ((1 << numBits) < pcSlice->getNumILRRefIdx()) 1579 { 1580 numBits++; 1581 } 1582 if( !pcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) 1583 { 1584 READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); 1585 pcSlice->setActiveNumILRRefIdx(uiCode + 1); 1586 } 1587 else 1588 { 1589 #if P0079_DERIVE_NUMACTIVE_REF_PICS 1590 for( Int i = 0; i < pcSlice->getNumILRRefIdx(); i++ ) 1591 { 1592 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 1593 if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0) && 1594 (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) 1595 #else 1596 if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() && 1597 (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) 1598 #endif 1599 { 1600 pcSlice->setActiveNumILRRefIdx(1); 1601 break; 1602 } 1603 } 1604 #else 1605 pcSlice->setActiveNumILRRefIdx(1); 1606 #endif 1607 } 1608 1609 if( pcSlice->getActiveNumILRRefIdx() == pcSlice->getNumILRRefIdx() ) 1610 { 1611 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1612 { 1613 pcSlice->setInterLayerPredLayerIdc(i,i); 1614 } 1615 } 1616 else 1617 { 1618 for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1619 { 1620 READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); 1621 pcSlice->setInterLayerPredLayerIdc(uiCode,i); 1622 } 1623 } 1624 } 1625 else 1626 { 1627 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 1628 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 1629 if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,pcSlice->getLayerId()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0) && 1630 (pcSlice->getVPS()->getMaxTSLayersMinus1(0) >= pcSlice->getTLayer()) ) 1631 #else 1632 if( (pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,pcSlice->getLayerId()) > pcSlice->getTLayer()) && 1633 (pcSlice->getVPS()->getMaxTSLayersMinus1(0) >= pcSlice->getTLayer()) ) 1634 #endif 1635 { 1636 #endif 1637 pcSlice->setActiveNumILRRefIdx(1); 1638 pcSlice->setInterLayerPredLayerIdc(0,0); 1639 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 1640 } 1641 #endif 1642 } 1643 } 1644 } 1645 else if( pcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true && (pcSlice->getLayerId() > 0 )) 1646 { 1647 pcSlice->setInterLayerPredEnabledFlag(true); 1648 1649 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 1650 Int numRefLayerPics = 0; 1651 Int i = 0; 1652 Int refLayerPicIdc [MAX_VPS_LAYER_ID_PLUS1]; 1653 for(i = 0, numRefLayerPics = 0; i < pcSlice->getNumILRRefIdx(); i++ ) 1654 { 1655 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 1656 if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0) && 1657 (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) 1658 #else 1659 if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() && 1660 (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) 1661 #endif 1662 { 1663 refLayerPicIdc[ numRefLayerPics++ ] = i; 1664 } 1665 } 1666 pcSlice->setActiveNumILRRefIdx(numRefLayerPics); 1667 for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1668 { 1669 pcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i); 1670 } 1671 #else 1672 pcSlice->setActiveNumILRRefIdx(pcSlice->getNumILRRefIdx()); 1673 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1674 { 1675 pcSlice->setInterLayerPredLayerIdc(i,i); 1676 } 1677 #endif 1678 } 1679 #if P0312_VERT_PHASE_ADJ 1680 for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1681 { 1682 UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); 1683 #if !MOVE_SCALED_OFFSET_TO_PPS 1684 if( pcSlice->getSPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 1685 #else 1686 if( pcSlice->getPPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 1687 #endif 1688 { 1689 READ_FLAG( uiCode, "vert_phase_position_flag" ); pcSlice->setVertPhasePositionFlag( uiCode? true : false, refLayerIdc ); 1690 } 1691 } 1692 #endif 1693 #endif //SVC_EXTENSION 1694 1695 if(sps->getUseSAO()) 1696 { 1697 READ_FLAG(uiCode, "slice_sao_luma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, (Bool)uiCode); 1698 #if SVC_EXTENSION 1699 ChromaFormat format; 1700 if( sps->getLayerId() == 0 ) 1701 { 1702 format = sps->getChromaFormatIdc(); 1703 } 1704 else 1705 { 1706 format = pcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : pcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); 1707 #if Q0195_REP_FORMAT_CLEANUP 1708 assert( (sps->getUpdateRepFormatFlag()==false && pcSlice->getVPS()->getVpsNumRepFormats()==1) || pcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check 1709 #endif 1710 } 1711 if (format != CHROMA_400) 1712 #else 1713 if (bChroma) 1714 #endif 1715 { 1716 READ_FLAG(uiCode, "slice_sao_chroma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, (Bool)uiCode); 1717 } 1718 #if SVC_EXTENSION 1719 else 1720 { 1721 pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, false); 1722 } 1723 #endif 1724 } 1725 1726 if (pcSlice->getIdrPicFlag()) 1727 { 1728 pcSlice->setEnableTMVPFlag(false); 1729 } 1730 if (!pcSlice->isIntra()) 1731 { 1732 1733 READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); 1734 if (uiCode) 1735 { 1736 READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); 1737 if (pcSlice->isInterB()) 1738 { 1739 READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); 1740 } 1741 else 1742 { 1743 pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); 1744 } 1745 } 1746 else 1747 { 1748 pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getPPS()->getNumRefIdxL0DefaultActive()); 1749 if (pcSlice->isInterB()) 1750 { 1751 pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getPPS()->getNumRefIdxL1DefaultActive()); 1752 } 1753 else 1754 { 1755 pcSlice->setNumRefIdx(REF_PIC_LIST_1,0); 1756 } 1757 } 1758 } 1759 // } 1760 TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); 1761 if(!pcSlice->isIntra()) 1762 { 1763 if( !pcSlice->getPPS()->getListsModificationPresentFlag() || pcSlice->getNumRpsCurrTempList() <= 1 ) 1764 { 1765 refPicListModification->setRefPicListModificationFlagL0( 0 ); 1766 } 1767 else 1768 { 1769 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); 1770 } 1771 1772 if(refPicListModification->getRefPicListModificationFlagL0()) 1773 { 1774 uiCode = 0; 1775 Int i = 0; 1776 Int numRpsCurrTempList0 = pcSlice->getNumRpsCurrTempList(); 1777 if ( numRpsCurrTempList0 > 1 ) 1778 { 1779 Int length = 1; 1780 numRpsCurrTempList0 --; 1781 while ( numRpsCurrTempList0 >>= 1) 1782 { 1783 length ++; 1784 } 1785 for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 1786 { 1787 READ_CODE( length, uiCode, "list_entry_l0" ); 1788 refPicListModification->setRefPicSetIdxL0(i, uiCode ); 1789 } 1790 } 1791 else 1792 { 1793 for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 1794 { 1795 refPicListModification->setRefPicSetIdxL0(i, 0 ); 1796 } 1797 } 1798 } 1799 } 1800 else 1801 { 1802 refPicListModification->setRefPicListModificationFlagL0(0); 1803 } 1804 if(pcSlice->isInterB()) 1805 { 1806 if( !pcSlice->getPPS()->getListsModificationPresentFlag() || pcSlice->getNumRpsCurrTempList() <= 1 ) 1807 { 1808 refPicListModification->setRefPicListModificationFlagL1( 0 ); 1809 } 1810 else 1811 { 1812 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); 1813 } 1814 if(refPicListModification->getRefPicListModificationFlagL1()) 1815 { 1816 uiCode = 0; 1817 Int i = 0; 1818 Int numRpsCurrTempList1 = pcSlice->getNumRpsCurrTempList(); 1819 if ( numRpsCurrTempList1 > 1 ) 1820 { 1821 Int length = 1; 1822 numRpsCurrTempList1 --; 1823 while ( numRpsCurrTempList1 >>= 1) 1824 { 1825 length ++; 1826 } 1827 for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 1828 { 1829 READ_CODE( length, uiCode, "list_entry_l1" ); 1830 refPicListModification->setRefPicSetIdxL1(i, uiCode ); 1831 } 1832 } 1833 else 1834 { 1835 for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 1836 { 1837 refPicListModification->setRefPicSetIdxL1(i, 0 ); 1838 } 1839 } 1840 } 1841 } 1842 else 1843 { 1844 refPicListModification->setRefPicListModificationFlagL1(0); 1845 } 1846 if (pcSlice->isInterB()) 1847 { 1848 READ_FLAG( uiCode, "mvd_l1_zero_flag" ); pcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); 1849 } 1850 1851 pcSlice->setCabacInitFlag( false ); // default 1852 if(pps->getCabacInitPresentFlag() && !pcSlice->isIntra()) 1853 { 1854 READ_FLAG(uiCode, "cabac_init_flag"); 1855 pcSlice->setCabacInitFlag( uiCode ? true : false ); 1856 } 1857 1858 if ( pcSlice->getEnableTMVPFlag() ) 1859 { 1860 #if SVC_EXTENSION && REF_IDX_MFM 1861 // set motion mapping flag 1862 pcSlice->setMFMEnabledFlag( ( pcSlice->getNumMotionPredRefLayers() > 0 && pcSlice->getActiveNumILRRefIdx() && !pcSlice->isIntra() ) ? true : false ); 1863 #endif 1864 if ( pcSlice->getSliceType() == B_SLICE ) 1865 { 1866 READ_FLAG( uiCode, "collocated_from_l0_flag" ); 1867 pcSlice->setColFromL0Flag(uiCode); 1868 } 1869 else 1870 { 1871 pcSlice->setColFromL0Flag( 1 ); 1872 } 1873 1874 if ( pcSlice->getSliceType() != I_SLICE && 1875 ((pcSlice->getColFromL0Flag() == 1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| 1876 (pcSlice->getColFromL0Flag() == 0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) 1877 { 1878 READ_UVLC( uiCode, "collocated_ref_idx" ); 1879 pcSlice->setColRefIdx(uiCode); 1880 } 1881 else 1882 { 1883 pcSlice->setColRefIdx(0); 1884 } 1885 } 1886 if ( (pps->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) ) 1887 { 1888 xParsePredWeightTable(pcSlice); 1889 pcSlice->initWpScaling(); 1890 } 1891 if (!pcSlice->isIntra()) 1892 { 1893 READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); 1894 pcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); 1895 } 1896 1897 READ_SVLC( iCode, "slice_qp_delta" ); 1898 pcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); 1899 1900 #if REPN_FORMAT_IN_VPS 1901 #if O0194_DIFFERENT_BITDEPTH_EL_BL 1902 g_bitDepthLayer[CHANNEL_TYPE_LUMA][pcSlice->getLayerId()] = pcSlice->getBitDepthY(); 1903 g_bitDepthLayer[CHANNEL_TYPE_CHROMA][pcSlice->getLayerId()] = pcSlice->getBitDepthC(); 1904 #endif 1905 assert( pcSlice->getSliceQp() >= -pcSlice->getQpBDOffsetY() ); 1906 #else 1907 assert( pcSlice->getSliceQp() >= -sps->getQpBDOffset(CHANNEL_TYPE_LUMA) ); 1908 #endif 1909 assert( pcSlice->getSliceQp() <= 51 ); 1910 1911 if (pcSlice->getPPS()->getSliceChromaQpFlag()) 1912 { 1913 if (numValidComp>COMPONENT_Cb) 1914 { 1915 READ_SVLC( iCode, "slice_qp_delta_cb" ); 1916 pcSlice->setSliceChromaQpDelta(COMPONENT_Cb, iCode ); 1917 assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) >= -12 ); 1918 assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) <= 12 ); 1919 assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) >= -12 ); 1920 assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) <= 12 ); 1921 } 1922 1923 if (numValidComp>COMPONENT_Cr) 1924 { 1925 READ_SVLC( iCode, "slice_qp_delta_cr" ); 1926 pcSlice->setSliceChromaQpDelta(COMPONENT_Cr, iCode ); 1927 assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) >= -12 ); 1928 assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) <= 12 ); 1929 assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) >= -12 ); 1930 assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) <= 12 ); 1931 } 1932 } 1933 1934 if (pcSlice->getPPS()->getChromaQpAdjTableSize() > 0) 1935 { 1936 READ_FLAG(uiCode, "slice_chroma_qp_adjustment_enabled_flag"); pcSlice->setUseChromaQpAdj(uiCode != 0); 1937 } 1938 else pcSlice->setUseChromaQpAdj(false); 1939 1940 if (pcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) 1941 { 1942 if(pcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) 1943 { 1944 READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); pcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); 1945 } 1946 else 1947 { 1948 pcSlice->setDeblockingFilterOverrideFlag(0); 1949 } 1950 if(pcSlice->getDeblockingFilterOverrideFlag()) 1951 { 1952 READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); pcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); 1953 if(!pcSlice->getDeblockingFilterDisable()) 1954 { 1955 READ_SVLC( iCode, "slice_beta_offset_div2" ); pcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); 1956 assert(pcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && 1957 pcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); 1958 READ_SVLC( iCode, "slice_tc_offset_div2" ); pcSlice->setDeblockingFilterTcOffsetDiv2(iCode); 1959 assert(pcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && 1960 pcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); 1961 } 1962 } 1963 else 1964 { 1965 pcSlice->setDeblockingFilterDisable ( pcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); 1966 pcSlice->setDeblockingFilterBetaOffsetDiv2( pcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); 1967 pcSlice->setDeblockingFilterTcOffsetDiv2 ( pcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); 1968 } 1969 } 1970 else 1971 { 1972 pcSlice->setDeblockingFilterDisable ( false ); 1973 pcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); 1974 pcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); 1975 } 1976 1977 Bool isSAOEnabled = pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA) || (bChroma && pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA))); 1978 Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable()); 1979 1980 if(pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) 1981 { 1982 READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); 1983 } 1984 else 1985 { 1986 uiCode = pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; 1987 } 1988 pcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); 1989 1990 } 1991 1992 std::vector<UInt> entryPointOffset; 1993 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 1994 { 1995 UInt numEntryPointOffsets; 1996 UInt offsetLenMinus1; 1997 READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); 1998 if (numEntryPointOffsets>0) 1999 { 2000 READ_UVLC(offsetLenMinus1, "offset_len_minus1"); 2001 entryPointOffset.resize(numEntryPointOffsets); 2002 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 2003 { 2004 READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); 2005 entryPointOffset[ idx ] = uiCode + 1; 2006 } 2007 } 2008 } 2009 2010 #if POC_RESET_IDC_SIGNALLING 2011 Int sliceHeaderExtensionLength = 0; 2012 if(pps->getSliceHeaderExtensionPresentFlag()) 2013 { 2014 READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode; 2015 } 2016 else 2017 { 2018 sliceHeaderExtensionLength = 0; 2019 #if INFERENCE_POC_MSB_VAL_PRESENT 2020 pcSlice->setPocMsbValPresentFlag( false ); 2021 #endif 2022 } 2023 UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits 2024 if( sliceHeaderExtensionLength > 0 ) 2025 { 2026 if( pcSlice->getPPS()->getPocResetInfoPresentFlag() ) 2027 { 2028 READ_CODE( 2, uiCode, "poc_reset_idc"); pcSlice->setPocResetIdc(uiCode); 2029 #if POC_RESET_RESTRICTIONS 2030 /* The value of poc_reset_idc shall not be equal to 1 or 2 for a RASL picture, a RADL picture, 2031 a sub-layer non-reference picture, or a picture that has TemporalId greater than 0, 2032 or a picture that has discardable_flag equal to 1. */ 2033 if( pcSlice->getPocResetIdc() == 1 || pcSlice->getPocResetIdc() == 2 ) 2034 { 2035 assert( !pcSlice->isRASL() ); 2036 assert( !pcSlice->isRADL() ); 2037 assert( !pcSlice->isSLNR() ); 2038 assert( pcSlice->getTLayer() == 0 ); 2039 assert( pcSlice->getDiscardableFlag() == 0 ); 2040 } 2041 2042 // The value of poc_reset_idc of a CRA or BLA picture shall be less than 3. 2043 if( pcSlice->getPocResetIdc() == 3) 2044 { 2045 assert( ! ( pcSlice->isCRA() || pcSlice->isBLA() ) ); 2046 } 2047 #endif 2048 } 2049 else 2050 { 2051 pcSlice->setPocResetIdc( 0 ); 2052 } 2053 #if Q0142_POC_LSB_NOT_PRESENT 2054 if ( pcSlice->getVPS()->getPocLsbNotPresentFlag(pcSlice->getLayerId()) && iPOClsb > 0 ) 2055 { 2056 assert( pcSlice->getPocResetIdc() != 2 ); 2057 } 2058 #endif 2059 if( pcSlice->getPocResetIdc() > 0 ) 2060 { 2061 READ_CODE(6, uiCode, "poc_reset_period_id"); pcSlice->setPocResetPeriodId(uiCode); 2062 } 2063 else 2064 { 2065 2066 pcSlice->setPocResetPeriodId( 0 ); 2067 } 2068 2069 if (pcSlice->getPocResetIdc() == 3) 2070 { 2071 READ_FLAG( uiCode, "full_poc_reset_flag"); pcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); 2072 READ_CODE(pcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); pcSlice->setPocLsbVal(uiCode); 2073 #if Q0142_POC_LSB_NOT_PRESENT 2074 if ( pcSlice->getVPS()->getPocLsbNotPresentFlag(pcSlice->getLayerId()) && pcSlice->getFullPocResetFlag() ) 2075 { 2076 assert( pcSlice->getPocLsbVal() == 0 ); 2077 } 2078 #endif 2079 } 2080 2081 // Derive the value of PocMsbValRequiredFlag 2082 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2083 pcSlice->setPocMsbValRequiredFlag( (pcSlice->getCraPicFlag() || pcSlice->getBlaPicFlag()) 2084 && (!pcSlice->getVPS()->getVpsPocLsbAlignedFlag() || 2085 (pcSlice->getVPS()->getVpsPocLsbAlignedFlag() && pcSlice->getVPS()->getNumDirectRefLayers(pcSlice->getLayerId()) == 0)) 2086 ); 2087 #else 2088 pcSlice->setPocMsbValRequiredFlag( pcSlice->getCraPicFlag() || pcSlice->getBlaPicFlag() ); 2089 #endif 2090 2091 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2092 if (!pcSlice->getPocMsbValRequiredFlag() && pcSlice->getVPS()->getVpsPocLsbAlignedFlag()) 2093 #else 2094 if (!pcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */) 2095 #endif 2096 { 2097 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2098 READ_FLAG(uiCode, "poc_msb_cycle_val_present_flag"); pcSlice->setPocMsbValPresentFlag(uiCode ? true : false); 2099 #else 2100 READ_FLAG(uiCode, "poc_msb_val_present_flag"); pcSlice->setPocMsbValPresentFlag(uiCode ? true : false); 2101 #endif 2102 } 2103 else 2104 { 2105 #if POC_MSB_VAL_PRESENT_FLAG_SEM 2106 if( sliceHeaderExtensionLength == 0 ) 2107 { 2108 pcSlice->setPocMsbValPresentFlag( false ); 2109 } 2110 else if( pcSlice->getPocMsbValRequiredFlag() ) 2111 #else 2112 if( pcSlice->getPocMsbValRequiredFlag() ) 2113 #endif 2114 { 2115 pcSlice->setPocMsbValPresentFlag( true ); 2116 } 2117 else 2118 { 2119 pcSlice->setPocMsbValPresentFlag( false ); 2120 } 2121 } 2122 2123 #if !POC_RESET_IDC_DECODER 2124 Int maxPocLsb = 1 << pcSlice->getSPS()->getBitsForPOC(); 2125 #endif 2126 if( pcSlice->getPocMsbValPresentFlag() ) 2127 { 2128 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2129 READ_UVLC( uiCode, "poc_msb_cycle_val"); pcSlice->setPocMsbVal( uiCode ); 2130 #else 2131 READ_UVLC( uiCode, "poc_msb_val"); pcSlice->setPocMsbVal( uiCode ); 2132 #endif 2133 2134 #if !POC_RESET_IDC_DECODER 2135 // Update POC of the slice based on this MSB val 2136 Int pocLsb = pcSlice->getPOC() % maxPocLsb; 2137 pcSlice->setPOC((pcSlice->getPocMsbVal() * maxPocLsb) + pocLsb); 2138 } 2139 else 2140 { 2141 pcSlice->setPocMsbVal( pcSlice->getPOC() / maxPocLsb ); 2142 #endif 2143 } 2144 2145 // Read remaining bits in the slice header extension. 2146 UInt endBits = m_pcBitstream->getNumBitsRead(); 2147 Int counter = (endBits - startBits) % 8; 2148 if( counter ) 2149 { 2150 counter = 8 - counter; 2151 } 2152 2153 while( counter ) 2154 { 2155 #if Q0146_SSH_EXT_DATA_BIT 2156 READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); 2157 #else 2158 READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 ); 2159 #endif 2160 counter--; 2161 } 2162 } 2163 #else 2164 if(pps->getSliceHeaderExtensionPresentFlag()) 2165 { 2166 READ_UVLC(uiCode,"slice_header_extension_length"); 2167 for(Int i=0; i<uiCode; i++) 2168 { 2169 UInt ignore; 2170 READ_CODE(8,ignore,"slice_header_extension_data_byte"); 2171 } 2172 } 2173 #endif 2174 #if RExt__DECODER_DEBUG_BIT_STATISTICS 2175 TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,m_pcBitstream->readByteAlignment(),0); 2176 #else 2177 m_pcBitstream->readByteAlignment(); 2178 #endif 2179 2180 pcSlice->clearSubstreamSizes(); 2181 2182 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 2183 { 2184 Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); 2185 2186 // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header 2187 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 2188 { 2189 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) 2190 { 2191 endOfSliceHeaderLocation++; 2192 } 2193 } 2194 2195 Int curEntryPointOffset = 0; 2196 Int prevEntryPointOffset = 0; 2197 for (UInt idx=0; idx<entryPointOffset.size(); idx++) 2198 { 2199 curEntryPointOffset += entryPointOffset[ idx ]; 2200 2201 Int emulationPreventionByteCount = 0; 2202 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 2203 { 2204 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && 2205 m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) 2206 { 2207 emulationPreventionByteCount++; 2208 } 2209 } 2210 2211 entryPointOffset[ idx ] -= emulationPreventionByteCount; 2212 prevEntryPointOffset = curEntryPointOffset; 2213 pcSlice->addSubstreamSize(entryPointOffset [ idx ] ); 2214 } 2215 } 2216 2217 return; 2218 } 2219 2220 Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) 2221 { 2222 UInt uiCode; 2223 if(profilePresentFlag) 2224 { 2225 parseProfileTier(rpcPTL->getGeneralPTL()); 2226 } 2227 READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(Level::Name(uiCode)); 2228 2229 for (Int i = 0; i < maxNumSubLayersMinus1; i++) 2230 { 2231 if(profilePresentFlag) 2232 { 2233 READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); 2234 } 2235 READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); 2236 } 2237 2238 if (maxNumSubLayersMinus1 > 0) 2239 { 2240 for (Int i = maxNumSubLayersMinus1; i < 8; i++) 2241 { 2242 READ_CODE(2, uiCode, "reserved_zero_2bits"); 2243 assert(uiCode == 0); 2244 } 2245 } 2246 2247 for(Int i = 0; i < maxNumSubLayersMinus1; i++) 2248 { 2249 if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) 2250 { 2251 parseProfileTier(rpcPTL->getSubLayerPTL(i)); 2252 } 2253 if(rpcPTL->getSubLayerLevelPresentFlag(i)) 2254 { 2255 READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(Level::Name(uiCode)); 2256 } 2257 } 2258 } 2259 2260 Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) 2261 { 2262 UInt uiCode; 2263 READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); 2264 READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? Level::HIGH : Level::MAIN); 2265 READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (Profile::Name(uiCode)); 2266 for(Int j = 0; j < 32; j++) 2267 { 2268 READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); 2269 } 2270 READ_FLAG(uiCode, "general_progressive_source_flag"); 2271 ptl->setProgressiveSourceFlag(uiCode ? true : false); 2272 2273 READ_FLAG(uiCode, "general_interlaced_source_flag"); 2274 ptl->setInterlacedSourceFlag(uiCode ? true : false); 2275 2276 READ_FLAG(uiCode, "general_non_packed_constraint_flag"); 2277 ptl->setNonPackedConstraintFlag(uiCode ? true : false); 2278 2279 READ_FLAG(uiCode, "general_frame_only_constraint_flag"); 2280 ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); 2281 2282 if (ptl->getProfileIdc() == Profile::MAINREXT || ptl->getProfileIdc() == Profile::HIGHTHROUGHPUTREXT ) 2283 { 2284 UInt maxBitDepth=16; 2285 READ_FLAG( uiCode, "general_max_12bit_constraint_flag" ); if (uiCode) maxBitDepth=12; 2286 READ_FLAG( uiCode, "general_max_10bit_constraint_flag" ); if (uiCode) maxBitDepth=10; 2287 READ_FLAG( uiCode, "general_max_8bit_constraint_flag" ); if (uiCode) maxBitDepth=8; 2288 ptl->setBitDepthConstraint(maxBitDepth); 2289 ChromaFormat chromaFmtConstraint=CHROMA_444; 2290 READ_FLAG( uiCode, "general_max_422chroma_constraint_flag" ); if (uiCode) chromaFmtConstraint=CHROMA_422; 2291 READ_FLAG( uiCode, "general_max_420chroma_constraint_flag" ); if (uiCode) chromaFmtConstraint=CHROMA_420; 2292 READ_FLAG( uiCode, "general_max_monochrome_constraint_flag" ); if (uiCode) chromaFmtConstraint=CHROMA_400; 2293 ptl->setChromaFormatConstraint(chromaFmtConstraint); 2294 READ_FLAG( uiCode, "general_intra_constraint_flag"); ptl->setIntraConstraintFlag(uiCode != 0); 2295 READ_FLAG( uiCode, "general_one_picture_only_constraint_flag"); 2296 READ_FLAG( uiCode, "general_lower_bit_rate_constraint_flag"); ptl->setLowerBitRateConstraintFlag(uiCode != 0); 2297 READ_CODE(16, uiCode, "XXX_reserved_zero_35bits[0..15]"); 2298 READ_CODE(16, uiCode, "XXX_reserved_zero_35bits[16..31]"); 2299 READ_CODE(3, uiCode, "XXX_reserved_zero_35bits[32..34]"); 2300 } 2301 else 2302 { 2303 ptl->setBitDepthConstraint((ptl->getProfileIdc() == Profile::MAIN10)?10:8); 2304 ptl->setChromaFormatConstraint(CHROMA_420); 2305 ptl->setIntraConstraintFlag(false); 2306 ptl->setLowerBitRateConstraintFlag(true); 2307 READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); 2308 READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); 2309 READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); 2310 } 2311 } 2312 2313 Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) 2314 { 2315 ruiBit = false; 2316 Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); 2317 if(iBitsLeft <= 8) 2318 { 2319 UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); 2320 if (uiPeekValue == (1<<(iBitsLeft-1))) 2321 { 2322 ruiBit = true; 2323 } 2324 } 2325 } 2326 2327 Void TDecCavlc::parseRemainingBytes( Bool noTrailingBytesExpected ) 2328 { 2329 if (noTrailingBytesExpected) 2330 { 2331 const UInt numberOfRemainingSubstreamBytes=m_pcBitstream->getNumBitsLeft(); 2332 assert (numberOfRemainingSubstreamBytes == 0); 2333 } 2334 else 2335 { 2336 while (m_pcBitstream->getNumBitsLeft()) 2337 { 2338 UInt trailingNullByte=m_pcBitstream->readByte(); 2339 if (trailingNullByte!=0) 2340 { 2341 printf("Trailing byte should be 0, but has value %02x\n", trailingNullByte); 2342 assert(trailingNullByte==0); 2343 } 2344 } 2345 } 2346 } 2347 2348 Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2349 { 2350 assert(0); 2351 } 2352 2353 Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2354 { 2355 assert(0); 2356 } 2357 2358 Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) 2359 { 2360 assert(0); 2361 } 2362 2363 Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2364 { 2365 assert(0); 2366 } 2367 2368 Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2369 { 2370 assert(0); 2371 } 2372 2373 Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2374 { 2375 assert(0); 2376 } 2377 2378 /** Parse I_PCM information. 2379 * \param pcCU pointer to CU 2380 * \param uiAbsPartIdx CU index 2381 * \param uiDepth CU depth 2382 * \returns Void 2383 * 2384 * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. 2385 */ 2386 Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2387 { 2388 assert(0); 2389 } 2390 2391 Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2392 { 2393 assert(0); 2394 } 2395 2396 Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2397 { 2398 assert(0); 2399 } 2400 2401 Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) 2402 { 2403 assert(0); 2404 } 2405 2406 Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) 2407 { 2408 assert(0); 2409 } 2410 2411 Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) 2412 { 2413 assert(0); 2414 } 2415 2416 Void TDecCavlc::parseCrossComponentPrediction( class TComTU& /*rTu*/, ComponentID /*compID*/ ) 2417 { 2418 assert(0); 2419 } 2420 2421 Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 2422 { 2423 Int qp; 2424 Int iDQp; 2425 2426 #if RExt__DECODER_DEBUG_BIT_STATISTICS 2427 READ_SVLC(iDQp, "delta_qp"); 2428 #else 2429 xReadSvlc( iDQp ); 2430 #endif 2431 2432 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); 2433 qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; 2434 2435 UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; 2436 UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; 2437 2438 pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); 2439 } 2440 2441 Void TDecCavlc::parseChromaQpAdjustment( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2442 { 2443 assert(0); 2444 } 2445 2446 Void TDecCavlc::parseCoeffNxN( TComTU &/*rTu*/, ComponentID /*compID*/ ) 2447 { 2448 assert(0); 2449 } 2450 2451 Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) 2452 { 2453 assert(0); 2454 } 2455 2456 Void TDecCavlc::parseQtCbf( TComTU &/*rTu*/, const ComponentID /*compID*/, const Bool /*lowestLevel*/ ) 2457 { 2458 assert(0); 2459 } 2460 2461 Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) 2462 { 2463 assert(0); 2464 } 2465 2466 Void TDecCavlc::parseTransformSkipFlags (TComTU &/*rTu*/, ComponentID /*component*/) 2467 { 2468 assert(0); 2469 } 2470 2471 Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) 2472 { 2473 assert(0); 2474 } 2475 2476 Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) 2477 { 2478 assert(0); 2479 } 2480 2481 // ==================================================================================================================== 2482 // Protected member functions 2483 // ==================================================================================================================== 2484 2485 /** parse explicit wp tables 2486 * \param TComSlice* pcSlice 2487 * \returns Void 2488 */ 2489 Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) 2490 { 2491 WPScalingParam *wp; 2492 TComSPS *sps = pcSlice->getSPS(); 2493 const ChromaFormat chFmt = sps->getChromaFormatIdc(); 2494 const Int numValidComp = Int(getNumberValidComponents(chFmt)); 2495 const Bool bChroma = (chFmt!=CHROMA_400); 2496 const SliceType eSliceType = pcSlice->getSliceType(); 2497 const Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); 2498 UInt uiLog2WeightDenomLuma=0, uiLog2WeightDenomChroma=0; 2499 UInt uiTotalSignalledWeightFlags = 0; 2500 2501 Int iDeltaDenom; 2502 // decode delta_luma_log2_weight_denom : 2503 READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom 2504 assert( uiLog2WeightDenomLuma <= 7 ); 2505 if( bChroma ) 2506 { 2507 READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom 2508 assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); 2509 assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); 2510 uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); 2511 } 2512 2513 for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) 2514 { 2515 RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 2516 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2517 { 2518 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2519 2520 wp[COMPONENT_Y].uiLog2WeightDenom = uiLog2WeightDenomLuma; 2521 for(Int j=1; j<numValidComp; j++) 2522 { 2523 wp[j].uiLog2WeightDenom = uiLog2WeightDenomChroma; 2524 } 2525 2526 UInt uiCode; 2527 READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag 2528 wp[COMPONENT_Y].bPresentFlag = ( uiCode == 1 ); 2529 uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag; 2530 } 2531 if ( bChroma ) 2532 { 2533 UInt uiCode; 2534 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2535 { 2536 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2537 READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag 2538 for(Int j=1; j<numValidComp; j++) 2539 { 2540 wp[j].bPresentFlag = ( uiCode == 1 ); 2541 } 2542 uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag; 2543 } 2544 } 2545 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2546 { 2547 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2548 if ( wp[COMPONENT_Y].bPresentFlag ) 2549 { 2550 Int iDeltaWeight; 2551 READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] 2552 assert( iDeltaWeight >= -128 ); 2553 assert( iDeltaWeight <= 127 ); 2554 wp[COMPONENT_Y].iWeight = (iDeltaWeight + (1<<wp[COMPONENT_Y].uiLog2WeightDenom)); 2555 READ_SVLC( wp[COMPONENT_Y].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] 2556 Int range=sps->getUseHighPrecisionPredictionWeighting() ? (1<<g_bitDepth[CHANNEL_TYPE_LUMA])/2 : 128; 2557 assert( wp[0].iOffset >= -range ); 2558 assert( wp[0].iOffset < range ); 2559 } 2560 else 2561 { 2562 wp[COMPONENT_Y].iWeight = (1 << wp[COMPONENT_Y].uiLog2WeightDenom); 2563 wp[COMPONENT_Y].iOffset = 0; 2564 } 2565 if ( bChroma ) 2566 { 2567 if ( wp[COMPONENT_Cb].bPresentFlag ) 2568 { 2569 Int range=sps->getUseHighPrecisionPredictionWeighting() ? (1<<g_bitDepth[CHANNEL_TYPE_CHROMA])/2 : 128; 2570 for ( Int j=1 ; j<numValidComp ; j++ ) 2571 { 2572 Int iDeltaWeight; 2573 READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] 2574 assert( iDeltaWeight >= -128 ); 2575 assert( iDeltaWeight <= 127 ); 2576 wp[j].iWeight = (iDeltaWeight + (1<<wp[j].uiLog2WeightDenom)); 2577 2578 Int iDeltaChroma; 2579 READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] 2580 assert( iDeltaChroma >= -4*range); 2581 assert( iDeltaChroma < 4*range); 2582 Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); 2583 wp[j].iOffset = Clip3(-range, range-1, (iDeltaChroma + pred) ); 2584 } 2585 } 2586 else 2587 { 2588 for ( Int j=1 ; j<numValidComp ; j++ ) 2589 { 2590 wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); 2591 wp[j].iOffset = 0; 2592 } 2593 } 2594 } 2595 } 2596 2597 for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) 2598 { 2599 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2600 2601 wp[0].bPresentFlag = false; 2602 wp[1].bPresentFlag = false; 2603 wp[2].bPresentFlag = false; 2604 } 2605 } 2606 assert(uiTotalSignalledWeightFlags<=24); 2607 } 2608 2609 /** decode quantization matrix 2610 * \param scalingList quantization matrix information 2611 */ 2612 Void TDecCavlc::parseScalingList(TComScalingList* scalingList) 2613 { 2614 UInt code, sizeId, listId; 2615 Bool scalingListPredModeFlag; 2616 //for each size 2617 for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) 2618 { 2619 for(listId = 0; listId < SCALING_LIST_NUM; listId++) 2620 { 2621 if ((sizeId==SCALING_LIST_32x32) && (listId%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) != 0)) 2622 { 2623 Int *src = scalingList->getScalingListAddress(sizeId, listId); 2624 const Int size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); 2625 const Int *srcNextSmallerSize = scalingList->getScalingListAddress(sizeId-1, listId); 2626 for(Int i=0; i<size; i++) 2627 { 2628 src[i] = srcNextSmallerSize[i]; 2629 } 2630 scalingList->setScalingListDC(sizeId,listId,(sizeId > SCALING_LIST_8x8) ? scalingList->getScalingListDC(sizeId-1, listId) : src[0]); 2631 } 2632 else 2633 { 2634 READ_FLAG( code, "scaling_list_pred_mode_flag"); 2635 scalingListPredModeFlag = (code) ? true : false; 2636 if(!scalingListPredModeFlag) //Copy Mode 2637 { 2638 READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); 2639 2640 if (sizeId==SCALING_LIST_32x32) 2641 code*=(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES); // Adjust the decoded code for this size, to cope with the missing 32x32 chroma entries. 2642 2643 scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); 2644 if( sizeId > SCALING_LIST_8x8 ) 2645 { 2646 scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); 2647 } 2648 scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); 2649 2650 } 2651 else //DPCM Mode 2652 { 2653 xDecodeScalingList(scalingList, sizeId, listId); 2654 } 2655 } 2656 } 2657 } 2658 2659 return; 2660 } 2661 /** decode DPCM 2662 * \param scalingList quantization matrix information 2663 * \param sizeId size index 2664 * \param listId list index 2665 */ 2666 Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) 2667 { 2668 Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); 2669 Int data; 2670 Int scalingListDcCoefMinus8 = 0; 2671 Int nextCoef = SCALING_LIST_START_VALUE; 2672 UInt* scan = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][sizeId==0 ? 2 : 3][sizeId==0 ? 2 : 3]; 2673 Int *dst = scalingList->getScalingListAddress(sizeId, listId); 2674 2675 if( sizeId > SCALING_LIST_8x8 ) 2676 { 2677 READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); 2678 scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); 2679 nextCoef = scalingList->getScalingListDC(sizeId,listId); 2680 } 2681 2682 for(i = 0; i < coefNum; i++) 2683 { 2684 READ_SVLC( data, "scaling_list_delta_coef"); 2685 nextCoef = (nextCoef + data + 256 ) % 256; 2686 dst[scan[i]] = nextCoef; 2687 } 2688 } 2689 2690 Bool TDecCavlc::xMoreRbspData() 2691 { 2692 Int bitsLeft = m_pcBitstream->getNumBitsLeft(); 2693 2694 // if there are more than 8 bits, it cannot be rbsp_trailing_bits 2695 if (bitsLeft > 8) 2696 { 2697 return true; 2698 } 2699 2700 UChar lastByte = m_pcBitstream->peekBits(bitsLeft); 2701 Int cnt = bitsLeft; 2702 2703 // remove trailing bits equal to zero 2704 while ((cnt>0) && ((lastByte & 1) == 0)) 2705 { 2706 lastByte >>= 1; 2707 cnt--; 2708 } 2709 // remove bit equal to one 2710 cnt--; 2711 2712 // we should not have a negative number of bits 2713 assert (cnt>=0); 2714 2715 // we have more data, if cnt is not zero 2716 return (cnt>0); 2717 } 2718 2719 Void TDecCavlc::parseExplicitRdpcmMode( TComTU &rTu, ComponentID compID ) 2720 { 2721 assert(0); 1358 2722 } 1359 2723 … … 2933 4297 } 2934 4298 2935 #endif //SVC_EXTENSION 2936 2937 Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) 2938 { 2939 UInt uiCode; 2940 Int iCode; 2941 2942 #if ENC_DEC_TRACE 2943 xTraceSliceHeader(rpcSlice); 2944 #endif 2945 TComPPS* pps = NULL; 2946 TComSPS* sps = NULL; 2947 2948 UInt firstSliceSegmentInPic; 2949 READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); 2950 if( rpcSlice->getRapPicFlag()) 2951 { 2952 READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already 2953 #if SETTING_NO_OUT_PIC_PRIOR 2954 rpcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); 2955 #else 2956 rpcSlice->setNoOutputPicPrior( false ); 2957 #endif 2958 } 2959 READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); 2960 pps = parameterSetManager->getPrefetchedPPS(uiCode); 2961 //!KS: need to add error handling code here, if PPS is not available 2962 assert(pps!=0); 2963 sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); 2964 //!KS: need to add error handling code here, if SPS is not available 2965 assert(sps!=0); 2966 rpcSlice->setSPS(sps); 2967 rpcSlice->setPPS(pps); 2968 2969 #if R0227_REP_FORMAT_CONSTRAINT //Conformance checking for rep format -- rep format of current picture of current layer shall never be greater rep format defined in VPS for the current layer 2970 TComVPS* vps = NULL; 2971 vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId()); 2972 #if R0279_REP_FORMAT_INBL 2973 if ( vps->getVpsExtensionFlag() == 1 && (rpcSlice->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) ) 2974 { 2975 assert( sps->getPicWidthInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getPicWidthVpsInLumaSamples() ); 2976 assert( sps->getPicHeightInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getPicHeightVpsInLumaSamples() ); 2977 assert( sps->getChromaFormatIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getChromaFormatVpsIdc() ); 2978 assert( sps->getBitDepthY() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getBitDepthVpsLuma() ); 2979 assert( sps->getBitDepthC() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getBitDepthVpsChroma() ); 2980 #else 2981 if ( rpcSlice->getLayerId() == 0 && vps->getVpsExtensionFlag() == 1 ) 2982 { 2983 assert( sps->getPicWidthInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getPicWidthVpsInLumaSamples() ); 2984 assert( sps->getPicHeightInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getPicHeightVpsInLumaSamples() ); 2985 assert( sps->getChromaFormatIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getChromaFormatVpsIdc() ); 2986 assert( sps->getBitDepthY() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getBitDepthVpsLuma() ); 2987 assert( sps->getBitDepthC() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getBitDepthVpsChroma() ); 2988 #endif 2989 } 2990 else if ( vps->getVpsExtensionFlag() == 1 ) 2991 { 2992 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getPicWidthVpsInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getPicWidthVpsInLumaSamples()); 2993 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getPicHeightVpsInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getPicHeightVpsInLumaSamples()); 2994 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getChromaFormatVpsIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getChromaFormatVpsIdc()); 2995 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getBitDepthVpsLuma() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getBitDepthVpsLuma()); 2996 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getBitDepthVpsChroma() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getBitDepthVpsChroma()); 2997 } 2998 #endif 2999 3000 if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) 3001 { 3002 READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); 3003 } 3004 else 3005 { 3006 rpcSlice->setDependentSliceSegmentFlag(false); 3007 } 3008 #if REPN_FORMAT_IN_VPS 3009 Int numCTUs = ((rpcSlice->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((rpcSlice->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); 3010 #else 3011 Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); 3012 #endif 3013 Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); 3014 UInt sliceSegmentAddress = 0; 3015 Int bitsSliceSegmentAddress = 0; 3016 while(numCTUs>(1<<bitsSliceSegmentAddress)) 3017 { 3018 bitsSliceSegmentAddress++; 3019 } 3020 3021 if(!firstSliceSegmentInPic) 3022 { 3023 READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); 3024 } 3025 //set uiCode to equal slice start address (or dependent slice start address) 3026 Int startCuAddress = maxParts*sliceSegmentAddress; 3027 rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); 3028 rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); 3029 3030 if (rpcSlice->getDependentSliceSegmentFlag()) 3031 { 3032 rpcSlice->setNextSlice ( false ); 3033 rpcSlice->setNextSliceSegment ( true ); 3034 } 3035 else 3036 { 3037 rpcSlice->setNextSlice ( true ); 3038 rpcSlice->setNextSliceSegment ( false ); 3039 3040 rpcSlice->setSliceCurStartCUAddr(startCuAddress); 3041 rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); 3042 } 3043 3044 #if Q0142_POC_LSB_NOT_PRESENT 3045 #if SHM_FIX7 3046 Int iPOClsb = 0; 3047 #endif 3048 #endif 3049 3050 if(!rpcSlice->getDependentSliceSegmentFlag()) 3051 { 3052 #if SVC_EXTENSION 3053 #if POC_RESET_FLAG 3054 Int iBits = 0; 3055 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3056 { 3057 READ_FLAG(uiCode, "poc_reset_flag"); rpcSlice->setPocResetFlag( uiCode ? true : false ); 3058 iBits++; 3059 } 3060 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3061 { 3062 #if DISCARDABLE_PIC_RPS 3063 READ_FLAG(uiCode, "discardable_flag"); rpcSlice->setDiscardableFlag( uiCode ? true : false ); 3064 #else 3065 READ_FLAG(uiCode, "discardable_flag"); // ignored 3066 #endif 3067 iBits++; 3068 } 3069 #if O0149_CROSS_LAYER_BLA_FLAG 3070 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3071 { 3072 READ_FLAG(uiCode, "cross_layer_bla_flag"); rpcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); 3073 iBits++; 3074 } 3075 #endif 3076 for (; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 3077 { 3078 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 3079 } 3080 #else 3081 #if CROSS_LAYER_BLA_FLAG_FIX 3082 Int iBits = 0; 3083 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3084 #else 3085 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) 3086 #endif 3087 { 3088 READ_FLAG(uiCode, "discardable_flag"); // ignored 3089 #if NON_REF_NAL_TYPE_DISCARDABLE 3090 rpcSlice->setDiscardableFlag( uiCode ? true : false ); 3091 if (uiCode) 3092 { 3093 assert(rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && 3094 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && 3095 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && 3096 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && 3097 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); 3098 } 3099 #endif 3100 #if CROSS_LAYER_BLA_FLAG_FIX 3101 iBits++; 3102 #endif 3103 } 3104 #if CROSS_LAYER_BLA_FLAG_FIX 3105 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3106 { 3107 READ_FLAG(uiCode, "cross_layer_bla_flag"); rpcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); 3108 iBits++; 3109 } 3110 for ( ; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 3111 #else 3112 for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 3113 #endif 3114 { 3115 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 3116 } 3117 #endif 3118 #else //SVC_EXTENSION 3119 for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 3120 { 3121 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 3122 } 3123 #endif //SVC_EXTENSION 3124 3125 READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); 3126 if( pps->getOutputFlagPresentFlag() ) 3127 { 3128 READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); 3129 } 3130 else 3131 { 3132 rpcSlice->setPicOutputFlag( true ); 3133 } 3134 // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present 3135 assert (sps->getChromaFormatIdc() == 1 ); 3136 // if( separate_colour_plane_flag == 1 ) 3137 // colour_plane_id u(2) 3138 3139 if( rpcSlice->getIdrPicFlag() ) 3140 { 3141 rpcSlice->setPOC(0); 3142 TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); 3143 rps->setNumberOfNegativePictures(0); 3144 rps->setNumberOfPositivePictures(0); 3145 rps->setNumberOfLongtermPictures(0); 3146 rps->setNumberOfPictures(0); 3147 rpcSlice->setRPS(rps); 3148 } 3149 #if N0065_LAYER_POC_ALIGNMENT 3150 #if !Q0142_POC_LSB_NOT_PRESENT 3151 #if SHM_FIX7 3152 Int iPOClsb = 0; 3153 #endif 3154 #endif 3155 #if O0062_POC_LSB_NOT_PRESENT_FLAG 3156 if( ( rpcSlice->getLayerId() > 0 && !rpcSlice->getVPS()->getPocLsbNotPresentFlag( rpcSlice->getVPS()->getLayerIdInVps(rpcSlice->getLayerId())) ) || !rpcSlice->getIdrPicFlag()) 3157 #else 3158 if( rpcSlice->getLayerId() > 0 || !rpcSlice->getIdrPicFlag() ) 3159 #endif 3160 #else 3161 else 3162 #endif 3163 { 3164 READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); 3165 #if POC_RESET_IDC_DECODER 3166 rpcSlice->setPicOrderCntLsb( uiCode ); 3167 #endif 3168 #if SHM_FIX7 3169 iPOClsb = uiCode; 3170 #else 3171 Int iPOClsb = uiCode; 3172 #endif 3173 Int iPrevPOC = rpcSlice->getPrevTid0POC(); 3174 Int iMaxPOClsb = 1<< sps->getBitsForPOC(); 3175 Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); 3176 Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; 3177 Int iPOCmsb; 3178 if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) 3179 { 3180 iPOCmsb = iPrevPOCmsb + iMaxPOClsb; 3181 } 3182 else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) 3183 { 3184 iPOCmsb = iPrevPOCmsb - iMaxPOClsb; 3185 } 3186 else 3187 { 3188 iPOCmsb = iPrevPOCmsb; 3189 } 3190 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 3191 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 3192 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 3193 { 3194 // For BLA picture types, POCmsb is set to 0. 3195 iPOCmsb = 0; 3196 } 3197 rpcSlice->setPOC (iPOCmsb+iPOClsb); 3198 3199 #if N0065_LAYER_POC_ALIGNMENT 3200 #if SHM_FIX7 3201 } 3202 #endif 3203 #if POC_RESET_IDC_DECODER 3204 else 3205 { 3206 rpcSlice->setPicOrderCntLsb( 0 ); 3207 } 3208 #endif 3209 if( !rpcSlice->getIdrPicFlag() ) 3210 { 3211 #endif 3212 TComReferencePictureSet* rps; 3213 rps = rpcSlice->getLocalRPS(); 3214 rpcSlice->setRPS(rps); 3215 READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); 3216 if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header 3217 { 3218 parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); 3219 } 3220 else // use reference to short-term reference picture set in PPS 3221 { 3222 Int numBits = 0; 3223 while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) 3224 { 3225 numBits++; 3226 } 3227 if (numBits > 0) 3228 { 3229 READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); 3230 } 3231 else 3232 { 3233 uiCode = 0; 3234 } 3235 *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); 3236 } 3237 if(sps->getLongTermRefsPresent()) 3238 { 3239 Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); 3240 UInt numOfLtrp = 0; 3241 UInt numLtrpInSPS = 0; 3242 if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) 3243 { 3244 READ_UVLC( uiCode, "num_long_term_sps"); 3245 numLtrpInSPS = uiCode; 3246 numOfLtrp += numLtrpInSPS; 3247 rps->setNumberOfLongtermPictures(numOfLtrp); 3248 } 3249 Int bitsForLtrpInSPS = 0; 3250 while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) 3251 { 3252 bitsForLtrpInSPS++; 3253 } 3254 READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); 3255 numOfLtrp += uiCode; 3256 rps->setNumberOfLongtermPictures(numOfLtrp); 3257 Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); 3258 Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; 3259 for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) 3260 { 3261 Int pocLsbLt; 3262 if (k < numLtrpInSPS) 3263 { 3264 uiCode = 0; 3265 if (bitsForLtrpInSPS > 0) 3266 { 3267 READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); 3268 } 3269 Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); 3270 3271 pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); 3272 rps->setUsed(j,usedByCurrFromSPS); 3273 } 3274 else 3275 { 3276 READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; 3277 READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); 3278 } 3279 READ_FLAG(uiCode,"delta_poc_msb_present_flag"); 3280 Bool mSBPresentFlag = uiCode ? true : false; 3281 if(mSBPresentFlag) 3282 { 3283 READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); 3284 Bool deltaFlag = false; 3285 // First LTRP || First LTRP from SH 3286 if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) 3287 { 3288 deltaFlag = true; 3289 } 3290 if(deltaFlag) 3291 { 3292 deltaPocMSBCycleLT = uiCode; 3293 } 3294 else 3295 { 3296 deltaPocMSBCycleLT = uiCode + prevDeltaMSB; 3297 } 3298 3299 Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB 3300 - iPOClsb + pocLsbLt; 3301 rps->setPOC (j, pocLTCurr); 3302 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); 3303 rps->setCheckLTMSBPresent(j,true); 3304 } 3305 else 3306 { 3307 rps->setPOC (j, pocLsbLt); 3308 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); 3309 rps->setCheckLTMSBPresent(j,false); 3310 3311 // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present 3312 if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) 3313 { 3314 deltaPocMSBCycleLT = 0; 3315 } 3316 } 3317 prevDeltaMSB = deltaPocMSBCycleLT; 3318 } 3319 offset += rps->getNumberOfLongtermPictures(); 3320 rps->setNumberOfPictures(offset); 3321 } 3322 #if DPB_CONSTRAINTS 3323 if(rpcSlice->getVPS()->getVpsExtensionFlag()==1) 3324 { 3325 #if Q0078_ADD_LAYER_SETS 3326 for (Int ii = 1; ii < (rpcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++) // prevent assert error when num_add_layer_sets > 0 3327 #else 3328 for (Int ii=1; ii< rpcSlice->getVPS()->getNumOutputLayerSets(); ii++ ) 3329 #endif 3330 { 3331 Int layerSetIdxForOutputLayerSet = rpcSlice->getVPS()->getOutputLayerSetIdx( ii ); 3332 Int chkAssert=0; 3333 for(Int kk = 0; kk < rpcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++) 3334 { 3335 if(rpcSlice->getLayerId()==rpcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk)) 3336 { 3337 chkAssert=1; 3338 } 3339 } 3340 if(chkAssert) 3341 { 3342 // There may be something wrong here (layer id assumed to be layer idx?) 3343 assert(rps->getNumberOfNegativePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 3344 assert(rps->getNumberOfPositivePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); 3345 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 3346 } 3347 } 3348 3349 3350 } 3351 if(rpcSlice->getLayerId() == 0) 3352 { 3353 assert(rps->getNumberOfNegativePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) ); 3354 assert(rps->getNumberOfPositivePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures()); 3355 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1)); 3356 } 3357 #endif 3358 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 3359 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 3360 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 3361 { 3362 // In the case of BLA picture types, rps data is read from slice header but ignored 3363 rps = rpcSlice->getLocalRPS(); 3364 rps->setNumberOfNegativePictures(0); 3365 rps->setNumberOfPositivePictures(0); 3366 rps->setNumberOfLongtermPictures(0); 3367 rps->setNumberOfPictures(0); 3368 rpcSlice->setRPS(rps); 3369 } 3370 if (rpcSlice->getSPS()->getTMVPFlagsPresent()) 3371 { 3372 #if R0226_SLICE_TMVP 3373 READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" ); 3374 #else 3375 READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); 3376 #endif 3377 rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); 3378 } 3379 else 3380 { 3381 rpcSlice->setEnableTMVPFlag(false); 3382 } 3383 #if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX7 3384 } 3385 #endif 3386 } 3387 3388 #if SVC_EXTENSION 3389 rpcSlice->setActiveNumILRRefIdx(0); 3390 if((rpcSlice->getLayerId() > 0) && !(rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (rpcSlice->getNumILRRefIdx() > 0) ) 3391 { 3392 READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); 3393 rpcSlice->setInterLayerPredEnabledFlag(uiCode); 3394 if( rpcSlice->getInterLayerPredEnabledFlag()) 3395 { 3396 if(rpcSlice->getNumILRRefIdx() > 1) 3397 { 3398 Int numBits = 1; 3399 while ((1 << numBits) < rpcSlice->getNumILRRefIdx()) 3400 { 3401 numBits++; 3402 } 3403 if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) 3404 { 3405 READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); 3406 rpcSlice->setActiveNumILRRefIdx(uiCode + 1); 3407 } 3408 else 3409 { 3410 #if P0079_DERIVE_NUMACTIVE_REF_PICS 3411 for( Int i = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) 3412 { 3413 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 3414 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 3415 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 3416 #else 3417 if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && 3418 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 3419 #endif 3420 { 3421 rpcSlice->setActiveNumILRRefIdx(1); 3422 break; 3423 } 3424 } 3425 #else 3426 rpcSlice->setActiveNumILRRefIdx(1); 3427 #endif 3428 } 3429 3430 if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() ) 3431 { 3432 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3433 { 3434 rpcSlice->setInterLayerPredLayerIdc(i,i); 3435 } 3436 } 3437 else 3438 { 3439 for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3440 { 3441 READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); 3442 rpcSlice->setInterLayerPredLayerIdc(uiCode,i); 3443 } 3444 } 3445 } 3446 else 3447 { 3448 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 3449 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 3450 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 3451 (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) 3452 #else 3453 if( (rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer()) && 3454 (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) 3455 #endif 3456 { 3457 #endif 3458 rpcSlice->setActiveNumILRRefIdx(1); 3459 rpcSlice->setInterLayerPredLayerIdc(0,0); 3460 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 3461 } 3462 #endif 3463 } 3464 } 3465 } 3466 else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true && (rpcSlice->getLayerId() > 0 )) 3467 { 3468 rpcSlice->setInterLayerPredEnabledFlag(true); 3469 3470 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 3471 Int numRefLayerPics = 0; 3472 Int i = 0; 3473 Int refLayerPicIdc [MAX_VPS_LAYER_ID_PLUS1]; 3474 for(i = 0, numRefLayerPics = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) 3475 { 3476 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 3477 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 3478 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 3479 #else 3480 if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && 3481 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 3482 #endif 3483 { 3484 refLayerPicIdc[ numRefLayerPics++ ] = i; 3485 } 3486 } 3487 rpcSlice->setActiveNumILRRefIdx(numRefLayerPics); 3488 for( i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3489 { 3490 rpcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i); 3491 } 3492 #else 3493 rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx()); 3494 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3495 { 3496 rpcSlice->setInterLayerPredLayerIdc(i,i); 3497 } 3498 #endif 3499 } 4299 Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) 4300 { 4301 UInt uiCode; 4302 // more syntax elements to be parsed here 4303 4304 READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); 4305 // Vertical MV component restriction is not used in SHVC CTC 4306 assert( uiCode == 0 ); 4307 4308 #if !MOVE_SCALED_OFFSET_TO_PPS 4309 if( pcSPS->getLayerId() > 0 ) 4310 { 4311 Int iCode; 4312 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); 4313 for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) 4314 { 4315 Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); 4316 #if O0098_SCALED_REF_LAYER_ID 4317 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); 4318 #endif 4319 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 4320 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 4321 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 4322 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 3500 4323 #if P0312_VERT_PHASE_ADJ 3501 for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3502 { 3503 UInt refLayerIdc = rpcSlice->getInterLayerPredLayerIdc(i); 3504 #if !MOVE_SCALED_OFFSET_TO_PPS 3505 if( rpcSlice->getSPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 3506 #else 3507 if( rpcSlice->getPPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 3508 #endif 3509 { 3510 READ_FLAG( uiCode, "vert_phase_position_flag" ); rpcSlice->setVertPhasePositionFlag( uiCode? true : false, refLayerIdc ); 3511 } 3512 } 3513 #endif 3514 #endif //SVC_EXTENSION 3515 3516 if(sps->getUseSAO()) 3517 { 3518 READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); 3519 #if AUXILIARY_PICTURES 3520 ChromaFormat format; 3521 #if REPN_FORMAT_IN_VPS 3522 #if O0096_REP_FORMAT_INDEX 3523 if( sps->getLayerId() == 0 ) 3524 { 3525 format = sps->getChromaFormatIdc(); 3526 } 3527 else 3528 { 3529 format = rpcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); 3530 #if Q0195_REP_FORMAT_CLEANUP 3531 assert( (sps->getUpdateRepFormatFlag()==false && rpcSlice->getVPS()->getVpsNumRepFormats()==1) || rpcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check 3532 #endif 3533 } 3534 #else 3535 if( ( sps->getLayerId() == 0 ) || sps->getUpdateRepFormatFlag() ) 3536 { 3537 format = sps->getChromaFormatIdc(); 3538 } 3539 else 3540 { 3541 format = rpcSlice->getVPS()->getVpsRepFormat( rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); 3542 } 3543 #endif 3544 #else 3545 format = sps->getChromaFormatIdc(); 3546 #endif 3547 if (format != CHROMA_400) 3548 { 3549 #endif 3550 READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); 3551 #if AUXILIARY_PICTURES 3552 } 3553 else 3554 { 3555 rpcSlice->setSaoEnabledFlagChroma(false); 3556 } 3557 #endif 3558 } 3559 3560 if (rpcSlice->getIdrPicFlag()) 3561 { 3562 rpcSlice->setEnableTMVPFlag(false); 3563 } 3564 if (!rpcSlice->isIntra()) 3565 { 3566 3567 READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); 3568 if (uiCode) 3569 { 3570 READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); 3571 if (rpcSlice->isInterB()) 3572 { 3573 READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); 3574 } 3575 else 3576 { 3577 rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); 3578 } 3579 } 3580 else 3581 { 3582 rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); 3583 if (rpcSlice->isInterB()) 3584 { 3585 rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); 3586 } 3587 else 3588 { 3589 rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); 3590 } 3591 } 3592 } 3593 // } 3594 TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); 3595 if(!rpcSlice->isIntra()) 3596 { 3597 if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) 3598 { 3599 refPicListModification->setRefPicListModificationFlagL0( 0 ); 3600 } 3601 else 3602 { 3603 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); 3604 } 3605 3606 if(refPicListModification->getRefPicListModificationFlagL0()) 3607 { 3608 uiCode = 0; 3609 Int i = 0; 3610 Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); 3611 if ( numRpsCurrTempList0 > 1 ) 3612 { 3613 Int length = 1; 3614 numRpsCurrTempList0 --; 3615 while ( numRpsCurrTempList0 >>= 1) 3616 { 3617 length ++; 3618 } 3619 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 3620 { 3621 READ_CODE( length, uiCode, "list_entry_l0" ); 3622 refPicListModification->setRefPicSetIdxL0(i, uiCode ); 3623 } 3624 } 3625 else 3626 { 3627 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 3628 { 3629 refPicListModification->setRefPicSetIdxL0(i, 0 ); 3630 } 3631 } 3632 } 3633 } 3634 else 3635 { 3636 refPicListModification->setRefPicListModificationFlagL0(0); 3637 } 3638 if(rpcSlice->isInterB()) 3639 { 3640 if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) 3641 { 3642 refPicListModification->setRefPicListModificationFlagL1( 0 ); 3643 } 3644 else 3645 { 3646 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); 3647 } 3648 if(refPicListModification->getRefPicListModificationFlagL1()) 3649 { 3650 uiCode = 0; 3651 Int i = 0; 3652 Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); 3653 if ( numRpsCurrTempList1 > 1 ) 3654 { 3655 Int length = 1; 3656 numRpsCurrTempList1 --; 3657 while ( numRpsCurrTempList1 >>= 1) 3658 { 3659 length ++; 3660 } 3661 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 3662 { 3663 READ_CODE( length, uiCode, "list_entry_l1" ); 3664 refPicListModification->setRefPicSetIdxL1(i, uiCode ); 3665 } 3666 } 3667 else 3668 { 3669 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 3670 { 3671 refPicListModification->setRefPicSetIdxL1(i, 0 ); 3672 } 3673 } 3674 } 3675 } 3676 else 3677 { 3678 refPicListModification->setRefPicListModificationFlagL1(0); 3679 } 3680 if (rpcSlice->isInterB()) 3681 { 3682 READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); 3683 } 3684 3685 rpcSlice->setCabacInitFlag( false ); // default 3686 if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) 3687 { 3688 READ_FLAG(uiCode, "cabac_init_flag"); 3689 rpcSlice->setCabacInitFlag( uiCode ? true : false ); 3690 } 3691 3692 if ( rpcSlice->getEnableTMVPFlag() ) 3693 { 3694 #if SVC_EXTENSION && REF_IDX_MFM 3695 // set motion mapping flag 3696 rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() && !rpcSlice->isIntra() ) ? true : false ); 3697 #endif 3698 if ( rpcSlice->getSliceType() == B_SLICE ) 3699 { 3700 READ_FLAG( uiCode, "collocated_from_l0_flag" ); 3701 rpcSlice->setColFromL0Flag(uiCode); 3702 } 3703 else 3704 { 3705 rpcSlice->setColFromL0Flag( 1 ); 3706 } 3707 3708 if ( rpcSlice->getSliceType() != I_SLICE && 3709 ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| 3710 (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) 3711 { 3712 READ_UVLC( uiCode, "collocated_ref_idx" ); 3713 rpcSlice->setColRefIdx(uiCode); 3714 } 3715 else 3716 { 3717 rpcSlice->setColRefIdx(0); 3718 } 3719 } 3720 if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) 3721 { 3722 xParsePredWeightTable(rpcSlice); 3723 rpcSlice->initWpScaling(); 3724 } 3725 if (!rpcSlice->isIntra()) 3726 { 3727 READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); 3728 rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); 3729 } 3730 3731 READ_SVLC( iCode, "slice_qp_delta" ); 3732 rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); 3733 3734 #if REPN_FORMAT_IN_VPS 3735 #if O0194_DIFFERENT_BITDEPTH_EL_BL 3736 g_bitDepthYLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthY(); 3737 g_bitDepthCLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthC(); 3738 #endif 3739 assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() ); 3740 #else 3741 assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); 3742 #endif 3743 assert( rpcSlice->getSliceQp() <= 51 ); 3744 3745 if (rpcSlice->getPPS()->getSliceChromaQpFlag()) 3746 { 3747 READ_SVLC( iCode, "slice_qp_delta_cb" ); 3748 rpcSlice->setSliceQpDeltaCb( iCode ); 3749 assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); 3750 assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); 3751 assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); 3752 assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); 3753 3754 READ_SVLC( iCode, "slice_qp_delta_cr" ); 3755 rpcSlice->setSliceQpDeltaCr( iCode ); 3756 assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); 3757 assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); 3758 assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); 3759 assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); 3760 } 3761 3762 if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) 3763 { 3764 if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) 3765 { 3766 READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); 3767 } 3768 else 3769 { 3770 rpcSlice->setDeblockingFilterOverrideFlag(0); 3771 } 3772 if(rpcSlice->getDeblockingFilterOverrideFlag()) 3773 { 3774 READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); 3775 if(!rpcSlice->getDeblockingFilterDisable()) 3776 { 3777 READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); 3778 assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && 3779 rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); 3780 READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); 3781 assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && 3782 rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); 3783 } 3784 } 3785 else 3786 { 3787 rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); 3788 rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); 3789 rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); 3790 } 3791 } 3792 else 3793 { 3794 rpcSlice->setDeblockingFilterDisable ( false ); 3795 rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); 3796 rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); 3797 } 3798 3799 Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); 3800 Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); 3801 3802 if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) 3803 { 3804 READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); 3805 } 3806 else 3807 { 3808 uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; 3809 } 3810 rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); 3811 3812 } 3813 3814 UInt *entryPointOffset = NULL; 3815 UInt numEntryPointOffsets, offsetLenMinus1; 3816 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 3817 { 3818 READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); 3819 if (numEntryPointOffsets>0) 3820 { 3821 READ_UVLC(offsetLenMinus1, "offset_len_minus1"); 3822 } 3823 entryPointOffset = new UInt[numEntryPointOffsets]; 3824 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 3825 { 3826 READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); 3827 entryPointOffset[ idx ] = uiCode + 1; 3828 } 3829 } 3830 else 3831 { 3832 rpcSlice->setNumEntryPointOffsets ( 0 ); 3833 } 3834 3835 #if POC_RESET_IDC_SIGNALLING 3836 Int sliceHeaderExtensionLength = 0; 3837 if(pps->getSliceHeaderExtensionPresentFlag()) 3838 { 3839 READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode; 3840 } 3841 else 3842 { 3843 sliceHeaderExtensionLength = 0; 3844 #if INFERENCE_POC_MSB_VAL_PRESENT 3845 rpcSlice->setPocMsbValPresentFlag( false ); 3846 #endif 3847 } 3848 UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits 3849 if( sliceHeaderExtensionLength > 0 ) 3850 { 3851 if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() ) 3852 { 3853 READ_CODE( 2, uiCode, "poc_reset_idc"); rpcSlice->setPocResetIdc(uiCode); 3854 #if POC_RESET_RESTRICTIONS 3855 /* The value of poc_reset_idc shall not be equal to 1 or 2 for a RASL picture, a RADL picture, 3856 a sub-layer non-reference picture, or a picture that has TemporalId greater than 0, 3857 or a picture that has discardable_flag equal to 1. */ 3858 if( rpcSlice->getPocResetIdc() == 1 || rpcSlice->getPocResetIdc() == 2 ) 3859 { 3860 assert( !rpcSlice->isRASL() ); 3861 assert( !rpcSlice->isRADL() ); 3862 assert( !rpcSlice->isSLNR() ); 3863 assert( rpcSlice->getTLayer() == 0 ); 3864 assert( rpcSlice->getDiscardableFlag() == 0 ); 3865 } 3866 3867 // The value of poc_reset_idc of a CRA or BLA picture shall be less than 3. 3868 if( rpcSlice->getPocResetIdc() == 3) 3869 { 3870 assert( ! ( rpcSlice->isCRA() || rpcSlice->isBLA() ) ); 3871 } 3872 #endif 3873 } 3874 else 3875 { 3876 rpcSlice->setPocResetIdc( 0 ); 3877 } 3878 #if Q0142_POC_LSB_NOT_PRESENT 3879 if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && iPOClsb > 0 ) 3880 { 3881 assert( rpcSlice->getPocResetIdc() != 2 ); 3882 } 3883 #endif 3884 if( rpcSlice->getPocResetIdc() > 0 ) 3885 { 3886 READ_CODE(6, uiCode, "poc_reset_period_id"); rpcSlice->setPocResetPeriodId(uiCode); 3887 } 3888 else 3889 { 3890 3891 rpcSlice->setPocResetPeriodId( 0 ); 3892 } 3893 3894 if (rpcSlice->getPocResetIdc() == 3) 3895 { 3896 READ_FLAG( uiCode, "full_poc_reset_flag"); rpcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); 3897 READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); rpcSlice->setPocLsbVal(uiCode); 3898 #if Q0142_POC_LSB_NOT_PRESENT 3899 if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && rpcSlice->getFullPocResetFlag() ) 3900 { 3901 assert( rpcSlice->getPocLsbVal() == 0 ); 3902 } 3903 #endif 3904 } 3905 3906 // Derive the value of PocMsbValRequiredFlag 3907 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3908 rpcSlice->setPocMsbValRequiredFlag( (rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag()) 3909 && (!rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() || 3910 (rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() && rpcSlice->getVPS()->getNumDirectRefLayers(rpcSlice->getLayerId()) == 0)) 3911 ); 3912 #else 3913 rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag() ); 3914 #endif 3915 3916 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3917 if (!rpcSlice->getPocMsbValRequiredFlag() && rpcSlice->getVPS()->getVpsPocLsbAlignedFlag()) 3918 #else 3919 if (!rpcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */) 3920 #endif 3921 { 3922 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3923 READ_FLAG(uiCode, "poc_msb_cycle_val_present_flag"); rpcSlice->setPocMsbValPresentFlag(uiCode ? true : false); 3924 #else 3925 READ_FLAG(uiCode, "poc_msb_val_present_flag"); rpcSlice->setPocMsbValPresentFlag(uiCode ? true : false); 3926 #endif 3927 } 3928 else 3929 { 3930 #if POC_MSB_VAL_PRESENT_FLAG_SEM 3931 if( sliceHeaderExtensionLength == 0 ) 3932 { 3933 rpcSlice->setPocMsbValPresentFlag( false ); 3934 } 3935 else if( rpcSlice->getPocMsbValRequiredFlag() ) 3936 #else 3937 if( rpcSlice->getPocMsbValRequiredFlag() ) 3938 #endif 3939 { 3940 rpcSlice->setPocMsbValPresentFlag( true ); 3941 } 3942 else 3943 { 3944 rpcSlice->setPocMsbValPresentFlag( false ); 3945 } 3946 } 3947 3948 #if !POC_RESET_IDC_DECODER 3949 Int maxPocLsb = 1 << rpcSlice->getSPS()->getBitsForPOC(); 3950 #endif 3951 if( rpcSlice->getPocMsbValPresentFlag() ) 3952 { 3953 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3954 READ_UVLC( uiCode, "poc_msb_cycle_val"); rpcSlice->setPocMsbVal( uiCode ); 3955 #else 3956 READ_UVLC( uiCode, "poc_msb_val"); rpcSlice->setPocMsbVal( uiCode ); 3957 #endif 3958 3959 #if !POC_RESET_IDC_DECODER 3960 // Update POC of the slice based on this MSB val 3961 Int pocLsb = rpcSlice->getPOC() % maxPocLsb; 3962 rpcSlice->setPOC((rpcSlice->getPocMsbVal() * maxPocLsb) + pocLsb); 3963 } 3964 else 3965 { 3966 rpcSlice->setPocMsbVal( rpcSlice->getPOC() / maxPocLsb ); 3967 #endif 3968 } 3969 3970 // Read remaining bits in the slice header extension. 3971 UInt endBits = m_pcBitstream->getNumBitsRead(); 3972 Int counter = (endBits - startBits) % 8; 3973 if( counter ) 3974 { 3975 counter = 8 - counter; 3976 } 3977 3978 while( counter ) 3979 { 3980 #if Q0146_SSH_EXT_DATA_BIT 3981 READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); 3982 #else 3983 READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 ); 3984 #endif 3985 counter--; 3986 } 3987 } 3988 #else 3989 if(pps->getSliceHeaderExtensionPresentFlag()) 3990 { 3991 READ_UVLC(uiCode,"slice_header_extension_length"); 3992 for(Int i=0; i<uiCode; i++) 3993 { 3994 UInt ignore; 3995 READ_CODE(8,ignore,"slice_header_extension_data_byte"); 3996 } 3997 } 3998 #endif 3999 m_pcBitstream->readByteAlignment(); 4000 4001 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 4002 { 4003 Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); 4004 4005 // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header 4006 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 4007 { 4008 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) 4009 { 4010 endOfSliceHeaderLocation++; 4011 } 4012 } 4013 4014 Int curEntryPointOffset = 0; 4015 Int prevEntryPointOffset = 0; 4016 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 4017 { 4018 curEntryPointOffset += entryPointOffset[ idx ]; 4019 4020 Int emulationPreventionByteCount = 0; 4021 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 4022 { 4023 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && 4024 m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) 4025 { 4026 emulationPreventionByteCount++; 4027 } 4028 } 4029 4030 entryPointOffset[ idx ] -= emulationPreventionByteCount; 4031 prevEntryPointOffset = curEntryPointOffset; 4032 } 4033 4034 if ( pps->getTilesEnabledFlag() ) 4035 { 4036 rpcSlice->setTileLocationCount( numEntryPointOffsets ); 4037 4038 UInt prevPos = 0; 4039 for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) 4040 { 4041 rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); 4042 prevPos += entryPointOffset[ idx ]; 4043 } 4044 } 4045 else if ( pps->getEntropyCodingSyncEnabledFlag() ) 4046 { 4047 Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; 4048 rpcSlice->allocSubstreamSizes(numSubstreams); 4049 UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); 4050 for (Int idx=0; idx<numSubstreams-1; idx++) 4051 { 4052 if ( idx < numEntryPointOffsets ) 4053 { 4054 pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; 4055 } 4056 else 4057 { 4058 pSubstreamSizes[ idx ] = 0; 4059 } 4060 } 4061 } 4062 4063 if (entryPointOffset) 4064 { 4065 delete [] entryPointOffset; 4066 } 4067 } 4068 4069 return; 4070 } 4071 4072 Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) 4073 { 4074 UInt uiCode; 4075 if(profilePresentFlag) 4076 { 4077 parseProfileTier(rpcPTL->getGeneralPTL()); 4078 } 4079 READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); 4080 4081 for (Int i = 0; i < maxNumSubLayersMinus1; i++) 4082 { 4083 if(profilePresentFlag) 4084 { 4085 READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); 4086 } 4087 READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); 4088 } 4089 4090 if (maxNumSubLayersMinus1 > 0) 4091 { 4092 for (Int i = maxNumSubLayersMinus1; i < 8; i++) 4093 { 4094 READ_CODE(2, uiCode, "reserved_zero_2bits"); 4095 assert(uiCode == 0); 4096 } 4097 } 4098 4099 for(Int i = 0; i < maxNumSubLayersMinus1; i++) 4100 { 4101 if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) 4102 { 4103 parseProfileTier(rpcPTL->getSubLayerPTL(i)); 4104 } 4105 if(rpcPTL->getSubLayerLevelPresentFlag(i)) 4106 { 4107 READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); 4108 } 4109 } 4110 } 4111 4112 Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) 4113 { 4114 UInt uiCode; 4115 READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); 4116 READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); 4117 READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); 4118 for(Int j = 0; j < 32; j++) 4119 { 4120 READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); 4121 } 4122 READ_FLAG(uiCode, "general_progressive_source_flag"); 4123 ptl->setProgressiveSourceFlag(uiCode ? true : false); 4124 4125 READ_FLAG(uiCode, "general_interlaced_source_flag"); 4126 ptl->setInterlacedSourceFlag(uiCode ? true : false); 4127 4128 READ_FLAG(uiCode, "general_non_packed_constraint_flag"); 4129 ptl->setNonPackedConstraintFlag(uiCode ? true : false); 4130 4131 READ_FLAG(uiCode, "general_frame_only_constraint_flag"); 4132 ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); 4133 4134 READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); 4135 READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); 4136 READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); 4137 } 4138 4139 Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) 4140 { 4141 ruiBit = false; 4142 Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); 4143 if(iBitsLeft <= 8) 4144 { 4145 UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); 4146 if (uiPeekValue == (1<<(iBitsLeft-1))) 4147 { 4148 ruiBit = true; 4149 } 4150 } 4151 } 4152 4153 Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4154 { 4155 assert(0); 4156 } 4157 4158 Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4159 { 4160 assert(0); 4161 } 4162 4163 Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) 4164 { 4165 assert(0); 4166 } 4167 4168 Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4169 { 4170 assert(0); 4171 } 4172 4173 Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4174 { 4175 assert(0); 4176 } 4177 4178 Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4179 { 4180 assert(0); 4181 } 4182 4183 /** Parse I_PCM information. 4184 * \param pcCU pointer to CU 4185 * \param uiAbsPartIdx CU index 4186 * \param uiDepth CU depth 4187 * \returns Void 4188 * 4189 * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. 4190 */ 4191 Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4192 { 4193 assert(0); 4194 } 4195 4196 Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4197 { 4198 assert(0); 4199 } 4200 4201 Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4202 { 4203 assert(0); 4204 } 4205 4206 Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) 4207 { 4208 assert(0); 4209 } 4210 4211 Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) 4212 { 4213 assert(0); 4214 } 4215 4216 Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) 4217 { 4218 assert(0); 4219 } 4220 4221 Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 4222 { 4223 Int qp; 4224 Int iDQp; 4225 4226 xReadSvlc( iDQp ); 4227 4228 #if REPN_FORMAT_IN_VPS 4229 Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); 4230 #else 4231 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); 4232 #endif 4233 qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; 4234 4235 UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; 4236 UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; 4237 4238 pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); 4239 } 4240 4241 Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) 4242 { 4243 assert(0); 4244 } 4245 4246 Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) 4247 { 4248 assert(0); 4249 } 4250 4251 Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) 4252 { 4253 assert(0); 4254 } 4255 4256 Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) 4257 { 4258 assert(0); 4259 } 4260 4261 Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) 4262 { 4263 assert(0); 4264 } 4265 4266 Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) 4267 { 4268 assert(0); 4269 } 4270 4271 Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) 4272 { 4273 assert(0); 4274 } 4275 4276 // ==================================================================================================================== 4277 // Protected member functions 4278 // ==================================================================================================================== 4279 4280 /** parse explicit wp tables 4281 * \param TComSlice* pcSlice 4282 * \returns Void 4283 */ 4284 Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) 4285 { 4286 wpScalingParam *wp; 4287 Bool bChroma = true; // color always present in HEVC ? 4288 SliceType eSliceType = pcSlice->getSliceType(); 4289 Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); 4290 #if SVC_EXTENSION 4291 UInt uiLog2WeightDenomLuma = 0, uiLog2WeightDenomChroma = 0; 4292 #else 4293 UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; 4294 #endif 4295 UInt uiTotalSignalledWeightFlags = 0; 4296 4297 Int iDeltaDenom; 4298 #if AUXILIARY_PICTURES 4299 if (pcSlice->getChromaFormatIdc() == CHROMA_400) 4300 { 4301 bChroma = false; 4302 } 4303 #endif 4304 // decode delta_luma_log2_weight_denom : 4305 READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom 4306 assert( uiLog2WeightDenomLuma <= 7 ); 4307 if( bChroma ) 4308 { 4309 READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom 4310 assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); 4311 assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); 4312 uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); 4313 } 4314 4315 for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) 4316 { 4317 RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 4318 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 4319 { 4320 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 4321 4322 wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; 4323 #if AUXILIARY_PICTURES 4324 if (!bChroma) 4325 { 4326 wp[1].uiLog2WeightDenom = 0; 4327 wp[2].uiLog2WeightDenom = 0; 4328 } 4329 else 4330 { 4331 #endif 4332 wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; 4333 wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; 4334 #if AUXILIARY_PICTURES 4335 } 4336 #endif 4337 4338 UInt uiCode; 4339 READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag 4340 wp[0].bPresentFlag = ( uiCode == 1 ); 4341 uiTotalSignalledWeightFlags += wp[0].bPresentFlag; 4342 } 4343 if ( bChroma ) 4344 { 4345 UInt uiCode; 4346 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 4347 { 4348 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 4349 READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag 4350 wp[1].bPresentFlag = ( uiCode == 1 ); 4351 wp[2].bPresentFlag = ( uiCode == 1 ); 4352 uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; 4353 } 4354 } 4355 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 4356 { 4357 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 4358 if ( wp[0].bPresentFlag ) 4359 { 4360 Int iDeltaWeight; 4361 READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] 4362 assert( iDeltaWeight >= -128 ); 4363 assert( iDeltaWeight <= 127 ); 4364 wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); 4365 READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] 4366 assert( wp[0].iOffset >= -128 ); 4367 assert( wp[0].iOffset <= 127 ); 4368 } 4369 else 4370 { 4371 wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); 4372 wp[0].iOffset = 0; 4373 } 4374 if ( bChroma ) 4375 { 4376 if ( wp[1].bPresentFlag ) 4377 { 4378 for ( Int j=1 ; j<3 ; j++ ) 4379 { 4380 Int iDeltaWeight; 4381 READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] 4382 assert( iDeltaWeight >= -128 ); 4383 assert( iDeltaWeight <= 127 ); 4384 wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); 4385 4386 Int iDeltaChroma; 4387 READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] 4388 assert( iDeltaChroma >= -512 ); 4389 assert( iDeltaChroma <= 511 ); 4390 Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); 4391 wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); 4392 } 4393 } 4394 else 4395 { 4396 for ( Int j=1 ; j<3 ; j++ ) 4397 { 4398 wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); 4399 wp[j].iOffset = 0; 4400 } 4401 } 4402 } 4403 } 4404 4405 for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) 4406 { 4407 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 4408 4409 wp[0].bPresentFlag = false; 4410 wp[1].bPresentFlag = false; 4411 wp[2].bPresentFlag = false; 4412 } 4413 } 4414 assert(uiTotalSignalledWeightFlags<=24); 4415 } 4416 4417 /** decode quantization matrix 4418 * \param scalingList quantization matrix information 4419 */ 4420 Void TDecCavlc::parseScalingList(TComScalingList* scalingList) 4421 { 4422 UInt code, sizeId, listId; 4423 Bool scalingListPredModeFlag; 4424 //for each size 4425 for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) 4426 { 4427 for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) 4428 { 4429 READ_FLAG( code, "scaling_list_pred_mode_flag"); 4430 scalingListPredModeFlag = (code) ? true : false; 4431 if(!scalingListPredModeFlag) //Copy Mode 4432 { 4433 READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); 4434 scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); 4435 if( sizeId > SCALING_LIST_8x8 ) 4436 { 4437 scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); 4438 } 4439 scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); 4440 4441 } 4442 else //DPCM Mode 4443 { 4444 xDecodeScalingList(scalingList, sizeId, listId); 4445 } 4446 } 4447 } 4448 4449 return; 4450 } 4451 /** decode DPCM 4452 * \param scalingList quantization matrix information 4453 * \param sizeId size index 4454 * \param listId list index 4455 */ 4456 Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) 4457 { 4458 Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); 4459 Int data; 4460 Int scalingListDcCoefMinus8 = 0; 4461 Int nextCoef = SCALING_LIST_START_VALUE; 4462 UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; 4463 Int *dst = scalingList->getScalingListAddress(sizeId, listId); 4464 4465 if( sizeId > SCALING_LIST_8x8 ) 4466 { 4467 READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); 4468 scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); 4469 nextCoef = scalingList->getScalingListDC(sizeId,listId); 4470 } 4471 4472 for(i = 0; i < coefNum; i++) 4473 { 4474 READ_SVLC( data, "scaling_list_delta_coef"); 4475 nextCoef = (nextCoef + data + 256 ) % 256; 4476 dst[scan[i]] = nextCoef; 4477 } 4478 } 4479 4480 Bool TDecCavlc::xMoreRbspData() 4481 { 4482 Int bitsLeft = m_pcBitstream->getNumBitsLeft(); 4483 4484 // if there are more than 8 bits, it cannot be rbsp_trailing_bits 4485 if (bitsLeft > 8) 4486 { 4487 return true; 4488 } 4489 4490 UChar lastByte = m_pcBitstream->peekBits(bitsLeft); 4491 Int cnt = bitsLeft; 4492 4493 // remove trailing bits equal to zero 4494 while ((cnt>0) && ((lastByte & 1) == 0)) 4495 { 4496 lastByte >>= 1; 4497 cnt--; 4498 } 4499 // remove bit equal to one 4500 cnt--; 4501 4502 // we should not have a negative number of bits 4503 assert (cnt>=0); 4504 4505 // we have more data, if cnt is not zero 4506 return (cnt>0); 4507 } 4324 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcSPS->setVertPhasePositionEnableFlag( pcSPS->getScaledRefLayerId(i), uiCode); 4325 #endif 4326 } 4327 } 4328 #endif 4329 } 4330 #endif 4508 4331 4509 4332 #if Q0048_CGS_3D_ASYMLUT -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecCAVLC.h
r894 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 62 62 TDecCavlc(); 63 63 virtual ~TDecCavlc(); 64 64 65 65 protected: 66 void parseShortTermRefPicSet (TComSPS* pcSPS, TComReferencePictureSet* pcRPS, Int idx); 67 66 67 Void parseShortTermRefPicSet (TComSPS* pcSPS, TComReferencePictureSet* pcRPS, Int idx); 68 68 69 public: 69 70 … … 72 73 Void setBitstream ( TComInputBitstream* p ) { m_pcBitstream = p; } 73 74 Void parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ); 74 Void parseQtCbf ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth);75 Void parseQtCbf ( class TComTU &rTu, const ComponentID compID, const Bool lowestLevel ); 75 76 Void parseQtRootCbf ( UInt uiAbsPartIdx, UInt& uiQtRootCbf ); 76 77 Void parseVPS ( TComVPS* pcVPS ); 78 #if !SVC_EXTENSION 79 Void parseSPS ( TComSPS* pcSPS ); 80 Void parsePPS ( TComPPS* pcPPS ); 81 #endif 82 Void parseVUI ( TComVUI* pcVUI, TComSPS* pcSPS ); 83 Void parseSEI ( SEIMessages& ); 84 Void parsePTL ( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ); 85 Void parseProfileTier (ProfileTierLevel *ptl); 86 Void parseHrdParameters (TComHRD *hrd, Bool cprms_present_flag, UInt tempLevelHigh); 87 Void parseSliceHeader ( TComSlice* pcSlice, ParameterSetManagerDecoder *parameterSetManager); 88 Void parseTerminatingBit ( UInt& ruiBit ); 89 Void parseRemainingBytes ( Bool noTrailingBytesExpected ); 90 91 Void parseMVPIdx ( Int& riMVPIdx ); 92 93 Void parseSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 94 Void parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 95 Void parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ); 96 Void parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex ); 97 Void parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 98 Void parsePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 99 Void parsePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 100 101 Void parseIntraDirLumaAng ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 102 Void parseIntraDirChroma ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 103 104 Void parseInterDir ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx ); 105 Void parseRefFrmIdx ( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList ); 106 Void parseMvd ( TComDataCU* pcCU, UInt uiAbsPartAddr,UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ); 107 108 Void parseCrossComponentPrediction( class TComTU &rTu, ComponentID compID ); 109 110 Void parseDeltaQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 111 Void parseChromaQpAdjustment( TComDataCU* cu, UInt absPartIdx, UInt depth); 112 113 Void parseCoeffNxN ( class TComTU &rTu, ComponentID compID ); 114 115 Void parseTransformSkipFlags ( class TComTU &rTu, ComponentID component ); 116 117 Void parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth); 118 119 Void xParsePredWeightTable ( TComSlice* pcSlice ); 120 Void parseScalingList ( TComScalingList* scalingList ); 121 Void xDecodeScalingList ( TComScalingList *scalingList, UInt sizeId, UInt listId); 122 123 Void parseExplicitRdpcmMode( TComTU &rTu, ComponentID compID ); 124 125 protected: 126 Bool xMoreRbspData(); 127 77 128 #if SVC_EXTENSION 129 public: 78 130 Void parseVPSExtension ( TComVPS* pcVPS ); 79 131 Void defaultVPSExtension ( TComVPS* pcVPS ); … … 95 147 #endif 96 148 Void parseSPSExtension ( TComSPS* pcSPS ); 97 #else //SVC_EXTENSION98 Void parseSPS ( TComSPS* pcSPS );99 #endif //SVC_EXTENSION100 Void parsePPS ( TComPPS* pcPPS101 149 #if Q0048_CGS_3D_ASYMLUT 102 , TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID 150 Void parsePPS ( TComPPS* pcPPS, TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID ); 151 #else 152 Void parsePPS ( TComPPS* pcPPS ); 103 153 #endif 104 );105 Void parseVUI ( TComVUI* pcVUI, TComSPS* pcSPS );106 Void parseSEI ( SEIMessages& );107 Void parsePTL ( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 );108 Void parseProfileTier (ProfileTierLevel *ptl);109 Void parseHrdParameters (TComHRD *hrd, Bool cprms_present_flag, UInt tempLevelHigh);110 Void parseSliceHeader ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager);111 Void parseTerminatingBit ( UInt& ruiBit );112 113 Void parseMVPIdx ( Int& riMVPIdx );114 115 Void parseSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );116 Void parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );117 Void parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );118 Void parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex );119 Void parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );120 Void parsePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );121 Void parsePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );122 123 Void parseIntraDirLumaAng ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );124 125 Void parseIntraDirChroma ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );126 127 Void parseInterDir ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx );128 Void parseRefFrmIdx ( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList );129 Void parseMvd ( TComDataCU* pcCU, UInt uiAbsPartAddr,UInt uiPartIdx, UInt uiDepth, RefPicList eRefList );130 131 Void parseDeltaQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );132 Void parseCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType );133 Void parseTransformSkipFlags ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType);134 154 135 Void parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth);136 137 Void updateContextTables ( SliceType /*eSliceType*/, Int /*iQp*/ ) { return; }138 139 Void xParsePredWeightTable ( TComSlice* pcSlice );140 Void parseScalingList ( TComScalingList* scalingList );141 Void xDecodeScalingList ( TComScalingList *scalingList, UInt sizeId, UInt listId);142 155 protected: 143 Bool xMoreRbspData();144 145 156 #if Q0048_CGS_3D_ASYMLUT 146 157 Void xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ); … … 154 165 #endif 155 166 #endif 167 #endif //SVC_EXTENSION 168 156 169 }; 157 170 … … 159 172 160 173 #endif // !defined(AFX_TDECCAVLC_H__9732DD64_59B0_4A41_B29E_1A5B18821EAD__INCLUDED_) 161 -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecCu.cpp
r713 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 37 37 38 38 #include "TDecCu.h" 39 #include "TLibCommon/TComTU.h" 39 40 #if SVC_EXTENSION 40 41 #include "TDecTop.h" … … 95 96 \param uiMaxHeight largest CU height 96 97 */ 97 Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight )98 Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight, ChromaFormat chromaFormatIDC ) 98 99 { 99 100 m_uiMaxDepth = uiMaxDepth+1; 100 101 101 102 m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1]; 102 103 m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1]; 103 104 m_ppcCU = new TComDataCU*[m_uiMaxDepth-1]; 104 105 105 106 UInt uiNumPartitions; 106 107 for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) … … 109 110 UInt uiWidth = uiMaxWidth >> ui; 110 111 UInt uiHeight = uiMaxHeight >> ui; 111 112 m_ppcYuvResi[ui] = new TComYuv; m_ppcYuvResi[ui]->create( uiWidth, uiHeight );113 m_ppcYuvReco[ui] = new TComYuv; m_ppcYuvReco[ui]->create( uiWidth, uiHeight );114 m_ppcCU [ui] = new TComDataCU; m_ppcCU [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );115 } 116 112 113 m_ppcYuvResi[ui] = new TComYuv; m_ppcYuvResi[ui]->create( uiWidth, uiHeight, chromaFormatIDC ); 114 m_ppcYuvReco[ui] = new TComYuv; m_ppcYuvReco[ui]->create( uiWidth, uiHeight, chromaFormatIDC ); 115 m_ppcCU [ui] = new TComDataCU; m_ppcCU [ui]->create( chromaFormatIDC, uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) ); 116 } 117 117 118 m_bDecodeDQP = false; 119 m_IsChromaQpAdjCoded = false; 118 120 119 121 // initialize partition order. … … 121 123 initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp); 122 124 initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); 123 125 124 126 // initialize conversion matrix from partition index to pel 125 127 initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); … … 134 136 m_ppcCU [ui]->destroy(); delete m_ppcCU [ui]; m_ppcCU [ui] = NULL; 135 137 } 136 138 137 139 delete [] m_ppcYuvResi; m_ppcYuvResi = NULL; 138 140 delete [] m_ppcYuvReco; m_ppcYuvReco = NULL; … … 147 149 \param ruiIsLast last data? 148 150 */ 149 Void TDecCu::decodeC U( TComDataCU* pcCU, UInt& ruiIsLast )150 { 151 if ( p cCU->getSlice()->getPPS()->getUseDQP() )151 Void TDecCu::decodeCtu( TComDataCU* pCtu, Bool& isLastCtuOfSliceSegment ) 152 { 153 if ( pCtu->getSlice()->getPPS()->getUseDQP() ) 152 154 { 153 155 setdQPFlag(true); 154 156 } 155 157 158 if ( pCtu->getSlice()->getUseChromaQpAdj() ) 159 { 160 setIsChromaQpAdjCoded(true); 161 } 162 163 #if SVC_EXTENSION 164 pCtu->setLayerId(m_layerId); 165 #endif 166 156 167 // start from the top level CU 157 #if SVC_EXTENSION 158 pcCU->setLayerId(m_layerId); 159 #endif 160 xDecodeCU( pcCU, 0, 0, ruiIsLast); 168 xDecodeCU( pCtu, 0, 0, isLastCtuOfSliceSegment); 161 169 } 162 170 163 171 /** \param pcCU pointer of CU data 164 172 */ 165 Void TDecCu::decompressC U( TComDataCU* pcCU)166 { 167 xDecompressCU( p cCU, 0, 0 );173 Void TDecCu::decompressCtu( TComDataCU* pCtu ) 174 { 175 xDecompressCU( pCtu, 0, 0 ); 168 176 } 169 177 … … 174 182 /**decode end-of-slice flag 175 183 * \param pcCU 176 * \param uiAbsPartIdx 177 * \param uiDepth 184 * \param uiAbsPartIdx 185 * \param uiDepth 178 186 * \returns Bool 179 187 */ 180 Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth) 181 { 182 UInt uiIsLast; 183 TComPic* pcPic = pcCU->getPic(); 184 TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); 185 UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); 186 #if REPN_FORMAT_IN_VPS 187 UInt uiWidth = pcSlice->getPicWidthInLumaSamples(); 188 UInt uiHeight = pcSlice->getPicHeightInLumaSamples(); 189 #else 190 UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); 191 UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); 192 #endif 193 UInt uiGranularityWidth = g_uiMaxCUWidth; 194 UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; 195 UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; 196 197 if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) 198 &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight))) 199 { 200 m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast ); 188 Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx ) 189 { 190 UInt uiIsLastCtuOfSliceSegment; 191 192 if (pcCU->isLastSubCUOfCtu(uiAbsPartIdx)) 193 { 194 m_pcEntropyDecoder->decodeTerminatingBit( uiIsLastCtuOfSliceSegment ); 201 195 } 202 196 else 203 197 { 204 uiIsLast=0; 205 } 206 207 if(uiIsLast) 208 { 209 if(pcSlice->isNextSliceSegment()&&!pcSlice->isNextSlice()) 210 { 211 pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); 212 } 213 else 214 { 215 pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); 216 pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); 217 } 218 } 219 220 return uiIsLast>0; 198 uiIsLastCtuOfSliceSegment=0; 199 } 200 201 return uiIsLastCtuOfSliceSegment>0; 221 202 } 222 203 223 204 /** decode CU block recursively 224 205 * \param pcCU 225 * \param uiAbsPartIdx 226 * \param uiDepth 206 * \param uiAbsPartIdx 207 * \param uiDepth 227 208 * \returns Void 228 209 */ 229 210 230 Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)211 Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment) 231 212 { 232 213 TComPic* pcPic = pcCU->getPic(); 233 UInt uiCurNumParts = pcPic->getNumPart InCU() >> (uiDepth<<1);214 UInt uiCurNumParts = pcPic->getNumPartitionsInCtu() >> (uiDepth<<1); 234 215 UInt uiQNumParts = uiCurNumParts>>2; 235 216 236 217 Bool bBoundary = false; 237 218 UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; … … 239 220 UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; 240 221 UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; 241 222 242 223 TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); 243 Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();244 224 #if REPN_FORMAT_IN_VPS 245 if( (!bStartInCU) && ( uiRPelX < pcSlice->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getPicHeightInLumaSamples()) )225 if( ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getPicHeightInLumaSamples() ) ) 246 226 #else 247 if( (!bStartInCU) &&( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )227 if( ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 248 228 #endif 249 229 { … … 254 234 bBoundary = true; 255 235 } 256 236 257 237 if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) 258 238 { … … 264 244 } 265 245 246 if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuChromaQpAdjSize() && pcCU->getSlice()->getUseChromaQpAdj() ) 247 { 248 setIsChromaQpAdjCoded(true); 249 } 250 266 251 for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) 267 252 { 268 253 uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; 269 254 uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; 270 271 Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr(); 272 if ( bSubInSlice ) 273 { 255 274 256 #if REPN_FORMAT_IN_VPS 275 if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getPicHeightInLumaSamples()) )257 if ( !isLastCtuOfSliceSegment && ( uiLPelX < pcCU->getSlice()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getPicHeightInLumaSamples() ) ) 276 258 #else 277 if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) 278 #endif 279 { 280 xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast ); 281 } 282 else 283 { 284 pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); 285 } 286 } 287 259 if ( !isLastCtuOfSliceSegment && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) 260 #endif 261 { 262 xDecodeCU( pcCU, uiIdx, uiDepth+1, isLastCtuOfSliceSegment ); 263 } 264 else 265 { 266 pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); 267 } 268 288 269 uiIdx += uiQNumParts; 289 270 } … … 292 273 if ( getdQPFlag() ) 293 274 { 294 UInt uiQPSrcPartIdx; 295 if ( pcPic->getCU( pcCU->getAddr() )->getSliceSegmentStartCU(uiAbsPartIdx) != pcSlice->getSliceSegmentCurStartCUAddr() ) 296 { 297 uiQPSrcPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU(); 298 } 299 else 300 { 301 uiQPSrcPartIdx = uiAbsPartIdx; 302 } 275 UInt uiQPSrcPartIdx = uiAbsPartIdx; 303 276 pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP 304 277 } … … 306 279 return; 307 280 } 308 281 309 282 if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) 310 283 { … … 313 286 } 314 287 288 if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuChromaQpAdjSize() && pcCU->getSlice()->getUseChromaQpAdj() ) 289 { 290 setIsChromaQpAdjCoded(true); 291 } 292 315 293 if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) 316 294 { 317 295 m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); 318 296 } 319 297 320 298 // decode CU mode and the partition size 321 299 if( !pcCU->getSlice()->isIntra()) … … 360 338 TComMv cTmpMv( 0, 0 ); 361 339 for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) 362 { 340 { 363 341 if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) 364 342 { … … 369 347 } 370 348 } 371 xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );349 xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); 372 350 return; 373 351 } … … 382 360 if(pcCU->getIPCMFlag(uiAbsPartIdx)) 383 361 { 384 xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );362 xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); 385 363 return; 386 364 } 387 365 } 388 366 389 UInt uiCurrWidth = pcCU->getWidth ( uiAbsPartIdx );390 UInt uiCurrHeight = pcCU->getHeight( uiAbsPartIdx );391 392 367 // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) 393 368 m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); … … 395 370 // Coefficient decoding 396 371 Bool bCodeDQP = getdQPFlag(); 397 m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP ); 372 Bool isChromaQpAdjCoded = getIsChromaQpAdjCoded(); 373 m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, bCodeDQP, isChromaQpAdjCoded ); 374 setIsChromaQpAdjCoded( isChromaQpAdjCoded ); 398 375 setdQPFlag( bCodeDQP ); 399 xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );400 } 401 402 Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast)376 xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); 377 } 378 379 Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment) 403 380 { 404 381 if( pcCU->getSlice()->getPPS()->getUseDQP()) … … 407 384 } 408 385 409 ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth); 410 } 411 412 Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 413 { 414 TComPic* pcPic = pcCU->getPic(); 415 386 if (pcCU->getSlice()->getUseChromaQpAdj() && !getIsChromaQpAdjCoded()) 387 { 388 pcCU->setChromaQpAdjSubParts( pcCU->getCodedChromaQpAdj(), uiAbsPartIdx, uiDepth ); // set QP 389 } 390 391 isLastCtuOfSliceSegment = xDecodeSliceEnd( pcCU, uiAbsPartIdx ); 392 } 393 394 Void TDecCu::xDecompressCU( TComDataCU* pCtu, UInt uiAbsPartIdx, UInt uiDepth ) 395 { 396 TComPic* pcPic = pCtu->getPic(); 397 416 398 Bool bBoundary = false; 417 UInt uiLPelX = p cCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];399 UInt uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; 418 400 UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; 419 UInt uiTPelY = p cCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];401 UInt uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; 420 402 UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; 421 422 UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); 423 TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); 424 Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr(); 403 404 TComSlice * pcSlice = pCtu->getPic()->getSlice(pCtu->getPic()->getCurrSliceIdx()); 405 425 406 #if REPN_FORMAT_IN_VPS 426 if(bStartInCU||( uiRPelX >= pcSlice->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getPicHeightInLumaSamples() ) ) 407 if( ( uiRPelX >= pcSlice->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getPicHeightInLumaSamples() ) ) 408 427 409 #else 428 if( bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) )410 if( ( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 429 411 #endif 430 412 { 431 413 bBoundary = true; 432 414 } 433 434 if( ( ( uiDepth < p cCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )415 416 if( ( ( uiDepth < pCtu->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) 435 417 { 436 418 UInt uiNextDepth = uiDepth + 1; 437 UInt uiQNumParts = p cCU->getTotalNumPart() >> (uiNextDepth<<1);419 UInt uiQNumParts = pCtu->getTotalNumPart() >> (uiNextDepth<<1); 438 420 UInt uiIdx = uiAbsPartIdx; 439 421 for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) 440 422 { 441 uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; 442 uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; 443 444 Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr()); 423 uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; 424 uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; 425 445 426 #if REPN_FORMAT_IN_VPS 446 if( binSlice&&( uiLPelX < pcSlice->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getPicHeightInLumaSamples()) )427 if( ( uiLPelX < pcSlice->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getPicHeightInLumaSamples() ) ) 447 428 #else 448 if( binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )449 #endif 450 { 451 xDecompressCU(p cCU, uiIdx, uiNextDepth );452 } 453 429 if( ( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 430 #endif 431 { 432 xDecompressCU(pCtu, uiIdx, uiNextDepth ); 433 } 434 454 435 uiIdx += uiQNumParts; 455 436 } 456 437 return; 457 438 } 458 439 459 440 // Residual reconstruction 460 441 m_ppcYuvResi[uiDepth]->clear(); 461 462 m_ppcCU[uiDepth]->copySubCU( p cCU, uiAbsPartIdx, uiDepth );463 442 443 m_ppcCU[uiDepth]->copySubCU( pCtu, uiAbsPartIdx, uiDepth ); 444 464 445 switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) 465 446 { … … 474 455 break; 475 456 } 457 458 #ifdef DEBUG_STRING 459 const PredMode predMode=m_ppcCU[uiDepth]->getPredictionMode(0); 460 if (DebugOptionList::DebugString_Structure.getInt()&DebugStringGetPredModeMask(predMode)) 461 { 462 PartSize eSize=m_ppcCU[uiDepth]->getPartitionSize(0); 463 std::ostream &ss(std::cout); 464 465 ss <<"###: " << (predMode==MODE_INTRA?"Intra ":"Inter ") << partSizeToString[eSize] << " CU at " << m_ppcCU[uiDepth]->getCUPelX() << ", " << m_ppcCU[uiDepth]->getCUPelY() << " width=" << UInt(m_ppcCU[uiDepth]->getWidth(0)) << std::endl; 466 } 467 #endif 468 476 469 if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) 477 470 { 478 471 xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth); 479 472 } 480 473 481 474 xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); 482 475 } … … 484 477 Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth ) 485 478 { 486 479 487 480 // inter prediction 488 481 m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); 489 482 483 #ifdef DEBUG_STRING 484 const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTER); 485 if (DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) printBlockToStream(std::cout, "###inter-pred: ", *(m_ppcYuvReco[uiDepth])); 486 #endif 487 490 488 // inter recon 491 xDecodeInterTexture( pcCU, 0, uiDepth ); 492 489 xDecodeInterTexture( pcCU, uiDepth ); 490 491 #ifdef DEBUG_STRING 492 if (DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) printBlockToStream(std::cout, "###inter-resi: ", *(m_ppcYuvResi[uiDepth])); 493 #endif 494 493 495 // clip for only non-zero cbp case 494 if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V )) )496 if ( pcCU->getQtRootCbf( 0) ) 495 497 { 496 498 m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); … … 500 502 m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); 501 503 } 502 } 504 #ifdef DEBUG_STRING 505 if (DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) printBlockToStream(std::cout, "###inter-reco: ", *(m_ppcYuvReco[uiDepth])); 506 #endif 507 508 } 509 503 510 504 511 Void 505 TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU, 506 UInt uiTrDepth, 507 UInt uiAbsPartIdx, 508 TComYuv* pcRecoYuv, 509 TComYuv* pcPredYuv, 510 TComYuv* pcResiYuv ) 511 { 512 UInt uiWidth = pcCU ->getWidth ( 0 ) >> uiTrDepth; 513 UInt uiHeight = pcCU ->getHeight ( 0 ) >> uiTrDepth; 514 UInt uiStride = pcRecoYuv->getStride (); 515 Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); 516 Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); 517 Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); 518 519 UInt uiNumCoeffInc = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ); 520 TCoeff* pcCoeff = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx ); 521 522 UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); 523 524 UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; 525 Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); 526 UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); 527 Bool useTransformSkip = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA); 512 TDecCu::xIntraRecBlk( TComYuv* pcRecoYuv, 513 TComYuv* pcPredYuv, 514 TComYuv* pcResiYuv, 515 const ComponentID compID, 516 TComTU &rTu) 517 { 518 if (!rTu.ProcessComponentSection(compID)) return; 519 const Bool bIsLuma = isLuma(compID); 520 521 522 TComDataCU *pcCU = rTu.getCU(); 523 const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(); 524 525 const TComRectangle &tuRect =rTu.getRect(compID); 526 const UInt uiWidth = tuRect.width; 527 const UInt uiHeight = tuRect.height; 528 const UInt uiStride = pcRecoYuv->getStride (compID); 529 Pel* piPred = pcPredYuv->getAddr( compID, uiAbsPartIdx ); 530 const ChromaFormat chFmt = rTu.GetChromaFormat(); 531 532 if (uiWidth != uiHeight) 533 { 534 //------------------------------------------------ 535 536 //split at current level if dividing into square sub-TUs 537 538 TComTURecurse subTURecurse(rTu, false, TComTU::VERTICAL_SPLIT, true, compID); 539 540 //recurse further 541 do 542 { 543 xIntraRecBlk(pcRecoYuv, pcPredYuv, pcResiYuv, compID, subTURecurse); 544 } 545 while (subTURecurse.nextSection(rTu)); 546 547 //------------------------------------------------ 548 549 return; 550 } 551 552 const UInt uiChPredMode = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx ); 553 const UInt uiChCodedMode = (uiChPredMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, chFmt)) : uiChPredMode; 554 const UInt uiChFinalMode = ((chFmt == CHROMA_422) && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiChCodedMode] : uiChCodedMode; 555 528 556 //===== init availability pattern ===== 529 557 Bool bAboveAvail = false; 530 558 Bool bLeftAvail = false; 531 pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); 532 pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, 533 m_pcPrediction->getPredicBuf (), 534 m_pcPrediction->getPredicBufWidth (), 535 m_pcPrediction->getPredicBufHeight (), 536 bAboveAvail, bLeftAvail ); 537 559 560 const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(compID, uiChFinalMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getDisableIntraReferenceSmoothing()); 561 562 #ifdef DEBUG_STRING 563 std::ostream &ss(std::cout); 564 #endif 565 566 DEBUG_STRING_NEW(sTemp) 567 m_pcPrediction->initAdiPatternChType( rTu, bAboveAvail, bLeftAvail, compID, bUseFilteredPredictions DEBUG_STRING_PASS_INTO(sTemp) ); 568 569 538 570 //===== get prediction signal ===== 539 m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 540 541 if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) ) 542 { 571 572 m_pcPrediction->predIntraAng( compID, uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions ); 573 574 #ifdef DEBUG_STRING 575 ss << sTemp; 576 #endif 577 543 578 //===== inverse transform ===== 544 #if REPN_FORMAT_IN_VPS 545 m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getQpBDOffsetY(), 0 ); 579 Pel* piResi = pcResiYuv->getAddr( compID, uiAbsPartIdx ); 580 TCoeff* pcCoeff = pcCU->getCoeff(compID) + rTu.getCoefficientOffset(compID);//( uiNumCoeffInc * uiAbsPartIdx ); 581 582 const QpParam cQP(*pcCU, compID); 583 584 585 DEBUG_STRING_NEW(sDebug); 586 #ifdef DEBUG_STRING 587 const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA); 588 std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0; 589 #endif 590 591 if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0) 592 { 593 m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) ); 594 } 595 else 596 { 597 for (UInt y = 0; y < uiHeight; y++) 598 for (UInt x = 0; x < uiWidth; x++) 599 { 600 piResi[(y * uiStride) + x] = 0; 601 } 602 } 603 604 #ifdef DEBUG_STRING 605 if (psDebug) 606 ss << (*psDebug); 607 #endif 608 609 //===== reconstruction ===== 610 const UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); 611 612 const Bool useCrossComponentPrediction = isChroma(compID) && (pcCU->getCrossComponentPredictionAlpha(uiAbsPartIdx, compID) != 0); 613 const Pel* pResiLuma = pcResiYuv->getAddr( COMPONENT_Y, uiAbsPartIdx ); 614 const Int strideLuma = pcResiYuv->getStride( COMPONENT_Y ); 615 616 Pel* pPred = piPred; 617 Pel* pResi = piResi; 618 Pel* pReco = pcRecoYuv->getAddr( compID, uiAbsPartIdx ); 619 Pel* pRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); 620 621 622 #ifdef DEBUG_STRING 623 const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); 624 const Bool bDebugResi=((DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); 625 const Bool bDebugReco=((DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); 626 if (bDebugPred || bDebugResi || bDebugReco) 627 ss << "###: " << "CompID: " << compID << " pred mode (ch/fin): " << uiChPredMode << "/" << uiChFinalMode << " absPartIdx: " << rTu.GetAbsPartIdxTU() << std::endl; 628 #endif 629 630 #if O0043_BEST_EFFORT_DECODING 631 const Int bitDepthDelta = g_bitDepthInStream[toChannelType(compID)] - g_bitDepth[toChannelType(compID)]; 632 #endif 633 const Int clipbd = g_bitDepth[toChannelType(compID)]; 634 635 if( useCrossComponentPrediction ) 636 { 637 TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true ); 638 } 639 640 for( UInt uiY = 0; uiY < uiHeight; uiY++ ) 641 { 642 #ifdef DEBUG_STRING 643 if (bDebugPred || bDebugResi || bDebugReco) ss << "###: "; 644 645 if (bDebugPred) 646 { 647 ss << " - pred: "; 648 for( UInt uiX = 0; uiX < uiWidth; uiX++ ) 649 { 650 ss << pPred[ uiX ] << ", "; 651 } 652 } 653 if (bDebugResi) ss << " - resi: "; 654 #endif 655 656 for( UInt uiX = 0; uiX < uiWidth; uiX++ ) 657 { 658 #ifdef DEBUG_STRING 659 if (bDebugResi) 660 ss << pResi[ uiX ] << ", "; 661 #endif 662 #if O0043_BEST_EFFORT_DECODING 663 pReco [ uiX ] = ClipBD( rightShiftEvenRounding<Pel>(pPred[ uiX ] + pResi[ uiX ], bitDepthDelta), clipbd ); 546 664 #else 547 m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); 548 #endif 549 550 Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA]; 551 assert(scalingListType < SCALING_LIST_NUM); 552 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); 553 554 555 //===== reconstruction ===== 556 Pel* pPred = piPred; 557 Pel* pResi = piResi; 558 Pel* pReco = piReco; 559 Pel* pRecIPred = piRecIPred; 560 for( UInt uiY = 0; uiY < uiHeight; uiY++ ) 561 { 562 for( UInt uiX = 0; uiX < uiWidth; uiX++ ) 563 { 564 pReco [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] ); 665 pReco [ uiX ] = ClipBD( pPred[ uiX ] + pResi[ uiX ], clipbd ); 666 #endif 565 667 pRecIPred[ uiX ] = pReco[ uiX ]; 566 668 } 669 #ifdef DEBUG_STRING 670 if (bDebugReco) 671 { 672 ss << " - reco: "; 673 for( UInt uiX = 0; uiX < uiWidth; uiX++ ) 674 { 675 ss << pReco[ uiX ] << ", "; 676 } 677 } 678 679 if (bDebugPred || bDebugResi || bDebugReco) 680 ss << "\n"; 681 #endif 567 682 pPred += uiStride; 568 683 pResi += uiStride; … … 570 685 pRecIPred += uiRecIPredStride; 571 686 } 572 }573 else574 {575 //===== reconstruction =====576 Pel* pPred = piPred;577 Pel* pReco = piReco;578 Pel* pRecIPred = piRecIPred;579 for ( Int y = 0; y < uiHeight; y++ )580 {581 for ( Int x = 0; x < uiWidth; x++ )582 {583 pReco [ x ] = pPred[ x ];584 pRecIPred[ x ] = pReco[ x ];585 }586 pPred += uiStride;587 pReco += uiStride;588 pRecIPred += uiRecIPredStride;589 }590 }591 }592 593 594 Void595 TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU,596 UInt uiTrDepth,597 UInt uiAbsPartIdx,598 TComYuv* pcRecoYuv,599 TComYuv* pcPredYuv,600 TComYuv* pcResiYuv,601 UInt uiChromaId )602 {603 UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth;604 UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2;605 606 if( uiLog2TrSize == 2 )607 {608 assert( uiTrDepth > 0 );609 uiTrDepth--;610 UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 );611 Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 );612 if( !bFirstQ )613 {614 return;615 }616 }617 618 TextType eText = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U );619 UInt uiWidth = pcCU ->getWidth ( 0 ) >> ( uiTrDepth + 1 );620 UInt uiHeight = pcCU ->getHeight ( 0 ) >> ( uiTrDepth + 1 );621 UInt uiStride = pcRecoYuv->getCStride ();622 Pel* piReco = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) );623 Pel* piPred = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) );624 Pel* piResi = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) );625 626 UInt uiNumCoeffInc = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2;627 TCoeff* pcCoeff = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx );628 629 UInt uiChromaPredMode = pcCU->getChromaIntraDir( 0 );630 631 UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx;632 Pel* piRecIPred = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) );633 UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getCStride();634 Bool useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText);635 //===== init availability pattern =====636 Bool bAboveAvail = false;637 Bool bLeftAvail = false;638 pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx );639 640 pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth,641 m_pcPrediction->getPredicBuf (),642 m_pcPrediction->getPredicBufWidth (),643 m_pcPrediction->getPredicBufHeight (),644 bAboveAvail, bLeftAvail );645 Int* pPatChroma = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) );646 647 //===== get prediction signal =====648 if( uiChromaPredMode == DM_CHROMA_IDX )649 {650 uiChromaPredMode = pcCU->getLumaIntraDir( 0 );651 }652 m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );653 654 if ( pcCU->getCbf( uiAbsPartIdx, eText, uiTrDepth ) )655 {656 //===== inverse transform =====657 Int curChromaQpOffset;658 if(eText == TEXT_CHROMA_U)659 {660 curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();661 }662 else663 {664 curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();665 }666 #if O0194_DIFFERENT_BITDEPTH_EL_BL667 // Bug-fix668 #if REPN_FORMAT_IN_VPS669 m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getQpBDOffsetC(), curChromaQpOffset );670 #else671 m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );672 #endif673 #else674 m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );675 #endif676 677 Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];678 assert(scalingListType < SCALING_LIST_NUM);679 m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma );680 681 //===== reconstruction =====682 Pel* pPred = piPred;683 Pel* pResi = piResi;684 Pel* pReco = piReco;685 Pel* pRecIPred = piRecIPred;686 for( UInt uiY = 0; uiY < uiHeight; uiY++ )687 {688 for( UInt uiX = 0; uiX < uiWidth; uiX++ )689 {690 pReco [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] );691 pRecIPred[ uiX ] = pReco[ uiX ];692 }693 pPred += uiStride;694 pResi += uiStride;695 pReco += uiStride;696 pRecIPred += uiRecIPredStride;697 }698 }699 else700 {701 //===== reconstruction =====702 Pel* pPred = piPred;703 Pel* pReco = piReco;704 Pel* pRecIPred = piRecIPred;705 for ( Int y = 0; y < uiHeight; y++ )706 {707 for ( Int x = 0; x < uiWidth; x++ )708 {709 pReco [ x ] = pPred[ x ];710 pRecIPred[ x ] = pReco[ x ];711 }712 pPred += uiStride;713 pReco += uiStride;714 pRecIPred += uiRecIPredStride;715 }716 }717 687 } 718 688 … … 721 691 TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) 722 692 { 723 UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );724 UInt uiNumPart = pcCU->getNumPartitions();725 UInt uiNumQParts = pcCU->getTotalNumPart() >> 2;726 727 693 if (pcCU->getIPCMFlag(0)) 728 694 { … … 730 696 return; 731 697 } 732 733 for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) 734 { 735 xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); 736 } 737 738 for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) 739 { 740 xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); 741 } 742 743 } 744 745 /** Function for deriving recontructed PU/CU Luma sample with QTree structure 746 * \param pcCU pointer of current CU 747 * \param uiTrDepth current tranform split depth 748 * \param uiAbsPartIdx part index 749 * \param pcRecoYuv pointer to reconstructed sample arrays 750 * \param pcPredYuv pointer to prediction sample arrays 751 * \param pcResiYuv pointer to residue sample arrays 752 * 753 \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure 754 */ 755 Void 756 TDecCu::xIntraLumaRecQT( TComDataCU* pcCU, 757 UInt uiTrDepth, 758 UInt uiAbsPartIdx, 759 TComYuv* pcRecoYuv, 760 TComYuv* pcPredYuv, 761 TComYuv* pcResiYuv ) 762 { 763 UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; 764 UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); 765 if( uiTrMode == uiTrDepth ) 766 { 767 xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); 768 } 769 else 770 { 771 UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); 772 for( UInt uiPart = 0; uiPart < 4; uiPart++ ) 773 { 774 xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); 775 } 776 } 777 } 698 const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1; 699 for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++) 700 { 701 const ChannelType chanType=ChannelType(chType); 702 const Bool NxNPUHas4Parts = ::isChroma(chanType) ? enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) : true; 703 const UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) != SIZE_2Nx2N && NxNPUHas4Parts ? 1 : 0 ); 704 705 TComTURecurse tuRecurseCU(pcCU, 0); 706 TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT); 707 708 do 709 { 710 xIntraRecQT( m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], chanType, tuRecurseWithPU ); 711 } while (tuRecurseWithPU.nextSection(tuRecurseCU)); 712 } 713 } 714 715 778 716 779 717 /** Function for deriving recontructed PU/CU chroma samples with QTree structure … … 784 722 * \param pcPredYuv pointer to prediction sample arrays 785 723 * \param pcResiYuv pointer to residue sample arrays 786 * 724 * 787 725 \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure 788 726 */ 727 789 728 Void 790 TDecCu::xIntraChromaRecQT( TComDataCU* pcCU, 791 UInt uiTrDepth, 792 UInt uiAbsPartIdx, 793 TComYuv* pcRecoYuv, 794 TComYuv* pcPredYuv, 795 TComYuv* pcResiYuv ) 796 { 797 UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; 729 TDecCu::xIntraRecQT(TComYuv* pcRecoYuv, 730 TComYuv* pcPredYuv, 731 TComYuv* pcResiYuv, 732 const ChannelType chType, 733 TComTU &rTu) 734 { 735 UInt uiTrDepth = rTu.GetTransformDepthRel(); 736 TComDataCU *pcCU = rTu.getCU(); 737 UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); 798 738 UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); 799 739 if( uiTrMode == uiTrDepth ) 800 740 { 801 xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); 802 xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); 741 if (isLuma(chType)) 742 xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, COMPONENT_Y, rTu ); 743 else 744 { 745 const UInt numValidComp=getNumberValidComponents(rTu.GetChromaFormat()); 746 for(UInt compID=COMPONENT_Cb; compID<numValidComp; compID++) 747 { 748 xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, ComponentID(compID), rTu ); 749 } 750 } 803 751 } 804 752 else 805 753 { 806 UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1);807 for( UInt uiPart = 0; uiPart < 4; uiPart++ )808 { 809 xIntra ChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv);810 } 754 TComTURecurse tuRecurseChild(rTu, false); 755 do 756 { 757 xIntraRecQT( pcRecoYuv, pcPredYuv, pcResiYuv, chType, tuRecurseChild ); 758 } while (tuRecurseChild.nextSection(rTu)); 811 759 } 812 760 } … … 814 762 Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) 815 763 { 816 UInt uiC UAddr = pcCU->getAddr();817 818 m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiC UAddr, uiZorderIdx );819 764 UInt uiCtuRsAddr = pcCU->getCtuRsAddr(); 765 766 m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCtuRsAddr, uiZorderIdx ); 767 820 768 return; 821 769 } 822 770 823 Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 824 { 825 UInt uiWidth = pcCU->getWidth ( uiAbsPartIdx ); 826 UInt uiHeight = pcCU->getHeight( uiAbsPartIdx ); 827 TCoeff* piCoeff; 828 829 Pel* pResi; 830 UInt trMode = pcCU->getTransformIdx( uiAbsPartIdx ); 831 832 // Y 833 piCoeff = pcCU->getCoeffY(); 834 pResi = m_ppcYuvResi[uiDepth]->getLumaAddr(); 835 836 #if REPN_FORMAT_IN_VPS 837 m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getQpBDOffsetY(), 0 ); 838 #else 839 m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); 840 #endif 841 842 m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); 843 844 // Cb and Cr 845 Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); 846 #if O0194_DIFFERENT_BITDEPTH_EL_BL 847 // Bug-fix 848 #if REPN_FORMAT_IN_VPS 849 m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getQpBDOffsetC(), curChromaQpOffset ); 850 #else 851 m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); 852 #endif 853 #else 854 m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); 855 #endif 856 857 uiWidth >>= 1; 858 uiHeight >>= 1; 859 piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr(); 860 m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); 861 862 curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); 863 #if O0194_DIFFERENT_BITDEPTH_EL_BL 864 // Bug-fix 865 #if REPN_FORMAT_IN_VPS 866 m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getQpBDOffsetC(), curChromaQpOffset ); 867 #else 868 m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); 869 #endif 870 #else 871 m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); 872 #endif 873 874 piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr(); 875 m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); 771 Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth ) 772 { 773 774 TComTURecurse tuRecur(pcCU, 0, uiDepth); 775 776 for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++) 777 { 778 const ComponentID compID=ComponentID(ch); 779 DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[compID]) 780 781 m_pcTrQuant->invRecurTransformNxN ( compID, m_ppcYuvResi[uiDepth], tuRecur ); 782 } 783 784 DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[MAX_NUM_COMPONENT]) 876 785 } 877 786 … … 887 796 * \returns Void 888 797 */ 889 Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText) 890 { 891 UInt uiX, uiY; 892 Pel* piPicReco; 893 UInt uiPicStride; 894 UInt uiPcmLeftShiftBit; 895 896 if( ttText == TEXT_LUMA ) 897 { 898 uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(); 899 piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); 900 uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); 901 } 902 else 903 { 904 uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride(); 905 906 if( ttText == TEXT_CHROMA_U ) 907 { 908 piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); 909 } 910 else 911 { 912 piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); 913 } 914 uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); 915 } 916 917 for( uiY = 0; uiY < uiHeight; uiY++ ) 918 { 919 for( uiX = 0; uiX < uiWidth; uiX++ ) 798 Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, const UInt uiPartIdx, const Pel *piPCM, Pel* piReco, const UInt uiStride, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) 799 { 800 Pel* piPicReco = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiPartIdx); 801 const UInt uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); 802 const UInt uiPcmLeftShiftBit = g_bitDepth[toChannelType(compID)] - pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID)); 803 804 for(UInt uiY = 0; uiY < uiHeight; uiY++ ) 805 { 806 for(UInt uiX = 0; uiX < uiWidth; uiX++ ) 920 807 { 921 808 piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); … … 935 822 Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) 936 823 { 937 // Luma 938 UInt uiWidth = (g_uiMaxCUWidth >> uiDepth); 939 UInt uiHeight = (g_uiMaxCUHeight >> uiDepth); 940 941 Pel* piPcmY = pcCU->getPCMSampleY(); 942 Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth); 943 944 UInt uiStride = m_ppcYuvResi[uiDepth]->getStride(); 945 946 xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA); 947 948 // Cb and Cr 949 UInt uiCWidth = (uiWidth>>1); 950 UInt uiCHeight = (uiHeight>>1); 951 952 Pel* piPcmCb = pcCU->getPCMSampleCb(); 953 Pel* piPcmCr = pcCU->getPCMSampleCr(); 954 Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr(); 955 Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr(); 956 957 UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride(); 958 959 xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U); 960 xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V); 961 } 962 963 /** Function for filling the PCM buffer of a CU using its reconstructed sample array 824 for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++) 825 { 826 const ComponentID compID = ComponentID(ch); 827 const UInt width = (g_uiMaxCUWidth >>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleX(compID))); 828 const UInt height = (g_uiMaxCUHeight>>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleY(compID))); 829 const UInt stride = m_ppcYuvResi[uiDepth]->getStride(compID); 830 Pel * pPCMChannel = pcCU->getPCMSample(compID); 831 Pel * pRecChannel = m_ppcYuvReco[uiDepth]->getAddr(compID); 832 xDecodePCMTexture( pcCU, 0, pPCMChannel, pRecChannel, stride, width, height, compID ); 833 } 834 } 835 836 /** Function for filling the PCM buffer of a CU using its reconstructed sample array 964 837 * \param pcCU pointer to current CU 965 838 * \param uiDepth CU Depth … … 968 841 Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) 969 842 { 970 // Luma 971 UInt width = (g_uiMaxCUWidth >> depth); 972 UInt height = (g_uiMaxCUHeight >> depth); 973 974 Pel* pPcmY = pCU->getPCMSampleY(); 975 Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width); 976 977 UInt stride = m_ppcYuvReco[depth]->getStride(); 978 979 for(Int y = 0; y < height; y++ ) 980 { 981 for(Int x = 0; x < width; x++ ) 982 { 983 pPcmY[x] = pRecoY[x]; 984 } 985 pPcmY += width; 986 pRecoY += stride; 987 } 988 989 // Cb and Cr 990 UInt widthC = (width>>1); 991 UInt heightC = (height>>1); 992 993 Pel* pPcmCb = pCU->getPCMSampleCb(); 994 Pel* pPcmCr = pCU->getPCMSampleCr(); 995 Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr(); 996 Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr(); 997 998 UInt strideC = m_ppcYuvReco[depth]->getCStride(); 999 1000 for(Int y = 0; y < heightC; y++ ) 1001 { 1002 for(Int x = 0; x < widthC; x++ ) 1003 { 1004 pPcmCb[x] = pRecoCb[x]; 1005 pPcmCr[x] = pRecoCr[x]; 1006 } 1007 pPcmCr += widthC; 1008 pPcmCb += widthC; 1009 pRecoCb += strideC; 1010 pRecoCr += strideC; 1011 } 1012 843 const ChromaFormat format = pCU->getPic()->getChromaFormat(); 844 const UInt numValidComp=getNumberValidComponents(format); 845 846 for (UInt componentIndex = 0; componentIndex < numValidComp; componentIndex++) 847 { 848 const ComponentID component = ComponentID(componentIndex); 849 850 const UInt width = g_uiMaxCUWidth >> (depth + getComponentScaleX(component, format)); 851 const UInt height = g_uiMaxCUHeight >> (depth + getComponentScaleY(component, format)); 852 853 Pel *source = m_ppcYuvReco[depth]->getAddr(component, 0, width); 854 Pel *destination = pCU->getPCMSample(component); 855 856 const UInt sourceStride = m_ppcYuvReco[depth]->getStride(component); 857 858 for (Int line = 0; line < height; line++) 859 { 860 for (Int column = 0; column < width; column++) 861 { 862 destination[column] = source[column]; 863 } 864 865 source += sourceStride; 866 destination += width; 867 } 868 } 1013 869 } 1014 870 -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecCu.h
r595 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 65 65 TComYuv** m_ppcYuvReco; ///< array of prediction & reconstruction buffer 66 66 TComDataCU** m_ppcCU; ///< CU data array 67 67 68 68 // access channel 69 69 TComTrQuant* m_pcTrQuant; … … 72 72 73 73 Bool m_bDecodeDQP; 74 Bool m_IsChromaQpAdjCoded; 75 74 76 #if SVC_EXTENSION 75 77 TDecTop** m_ppcTDecTop; … … 80 82 TDecCu(); 81 83 virtual ~TDecCu(); 82 84 83 85 /// initialize access channels 84 86 #if SVC_EXTENSION … … 89 91 90 92 /// create internal buffers 91 Void create ( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight );92 93 Void create ( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight, ChromaFormat chromaFormatIDC ); 94 93 95 /// destroy internal buffers 94 96 Void destroy (); 95 96 /// decode C Uinformation97 Void decodeC U ( TComDataCU* pcCU, UInt& ruiIsLast );98 99 /// reconstruct C Uinformation100 Void decompressC U ( TComDataCU* pcCU);101 97 98 /// decode Ctu information 99 Void decodeCtu ( TComDataCU* pCtu, Bool &isLastCtuOfSliceSegment ); 100 101 /// reconstruct Ctu information 102 Void decompressCtu ( TComDataCU* pCtu ); 103 102 104 #if SVC_EXTENSION 103 105 TDecTop* getLayerDec ( UInt LayerId ) { return m_ppcTDecTop[LayerId]; } 104 106 #endif 105 107 protected: 106 107 Void xDecodeCU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt &ruiIsLast);108 Void xFinishDecodeCU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt &ruiIsLast);109 Bool xDecodeSliceEnd ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth);110 Void xDecompressCU ( TComDataCU* p cCU, UInt uiAbsPartIdx, UInt uiDepth );111 108 109 Void xDecodeCU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment); 110 Void xFinishDecodeCU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment); 111 Bool xDecodeSliceEnd ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 112 Void xDecompressCU ( TComDataCU* pCtu, UInt uiAbsPartIdx, UInt uiDepth ); 113 112 114 Void xReconInter ( TComDataCU* pcCU, UInt uiDepth ); 113 114 Void xReconIntraQT ( TComDataCU* pcCU, UInt uiDepth );115 Void xIntraRecLumaBlk ( TComDataCU* pcCU, UInt uiTrDepth, UInt uiAbsPartIdx, TComYuv* pcRecoYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv );116 Void xIntraRecChromaBlk ( TComDataCU* pcCU, UInt uiTrDepth, UInt uiAbsPartIdx, TComYuv* pcRecoYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv, UInt uiChromaId );117 118 Void xReconPCM ( TComDataCU* pcCU, UInt uiDepth );119 115 120 Void xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 121 Void xDecodePCMTexture ( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText); 122 116 Void xReconIntraQT ( TComDataCU* pcCU, UInt uiDepth ); 117 Void xIntraRecBlk ( TComYuv* pcRecoYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv, const ComponentID component, TComTU &rTu ); 118 Void xIntraRecQT ( TComYuv* pcRecoYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv, const ChannelType chType, TComTU &rTu ); 119 120 Void xReconPCM ( TComDataCU* pcCU, UInt uiDepth ); 121 122 Void xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth ); 123 Void xDecodePCMTexture ( TComDataCU* pcCU, const UInt uiPartIdx, const Pel *piPCM, Pel* piReco, const UInt uiStride, const UInt uiWidth, const UInt uiHeight, const ComponentID compID); 124 123 125 Void xCopyToPic ( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ); 124 125 Void xIntraLumaRecQT ( TComDataCU* pcCU, UInt uiTrDepth, UInt uiAbsPartIdx, TComYuv* pcRecoYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv );126 Void xIntraChromaRecQT ( TComDataCU* pcCU, UInt uiTrDepth, UInt uiAbsPartIdx, TComYuv* pcRecoYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv );127 126 128 127 Bool getdQPFlag () { return m_bDecodeDQP; } 129 128 Void setdQPFlag ( Bool b ) { m_bDecodeDQP = b; } 129 Bool getIsChromaQpAdjCoded () { return m_IsChromaQpAdjCoded; } 130 Void setIsChromaQpAdjCoded ( Bool b ) { m_IsChromaQpAdjCoded = b; } 131 130 132 Void xFillPCMBuffer (TComDataCU* pCU, UInt depth); 131 133 }; -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecEntropy.cpp
r595 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 37 37 38 38 #include "TDecEntropy.h" 39 #include "TLibCommon/TComTU.h" 40 41 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 42 #include "../TLibCommon/Debug.h" 43 static const Bool bDebugRQT = DebugOptionList::DebugRQT.getInt()!=0; 44 static const Bool bDebugPredEnabled = DebugOptionList::DebugPred.getInt()!=0; 45 Bool g_bFinalEncode=true; 46 #endif 39 47 40 48 //! \ingroup TLibDecoder … … 53 61 } 54 62 63 55 64 Void TDecEntropy::decodeCUTransquantBypassFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 56 65 { 57 66 m_pcEntropyDecoderIf->parseCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); 58 67 } 68 59 69 60 70 /** decode merge flag 61 71 * \param pcSubCU 62 * \param uiAbsPartIdx 72 * \param uiAbsPartIdx 63 73 * \param uiDepth 64 * \param uiPUIdx 74 * \param uiPUIdx 65 75 * \returns Void 66 76 */ 67 77 Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) 68 { 78 { 69 79 // at least one merge candidate exists 70 80 m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx ); … … 73 83 /** decode merge index 74 84 * \param pcCU 75 * \param uiPartIdx 76 * \param uiAbsPartIdx 85 * \param uiPartIdx 86 * \param uiAbsPartIdx 77 87 * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours 78 88 * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours … … 107 117 { 108 118 decodeIntraDirModeLuma ( pcCU, uiAbsPartIdx, uiDepth ); 109 decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); 119 if (pcCU->getPic()->getChromaFormat()!=CHROMA_400) 120 { 121 decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); 122 if (enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) && pcCU->getPartitionSize( uiAbsPartIdx )==SIZE_NxN) 123 { 124 UInt uiPartOffset = ( pcCU->getPic()->getNumPartitionsInCtu() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2; 125 decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset, uiDepth+1 ); 126 decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset*2, uiDepth+1 ); 127 decodeIntraDirModeChroma( pcCU, uiAbsPartIdx + uiPartOffset*3, uiDepth+1 ); 128 } 129 } 110 130 } 111 131 else // if it is Inter mode, encode motion vector and reference index … … 115 135 } 116 136 117 /** Parse I_PCM information. 137 /** Parse I_PCM information. 118 138 * \param pcCU pointer to CUpointer to CU 119 139 * \param uiAbsPartIdx CU index … … 129 149 return; 130 150 } 131 151 132 152 m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); 133 153 } … … 141 161 { 142 162 m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth ); 143 } 163 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 164 if (bDebugPredEnabled) 165 { 166 UInt cdir=pcCU->getIntraDir(CHANNEL_TYPE_CHROMA, uiAbsPartIdx); 167 if (cdir==36) cdir=pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiAbsPartIdx); 168 printf("coding chroma Intra dir: %d, uiAbsPartIdx: %d, luma dir: %d\n", cdir, uiAbsPartIdx, pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiAbsPartIdx)); 169 } 170 #endif 171 } 172 144 173 145 174 /** decode motion information for every PU block. 146 175 * \param pcCU 147 * \param uiAbsPartIdx 176 * \param uiAbsPartIdx 148 177 * \param uiDepth 149 178 * \param pcSubCU … … 174 203 { 175 204 decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth ); 205 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 206 if (bDebugPredEnabled) 207 { 208 std::cout << "Coded merge flag, CU absPartIdx: " << uiAbsPartIdx << " PU(" << uiPartIdx << ") absPartIdx: " << uiSubPartIdx; 209 std::cout << " merge index: " << (UInt)pcCU->getMergeIndex(uiSubPartIdx) << std::endl; 210 } 211 #endif 212 176 213 UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); 177 if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) 214 if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) 178 215 { 179 216 pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); … … 190 227 pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); 191 228 } 229 192 230 pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); 193 231 194 232 TComMv cTmpMv( 0, 0 ); 195 233 for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) 196 { 234 { 197 235 if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) 198 236 { … … 201 239 pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); 202 240 pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); 241 203 242 } 204 243 } … … 208 247 decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); 209 248 for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) 210 { 249 { 211 250 if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) 212 251 { … … 214 253 decodeMvdPU ( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); 215 254 decodeMVPIdxPU ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); 255 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 256 if (bDebugPredEnabled) 257 { 258 std::cout << "refListIdx: " << uiRefListIdx << std::endl; 259 std::cout << "MVD horizontal: " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getHor() << std::endl; 260 std::cout << "MVD vertical: " << pcCU->getCUMvField(RefPicList(uiRefListIdx))->getMvd( uiAbsPartIdx ).getVer() << std::endl; 261 std::cout << "MVPIdxPU: " << pcCU->getMVPIdx(RefPicList( uiRefListIdx ), uiSubPartIdx) << std::endl; 262 std::cout << "InterDir: " << (UInt)pcCU->getInterDir(uiSubPartIdx) << std::endl; 263 } 264 #endif 216 265 } 217 266 } 218 267 } 268 219 269 if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) ) 220 270 { … … 229 279 /** decode inter direction for a PU block 230 280 * \param pcCU 231 * \param uiAbsPartIdx 281 * \param uiAbsPartIdx 232 282 * \param uiDepth 233 * \param uiPartIdx 283 * \param uiPartIdx 234 284 * \returns Void 235 285 */ … … 274 324 /** decode motion vector difference for a PU block 275 325 * \param pcCU 276 * \param uiAbsPartIdx 326 * \param uiAbsPartIdx 277 327 * \param uiDepth 278 328 * \param uiPartIdx 279 * \param eRefList 329 * \param eRefList 280 330 * \returns Void 281 331 */ … … 319 369 } 320 370 321 Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP, Int quadtreeTULog2MinSizeInCU) 322 { 371 Void TDecEntropy::xDecodeTransform ( Bool& bCodeDQP, Bool& isChromaQpAdjCoded, TComTU &rTu, const Int quadtreeTULog2MinSizeInCU ) 372 { 373 TComDataCU *pcCU=rTu.getCU(); 374 const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(); 375 const UInt uiDepth=rTu.GetTransformDepthTotal(); 376 const UInt uiTrDepth = rTu.GetTransformDepthRel(); 377 323 378 UInt uiSubdiv; 324 const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth; 325 326 if(uiTrIdx==0) 327 { 328 m_bakAbsPartIdxCU = uiAbsPartIdx; 329 } 330 if( uiLog2TrafoSize == 2 ) 331 { 332 UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); 333 if( ( uiAbsPartIdx % partNum ) == 0 ) 334 { 335 m_uiBakAbsPartIdx = uiAbsPartIdx; 336 m_uiBakChromaOffset = offsetChroma; 337 } 338 } 339 if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) 379 const UInt numValidComponent = pcCU->getPic()->getNumberValidComponents(); 380 const Bool bChroma = isChromaEnabled(pcCU->getPic()->getChromaFormat()); 381 382 const UInt uiLog2TrafoSize = rTu.GetLog2LumaTrSize(); 383 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 384 if (bDebugRQT) 385 { 386 printf("x..codeTransform: offsetLuma=%d offsetChroma=%d absPartIdx=%d, uiDepth=%d\n width=%d, height=%d, uiTrIdx=%d, uiInnerQuadIdx=%d\n", 387 rTu.getCoefficientOffset(COMPONENT_Y), rTu.getCoefficientOffset(COMPONENT_Cb), uiAbsPartIdx, uiDepth, rTu.getRect(COMPONENT_Y).width, rTu.getRect(COMPONENT_Y).height, rTu.GetTransformDepthRel(), rTu.GetSectionNumber()); 388 fflush(stdout); 389 } 390 #endif 391 392 if( pcCU->isIntra(uiAbsPartIdx) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) 340 393 { 341 394 uiSubdiv = 1; 342 395 } 343 else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU-> getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) )344 { 345 uiSubdiv = (uiLog2TrafoSize > 396 else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->isInter(uiAbsPartIdx)) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) ) 397 { 398 uiSubdiv = (uiLog2TrafoSize >quadtreeTULog2MinSizeInCU); 346 399 } 347 400 else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) … … 362 415 m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize ); 363 416 } 364 365 const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx ); 366 { 417 418 for(Int chan=COMPONENT_Cb; chan<numValidComponent; chan++) 419 { 420 const ComponentID compID=ComponentID(chan); 421 const UInt trDepthTotalAdj=rTu.GetTransformDepthTotalAdj(compID); 422 367 423 const Bool bFirstCbfOfCU = uiTrDepth == 0; 424 368 425 if( bFirstCbfOfCU ) 369 426 { 370 pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); 371 pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); 372 } 373 if( bFirstCbfOfCU || uiLog2TrafoSize > 2 ) 374 { 375 if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) ) 376 { 377 m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth ); 378 } 379 if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) ) 380 { 381 m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth ); 382 } 383 } 384 else 385 { 386 pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); 387 pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); 388 } 389 } 390 427 pcCU->setCbfSubParts( 0, compID, rTu.GetAbsPartIdxTU(compID), trDepthTotalAdj); 428 } 429 if( bFirstCbfOfCU || rTu.ProcessingAllQuadrants(compID) ) 430 { 431 if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, compID, uiTrDepth - 1 ) ) 432 { 433 m_pcEntropyDecoderIf->parseQtCbf( rTu, compID, (uiSubdiv == 0) ); 434 } 435 } 436 } 437 391 438 if( uiSubdiv ) 392 439 { 393 UInt size; 394 width >>= 1; 395 height >>= 1; 396 size = width*height; 397 uiTrIdx++; 398 ++uiDepth; 399 const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); 400 const UInt uiStartAbsPartIdx = uiAbsPartIdx; 401 UInt uiYCbf = 0; 402 UInt uiUCbf = 0; 403 UInt uiVCbf = 0; 404 405 for( Int i = 0; i < 4; i++ ) 406 { 407 xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, quadtreeTULog2MinSizeInCU ); 408 uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth+1 ); 409 uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth+1 ); 410 uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth+1 ); 411 uiAbsPartIdx += uiQPartNum; 412 offsetLuma += size; offsetChroma += (size>>2); 413 } 414 415 for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui ) 416 { 417 pcCU->getCbf( TEXT_LUMA )[uiStartAbsPartIdx + ui] |= uiYCbf << uiTrDepth; 418 pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiTrDepth; 419 pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiTrDepth; 440 const UInt uiQPartNum = pcCU->getPic()->getNumPartitionsInCtu() >> ((uiDepth+1) << 1); 441 UInt uiYUVCbf[MAX_NUM_COMPONENT] = {0,0,0}; 442 443 TComTURecurse tuRecurseChild(rTu, true); 444 445 do 446 { 447 xDecodeTransform( bCodeDQP, isChromaQpAdjCoded, tuRecurseChild, quadtreeTULog2MinSizeInCU ); 448 UInt childTUAbsPartIdx=tuRecurseChild.GetAbsPartIdxTU(); 449 for(UInt ch=0; ch<numValidComponent; ch++) 450 { 451 uiYUVCbf[ch] |= pcCU->getCbf(childTUAbsPartIdx , ComponentID(ch), uiTrDepth+1 ); 452 } 453 454 } while (tuRecurseChild.nextSection(rTu) ); 455 456 for(UInt ch=0; ch<numValidComponent; ch++) 457 { 458 UChar *pBase = pcCU->getCbf( ComponentID(ch) ) + uiAbsPartIdx; 459 const UChar flag = uiYUVCbf[ch] << uiTrDepth; 460 461 for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui ) 462 { 463 pBase[ui] |= flag; 464 } 420 465 } 421 466 } … … 424 469 assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) ); 425 470 pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth ); 426 471 427 472 { 428 473 DTRACE_CABAC_VL( g_nSymbolCounter++ ); … … 435 480 DTRACE_CABAC_T( "\n" ); 436 481 } 437 438 pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth ); 439 if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) ) 440 { 441 pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_LUMA, uiAbsPartIdx, uiDepth ); 482 483 pcCU->setCbfSubParts ( 0, COMPONENT_Y, uiAbsPartIdx, uiDepth ); 484 485 if( (!pcCU->isIntra(uiAbsPartIdx)) && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && ((!bChroma) || (!pcCU->getCbf( uiAbsPartIdx, COMPONENT_Cb, 0 ) && !pcCU->getCbf( uiAbsPartIdx, COMPONENT_Cr, 0 )) )) 486 { 487 pcCU->setCbfSubParts( 1 << uiTrDepth, COMPONENT_Y, uiAbsPartIdx, uiDepth ); 442 488 } 443 489 else 444 490 { 445 m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrDepth, uiDepth);491 m_pcEntropyDecoderIf->parseQtCbf( rTu, COMPONENT_Y, true ); 446 492 } 447 493 448 494 449 495 // transform_unit begin 450 UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA , uiTrIdx ); 451 UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); 452 UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); 453 if( uiLog2TrafoSize == 2 ) 454 { 455 UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); 456 if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) 457 { 458 cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); 459 cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); 460 } 461 } 462 if ( cbfY || cbfU || cbfV ) 463 { 464 // dQP: only for LCU 496 UInt cbf[MAX_NUM_COMPONENT]={0,0,0}; 497 Bool validCbf = false; 498 Bool validChromaCbf = false; 499 const UInt uiTrIdx = rTu.GetTransformDepthRel(); 500 501 for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++) 502 { 503 const ComponentID compID = ComponentID(ch); 504 505 cbf[compID] = pcCU->getCbf( uiAbsPartIdx, compID, uiTrIdx ); 506 507 if (cbf[compID] != 0) 508 { 509 validCbf = true; 510 if (isChroma(compID)) validChromaCbf = true; 511 } 512 } 513 514 if ( validCbf ) 515 { 516 517 // dQP: only for CTU 465 518 if ( pcCU->getSlice()->getPPS()->getUseDQP() ) 466 519 { 467 520 if ( bCodeDQP ) 468 521 { 469 decodeQP( pcCU, m_bakAbsPartIdxCU); 522 const UInt uiAbsPartIdxCU=rTu.GetAbsPartIdxCU(); 523 decodeQP( pcCU, uiAbsPartIdxCU); 470 524 bCodeDQP = false; 471 525 } 472 526 } 473 } 474 if( cbfY ) 475 { 476 Int trWidth = width; 477 Int trHeight = height; 478 m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); 479 } 480 if( uiLog2TrafoSize > 2 ) 481 { 482 Int trWidth = width >> 1; 483 Int trHeight = height >> 1; 484 if( cbfU ) 485 { 486 m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); 487 } 488 if( cbfV ) 489 { 490 m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); 491 } 492 } 493 else 494 { 495 UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); 496 if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) 497 { 498 Int trWidth = width; 499 Int trHeight = height; 500 if( cbfU ) 527 528 if ( pcCU->getSlice()->getUseChromaQpAdj() ) 529 { 530 if ( validChromaCbf && isChromaQpAdjCoded && !pcCU->getCUTransquantBypass(rTu.GetAbsPartIdxCU()) ) 501 531 { 502 m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); 532 decodeChromaQpAdjustment( pcCU, rTu.GetAbsPartIdxCU() ); 533 isChromaQpAdjCoded = false; 503 534 } 504 if( cbfV ) 535 } 536 537 const UInt numValidComp=pcCU->getPic()->getNumberValidComponents(); 538 539 for(UInt ch=COMPONENT_Y; ch<numValidComp; ch++) 540 { 541 const ComponentID compID=ComponentID(ch); 542 543 if( rTu.ProcessComponentSection(compID) ) 505 544 { 506 m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); 545 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 546 if (bDebugRQT) printf("Call NxN for chan %d width=%d height=%d cbf=%d\n", compID, rTu.getRect(compID).width, rTu.getRect(compID).height, 1); 547 #endif 548 549 if (rTu.getRect(compID).width != rTu.getRect(compID).height) 550 { 551 //code two sub-TUs 552 TComTURecurse subTUIterator(rTu, false, TComTU::VERTICAL_SPLIT, true, compID); 553 554 do 555 { 556 const UInt subTUCBF = pcCU->getCbf(subTUIterator.GetAbsPartIdxTU(), compID, (uiTrIdx + 1)); 557 558 if (subTUCBF != 0) 559 { 560 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 561 if (bDebugRQT) printf("Call NxN for chan %d width=%d height=%d cbf=%d\n", compID, subTUIterator.getRect(compID).width, subTUIterator.getRect(compID).height, 1); 562 #endif 563 m_pcEntropyDecoderIf->parseCoeffNxN( subTUIterator, compID ); 564 } 565 } 566 while (subTUIterator.nextSection(rTu)); 567 } 568 else 569 { 570 if(isChroma(compID) && (cbf[COMPONENT_Y] != 0)) 571 { 572 m_pcEntropyDecoderIf->parseCrossComponentPrediction( rTu, compID ); 573 } 574 575 if(cbf[compID] != 0) 576 { 577 m_pcEntropyDecoderIf->parseCoeffNxN( rTu, compID ); 578 } 579 } 507 580 } 508 581 } … … 517 590 { 518 591 m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) ); 592 } 593 } 594 595 Void TDecEntropy::decodeChromaQpAdjustment( TComDataCU* pcCU, UInt uiAbsPartIdx ) 596 { 597 if ( pcCU->getSlice()->getUseChromaQpAdj() ) 598 { 599 m_pcEntropyDecoderIf->parseChromaQpAdjustment( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) ); 519 600 } 520 601 } … … 523 604 /** decode coefficients 524 605 * \param pcCU 525 * \param uiAbsPartIdx 606 * \param uiAbsPartIdx 526 607 * \param uiDepth 527 608 * \param uiWidth 528 * \param uiHeight 609 * \param uiHeight 529 610 * \returns Void 530 611 */ 531 Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP ) 532 { 533 UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); 534 UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; 535 UInt uiChromaOffset = uiLumaOffset>>2; 536 612 Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool& bCodeDQP, Bool& isChromaQpAdjCoded ) 613 { 537 614 if( pcCU->isIntra(uiAbsPartIdx) ) 538 615 { … … 547 624 if ( !uiQtRootCbf ) 548 625 { 549 pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth ); 626 static const UInt cbfZero[MAX_NUM_COMPONENT]={0,0,0}; 627 pcCU->setCbfSubParts( cbfZero, uiAbsPartIdx, uiDepth ); 550 628 pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth ); 551 629 return; 552 630 } 553 554 } 631 632 } 633 634 TComTURecurse tuRecurse(pcCU, uiAbsPartIdx, uiDepth); 635 636 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 637 if (bDebugRQT) 638 printf("..codeCoeff: uiAbsPartIdx=%d, PU format=%d, 2Nx2N=%d, NxN=%d\n", uiAbsPartIdx, pcCU->getPartitionSize(uiAbsPartIdx), SIZE_2Nx2N, SIZE_NxN); 639 #endif 640 641 Int quadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx); 555 642 556 Int getQuadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx); 557 558 xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP, getQuadtreeTULog2MinSizeInCU ); 643 xDecodeTransform( bCodeDQP, isChromaQpAdjCoded, tuRecurse, quadtreeTULog2MinSizeInCU ); 559 644 } 560 645 -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecEntropy.h
r713 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 45 45 #include "TLibCommon/TComPrediction.h" 46 46 #include "TLibCommon/TComSampleAdaptiveOffset.h" 47 #include "TLibCommon/TComRectangle.h" 47 48 48 49 class TDecSbac; … … 68 69 virtual Void setBitstream ( TComInputBitstream* p ) = 0; 69 70 70 virtual Void parseVPS ( TComVPS* pcVPS ) = 0; 71 #if SVC_EXTENSION && !SPS_DPB_PARAMS 72 virtual Void parseSPS ( TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager ) = 0; 71 virtual Void parseVPS ( TComVPS* pcVPS ) = 0; 72 virtual Void parseSPS ( TComSPS* pcSPS ) = 0; 73 #if Q0048_CGS_3D_ASYMLUT 74 virtual Void parsePPS ( TComPPS* pcPPS, TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID ) = 0; 73 75 #else 74 virtual Void parse SPS ( TComSPS* pcSPS )= 0;76 virtual Void parsePPS ( TComPPS* pcPPS ) = 0; 75 77 #endif 76 virtual Void parsePPS ( TComPPS* pcPPS77 #if Q0048_CGS_3D_ASYMLUT78 , TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID79 #endif80 ) = 0;81 78 82 virtual Void parseSliceHeader ( TComSlice* & rpcSlice, ParameterSetManagerDecoder *parameterSetManager) = 0;79 virtual Void parseSliceHeader ( TComSlice* pcSlice, ParameterSetManagerDecoder *parameterSetManager) = 0; 83 80 84 virtual Void parseTerminatingBit ( UInt& ruilsLast ) = 0; 85 81 virtual Void parseTerminatingBit ( UInt& ruilsLast ) = 0; 82 virtual Void parseRemainingBytes( Bool noTrailingBytesExpected ) = 0; 83 86 84 virtual Void parseMVPIdx ( Int& riMVPIdx ) = 0; 87 85 88 86 public: 89 87 virtual Void parseSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; … … 94 92 virtual Void parsePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; 95 93 virtual Void parsePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; 96 94 97 95 virtual Void parseIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; 98 99 96 virtual Void parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; 100 97 101 98 virtual Void parseInterDir ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx ) = 0; 102 99 virtual Void parseRefFrmIdx ( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList ) = 0; 103 100 virtual Void parseMvd ( TComDataCU* pcCU, UInt uiAbsPartAddr, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) = 0; 104 101 102 virtual Void parseCrossComponentPrediction ( class TComTU &rTu, ComponentID compID ) = 0; 103 105 104 virtual Void parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) = 0; 106 virtual Void parseQtCbf ( TCom DataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth) = 0;105 virtual Void parseQtCbf ( TComTU &rTu, const ComponentID compID, const Bool lowestLevel ) = 0; 107 106 virtual Void parseQtRootCbf ( UInt uiAbsPartIdx, UInt& uiQtRootCbf ) = 0; 108 107 109 108 virtual Void parseDeltaQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; 110 109 virtual Void parseChromaQpAdjustment( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0; 110 111 111 virtual Void parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth) = 0; 112 112 113 virtual Void parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) = 0; 114 virtual Void parseTransformSkipFlags ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType) = 0; 115 virtual Void updateContextTables( SliceType eSliceType, Int iQp ) = 0; 116 113 virtual Void parseCoeffNxN( class TComTU &rTu, ComponentID compID ) = 0; 114 115 virtual Void parseTransformSkipFlags ( class TComTU &rTu, ComponentID component ) = 0; 116 117 virtual Void parseExplicitRdpcmMode ( TComTU &rTu, ComponentID compID ) = 0; 118 117 119 virtual ~TDecEntropyIf() {} 118 120 }; … … 124 126 TDecEntropyIf* m_pcEntropyDecoderIf; 125 127 TComPrediction* m_pcPrediction; 126 UInt m_uiBakAbsPartIdx;127 UInt m_uiBakChromaOffset;128 UInt m_bakAbsPartIdxCU;129 128 //UInt m_uiBakAbsPartIdx; 129 //UInt m_uiBakChromaOffset; 130 //UInt m_bakAbsPartIdxCU; 131 130 132 public: 131 133 Void init (TComPrediction* p) {m_pcPrediction = p;} … … 135 137 Void decodeMvdPU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ); 136 138 Void decodeMVPIdxPU ( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ); 137 139 138 140 Void setEntropyDecoder ( TDecEntropyIf* p ); 139 141 Void setBitstream ( TComInputBitstream* p ) { m_pcEntropyDecoderIf->setBitstream(p); } 140 142 Void resetEntropy ( TComSlice* p) { m_pcEntropyDecoderIf->resetEntropy(p); } 143 141 144 Void decodeVPS ( TComVPS* pcVPS ) { m_pcEntropyDecoderIf->parseVPS(pcVPS); } 142 #if SVC_EXTENSION && !SPS_DPB_PARAMS 143 Void decodeSPS ( TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager ) { m_pcEntropyDecoderIf->parseSPS(pcSPS, parameterSetManager); } 144 #else 145 Void decodeSPS ( TComSPS* pcSPS ) { m_pcEntropyDecoderIf->parseSPS(pcSPS); } 146 #endif 145 Void decodeSPS ( TComSPS* pcSPS ) { m_pcEntropyDecoderIf->parseSPS(pcSPS); } 147 146 148 147 #if Q0048_CGS_3D_ASYMLUT 149 148 Void decodePPS ( TComPPS* pcPPS, TCom3DAsymLUT * pc3DAsymLUT, Int nLayerID ) { m_pcEntropyDecoderIf->parsePPS(pcPPS, pc3DAsymLUT , nLayerID ); } 150 149 #else 151 Void decodePPS ( TComPPS* pcPPS ) { m_pcEntropyDecoderIf->parsePPS(pcPPS );}150 Void decodePPS ( TComPPS* pcPPS ) { m_pcEntropyDecoderIf->parsePPS(pcPPS); } 152 151 #endif 153 Void decodeSliceHeader ( TComSlice* & rpcSlice, ParameterSetManagerDecoder *parameterSetManager) { m_pcEntropyDecoderIf->parseSliceHeader(rpcSlice, parameterSetManager); }152 Void decodeSliceHeader ( TComSlice* pcSlice, ParameterSetManagerDecoder *parameterSetManager) { m_pcEntropyDecoderIf->parseSliceHeader(pcSlice, parameterSetManager); } 154 153 155 154 Void decodeTerminatingBit ( UInt& ruiIsLast ) { m_pcEntropyDecoderIf->parseTerminatingBit(ruiIsLast); } 156 155 Void decodeRemainingBytes( Bool noTrailingBytesExpected ) { m_pcEntropyDecoderIf->parseRemainingBytes(noTrailingBytesExpected); } 156 157 157 TDecEntropyIf* getEntropyDecoder() { return m_pcEntropyDecoderIf; } 158 158 159 159 public: 160 160 Void decodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); … … 165 165 Void decodePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 166 166 Void decodePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 167 167 168 168 Void decodeIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 169 169 170 170 Void decodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ); 171 171 172 172 Void decodeIntraDirModeLuma ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 173 173 Void decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 174 174 175 175 Void decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 176 177 Void updateContextTables ( SliceType eSliceType, Int iQp ) { m_pcEntropyDecoderIf->updateContextTables( eSliceType, iQp ); } 178 179 176 Void decodeChromaQpAdjustment( TComDataCU* pcCU, UInt uiAbsPartIdx ); 177 180 178 private: 181 Void xDecodeTransform ( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP, Int getQuadtreeTULog2MinSizeInCU ); 179 180 Void xDecodeTransform ( Bool& bCodeDQP, Bool& isChromaQpAdjCoded, TComTU &rTu, const Int quadtreeTULog2MinSizeInCU ); 182 181 183 182 public: 184 Void decodeCoeff ( TComDataCU* pcCU , UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP ); 185 183 184 Void decodeCoeff ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool& bCodeDQP, Bool& isChromaQpAdjCoded ); 185 186 186 };// END CLASS DEFINITION TDecEntropy 187 187 -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecGop.cpp
r890 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 53 53 //! \ingroup TLibDecoder 54 54 //! \{ 55 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI);55 static Void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI); 56 56 #if Q0074_COLOUR_REMAPPING_SEI 57 57 static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* colourRemappingInfoSEI, UInt layerId=0 ); … … 65 65 { 66 66 m_dDecTime = 0; 67 m_pcSbacDecoders = NULL;68 m_pcBinCABACs = NULL;69 67 } 70 68 71 69 TDecGop::~TDecGop() 72 70 { 73 71 74 72 } 75 73 … … 82 80 Void TDecGop::create() 83 81 { 84 82 85 83 } 86 84 #endif … … 89 87 { 90 88 } 91 #if SVC_EXTENSION 92 Void TDecGop::init(TDecTop** ppcDecTop, 93 TDecEntropy* pcEntropyDecoder, 94 #else 95 Void TDecGop::init( TDecEntropy* pcEntropyDecoder, 96 #endif 97 TDecSbac* pcSbacDecoder, 89 90 #if SVC_EXTENSION 91 Void TDecGop::init( TDecTop** ppcDecTop, 92 TDecEntropy* pcEntropyDecoder, 93 #else 94 Void TDecGop::init( TDecEntropy* pcEntropyDecoder, 95 #endif 96 TDecSbac* pcSbacDecoder, 98 97 TDecBinCABAC* pcBinCABAC, 99 TDecCavlc* pcCavlcDecoder, 100 TDecSlice* pcSliceDecoder, 98 TDecCavlc* pcCavlcDecoder, 99 TDecSlice* pcSliceDecoder, 101 100 TComLoopFilter* pcLoopFilter, 102 101 TComSampleAdaptiveOffset* pcSAO … … 123 122 // ==================================================================================================================== 124 123 125 Void TDecGop::decompressSlice(TComInputBitstream* pcBitstream, TComPic* & rpcPic)126 { 127 TComSlice* pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx());124 Void TDecGop::decompressSlice(TComInputBitstream* pcBitstream, TComPic* pcPic) 125 { 126 TComSlice* pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); 128 127 // Table of extracted substreams. 129 128 // These must be deallocated AND their internal fifos, too. … … 131 130 132 131 //-- For time output for each slice 133 longiBeforeTime = clock();132 clock_t iBeforeTime = clock(); 134 133 m_pcSbacDecoder->init( (TDecBinIf*)m_pcBinCABAC ); 135 134 m_pcEntropyDecoder->setEntropyDecoder (m_pcSbacDecoder); 136 135 137 UInt uiNumSubstreams = pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() ? pcSlice->getNumEntryPointOffsets()+1 : pcSlice->getPPS()->getNumSubstreams(); 136 const UInt uiNumSubstreams = pcSlice->getNumberOfSubstreamSizes()+1; 137 // const UInt uiNumSubstreams = pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() ? pcSlice->getNumberOfSubstreamSizes()+1 : pcSlice->getPPS()->getNumSubstreams(); 138 138 139 139 // init each couple {EntropyDecoder, Substream} 140 UInt *puiSubstreamSizes = pcSlice->getSubstreamSizes();141 140 ppcSubstreams = new TComInputBitstream*[uiNumSubstreams]; 142 m_pcSbacDecoders = new TDecSbac[uiNumSubstreams];143 m_pcBinCABACs = new TDecBinCABAC[uiNumSubstreams];144 141 for ( UInt ui = 0 ; ui < uiNumSubstreams ; ui++ ) 145 142 { 146 m_pcSbacDecoders[ui].init(&m_pcBinCABACs[ui]); 147 ppcSubstreams[ui] = pcBitstream->extractSubstream(ui+1 < uiNumSubstreams ? puiSubstreamSizes[ui] : pcBitstream->getNumBitsLeft()); 148 } 149 150 for ( UInt ui = 0 ; ui+1 < uiNumSubstreams; ui++ ) 151 { 152 m_pcEntropyDecoder->setEntropyDecoder ( &m_pcSbacDecoders[uiNumSubstreams - 1 - ui] ); 153 m_pcEntropyDecoder->setBitstream ( ppcSubstreams [uiNumSubstreams - 1 - ui] ); 154 m_pcEntropyDecoder->resetEntropy (pcSlice); 155 } 156 157 m_pcEntropyDecoder->setEntropyDecoder ( m_pcSbacDecoder ); 158 m_pcEntropyDecoder->setBitstream ( ppcSubstreams[0] ); 159 m_pcEntropyDecoder->resetEntropy (pcSlice); 160 m_pcSbacDecoders[0].load(m_pcSbacDecoder); 161 m_pcSliceDecoder->decompressSlice( ppcSubstreams, rpcPic, m_pcSbacDecoder, m_pcSbacDecoders); 162 m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiNumSubstreams-1] ); 143 ppcSubstreams[ui] = pcBitstream->extractSubstream(ui+1 < uiNumSubstreams ? (pcSlice->getSubstreamSize(ui)<<3) : pcBitstream->getNumBitsLeft()); 144 } 145 146 m_pcSliceDecoder->decompressSlice( ppcSubstreams, pcPic, m_pcSbacDecoder); 163 147 // deallocate all created substreams, including internal buffers. 164 148 for (UInt ui = 0; ui < uiNumSubstreams; ui++) … … 168 152 } 169 153 delete[] ppcSubstreams; 170 delete[] m_pcSbacDecoders; m_pcSbacDecoders = NULL;171 delete[] m_pcBinCABACs; m_pcBinCABACs = NULL;172 154 173 155 m_dDecTime += (Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC; 174 156 } 175 157 176 Void TDecGop::filterPicture(TComPic* & rpcPic)177 { 178 TComSlice* pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx());158 Void TDecGop::filterPicture(TComPic* pcPic) 159 { 160 TComSlice* pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); 179 161 180 162 //-- For time output for each slice 181 longiBeforeTime = clock();163 clock_t iBeforeTime = clock(); 182 164 183 165 // deblocking filter 184 166 Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag(); 185 167 m_pcLoopFilter->setCfg(bLFCrossTileBoundary); 186 m_pcLoopFilter->loopFilterPic( rpcPic ); 168 m_pcLoopFilter->loopFilterPic( pcPic ); 169 187 170 if( pcSlice->getSPS()->getUseSAO() ) 188 171 { 189 m_pcSAO->reconstructBlkSAOParams(rpcPic, rpcPic->getPicSym()->getSAOBlkParam()); 190 m_pcSAO->SAOProcess(rpcPic); 191 m_pcSAO->PCMLFDisableProcess(rpcPic); 192 } 193 rpcPic->compressMotion(); 172 m_pcSAO->reconstructBlkSAOParams(pcPic, pcPic->getPicSym()->getSAOBlkParam()); 173 m_pcSAO->SAOProcess(pcPic); 174 m_pcSAO->PCMLFDisableProcess(pcPic); 175 } 176 177 pcPic->compressMotion(); 194 178 Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B'); 195 179 if (!pcSlice->isReferenced()) c += 32; … … 198 182 #if SVC_EXTENSION 199 183 printf("\nPOC %4d LId: %1d TId: %1d ( %c-SLICE %s, QP%3d ) ", pcSlice->getPOC(), 200 rpcPic->getLayerId(),184 pcPic->getLayerId(), 201 185 pcSlice->getTLayer(), 202 186 c, … … 204 188 pcSlice->getSliceQp() ); 205 189 #else 206 printf("\nPOC %4d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getPOC(), 207 pcSlice->getTLayer(), 208 c, 209 pcSlice->getSliceQp() ); 190 printf("POC %4d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getPOC(), 191 pcSlice->getTLayer(), 192 c, 193 pcSlice->getSliceQp() ); 194 210 195 #endif 211 196 m_dDecTime += (Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC; … … 248 233 if (m_decodedPictureHashSEIEnabled) 249 234 { 250 SEIMessages pictureHashes = getSeisByType( rpcPic->getSEIs(), SEI::DECODED_PICTURE_HASH );235 SEIMessages pictureHashes = getSeisByType(pcPic->getSEIs(), SEI::DECODED_PICTURE_HASH ); 251 236 const SEIDecodedPictureHash *hash = ( pictureHashes.size() > 0 ) ? (SEIDecodedPictureHash*) *(pictureHashes.begin()) : NULL; 252 237 if (pictureHashes.size() > 1) … … 254 239 printf ("Warning: Got multiple decoded picture hash SEI messages. Using first."); 255 240 } 256 calcAndPrintHashStatus(* rpcPic->getPicYuvRec(), hash);241 calcAndPrintHashStatus(*(pcPic->getPicYuvRec()), hash); 257 242 } 258 243 #if Q0074_COLOUR_REMAPPING_SEI 259 244 if (m_colourRemapSEIEnabled) 260 245 { 261 SEIMessages colourRemappingInfo = getSeisByType( rpcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO );246 SEIMessages colourRemappingInfo = getSeisByType(pcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO ); 262 247 const SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL; 263 248 if (colourRemappingInfo.size() > 1) … … 265 250 printf ("Warning: Got multiple Colour Remapping Information SEI messages. Using first."); 266 251 } 267 applyColourRemapping(* rpcPic->getPicYuvRec(), seiColourRemappingInfo268 #if SVC_EXTENSION 269 , rpcPic->getLayerId()252 applyColourRemapping(*pcPic->getPicYuvRec(), seiColourRemappingInfo 253 #if SVC_EXTENSION 254 , pcPic->getLayerId() 270 255 #endif 271 256 ); … … 273 258 #endif 274 259 275 #if SETTING_PIC_OUTPUT_MARK 276 rpcPic->setOutputMark(rpcPic->getSlice(0)->getPicOutputFlag() ? true : false); 277 #else 278 rpcPic->setOutputMark(true); 279 #endif 280 rpcPic->setReconMark(true); 260 printf("\n"); 261 262 pcPic->setOutputMark(pcPic->getSlice(0)->getPicOutputFlag() ? true : false); 263 pcPic->setReconMark(true); 281 264 } 282 265 … … 292 275 * unk - no SEI message was available for comparison 293 276 */ 294 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI)277 static Void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI) 295 278 { 296 279 /* calculate MD5sum for entire reconstructed picture */ 297 UChar recon_digest[3][16];280 TComDigest recon_digest; 298 281 Int numChar=0; 299 282 const Char* hashType = "\0"; … … 303 286 switch (pictureHashSEI->method) 304 287 { 305 case SEIDecodedPictureHash::MD5: 306 { 307 hashType = "MD5"; 308 calcMD5(pic, recon_digest); 309 numChar = 16; 310 break; 311 } 312 case SEIDecodedPictureHash::CRC: 313 { 314 hashType = "CRC"; 315 calcCRC(pic, recon_digest); 316 numChar = 2; 317 break; 318 } 319 case SEIDecodedPictureHash::CHECKSUM: 320 { 321 hashType = "Checksum"; 322 calcChecksum(pic, recon_digest); 323 numChar = 4; 324 break; 325 } 326 default: 327 { 328 assert (!"unknown hash type"); 329 } 288 case SEIDecodedPictureHash::MD5: 289 { 290 hashType = "MD5"; 291 numChar = calcMD5(pic, recon_digest); 292 break; 293 } 294 case SEIDecodedPictureHash::CRC: 295 { 296 hashType = "CRC"; 297 numChar = calcCRC(pic, recon_digest); 298 break; 299 } 300 case SEIDecodedPictureHash::CHECKSUM: 301 { 302 hashType = "Checksum"; 303 numChar = calcChecksum(pic, recon_digest); 304 break; 305 } 306 default: 307 { 308 assert (!"unknown hash type"); 309 break; 310 } 330 311 } 331 312 } … … 338 319 { 339 320 ok = "(OK)"; 340 for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++) 341 { 342 for (UInt i = 0; i < numChar; i++) 343 { 344 if (recon_digest[yuvIdx][i] != pictureHashSEI->digest[yuvIdx][i]) 345 { 346 ok = "(***ERROR***)"; 347 mismatch = true; 348 } 349 } 350 } 351 } 352 353 printf("[%s:%s,%s] ", hashType, digestToString(recon_digest, numChar), ok); 321 if (recon_digest != pictureHashSEI->m_digest) 322 { 323 ok = "(***ERROR***)"; 324 mismatch = true; 325 } 326 } 327 328 printf("[%s:%s,%s] ", hashType, digestToString(recon_digest, numChar).c_str(), ok); 354 329 355 330 if (mismatch) 356 331 { 357 332 g_md5_mismatch = true; 358 printf("[rx%s:%s] ", hashType, digestToString(pictureHashSEI-> digest, numChar));333 printf("[rx%s:%s] ", hashType, digestToString(pictureHashSEI->m_digest, numChar).c_str()); 359 334 } 360 335 } … … 418 393 } 419 394 420 static void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, UInt layerId )395 static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, UInt layerId ) 421 396 { 422 397 if( !storeCriSEI.size() ) … … 432 407 if( !storeCriSEI[layerId].m_colourRemapCancelFlag ) 433 408 { 434 Int iHeight = pic.getHeight( );435 Int iWidth = pic.getWidth( );436 Int iStride = pic.getStride( );437 Int iCStride = pic.get CStride();409 Int iHeight = pic.getHeight(COMPONENT_Y); 410 Int iWidth = pic.getWidth(COMPONENT_Y); 411 Int iStride = pic.getStride(COMPONENT_Y); 412 Int iCStride = pic.getStride(COMPONENT_Cb); 438 413 439 414 Pel *YUVIn[3], *YUVOut[3]; 440 YUVIn[0] = pic.get LumaAddr();441 YUVIn[1] = pic.get CbAddr();442 YUVIn[2] = pic.get CrAddr();415 YUVIn[0] = pic.getAddr(COMPONENT_Y); 416 YUVIn[1] = pic.getAddr(COMPONENT_Cb); 417 YUVIn[2] = pic.getAddr(COMPONENT_Cr); 443 418 444 419 TComPicYuv picColourRemapped; 445 420 #if SVC_EXTENSION 446 #if AUXILIARY_PICTURES 447 picColourRemapped.create( pic.getWidth(), pic.getHeight(), pic.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); 448 #else 449 picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); 450 #endif 451 #else 452 picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 421 picColourRemapped.create( pic.getWidth(COMPONENT_Y), pic.getHeight(COMPONENT_Y), pic.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); 422 #else 423 picColourRemapped.create( pic.getWidth(COMPONENT_Y), pic.getHeight(COMPONENT_Y), pic.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 453 424 #endif 454 YUVOut[0] = picColourRemapped.get LumaAddr();455 YUVOut[1] = picColourRemapped.get CbAddr();456 YUVOut[2] = picColourRemapped.get CrAddr();457 458 #if SVC_EXTENSION 459 Int bitDepthY = g_bitDepth YLayer[layerId];460 Int bitDepthC = g_bitDepth CLayer[layerId];461 462 assert( g_bitDepth Y== bitDepthY );463 assert( g_bitDepth C== bitDepthC );464 #else 465 Int bitDepthY = g_bitDepth Y;466 Int bitDepthC = g_bitDepth C;425 YUVOut[0] = picColourRemapped.getAddr(COMPONENT_Y); 426 YUVOut[1] = picColourRemapped.getAddr(COMPONENT_Cb); 427 YUVOut[2] = picColourRemapped.getAddr(COMPONENT_Cr); 428 429 #if SVC_EXTENSION 430 Int bitDepthY = g_bitDepthLayer[CHANNEL_TYPE_LUMA][layerId]; 431 Int bitDepthC = g_bitDepthLayer[CHANNEL_TYPE_CHROMA][layerId]; 432 433 assert( g_bitDepth[CHANNEL_TYPE_LUMA] == bitDepthY ); 434 assert( g_bitDepth[CHANNEL_TYPE_CHROMA] == bitDepthC ); 435 #else 436 Int bitDepthY = g_bitDepth[CHANNEL_TYPE_LUMA]; 437 Int bitDepthC = g_bitDepth[CHANNEL_TYPE_CHROMA]; 467 438 #endif 468 439 -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecGop.h
r856 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 68 68 private: 69 69 TComList<TComPic*> m_cListPic; // Dynamic buffer 70 70 71 71 // Access channel 72 72 TDecEntropy* m_pcEntropyDecoder; 73 73 TDecSbac* m_pcSbacDecoder; 74 74 TDecBinCABAC* m_pcBinCABAC; 75 TDecSbac* m_pcSbacDecoders; // independant CABAC decoders76 TDecBinCABAC* m_pcBinCABACs;77 75 TDecCavlc* m_pcCavlcDecoder; 78 76 TDecSlice* m_pcSliceDecoder; 79 77 TComLoopFilter* m_pcLoopFilter; 80 78 81 79 TComSampleAdaptiveOffset* m_pcSAO; 82 80 Double m_dDecTime; … … 101 99 TDecSbac* pcSbacDecoder, 102 100 TDecBinCABAC* pcBinCABAC, 103 TDecCavlc* pcCavlcDecoder, 104 TDecSlice* pcSliceDecoder, 101 TDecCavlc* pcCavlcDecoder, 102 TDecSlice* pcSliceDecoder, 105 103 TComLoopFilter* pcLoopFilter, 106 104 TComSampleAdaptiveOffset* pcSAO … … 112 110 #endif 113 111 Void destroy (); 114 Void decompressSlice(TComInputBitstream* pcBitstream, TComPic* & rpcPic );115 Void filterPicture (TComPic* & rpcPic );112 Void decompressSlice(TComInputBitstream* pcBitstream, TComPic* pcPic ); 113 Void filterPicture (TComPic* pcPic ); 116 114 117 void setDecodedPictureHashSEIEnabled(Int enabled) { m_decodedPictureHashSEIEnabled = enabled; }115 Void setDecodedPictureHashSEIEnabled(Int enabled) { m_decodedPictureHashSEIEnabled = enabled; } 118 116 #if Q0074_COLOUR_REMAPPING_SEI 119 117 void setColourRemappingInfoSEIEnabled(Int enabled) { m_colourRemapSEIEnabled = enabled; } -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecSbac.cpp
r644 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 37 37 38 38 #include "TDecSbac.h" 39 #include "TLibCommon/TComTU.h" 40 41 #if RExt__DECODER_DEBUG_BIT_STATISTICS 42 #include "TLibCommon/TComCodingStatistics.h" 43 // 44 #define RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(a) , a 45 #else 46 #define RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(a) 47 #endif 39 48 40 49 //! \ingroup TLibDecoder 41 50 //! \{ 51 52 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 53 #include "../TLibCommon/Debug.h" 54 #endif 55 42 56 43 57 ////////////////////////////////////////////////////////////////////// … … 45 59 ////////////////////////////////////////////////////////////////////// 46 60 47 TDecSbac::TDecSbac() 61 TDecSbac::TDecSbac() 48 62 // new structure here 49 : m_pcBitstream ( 0 ) 50 , m_pcTDecBinIf ( NULL ) 51 , m_numContextModels ( 0 ) 52 , m_cCUSplitFlagSCModel ( 1, 1, NUM_SPLIT_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels ) 53 , m_cCUSkipFlagSCModel ( 1, 1, NUM_SKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 54 , m_cCUMergeFlagExtSCModel ( 1, 1, NUM_MERGE_FLAG_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) 55 , m_cCUMergeIdxExtSCModel ( 1, 1, NUM_MERGE_IDX_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) 56 , m_cCUPartSizeSCModel ( 1, 1, NUM_PART_SIZE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 57 , m_cCUPredModeSCModel ( 1, 1, NUM_PRED_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 58 , m_cCUIntraPredSCModel ( 1, 1, NUM_ADI_CTX , m_contextModels + m_numContextModels, m_numContextModels) 59 , m_cCUChromaPredSCModel ( 1, 1, NUM_CHROMA_PRED_CTX , m_contextModels + m_numContextModels, m_numContextModels) 60 , m_cCUDeltaQpSCModel ( 1, 1, NUM_DELTA_QP_CTX , m_contextModels + m_numContextModels, m_numContextModels) 61 , m_cCUInterDirSCModel ( 1, 1, NUM_INTER_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) 62 , m_cCURefPicSCModel ( 1, 1, NUM_REF_NO_CTX , m_contextModels + m_numContextModels, m_numContextModels) 63 , m_cCUMvdSCModel ( 1, 1, NUM_MV_RES_CTX , m_contextModels + m_numContextModels, m_numContextModels) 64 , m_cCUQtCbfSCModel ( 1, 2, NUM_QT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) 65 , m_cCUTransSubdivFlagSCModel ( 1, 1, NUM_TRANS_SUBDIV_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 66 , m_cCUQtRootCbfSCModel ( 1, 1, NUM_QT_ROOT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) 67 , m_cCUSigCoeffGroupSCModel ( 1, 2, NUM_SIG_CG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 68 , m_cCUSigSCModel ( 1, 1, NUM_SIG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 69 , m_cCuCtxLastX ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) 70 , m_cCuCtxLastY ( 1, 2, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) 71 , m_cCUOneSCModel ( 1, 1, NUM_ONE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 72 , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 73 , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 74 , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 75 , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 76 , m_cTransformSkipSCModel ( 1, 2, NUM_TRANSFORMSKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 77 , m_CUTransquantBypassFlagSCModel( 1, 1, NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels) 63 : m_pcBitstream ( 0 ) 64 , m_pcTDecBinIf ( NULL ) 65 , m_numContextModels ( 0 ) 66 , m_cCUSplitFlagSCModel ( 1, 1, NUM_SPLIT_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 67 , m_cCUSkipFlagSCModel ( 1, 1, NUM_SKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 68 , m_cCUMergeFlagExtSCModel ( 1, 1, NUM_MERGE_FLAG_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) 69 , m_cCUMergeIdxExtSCModel ( 1, 1, NUM_MERGE_IDX_EXT_CTX , m_contextModels + m_numContextModels, m_numContextModels) 70 , m_cCUPartSizeSCModel ( 1, 1, NUM_PART_SIZE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 71 , m_cCUPredModeSCModel ( 1, 1, NUM_PRED_MODE_CTX , m_contextModels + m_numContextModels, m_numContextModels) 72 , m_cCUIntraPredSCModel ( 1, 1, NUM_ADI_CTX , m_contextModels + m_numContextModels, m_numContextModels) 73 , m_cCUChromaPredSCModel ( 1, 1, NUM_CHROMA_PRED_CTX , m_contextModels + m_numContextModels, m_numContextModels) 74 , m_cCUDeltaQpSCModel ( 1, 1, NUM_DELTA_QP_CTX , m_contextModels + m_numContextModels, m_numContextModels) 75 , m_cCUInterDirSCModel ( 1, 1, NUM_INTER_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) 76 , m_cCURefPicSCModel ( 1, 1, NUM_REF_NO_CTX , m_contextModels + m_numContextModels, m_numContextModels) 77 , m_cCUMvdSCModel ( 1, 1, NUM_MV_RES_CTX , m_contextModels + m_numContextModels, m_numContextModels) 78 , m_cCUQtCbfSCModel ( 1, NUM_QT_CBF_CTX_SETS, NUM_QT_CBF_CTX_PER_SET , m_contextModels + m_numContextModels, m_numContextModels) 79 , m_cCUTransSubdivFlagSCModel ( 1, 1, NUM_TRANS_SUBDIV_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 80 , m_cCUQtRootCbfSCModel ( 1, 1, NUM_QT_ROOT_CBF_CTX , m_contextModels + m_numContextModels, m_numContextModels) 81 , m_cCUSigCoeffGroupSCModel ( 1, 2, NUM_SIG_CG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 82 , m_cCUSigSCModel ( 1, 1, NUM_SIG_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 83 , m_cCuCtxLastX ( 1, NUM_CTX_LAST_FLAG_SETS, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) 84 , m_cCuCtxLastY ( 1, NUM_CTX_LAST_FLAG_SETS, NUM_CTX_LAST_FLAG_XY , m_contextModels + m_numContextModels, m_numContextModels) 85 , m_cCUOneSCModel ( 1, 1, NUM_ONE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 86 , m_cCUAbsSCModel ( 1, 1, NUM_ABS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 87 , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 88 , m_cSaoMergeSCModel ( 1, 1, NUM_SAO_MERGE_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 89 , m_cSaoTypeIdxSCModel ( 1, 1, NUM_SAO_TYPE_IDX_CTX , m_contextModels + m_numContextModels, m_numContextModels) 90 , m_cTransformSkipSCModel ( 1, MAX_NUM_CHANNEL_TYPE, NUM_TRANSFORMSKIP_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 91 , m_CUTransquantBypassFlagSCModel ( 1, 1, NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 92 , m_explicitRdpcmFlagSCModel ( 1, MAX_NUM_CHANNEL_TYPE, NUM_EXPLICIT_RDPCM_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 93 , m_explicitRdpcmDirSCModel ( 1, MAX_NUM_CHANNEL_TYPE, NUM_EXPLICIT_RDPCM_DIR_CTX , m_contextModels + m_numContextModels, m_numContextModels) 94 , m_cCrossComponentPredictionSCModel ( 1, 1, NUM_CROSS_COMPONENT_PREDICTION_CTX , m_contextModels + m_numContextModels, m_numContextModels) 95 , m_ChromaQpAdjFlagSCModel ( 1, 1, NUM_CHROMA_QP_ADJ_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 96 , m_ChromaQpAdjIdcSCModel ( 1, 1, NUM_CHROMA_QP_ADJ_IDC_CTX , m_contextModels + m_numContextModels, m_numContextModels) 78 97 { 79 98 assert( m_numContextModels <= MAX_NUM_CTX_MOD ); … … 98 117 { 99 118 case P_SLICE: // change initialization table to B_SLICE initialization 100 sliceType = B_SLICE; 119 sliceType = B_SLICE; 101 120 break; 102 121 case B_SLICE: // change initialization table to P_SLICE initialization 103 sliceType = P_SLICE; 122 sliceType = P_SLICE; 104 123 break; 105 124 default : // should not occur 106 125 assert(0); 107 } 108 } 109 110 m_cCUSplitFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG ); 111 m_cCUSkipFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SKIP_FLAG ); 112 m_cCUMergeFlagExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT ); 113 m_cCUMergeIdxExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT ); 114 m_cCUPartSizeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PART_SIZE ); 115 m_cCUPredModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PRED_MODE ); 116 m_cCUIntraPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); 117 m_cCUChromaPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_PRED_MODE ); 118 m_cCUInterDirSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_DIR ); 119 m_cCUMvdSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVD ); 120 m_cCURefPicSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_REF_PIC ); 121 m_cCUDeltaQpSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DQP ); 122 m_cCUQtCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_CBF ); 123 m_cCUQtRootCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_ROOT_CBF ); 124 m_cCUSigCoeffGroupSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_CG_FLAG ); 125 m_cCUSigSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_FLAG ); 126 m_cCuCtxLastX.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); 127 m_cCuCtxLastY.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); 128 m_cCUOneSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ONE_FLAG ); 129 m_cCUAbsSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ABS_FLAG ); 130 m_cMVPIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVP_IDX ); 131 m_cSaoMergeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG ); 132 m_cSaoTypeIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); 133 134 m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); 135 m_cTransformSkipSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); 136 m_CUTransquantBypassFlagSCModel.initBuffer( sliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); 137 m_uiLastDQpNonZero = 0; 138 139 // new structure 140 m_uiLastQp = qp; 141 126 break; 127 } 128 } 129 130 m_cCUSplitFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG ); 131 m_cCUSkipFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SKIP_FLAG ); 132 m_cCUMergeFlagExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT ); 133 m_cCUMergeIdxExtSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT ); 134 m_cCUPartSizeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PART_SIZE ); 135 m_cCUPredModeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_PRED_MODE ); 136 m_cCUIntraPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTRA_PRED_MODE ); 137 m_cCUChromaPredSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_PRED_MODE ); 138 m_cCUInterDirSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_DIR ); 139 m_cCUMvdSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVD ); 140 m_cCURefPicSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_REF_PIC ); 141 m_cCUDeltaQpSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_DQP ); 142 m_cCUQtCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_CBF ); 143 m_cCUQtRootCbfSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_QT_ROOT_CBF ); 144 m_cCUSigCoeffGroupSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_CG_FLAG ); 145 m_cCUSigSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SIG_FLAG ); 146 m_cCuCtxLastX.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); 147 m_cCuCtxLastY.initBuffer ( sliceType, qp, (UChar*)INIT_LAST ); 148 m_cCUOneSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ONE_FLAG ); 149 m_cCUAbsSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_ABS_FLAG ); 150 m_cMVPIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_MVP_IDX ); 151 m_cSaoMergeSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG ); 152 m_cSaoTypeIdxSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX ); 153 m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG ); 154 m_cTransformSkipSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG ); 155 m_CUTransquantBypassFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG ); 156 m_explicitRdpcmFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_EXPLICIT_RDPCM_FLAG); 157 m_explicitRdpcmDirSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_EXPLICIT_RDPCM_DIR); 158 m_cCrossComponentPredictionSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CROSS_COMPONENT_PREDICTION ); 159 m_ChromaQpAdjFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_QP_ADJ_FLAG ); 160 m_ChromaQpAdjIdcSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_CHROMA_QP_ADJ_IDC ); 161 162 for (UInt statisticIndex = 0; statisticIndex < RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS ; statisticIndex++) 163 { 164 m_golombRiceAdaptationStatistics[statisticIndex] = 0; 165 } 166 142 167 m_pcTDecBinIf->start(); 143 168 } 144 169 145 /** The function does the following: Read out terminate bit. Flush CABAC. Byte-align for next tile.146 * Intialize CABAC states. Start CABAC.147 */148 Void TDecSbac::updateContextTables( SliceType eSliceType, Int iQp )149 {150 UInt uiBit;151 m_pcTDecBinIf->decodeBinTrm(uiBit);152 assert(uiBit); // end_of_sub_stream_one_bit must be equal to 1153 m_pcTDecBinIf->finish();154 m_pcBitstream->readOutTrailingBits();155 m_cCUSplitFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG );156 m_cCUSkipFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG );157 m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT );158 m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT );159 m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );160 m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_PRED_MODE );161 m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTRA_PRED_MODE );162 m_cCUChromaPredSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_CHROMA_PRED_MODE );163 m_cCUInterDirSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_DIR );164 m_cCUMvdSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVD );165 m_cCURefPicSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_REF_PIC );166 m_cCUDeltaQpSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DQP );167 m_cCUQtCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_CBF );168 m_cCUQtRootCbfSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_QT_ROOT_CBF );169 m_cCUSigCoeffGroupSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_CG_FLAG );170 m_cCUSigSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SIG_FLAG );171 m_cCuCtxLastX.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST );172 m_cCuCtxLastY.initBuffer ( eSliceType, iQp, (UChar*)INIT_LAST );173 m_cCUOneSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ONE_FLAG );174 m_cCUAbsSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_ABS_FLAG );175 m_cMVPIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_MVP_IDX );176 m_cSaoMergeSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG );177 m_cSaoTypeIdxSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );178 m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG );179 m_cTransformSkipSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG );180 m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG );181 m_pcTDecBinIf->start();182 }183 184 170 Void TDecSbac::parseTerminatingBit( UInt& ruiBit ) 185 171 { 186 172 m_pcTDecBinIf->decodeBinTrm( ruiBit ); 187 if ( ruiBit )173 if ( ruiBit == 1 ) 188 174 { 189 175 m_pcTDecBinIf->finish(); 190 } 191 } 192 193 176 177 #if RExt__DECODER_DEBUG_BIT_STATISTICS 178 TComCodingStatistics::IncrementStatisticEP(STATS__TRAILING_BITS, m_pcBitstream->readOutTrailingBits(),0); 179 #else 180 m_pcBitstream->readOutTrailingBits(); 181 #endif 182 } 183 } 184 185 Void TDecSbac::parseRemainingBytes( Bool noTrailingBytesExpected ) 186 { 187 if (noTrailingBytesExpected) 188 { 189 const UInt numberOfRemainingSubstreamBytes=m_pcBitstream->getNumBitsLeft(); 190 assert (numberOfRemainingSubstreamBytes == 0); 191 } 192 else 193 { 194 while (m_pcBitstream->getNumBitsLeft()) 195 { 196 UInt trailingNullByte=m_pcBitstream->readByte(); 197 if (trailingNullByte!=0) 198 { 199 printf("Trailing byte should be 0, but has value %02x\n", trailingNullByte); 200 assert(trailingNullByte==0); 201 } 202 } 203 } 204 } 205 206 #if RExt__DECODER_DEBUG_BIT_STATISTICS 207 Void TDecSbac::xReadUnaryMaxSymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol, const class TComCodingStatisticsClassType &whichStat ) 208 #else 194 209 Void TDecSbac::xReadUnaryMaxSymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol ) 210 #endif 195 211 { 196 212 if (uiMaxSymbol == 0) … … 199 215 return; 200 216 } 201 202 m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] );203 217 218 m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); 219 204 220 if( ruiSymbol == 0 || uiMaxSymbol == 1 ) 205 221 { 206 222 return; 207 223 } 208 224 209 225 UInt uiSymbol = 0; 210 226 UInt uiCont; 211 227 212 228 do 213 229 { 214 m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] );230 m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); 215 231 uiSymbol++; 216 232 } 217 233 while( uiCont && ( uiSymbol < uiMaxSymbol - 1 ) ); 218 234 219 235 if( uiCont && ( uiSymbol == uiMaxSymbol - 1 ) ) 220 236 { 221 237 uiSymbol++; 222 238 } 223 239 224 240 ruiSymbol = uiSymbol; 225 241 } 226 242 243 #if RExt__DECODER_DEBUG_BIT_STATISTICS 244 Void TDecSbac::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount, const class TComCodingStatisticsClassType &whichStat ) 245 #else 227 246 Void TDecSbac::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount ) 247 #endif 228 248 { 229 249 UInt uiSymbol = 0; 230 250 UInt uiBit = 1; 231 251 232 252 while( uiBit ) 233 253 { 234 m_pcTDecBinIf->decodeBinEP( uiBit );254 m_pcTDecBinIf->decodeBinEP( uiBit RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); 235 255 uiSymbol += uiBit << uiCount++; 236 256 } 237 257 238 258 if ( --uiCount ) 239 259 { 240 260 UInt bins; 241 m_pcTDecBinIf->decodeBinsEP( bins, uiCount );261 m_pcTDecBinIf->decodeBinsEP( bins, uiCount RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); 242 262 uiSymbol += bins; 243 263 } 244 264 245 265 ruiSymbol = uiSymbol; 246 266 } 247 267 268 #if RExt__DECODER_DEBUG_BIT_STATISTICS 269 Void TDecSbac::xReadUnarySymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, const class TComCodingStatisticsClassType &whichStat ) 270 #else 248 271 Void TDecSbac::xReadUnarySymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset ) 249 { 250 m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); 251 272 #endif 273 { 274 m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); 275 252 276 if( !ruiSymbol ) 253 277 { 254 278 return; 255 279 } 256 280 257 281 UInt uiSymbol = 0; 258 282 UInt uiCont; 259 283 260 284 do 261 285 { 262 m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] );286 m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); 263 287 uiSymbol++; 264 288 } 265 289 while( uiCont ); 266 290 267 291 ruiSymbol = uiSymbol; 268 292 } … … 274 298 * \returns Void 275 299 */ 276 Void TDecSbac::xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam ) 277 { 278 300 #if RExt__DECODER_DEBUG_BIT_STATISTICS 301 Void TDecSbac::xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam, const Bool useLimitedPrefixLength, const ChannelType channelType, const class TComCodingStatisticsClassType &whichStat ) 302 #else 303 Void TDecSbac::xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam, const Bool useLimitedPrefixLength, const ChannelType channelType ) 304 #endif 305 { 279 306 UInt prefix = 0; 280 307 UInt codeWord = 0; 281 do 282 { 283 prefix++; 284 m_pcTDecBinIf->decodeBinEP( codeWord ); 285 } 286 while( codeWord); 308 309 if (useLimitedPrefixLength) 310 { 311 const UInt longestPossiblePrefix = (32 - (COEF_REMAIN_BIN_REDUCTION + g_maxTrDynamicRange[channelType])) + COEF_REMAIN_BIN_REDUCTION; 312 313 do 314 { 315 prefix++; 316 m_pcTDecBinIf->decodeBinEP( codeWord RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); 317 } 318 while((codeWord != 0) && (prefix < longestPossiblePrefix)); 319 } 320 else 321 { 322 do 323 { 324 prefix++; 325 m_pcTDecBinIf->decodeBinEP( codeWord RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat) ); 326 } 327 while( codeWord); 328 } 329 287 330 codeWord = 1 - codeWord; 288 331 prefix -= codeWord; 289 332 codeWord=0; 333 290 334 if (prefix < COEF_REMAIN_BIN_REDUCTION ) 291 335 { 292 m_pcTDecBinIf->decodeBinsEP(codeWord,rParam );336 m_pcTDecBinIf->decodeBinsEP(codeWord,rParam RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); 293 337 rSymbol = (prefix<<rParam) + codeWord; 294 338 } 339 else if (useLimitedPrefixLength) 340 { 341 const UInt maximumPrefixLength = (32 - (COEF_REMAIN_BIN_REDUCTION + g_maxTrDynamicRange[channelType])); 342 343 const UInt prefixLength = prefix - COEF_REMAIN_BIN_REDUCTION; 344 const UInt suffixLength = (prefixLength == maximumPrefixLength) ? (g_maxTrDynamicRange[channelType] - rParam) : prefixLength; 345 346 m_pcTDecBinIf->decodeBinsEP(codeWord, (suffixLength + rParam) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); 347 348 rSymbol = codeWord + ((((1 << prefixLength) - 1) + COEF_REMAIN_BIN_REDUCTION) << rParam); 349 } 295 350 else 296 351 { 297 m_pcTDecBinIf->decodeBinsEP(codeWord,prefix-COEF_REMAIN_BIN_REDUCTION+rParam );352 m_pcTDecBinIf->decodeBinsEP(codeWord,prefix-COEF_REMAIN_BIN_REDUCTION+rParam RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(whichStat)); 298 353 rSymbol = (((1<<(prefix-COEF_REMAIN_BIN_REDUCTION))+COEF_REMAIN_BIN_REDUCTION-1)<<rParam)+codeWord; 299 354 } 300 355 } 301 356 302 /** Parse I_PCM information. 357 358 /** Parse I_PCM information. 303 359 * \param pcCU 304 * \param uiAbsPartIdx 360 * \param uiAbsPartIdx 305 361 * \param uiDepth 306 362 * \returns Void 307 363 * 308 * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. 364 * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. 309 365 */ 310 366 Void TDecSbac::parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) … … 312 368 UInt uiSymbol; 313 369 314 315 316 if (uiSymbol)317 370 m_pcTDecBinIf->decodeBinTrm(uiSymbol); 371 372 if (uiSymbol == 1) 373 { 318 374 Bool bIpcmFlag = true; 319 375 … … 323 379 pcCU->setIPCMFlagSubParts ( bIpcmFlag, uiAbsPartIdx, uiDepth ); 324 380 325 UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); 326 UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; 327 UInt uiChromaOffset = uiLumaOffset>>2; 328 329 Pel* piPCMSample; 330 UInt uiWidth; 331 UInt uiHeight; 332 UInt uiSampleBits; 333 UInt uiX, uiY; 334 335 piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset; 336 uiWidth = pcCU->getWidth(uiAbsPartIdx); 337 uiHeight = pcCU->getHeight(uiAbsPartIdx); 338 uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); 339 340 for(uiY = 0; uiY < uiHeight; uiY++) 341 { 342 for(uiX = 0; uiX < uiWidth; uiX++) 343 { 344 UInt uiSample; 345 m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); 346 piPCMSample[uiX] = uiSample; 347 } 348 piPCMSample += uiWidth; 349 } 350 351 piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset; 352 uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; 353 uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; 354 uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); 355 #if AUXILIARY_PICTURES 356 ChromaFormat format = pcCU->getSlice()->getChromaFormatIdc(); 357 UInt uiGrayVal = 1 << (uiSampleBits - 1); 358 #endif 359 360 for(uiY = 0; uiY < uiHeight; uiY++) 361 { 362 for(uiX = 0; uiX < uiWidth; uiX++) 363 { 364 UInt uiSample; 365 #if AUXILIARY_PICTURES 366 if (format == CHROMA_400) 381 const UInt minCoeffSizeY = pcCU->getPic()->getMinCUWidth() * pcCU->getPic()->getMinCUHeight(); 382 const UInt offsetY = minCoeffSizeY * uiAbsPartIdx; 383 for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++) 384 { 385 const ComponentID compID = ComponentID(ch); 386 const UInt offset = offsetY >> (pcCU->getPic()->getComponentScaleX(compID) + pcCU->getPic()->getComponentScaleY(compID)); 387 Pel * pPCMSample = pcCU->getPCMSample(compID) + offset; 388 const UInt width = pcCU->getWidth (uiAbsPartIdx) >> pcCU->getPic()->getComponentScaleX(compID); 389 const UInt height = pcCU->getHeight(uiAbsPartIdx) >> pcCU->getPic()->getComponentScaleY(compID); 390 const UInt sampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID)); 391 for (UInt y=0; y<height; y++) 392 { 393 for (UInt x=0; x<width; x++) 367 394 { 368 uiSample = uiGrayVal; 395 UInt sample; 396 m_pcTDecBinIf->xReadPCMCode(sampleBits, sample); 397 pPCMSample[x] = sample; 369 398 } 370 else 371 #endif 372 m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); 373 piPCMSample[uiX] = uiSample; 374 } 375 piPCMSample += uiWidth; 376 } 377 378 piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset; 379 uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; 380 uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; 381 uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); 382 383 for(uiY = 0; uiY < uiHeight; uiY++) 384 { 385 for(uiX = 0; uiX < uiWidth; uiX++) 386 { 387 UInt uiSample; 388 #if AUXILIARY_PICTURES 389 if (format == CHROMA_400) 390 { 391 uiSample = uiGrayVal; 392 } 393 else 394 #endif 395 m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample); 396 piPCMSample[uiX] = uiSample; 397 } 398 piPCMSample += uiWidth; 399 pPCMSample += width; 400 } 399 401 } 400 402 … … 406 408 { 407 409 UInt uiSymbol; 408 m_pcTDecBinIf->decodeBin( uiSymbol, m_CUTransquantBypassFlagSCModel.get( 0, 0, 0 ) );410 m_pcTDecBinIf->decodeBin( uiSymbol, m_CUTransquantBypassFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__TQ_BYPASS_FLAG) ); 409 411 pcCU->setCUTransquantBypassSubParts(uiSymbol ? true : false, uiAbsPartIdx, uiDepth); 410 412 } … … 412 414 /** parse skip flag 413 415 * \param pcCU 414 * \param uiAbsPartIdx 416 * \param uiAbsPartIdx 415 417 * \param uiDepth 416 418 * \returns Void … … 422 424 return; 423 425 } 424 426 425 427 UInt uiSymbol = 0; 426 428 UInt uiCtxSkip = pcCU->getCtxSkipFlag( uiAbsPartIdx ); 427 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) );429 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SKIP_FLAG) ); 428 430 DTRACE_CABAC_VL( g_nSymbolCounter++ ); 429 431 DTRACE_CABAC_T( "\tSkipFlag" ); … … 433 435 DTRACE_CABAC_V( uiSymbol ); 434 436 DTRACE_CABAC_T( "\n"); 435 437 436 438 if( uiSymbol ) 437 439 { … … 444 446 } 445 447 448 446 449 /** parse merge flag 447 450 * \param pcCU 448 * \param uiAbsPartIdx 451 * \param uiAbsPartIdx 449 452 * \param uiDepth 450 453 * \param uiPUIdx … … 454 457 { 455 458 UInt uiSymbol; 456 m_pcTDecBinIf->decodeBin( uiSymbol, *m_cCUMergeFlagExtSCModel.get( 0 ) );459 m_pcTDecBinIf->decodeBin( uiSymbol, *m_cCUMergeFlagExtSCModel.get( 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MERGE_FLAG) ); 457 460 pcCU->setMergeFlagSubParts( uiSymbol ? true : false, uiAbsPartIdx, uiPUIdx, uiDepth ); 458 461 … … 461 464 DTRACE_CABAC_V( uiSymbol ); 462 465 DTRACE_CABAC_T( "\tAddress: " ); 463 DTRACE_CABAC_V( pcCU->get Addr() );466 DTRACE_CABAC_V( pcCU->getCtuRsAddr() ); 464 467 DTRACE_CABAC_T( "\tuiAbsPartIdx: " ); 465 468 DTRACE_CABAC_V( uiAbsPartIdx ); … … 478 481 if ( uiUnaryIdx==0 ) 479 482 { 480 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, 0 ) );483 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MERGE_INDEX) ); 481 484 } 482 485 else 483 486 { 484 m_pcTDecBinIf->decodeBinEP( uiSymbol );487 m_pcTDecBinIf->decodeBinEP( uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MERGE_INDEX) ); 485 488 } 486 489 if( uiSymbol == 0 ) … … 502 505 { 503 506 UInt uiSymbol; 504 xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, AMVP_MAX_NUM_CANDS-1 );507 xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, AMVP_MAX_NUM_CANDS-1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVP_IDX) ); 505 508 riMVPIdx = uiSymbol; 506 509 } … … 513 516 return; 514 517 } 515 518 #if RExt__DECODER_DEBUG_BIT_STATISTICS 519 const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__SPLIT_FLAG, g_aucConvertToBit[g_uiMaxCUWidth>>uiDepth]+2); 520 #endif 521 516 522 UInt uiSymbol; 517 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) );523 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 518 524 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 519 525 DTRACE_CABAC_T( "\tSplitFlag\n" ) 520 526 pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx ); 521 527 522 528 return; 523 529 } … … 525 531 /** parse partition size 526 532 * \param pcCU 527 * \param uiAbsPartIdx 533 * \param uiAbsPartIdx 528 534 * \param uiDepth 529 535 * \returns Void … … 534 540 PartSize eMode; 535 541 542 #if RExt__DECODER_DEBUG_BIT_STATISTICS 543 const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__PART_SIZE, g_aucConvertToBit[g_uiMaxCUWidth>>uiDepth]+2); 544 #endif 545 536 546 if ( pcCU->isIntra( uiAbsPartIdx ) ) 537 547 { … … 539 549 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) 540 550 { 541 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) );551 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 542 552 } 543 553 eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN; 544 UInt uiTrLevel = 0; 554 UInt uiTrLevel = 0; 545 555 UInt uiWidthInBit = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2; 546 556 UInt uiTrSizeInBit = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxTrSize()]+2; … … 558 568 { 559 569 UInt uiMaxNumBits = 2; 570 560 571 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) ) 561 572 { 562 573 uiMaxNumBits ++; 563 574 } 575 564 576 for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) 565 577 { 566 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) );578 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 567 579 if ( uiSymbol ) 568 580 { … … 576 588 if (eMode == SIZE_2NxN) 577 589 { 578 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 ) );590 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype)); 579 591 if (uiSymbol == 0) 580 592 { 581 m_pcTDecBinIf->decodeBinEP(uiSymbol );593 m_pcTDecBinIf->decodeBinEP(uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 582 594 eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD); 583 595 } … … 585 597 else if (eMode == SIZE_Nx2N) 586 598 { 587 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 ) );599 m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 588 600 if (uiSymbol == 0) 589 601 { 590 m_pcTDecBinIf->decodeBinEP(uiSymbol );602 m_pcTDecBinIf->decodeBinEP(uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 591 603 eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N); 592 604 } … … 598 610 } 599 611 612 600 613 /** parse prediction mode 601 614 * \param pcCU 602 * \param uiAbsPartIdx 615 * \param uiAbsPartIdx 603 616 * \param uiDepth 604 617 * \returns Void … … 611 624 return; 612 625 } 613 626 614 627 UInt uiSymbol; 615 628 Int iPredMode = MODE_INTER; 616 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) );629 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__PRED_MODE) ); 617 630 iPredMode += uiSymbol; 618 631 pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth ); 619 632 } 620 633 634 621 635 Void TDecSbac::parseIntraDirLumaAng ( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) 622 636 { 623 637 PartSize mode = pcCU->getPartitionSize( absPartIdx ); 624 638 UInt partNum = mode==SIZE_NxN?4:1; 625 UInt partOffset = ( pcCU->getPic()->getNumPart InCU() >> ( pcCU->getDepth(absPartIdx) << 1 ) ) >> 2;639 UInt partOffset = ( pcCU->getPic()->getNumPartitionsInCtu() >> ( pcCU->getDepth(absPartIdx) << 1 ) ) >> 2; 626 640 UInt mpmPred[4],symbol; 627 Int j,intraPredMode; 641 Int j,intraPredMode; 628 642 if (mode==SIZE_NxN) 629 643 { 630 644 depth++; 631 645 } 646 #if RExt__DECODER_DEBUG_BIT_STATISTICS 647 const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__INTRA_DIR_ANG, g_aucConvertToBit[g_uiMaxCUWidth>>depth]+2, CHANNEL_TYPE_LUMA); 648 #endif 632 649 for (j=0;j<partNum;j++) 633 650 { 634 m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) );651 m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 635 652 mpmPred[j] = symbol; 636 653 } 637 654 for (j=0;j<partNum;j++) 638 655 { 639 Int preds[ 3] = {-1, -1, -1};640 Int predNum = pcCU->getIntraDir LumaPredictor(absPartIdx+partOffset*j, preds);656 Int preds[NUM_MOST_PROBABLE_MODES] = {-1, -1, -1}; 657 Int predNum = pcCU->getIntraDirPredictor(absPartIdx+partOffset*j, preds, COMPONENT_Y); 641 658 if (mpmPred[j]) 642 659 { 643 m_pcTDecBinIf->decodeBinEP( symbol );660 m_pcTDecBinIf->decodeBinEP( symbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 644 661 if (symbol) 645 662 { 646 m_pcTDecBinIf->decodeBinEP( symbol );663 m_pcTDecBinIf->decodeBinEP( symbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 647 664 symbol++; 648 665 } … … 651 668 else 652 669 { 653 m_pcTDecBinIf->decodeBinsEP( symbol, 5 );670 m_pcTDecBinIf->decodeBinsEP( symbol, 5 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 654 671 intraPredMode = symbol; 655 672 656 673 //postponed sorting of MPMs (only in remaining branch) 674 assert(predNum>=3); // It is currently always 3! 657 675 if (preds[0] > preds[1]) 658 { 659 std::swap(preds[0], preds[1]); 676 { 677 std::swap(preds[0], preds[1]); 660 678 } 661 679 if (preds[0] > preds[2]) … … 672 690 } 673 691 } 674 pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, absPartIdx+partOffset*j, depth ); 675 } 676 } 692 pcCU->setIntraDirSubParts(CHANNEL_TYPE_LUMA, (UChar)intraPredMode, absPartIdx+partOffset*j, depth ); 693 } 694 } 695 677 696 678 697 Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 679 698 { 680 699 UInt uiSymbol; 681 682 #if AUXILIARY_PICTURES 683 if ( pcCU->getSlice()->getChromaFormatIdc() == CHROMA_400 ) 684 { 685 uiSymbol = DC_IDX; 700 #if RExt__DECODER_DEBUG_BIT_STATISTICS 701 const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__INTRA_DIR_ANG, g_aucConvertToBit[g_uiMaxCUWidth>>uiDepth]+2, CHANNEL_TYPE_CHROMA); 702 #endif 703 704 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 705 if( uiSymbol == 0 ) 706 { 707 uiSymbol = DM_CHROMA_IDX; 686 708 } 687 709 else 688 710 { 689 #endif 690 m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) ); 691 692 if( uiSymbol == 0 ) 693 { 694 uiSymbol = DM_CHROMA_IDX; 695 } 696 else 697 { 698 { 699 UInt uiIPredMode; 700 m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 ); 701 UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ]; 702 pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir ); 703 uiSymbol = uiAllowedChromaDir[ uiIPredMode ]; 704 } 705 } 706 #if AUXILIARY_PICTURES 707 } 708 #endif 709 pcCU->setChromIntraDirSubParts( uiSymbol, uiAbsPartIdx, uiDepth ); 710 return; 711 } 711 UInt uiIPredMode; 712 m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 713 UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ]; 714 pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir ); 715 uiSymbol = uiAllowedChromaDir[ uiIPredMode ]; 716 } 717 718 pcCU->setIntraDirSubParts( CHANNEL_TYPE_CHROMA, uiSymbol, uiAbsPartIdx, uiDepth ); 719 } 720 712 721 713 722 Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx ) … … 716 725 const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx ); 717 726 ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 ); 727 718 728 uiSymbol = 0; 719 729 if (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N || pcCU->getHeight(uiAbsPartIdx) != 8 ) 720 730 { 721 m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) );731 m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__INTER_DIR) ); 722 732 } 723 733 … … 728 738 else 729 739 { 730 m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + 4 ) );740 m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + 4 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__INTER_DIR) ); 731 741 assert(uiSymbol == 0 || uiSymbol == 1); 732 742 } … … 740 750 { 741 751 UInt uiSymbol; 742 { 743 ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); 744 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); 745 746 if( uiSymbol ) 747 { 748 UInt uiRefNum = pcCU->getSlice()->getNumRefIdx( eRefList ) - 2; 749 pCtx++; 750 UInt ui; 751 for( ui = 0; ui < uiRefNum; ++ui ) 752 { 753 if( ui == 0 ) 754 { 755 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx ); 756 } 757 else 758 { 759 m_pcTDecBinIf->decodeBinEP( uiSymbol ); 760 } 761 if( uiSymbol == 0 ) 762 { 763 break; 764 } 765 } 766 uiSymbol = ui + 1; 767 } 768 riRefFrmIdx = uiSymbol; 769 } 752 753 ContextModel *pCtx = m_cCURefPicSCModel.get( 0 ); 754 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__REF_FRM_IDX) ); 755 756 if( uiSymbol ) 757 { 758 UInt uiRefNum = pcCU->getSlice()->getNumRefIdx( eRefList ) - 2; 759 pCtx++; 760 UInt ui; 761 for( ui = 0; ui < uiRefNum; ++ui ) 762 { 763 if( ui == 0 ) 764 { 765 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__REF_FRM_IDX) ); 766 } 767 else 768 { 769 m_pcTDecBinIf->decodeBinEP( uiSymbol RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__REF_FRM_IDX) ); 770 } 771 if( uiSymbol == 0 ) 772 { 773 break; 774 } 775 } 776 uiSymbol = ui + 1; 777 } 778 riRefFrmIdx = uiSymbol; 770 779 771 780 return; … … 788 797 else 789 798 { 790 m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx );791 m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx );799 m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD) ); 800 m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD) ); 792 801 793 802 const Bool bHorAbsGr0 = uiHorAbs != 0; … … 797 806 if( bHorAbsGr0 ) 798 807 { 799 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx );808 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD) ); 800 809 uiHorAbs += uiSymbol; 801 810 } … … 803 812 if( bVerAbsGr0 ) 804 813 { 805 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx );814 m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD) ); 806 815 uiVerAbs += uiSymbol; 807 816 } … … 811 820 if( 2 == uiHorAbs ) 812 821 { 813 xReadEpExGolomb( uiSymbol, 1 );822 xReadEpExGolomb( uiSymbol, 1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD_EP) ); 814 823 uiHorAbs += uiSymbol; 815 824 } 816 825 817 m_pcTDecBinIf->decodeBinEP( uiHorSign );826 m_pcTDecBinIf->decodeBinEP( uiHorSign RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD_EP) ); 818 827 } 819 828 … … 822 831 if( 2 == uiVerAbs ) 823 832 { 824 xReadEpExGolomb( uiSymbol, 1 );833 xReadEpExGolomb( uiSymbol, 1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD_EP) ); 825 834 uiVerAbs += uiSymbol; 826 835 } 827 836 828 m_pcTDecBinIf->decodeBinEP( uiVerSign );837 m_pcTDecBinIf->decodeBinEP( uiVerSign RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__MVD_EP) ); 829 838 } 830 839 … … 836 845 } 837 846 847 Void TDecSbac::parseCrossComponentPrediction( TComTU &rTu, ComponentID compID ) 848 { 849 TComDataCU *pcCU = rTu.getCU(); 850 851 if( isLuma(compID) || !pcCU->getSlice()->getPPS()->getUseCrossComponentPrediction() ) return; 852 853 const UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); 854 855 if (!pcCU->isIntra(uiAbsPartIdx) || (pcCU->getIntraDir( CHANNEL_TYPE_CHROMA, uiAbsPartIdx ) == DM_CHROMA_IDX)) 856 { 857 Char alpha = 0; 858 UInt symbol = 0; 859 860 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 861 DTRACE_CABAC_T("\tparseCrossComponentPrediction()") 862 DTRACE_CABAC_T( "\tAddr=" ) 863 DTRACE_CABAC_V( compID ) 864 DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) 865 DTRACE_CABAC_V( uiAbsPartIdx ) 866 #if RExt__DECODER_DEBUG_BIT_STATISTICS 867 TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__CROSS_COMPONENT_PREDICTION, (g_aucConvertToBit[rTu.getRect(compID).width] + 2), compID); 868 #endif 869 ContextModel *pCtx = m_cCrossComponentPredictionSCModel.get(0, 0) + ((compID == COMPONENT_Cr) ? (NUM_CROSS_COMPONENT_PREDICTION_CTX >> 1) : 0); 870 m_pcTDecBinIf->decodeBin( symbol, pCtx[0] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 871 872 if(symbol != 0) 873 { 874 // Cross-component prediction alpha is non-zero. 875 UInt sign = 0; 876 m_pcTDecBinIf->decodeBin( symbol, pCtx[1] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 877 878 if (symbol != 0) 879 { 880 // alpha is 2 (symbol=1), 4(symbol=2) or 8(symbol=3). 881 // Read up to two more bits 882 xReadUnaryMaxSymbol( symbol, (pCtx + 2), 1, 2 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 883 symbol += 1; 884 } 885 m_pcTDecBinIf->decodeBin( sign, pCtx[4] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 886 887 alpha = (sign != 0) ? -(1 << symbol) : (1 << symbol); 888 } 889 DTRACE_CABAC_T( "\tAlpha=" ) 890 DTRACE_CABAC_V( alpha ) 891 DTRACE_CABAC_T( "\n" ) 892 893 pcCU->setCrossComponentPredictionAlphaPartRange( alpha, compID, uiAbsPartIdx, rTu.GetAbsPartIdxNumParts( compID ) ); 894 } 895 } 838 896 839 897 Void TDecSbac::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) 840 898 { 841 m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) ); 899 m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) 900 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(TComCodingStatisticsClassType(STATS__CABAC_BITS__TRANSFORM_SUBDIV_FLAG, 5-uiLog2TransformBlockSize)) 901 ); 842 902 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 843 903 DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" ) … … 853 913 UInt uiSymbol; 854 914 const UInt uiCtx = 0; 855 m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) );915 m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__QT_ROOT_CBF) ); 856 916 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 857 917 DTRACE_CABAC_T( "\tparseQtRootCbf()" ) … … 863 923 DTRACE_CABAC_V( uiAbsPartIdx ) 864 924 DTRACE_CABAC_T( "\n" ) 865 925 866 926 uiQtRootCbf = uiSymbol; 867 927 } … … 872 932 UInt uiDQp; 873 933 Int iDQp; 874 934 875 935 UInt uiSymbol; 876 936 877 xReadUnaryMaxSymbol (uiDQp, &m_cCUDeltaQpSCModel.get( 0, 0, 0 ), 1, CU_DQP_TU_CMAX );937 xReadUnaryMaxSymbol (uiDQp, &m_cCUDeltaQpSCModel.get( 0, 0, 0 ), 1, CU_DQP_TU_CMAX RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTA_QP_EP) ); 878 938 879 939 if( uiDQp >= CU_DQP_TU_CMAX) 880 940 { 881 xReadEpExGolomb( uiSymbol, CU_DQP_EG_k );941 xReadEpExGolomb( uiSymbol, CU_DQP_EG_k RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTA_QP_EP)); 882 942 uiDQp+=uiSymbol; 883 943 } … … 889 949 Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); 890 950 #else 891 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset Y();892 #endif 893 m_pcTDecBinIf->decodeBinEP(uiSign );951 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); 952 #endif 953 m_pcTDecBinIf->decodeBinEP(uiSign RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DELTA_QP_EP)); 894 954 iDQp = uiDQp; 895 955 if(uiSign) … … 899 959 qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+qpBdOffsetY)) - qpBdOffsetY; 900 960 } 901 else 961 else 902 962 { 903 963 qp = pcCU->getRefQP(uiAbsPartIdx); 904 964 } 905 pcCU->setQPSubParts(qp, uiAbsPartIdx, uiDepth); 965 966 pcCU->setQPSubParts(qp, uiAbsPartIdx, uiDepth); 906 967 pcCU->setCodedQP(qp); 907 968 } 908 969 909 Void TDecSbac::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) 910 { 911 UInt uiSymbol; 912 const UInt uiCtx = pcCU->getCtxQtCbf( eType, uiTrDepth ); 913 #if AUXILIARY_PICTURES 914 if (pcCU->getSlice()->getChromaFormatIdc() == CHROMA_400 && (eType == TEXT_CHROMA_U || eType == TEXT_CHROMA_V)) 915 { 916 uiSymbol = 0; 970 /** parse chroma qp adjustment, converting to the internal table representation. 971 * \returns Void 972 */ 973 Void TDecSbac::parseChromaQpAdjustment( TComDataCU* cu, UInt absPartIdx, UInt depth ) 974 { 975 UInt symbol; 976 #if RExt__DECODER_DEBUG_BIT_STATISTICS 977 const TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__CHROMA_QP_ADJUSTMENT, g_aucConvertToBit[g_uiMaxCUWidth>>depth]+2, CHANNEL_TYPE_CHROMA); 978 #endif 979 980 Int tableSize = cu->getSlice()->getPPS()->getChromaQpAdjTableSize(); 981 982 /* cu_chroma_qp_adjustment_flag */ 983 m_pcTDecBinIf->decodeBin( symbol, m_ChromaQpAdjFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 984 985 if (symbol && tableSize > 1) { 986 /* cu_chroma_qp_adjustment_idc */ 987 xReadUnaryMaxSymbol( symbol, &m_ChromaQpAdjIdcSCModel.get( 0, 0, 0 ), 0, tableSize - 1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 988 symbol++; 989 } 990 /* NB, symbol = 0 if outer flag is not set, 991 * 1 if outer flag is set and there is no inner flag 992 * 1+ otherwise */ 993 cu->setChromaQpAdjSubParts( symbol, absPartIdx, depth ); 994 cu->setCodedChromaQpAdj(symbol); 995 } 996 997 Void TDecSbac::parseQtCbf( TComTU &rTu, const ComponentID compID, const Bool lowestLevel ) 998 { 999 TComDataCU* pcCU = rTu.getCU(); 1000 1001 const UInt absPartIdx = rTu.GetAbsPartIdxTU(compID); 1002 const UInt TUDepth = rTu.GetTransformDepthRel(); 1003 const UInt uiCtx = pcCU->getCtxQtCbf( rTu, toChannelType(compID) ); 1004 const UInt contextSet = toChannelType(compID); 1005 1006 const UInt width = rTu.getRect(compID).width; 1007 const UInt height = rTu.getRect(compID).height; 1008 const Bool canQuadSplit = (width >= (MIN_TU_SIZE * 2)) && (height >= (MIN_TU_SIZE * 2)); 1009 const UInt coveredPartIdxes = rTu.GetAbsPartIdxNumParts(compID); 1010 1011 // Since the CBF for chroma is coded at the highest level possible, if sub-TUs are 1012 // to be coded for a 4x8 chroma TU, their CBFs must be coded at the highest 4x8 level 1013 // (i.e. where luma TUs are 8x8 rather than 4x4) 1014 // ___ ___ 1015 // | | | <- 4 x (8x8 luma + 4x8 4:2:2 chroma) 1016 // |___|___| each quadrant has its own chroma CBF 1017 // | | | _ _ _ _ 1018 // |___|___| | 1019 // <--16---> V 1020 // _ _ 1021 // |_|_| <- 4 x 4x4 luma + 1 x 4x8 4:2:2 chroma 1022 // |_|_| no chroma CBF is coded - instead the parent CBF is inherited 1023 // <-8-> if sub-TUs are present, their CBFs had to be coded at the parent level 1024 1025 const UInt lowestTUDepth = TUDepth + ((!lowestLevel && !canQuadSplit) ? 1 : 0); //unsplittable TUs inherit their parent's CBF 1026 UInt lowestTUCBF = 0; 1027 1028 if ((width != height) && (lowestLevel || !canQuadSplit)) //if sub-TUs are present 1029 { 1030 const UInt subTUDepth = lowestTUDepth + 1; 1031 const UInt partIdxesPerSubTU = rTu.GetAbsPartIdxNumParts(compID) >> 1; 1032 1033 UInt combinedSubTUCBF = 0; 1034 1035 for (UInt subTU = 0; subTU < 2; subTU++) 1036 { 1037 UInt uiCbf = MAX_UINT; 1038 m_pcTDecBinIf->decodeBin(uiCbf, m_cCUQtCbfSCModel.get(0, contextSet, uiCtx) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(TComCodingStatisticsClassType(STATS__CABAC_BITS__QT_CBF, g_aucConvertToBit[rTu.getRect(compID).width]+2, compID))); 1039 1040 const UInt subTUAbsPartIdx = absPartIdx + (subTU * partIdxesPerSubTU); 1041 pcCU->setCbfPartRange((uiCbf << subTUDepth), compID, subTUAbsPartIdx, partIdxesPerSubTU); 1042 combinedSubTUCBF |= uiCbf; 1043 1044 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 1045 DTRACE_CABAC_T( "\tparseQtCbf()" ) 1046 DTRACE_CABAC_T( "\tsub-TU=" ) 1047 DTRACE_CABAC_V( subTU ) 1048 DTRACE_CABAC_T( "\tsymbol=" ) 1049 DTRACE_CABAC_V( uiCbf ) 1050 DTRACE_CABAC_T( "\tctx=" ) 1051 DTRACE_CABAC_V( uiCtx ) 1052 DTRACE_CABAC_T( "\tetype=" ) 1053 DTRACE_CABAC_V( compID ) 1054 DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) 1055 DTRACE_CABAC_V( subTUAbsPartIdx ) 1056 DTRACE_CABAC_T( "\n" ) 1057 } 1058 1059 //propagate the sub-TU CBF up to the lowest TU level 1060 if (combinedSubTUCBF != 0) 1061 { 1062 pcCU->bitwiseOrCbfPartRange((combinedSubTUCBF << lowestTUDepth), compID, absPartIdx, coveredPartIdxes); 1063 lowestTUCBF = combinedSubTUCBF; 1064 } 917 1065 } 918 1066 else 919 1067 { 920 #endif 921 m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA: eType, uiCtx ) ); 922 #if AUXILIARY_PICTURES 923 } 924 #endif 925 926 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 927 DTRACE_CABAC_T( "\tparseQtCbf()" ) 928 DTRACE_CABAC_T( "\tsymbol=" ) 929 DTRACE_CABAC_V( uiSymbol ) 930 DTRACE_CABAC_T( "\tctx=" ) 931 DTRACE_CABAC_V( uiCtx ) 932 DTRACE_CABAC_T( "\tetype=" ) 933 DTRACE_CABAC_V( eType ) 934 DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) 935 DTRACE_CABAC_V( uiAbsPartIdx ) 936 DTRACE_CABAC_T( "\n" ) 937 938 pcCU->setCbfSubParts( uiSymbol << uiTrDepth, eType, uiAbsPartIdx, uiDepth ); 939 } 940 941 void TDecSbac::parseTransformSkipFlags (TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType) 942 { 1068 UInt uiCbf = MAX_UINT; 1069 m_pcTDecBinIf->decodeBin(uiCbf, m_cCUQtCbfSCModel.get(0, contextSet, uiCtx) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(TComCodingStatisticsClassType(STATS__CABAC_BITS__QT_CBF, g_aucConvertToBit[rTu.getRect(compID).width]+2, compID))); 1070 1071 pcCU->setCbfSubParts((uiCbf << lowestTUDepth), compID, absPartIdx, rTu.GetTransformDepthTotalAdj(compID)); 1072 1073 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 1074 DTRACE_CABAC_T( "\tparseQtCbf()" ) 1075 DTRACE_CABAC_T( "\tsymbol=" ) 1076 DTRACE_CABAC_V( uiCbf ) 1077 DTRACE_CABAC_T( "\tctx=" ) 1078 DTRACE_CABAC_V( uiCtx ) 1079 DTRACE_CABAC_T( "\tetype=" ) 1080 DTRACE_CABAC_V( compID ) 1081 DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) 1082 DTRACE_CABAC_V( rTu.GetAbsPartIdxTU(compID) ) 1083 DTRACE_CABAC_T( "\n" ) 1084 1085 lowestTUCBF = uiCbf; 1086 } 1087 1088 //propagate the lowest level CBF up to the current level 1089 if (lowestTUCBF != 0) 1090 { 1091 for (UInt depth = TUDepth; depth < lowestTUDepth; depth++) 1092 { 1093 pcCU->bitwiseOrCbfPartRange((lowestTUCBF << depth), compID, absPartIdx, coveredPartIdxes); 1094 } 1095 } 1096 } 1097 1098 1099 Void TDecSbac::parseTransformSkipFlags (TComTU &rTu, ComponentID component) 1100 { 1101 TComDataCU* pcCU=rTu.getCU(); 1102 UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(component); 1103 943 1104 if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) 944 1105 { 945 1106 return; 946 1107 } 947 if(width != 4 || height != 4) 1108 1109 if (!TUCompRectHasAssociatedTransformSkipFlag(rTu.getRect(component), pcCU->getSlice()->getPPS()->getTransformSkipLog2MaxSize())) 948 1110 { 949 1111 return; 950 1112 } 951 1113 952 1114 UInt useTransformSkip; 953 m_pcTDecBinIf->decodeBin( useTransformSkip , m_cTransformSkipSCModel.get( 0, eTType? TEXT_CHROMA: TEXT_LUMA, 0 ) ); 954 if(eTType!= TEXT_LUMA) 955 { 956 const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - uiDepth; 957 if(uiLog2TrafoSize == 2) 958 { 959 uiDepth --; 960 } 961 } 1115 1116 m_pcTDecBinIf->decodeBin( useTransformSkip , m_cTransformSkipSCModel.get( 0, toChannelType(component), 0 ) 1117 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(TComCodingStatisticsClassType(STATS__CABAC_BITS__TRANSFORM_SKIP_FLAGS, component)) 1118 ); 1119 962 1120 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 963 1121 DTRACE_CABAC_T("\tparseTransformSkip()"); … … 965 1123 DTRACE_CABAC_V( useTransformSkip ) 966 1124 DTRACE_CABAC_T( "\tAddr=" ) 967 DTRACE_CABAC_V( pcCU->get Addr() )1125 DTRACE_CABAC_V( pcCU->getCtuRsAddr() ) 968 1126 DTRACE_CABAC_T( "\tetype=" ) 969 DTRACE_CABAC_V( eTType)1127 DTRACE_CABAC_V( component ) 970 1128 DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) 971 DTRACE_CABAC_V( uiAbsPartIdx)1129 DTRACE_CABAC_V( rTu.GetAbsPartIdxTU() ) 972 1130 DTRACE_CABAC_T( "\n" ) 973 1131 974 pcCU->setTransformSkipSubParts( useTransformSkip, eTType, uiAbsPartIdx, uiDepth); 975 } 1132 pcCU->setTransformSkipPartRange( useTransformSkip, component, uiAbsPartIdx, rTu.GetAbsPartIdxNumParts(component)); 1133 } 1134 976 1135 977 1136 /** Parse (X,Y) position of the last significant coefficient … … 985 1144 * This method decodes the X and Y component within a block of the last significant coefficient. 986 1145 */ 987 Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, TextType eTType, UInt uiScanIdx )1146 Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, ComponentID component, UInt uiScanIdx ) 988 1147 { 989 1148 UInt uiLast; 990 ContextModel *pCtxX = m_cCuCtxLastX.get( 0, eTType ); 991 ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType ); 1149 1150 ContextModel *pCtxX = m_cCuCtxLastX.get( 0, toChannelType(component) ); 1151 ContextModel *pCtxY = m_cCuCtxLastY.get( 0, toChannelType(component) ); 1152 1153 #if RExt__DECODER_DEBUG_BIT_STATISTICS 1154 TComCodingStatisticsClassType ctype(STATS__CABAC_BITS__LAST_SIG_X_Y, g_aucConvertToBit[width]+2, component); 1155 #endif 1156 1157 1158 if ( uiScanIdx == SCAN_VER ) 1159 { 1160 swap( width, height ); 1161 } 992 1162 993 1163 Int blkSizeOffsetX, blkSizeOffsetY, shiftX, shiftY; 994 blkSizeOffsetX = eTType ? 0: (g_aucConvertToBit[ width ] *3 + ((g_aucConvertToBit[ width ] +1)>>2));995 blkSizeOffsetY = eTType ? 0: (g_aucConvertToBit[ height ]*3 + ((g_aucConvertToBit[ height ]+1)>>2)); 996 shiftX= eTType ? g_aucConvertToBit[ width ] :((g_aucConvertToBit[ width ]+3)>>2);997 shiftY= eTType ? g_aucConvertToBit[ height ] :((g_aucConvertToBit[ height ]+3)>>2); 1164 getLastSignificantContextParameters(component, width, height, blkSizeOffsetX, blkSizeOffsetY, shiftX, shiftY); 1165 1166 //------------------ 1167 998 1168 // posX 1169 999 1170 for( uiPosLastX = 0; uiPosLastX < g_uiGroupIdx[ width - 1 ]; uiPosLastX++ ) 1000 1171 { 1001 m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + blkSizeOffsetX + (uiPosLastX >>shiftX) ) ); 1172 m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + blkSizeOffsetX + (uiPosLastX >>shiftX) ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1173 1002 1174 if( !uiLast ) 1003 1175 { … … 1007 1179 1008 1180 // posY 1181 1009 1182 for( uiPosLastY = 0; uiPosLastY < g_uiGroupIdx[ height - 1 ]; uiPosLastY++ ) 1010 1183 { 1011 m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + blkSizeOffsetY + (uiPosLastY >>shiftY)) ); 1184 m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + blkSizeOffsetY + (uiPosLastY >>shiftY)) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1185 1012 1186 if( !uiLast ) 1013 1187 { … … 1015 1189 } 1016 1190 } 1191 1192 // EP-coded part 1193 1017 1194 if ( uiPosLastX > 3 ) 1018 1195 { … … 1021 1198 for ( Int i = uiCount - 1; i >= 0; i-- ) 1022 1199 { 1023 m_pcTDecBinIf->decodeBinEP( uiLast );1200 m_pcTDecBinIf->decodeBinEP( uiLast RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1024 1201 uiTemp += uiLast << i; 1025 1202 } … … 1032 1209 for ( Int i = uiCount - 1; i >= 0; i-- ) 1033 1210 { 1034 m_pcTDecBinIf->decodeBinEP( uiLast );1211 m_pcTDecBinIf->decodeBinEP( uiLast RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype) ); 1035 1212 uiTemp += uiLast << i; 1036 1213 } 1037 1214 uiPosLastY = g_uiMinInGroup[ uiPosLastY ] + uiTemp; 1038 1215 } 1039 1216 1040 1217 if( uiScanIdx == SCAN_VER ) 1041 1218 { … … 1044 1221 } 1045 1222 1046 Void TDecSbac::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) 1047 { 1223 Void TDecSbac::parseCoeffNxN( TComTU &rTu, ComponentID compID ) 1224 { 1225 TComDataCU* pcCU=rTu.getCU(); 1226 const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(compID); 1227 const TComRectangle &rRect=rTu.getRect(compID); 1228 const UInt uiWidth=rRect.width; 1229 const UInt uiHeight=rRect.height; 1230 TCoeff* pcCoef=(pcCU->getCoeff(compID)+rTu.getCoefficientOffset(compID)); 1231 1048 1232 DTRACE_CABAC_VL( g_nSymbolCounter++ ) 1049 1233 DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" ) 1050 DTRACE_CABAC_V( eTType)1234 DTRACE_CABAC_V( compID ) 1051 1235 DTRACE_CABAC_T( "\twidth=" ) 1052 1236 DTRACE_CABAC_V( uiWidth ) … … 1054 1238 DTRACE_CABAC_V( uiHeight ) 1055 1239 DTRACE_CABAC_T( "\tdepth=" ) 1056 DTRACE_CABAC_V( uiDepth ) 1240 // DTRACE_CABAC_V( rTu.GetTransformDepthTotalAdj(compID) ) 1241 DTRACE_CABAC_V( rTu.GetTransformDepthTotal() ) 1057 1242 DTRACE_CABAC_T( "\tabspartidx=" ) 1058 DTRACE_CABAC_V( uiAbsPartIdx ) 1243 // DTRACE_CABAC_V( uiAbsPartIdx ) 1244 DTRACE_CABAC_V( rTu.GetAbsPartIdxTU(compID) ) 1059 1245 DTRACE_CABAC_T( "\ttoCU-X=" ) 1060 1246 DTRACE_CABAC_V( pcCU->getCUPelX() ) … … 1062 1248 DTRACE_CABAC_V( pcCU->getCUPelY() ) 1063 1249 DTRACE_CABAC_T( "\tCU-addr=" ) 1064 DTRACE_CABAC_V( pcCU->get Addr() )1250 DTRACE_CABAC_V( pcCU->getCtuRsAddr() ) 1065 1251 DTRACE_CABAC_T( "\tinCU-X=" ) 1066 DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) 1252 // DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) 1253 DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[rTu.GetAbsPartIdxTU(compID)] ] ) 1067 1254 DTRACE_CABAC_T( "\tinCU-Y=" ) 1068 DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) 1255 // DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) 1256 DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[rTu.GetAbsPartIdxTU(compID)] ] ) 1069 1257 DTRACE_CABAC_T( "\tpredmode=" ) 1070 1258 DTRACE_CABAC_V( pcCU->getPredictionMode( uiAbsPartIdx ) ) 1071 1259 DTRACE_CABAC_T( "\n" ) 1072 1260 1261 //-------------------------------------------------------------------------------------------------- 1262 1073 1263 if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() ) 1074 1264 { 1075 uiWidth = pcCU->getSlice()->getSPS()->getMaxTrSize(); 1076 uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize(); 1077 } 1265 std::cerr << "ERROR: parseCoeffNxN was passed a TU with dimensions larger than the maximum allowed size" << std::endl; 1266 assert(false); 1267 exit(1); 1268 } 1269 1270 //-------------------------------------------------------------------------------------------------- 1271 1272 //set parameters 1273 1274 const ChannelType chType = toChannelType(compID); 1275 const UInt uiLog2BlockWidth = g_aucConvertToBit[ uiWidth ] + 2; 1276 const UInt uiLog2BlockHeight = g_aucConvertToBit[ uiHeight ] + 2; 1277 const UInt uiMaxNumCoeff = uiWidth * uiHeight; 1278 const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; 1279 1280 const ChannelType channelType = toChannelType(compID); 1281 const Bool extendedPrecision = pcCU->getSlice()->getSPS()->getUseExtendedPrecision(); 1282 1283 const Bool alignCABACBeforeBypass = pcCU->getSlice()->getSPS()->getAlignCABACBeforeBypass(); 1284 1285 #if RExt__DECODER_DEBUG_BIT_STATISTICS 1286 TComCodingStatisticsClassType ctype_group(STATS__CABAC_BITS__SIG_COEFF_GROUP_FLAG, uiLog2BlockWidth, compID); 1287 TComCodingStatisticsClassType ctype_map(STATS__CABAC_BITS__SIG_COEFF_MAP_FLAG, uiLog2BlockWidth, compID); 1288 TComCodingStatisticsClassType ctype_gt1(STATS__CABAC_BITS__GT1_FLAG, uiLog2BlockWidth, compID); 1289 TComCodingStatisticsClassType ctype_gt2(STATS__CABAC_BITS__GT2_FLAG, uiLog2BlockWidth, compID); 1290 #endif 1291 1292 Bool beValid; 1293 if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) 1294 { 1295 beValid = false; 1296 if((!pcCU->isIntra(uiAbsPartIdx)) && pcCU->isRDPCMEnabled(uiAbsPartIdx)) 1297 parseExplicitRdpcmMode(rTu, compID); 1298 } 1299 else 1300 { 1301 beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; 1302 } 1303 1304 UInt absSum = 0; 1305 1306 //-------------------------------------------------------------------------------------------------- 1307 1078 1308 if(pcCU->getSlice()->getPPS()->getUseTransformSkip()) 1079 1309 { 1080 parseTransformSkipFlags( pcCU, uiAbsPartIdx, uiWidth, uiHeight, uiDepth, eTType); 1081 } 1082 1083 eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA ); 1084 1085 //----- parse significance map ----- 1086 const UInt uiLog2BlockSize = g_aucConvertToBit[ uiWidth ] + 2; 1087 const UInt uiMaxNumCoeff = uiWidth * uiHeight; 1088 const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; 1089 UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); 1090 1310 parseTransformSkipFlags(rTu, compID); 1311 // This TU has coefficients and is transform skipped. Check whether is inter coded and if yes decode the explicit RDPCM mode 1312 if(pcCU->getTransformSkip(uiAbsPartIdx, compID) && (!pcCU->isIntra(uiAbsPartIdx)) && pcCU->isRDPCMEnabled(uiAbsPartIdx) ) 1313 { 1314 parseExplicitRdpcmMode(rTu, compID); 1315 if(pcCU->getExplicitRdpcmMode(compID, uiAbsPartIdx) != RDPCM_OFF) 1316 { 1317 // Sign data hiding is avoided for horizontal and vertical RDPCM modes 1318 beValid = false; 1319 } 1320 } 1321 } 1322 1323 Int uiIntraMode = -1; 1324 const Bool bIsLuma = isLuma(compID); 1325 Int isIntra = pcCU->isIntra(uiAbsPartIdx) ? 1 : 0; 1326 if ( isIntra && pcCU->isRDPCMEnabled(uiAbsPartIdx) ) 1327 { 1328 uiIntraMode = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx ); 1329 uiIntraMode = (uiIntraMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, rTu.GetChromaFormat())) : uiIntraMode; 1330 uiIntraMode = ((rTu.GetChromaFormat() == CHROMA_422) && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiIntraMode] : uiIntraMode; 1331 1332 Bool transformSkip = pcCU->getTransformSkip( uiAbsPartIdx,compID); 1333 Bool rdpcm_lossy = ( transformSkip /*&& isIntra*/ && ( (uiIntraMode == HOR_IDX) || (uiIntraMode == VER_IDX) ) ); 1334 if ( rdpcm_lossy ) 1335 { 1336 beValid = false; 1337 } 1338 } 1339 1340 //-------------------------------------------------------------------------------------------------- 1341 1342 const Bool bUseGolombRiceParameterAdaptation = pcCU->getSlice()->getSPS()->getUseGolombRiceParameterAdaptation(); 1343 UInt ¤tGolombRiceStatistic = m_golombRiceAdaptationStatistics[rTu.getGolombRiceStatisticsIndex(compID)]; 1344 1345 //select scans 1346 TUEntropyCodingParameters codingParameters; 1347 getTUEntropyCodingParameters(codingParameters, rTu, compID); 1348 1091 1349 //===== decode last significant ===== 1092 1350 UInt uiPosLastX, uiPosLastY; 1093 parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, uiHeight, eTType, uiScanIdx);1094 UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2Block Size);1351 parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, uiHeight, compID, codingParameters.scanType ); 1352 UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2BlockWidth); 1095 1353 pcCoef[ uiBlkPosLast ] = 1; 1096 1354 1097 1355 //===== decode significance flags ===== 1098 1356 UInt uiScanPosLast; 1099 const UInt *scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ];1100 1357 for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ ) 1101 1358 { 1102 UInt uiBlkPos = scan[ uiScanPosLast ];1359 UInt uiBlkPos = codingParameters.scan[ uiScanPosLast ]; 1103 1360 if( uiBlkPosLast == uiBlkPos ) 1104 1361 { … … 1107 1364 } 1108 1365 1109 ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, eTType ); 1110 ContextModel * const baseCtx = (eTType==TEXT_LUMA) ? m_cCUSigSCModel.get( 0, 0 ) : m_cCUSigSCModel.get( 0, 0 ) + NUM_SIG_FLAG_CTX_LUMA; 1111 1112 const Int iLastScanSet = uiScanPosLast >> LOG2_SCAN_SET_SIZE; 1113 UInt c1 = 1; 1114 UInt uiGoRiceParam = 0; 1115 1116 Bool beValid; 1117 if (pcCU->getCUTransquantBypass(uiAbsPartIdx)) 1118 { 1119 beValid = false; 1120 } 1121 else 1122 { 1123 beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0; 1124 } 1125 UInt absSum = 0; 1366 ContextModel * const baseCoeffGroupCtx = m_cCUSigCoeffGroupSCModel.get( 0, isChroma(chType) ); 1367 ContextModel * const baseCtx = m_cCUSigSCModel.get( 0, 0 ) + getSignificanceMapContextOffset(compID); 1368 1369 const Int iLastScanSet = uiScanPosLast >> MLS_CG_SIZE; 1370 UInt c1 = 1; 1371 UInt uiGoRiceParam = 0; 1372 1126 1373 1127 1374 UInt uiSigCoeffGroupFlag[ MLS_GRP_NUM ]; 1128 ::memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); 1129 const UInt uiNumBlkSide = uiWidth >> (MLS_CG_SIZE >> 1); 1130 const UInt * scanCG; 1131 { 1132 scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0 ]; 1133 if( uiLog2BlockSize == 3 ) 1134 { 1135 scanCG = g_sigLastScan8x8[ uiScanIdx ]; 1136 } 1137 else if( uiLog2BlockSize == 5 ) 1138 { 1139 scanCG = g_sigLastScanCG32x32; 1140 } 1141 } 1375 memset( uiSigCoeffGroupFlag, 0, sizeof(UInt) * MLS_GRP_NUM ); 1376 1142 1377 Int iScanPosSig = (Int) uiScanPosLast; 1143 1378 for( Int iSubSet = iLastScanSet; iSubSet >= 0; iSubSet-- ) 1144 1379 { 1145 Int iSubPos = iSubSet << LOG2_SCAN_SET_SIZE; 1146 uiGoRiceParam = 0; 1380 Int iSubPos = iSubSet << MLS_CG_SIZE; 1381 uiGoRiceParam = currentGolombRiceStatistic / RExt__GOLOMB_RICE_INCREMENT_DIVISOR; 1382 Bool updateGolombRiceStatistics = bUseGolombRiceParameterAdaptation; //leave the statistics at 0 when not using the adaptation system 1147 1383 Int numNonZero = 0; 1148 1149 Int lastNZPosInCG = -1, firstNZPosInCG = SCAN_SET_SIZE; 1150 1151 Int pos[SCAN_SET_SIZE]; 1384 1385 Int lastNZPosInCG = -1; 1386 Int firstNZPosInCG = 1 << MLS_CG_SIZE; 1387 1388 Bool escapeDataPresentInGroup = false; 1389 1390 Int pos[1 << MLS_CG_SIZE]; 1391 1152 1392 if( iScanPosSig == (Int) uiScanPosLast ) 1153 1393 { … … 1160 1400 1161 1401 // decode significant_coeffgroup_flag 1162 Int iCGBlkPos = scanCG[ iSubSet ]; 1163 Int iCGPosY = iCGBlkPos / uiNumBlkSide; 1164 Int iCGPosX = iCGBlkPos - (iCGPosY * uiNumBlkSide); 1402 Int iCGBlkPos = codingParameters.scanCG[ iSubSet ]; 1403 Int iCGPosY = iCGBlkPos / codingParameters.widthInGroups; 1404 Int iCGPosX = iCGBlkPos - (iCGPosY * codingParameters.widthInGroups); 1405 1165 1406 if( iSubSet == iLastScanSet || iSubSet == 0) 1166 1407 { … … 1170 1411 { 1171 1412 UInt uiSigCoeffGroup; 1172 UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight);1173 m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] );1413 UInt uiCtxSig = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, codingParameters.widthInGroups, codingParameters.heightInGroups ); 1414 m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_group) ); 1174 1415 uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup; 1175 1416 } 1176 1417 1177 1418 // decode significant_coeff_flag 1178 Int patternSigCtx = TComTrQuant::calcPatternSigCtx( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight ); 1179 UInt uiBlkPos, uiPosY, uiPosX, uiSig, uiCtxSig; 1419 const Int patternSigCtx = TComTrQuant::calcPatternSigCtx(uiSigCoeffGroupFlag, iCGPosX, iCGPosY, codingParameters.widthInGroups, codingParameters.heightInGroups); 1420 1421 UInt uiBlkPos, uiSig, uiCtxSig; 1180 1422 for( ; iScanPosSig >= iSubPos; iScanPosSig-- ) 1181 1423 { 1182 uiBlkPos = scan[ iScanPosSig ]; 1183 uiPosY = uiBlkPos >> uiLog2BlockSize; 1184 uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); 1424 uiBlkPos = codingParameters.scan[ iScanPosSig ]; 1185 1425 uiSig = 0; 1186 1426 1187 1427 if( uiSigCoeffGroupFlag[ iCGBlkPos ] ) 1188 1428 { 1189 1429 if( iScanPosSig > iSubPos || iSubSet == 0 || numNonZero ) 1190 1430 { 1191 uiCtxSig = TComTrQuant::getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, uiLog2BlockSize, eTType );1192 m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] );1431 uiCtxSig = TComTrQuant::getSigCtxInc( patternSigCtx, codingParameters, iScanPosSig, uiLog2BlockWidth, uiLog2BlockHeight, chType ); 1432 m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_map) ); 1193 1433 } 1194 1434 else … … 1209 1449 } 1210 1450 } 1211 1212 if( numNonZero )1451 1452 if( numNonZero > 0 ) 1213 1453 { 1214 1454 Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= SBH_THRESHOLD ); 1455 1215 1456 absSum = 0; 1216 UInt uiCtxSet = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0; 1457 1458 const UInt uiCtxSet = getContextSetIndex(compID, iSubSet, (c1 == 0)); 1459 c1 = 1; 1217 1460 UInt uiBin; 1218 if( c1 == 0 ) 1219 { 1220 uiCtxSet++; 1221 } 1222 c1 = 1; 1223 ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet; 1224 Int absCoeff[SCAN_SET_SIZE]; 1225 1226 for ( Int i = 0; i < numNonZero; i++) absCoeff[i] = 1; 1461 1462 ContextModel *baseCtxMod = m_cCUOneSCModel.get( 0, 0 ) + (NUM_ONE_FLAG_CTX_PER_SET * uiCtxSet); 1463 1464 Int absCoeff[1 << MLS_CG_SIZE]; 1465 1466 for ( Int i = 0; i < numNonZero; i++) absCoeff[i] = 1; 1227 1467 Int numC1Flag = min(numNonZero, C1FLAG_NUMBER); 1228 1468 Int firstC2FlagIdx = -1; … … 1230 1470 for( Int idx = 0; idx < numC1Flag; idx++ ) 1231 1471 { 1232 m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c1] );1472 m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[c1] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_gt1) ); 1233 1473 if( uiBin == 1 ) 1234 1474 { … … 1238 1478 firstC2FlagIdx = idx; 1239 1479 } 1480 else //if a greater-than-one has been encountered already this group 1481 { 1482 escapeDataPresentInGroup = true; 1483 } 1240 1484 } 1241 1485 else if( (c1 < 3) && (c1 > 0) ) … … 1245 1489 absCoeff[ idx ] = uiBin + 1; 1246 1490 } 1247 1491 1248 1492 if (c1 == 0) 1249 1493 { 1250 baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUAbsSCModel.get( 0, 0 ) + uiCtxSet : m_cCUAbsSCModel.get( 0, 0 ) + NUM_ABS_FLAG_CTX_LUMA + uiCtxSet;1494 baseCtxMod = m_cCUAbsSCModel.get( 0, 0 ) + (NUM_ABS_FLAG_CTX_PER_SET * uiCtxSet); 1251 1495 if ( firstC2FlagIdx != -1) 1252 1496 { 1253 m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[0] );1497 m_pcTDecBinIf->decodeBin( uiBin, baseCtxMod[0] RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_gt2) ); 1254 1498 absCoeff[ firstC2FlagIdx ] = uiBin + 2; 1499 if (uiBin != 0) 1500 { 1501 escapeDataPresentInGroup = true; 1502 } 1255 1503 } 1504 } 1505 1506 escapeDataPresentInGroup = escapeDataPresentInGroup || (numNonZero > C1FLAG_NUMBER); 1507 1508 const Bool alignGroup = escapeDataPresentInGroup && alignCABACBeforeBypass; 1509 1510 #if RExt__DECODER_DEBUG_BIT_STATISTICS 1511 TComCodingStatisticsClassType ctype_signs((alignGroup ? STATS__CABAC_BITS__ALIGNED_SIGN_BIT : STATS__CABAC_BITS__SIGN_BIT ), uiLog2BlockWidth, compID); 1512 TComCodingStatisticsClassType ctype_escs ((alignGroup ? STATS__CABAC_BITS__ALIGNED_ESCAPE_BITS : STATS__CABAC_BITS__ESCAPE_BITS), uiLog2BlockWidth, compID); 1513 #endif 1514 1515 if (alignGroup) 1516 { 1517 m_pcTDecBinIf->align(); 1256 1518 } 1257 1519 … … 1259 1521 if ( signHidden && beValid ) 1260 1522 { 1261 m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero-1 );1523 m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero-1 RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_signs) ); 1262 1524 coeffSigns <<= 32 - (numNonZero-1); 1263 1525 } 1264 1526 else 1265 1527 { 1266 m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero );1528 m_pcTDecBinIf->decodeBinsEP( coeffSigns, numNonZero RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_signs) ); 1267 1529 coeffSigns <<= 32 - numNonZero; 1268 1530 } 1269 1270 Int iFirstCoeff2 = 1; 1271 if ( c1 == 0 || numNonZero > C1FLAG_NUMBER)1531 1532 Int iFirstCoeff2 = 1; 1533 if (escapeDataPresentInGroup) 1272 1534 { 1273 1535 for( Int idx = 0; idx < numNonZero; idx++ ) … … 1278 1540 { 1279 1541 UInt uiLevel; 1280 xReadCoefRemainExGolomb( uiLevel, uiGoRiceParam ); 1542 xReadCoefRemainExGolomb( uiLevel, uiGoRiceParam, extendedPrecision, channelType RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype_escs) ); 1543 1281 1544 absCoeff[ idx ] = uiLevel + baseLevel; 1282 if(absCoeff[idx]>3*(1<<uiGoRiceParam)) 1545 1546 if (absCoeff[idx] > (3 << uiGoRiceParam)) 1283 1547 { 1284 uiGoRiceParam = min<UInt>(uiGoRiceParam+ 1, 4); 1548 uiGoRiceParam = bUseGolombRiceParameterAdaptation ? (uiGoRiceParam + 1) : (std::min<UInt>((uiGoRiceParam + 1), 4)); 1549 } 1550 1551 if (updateGolombRiceStatistics) 1552 { 1553 const UInt initialGolombRiceParameter = currentGolombRiceStatistic / RExt__GOLOMB_RICE_INCREMENT_DIVISOR; 1554 1555 if (uiLevel >= (3 << initialGolombRiceParameter)) 1556 { 1557 currentGolombRiceStatistic++; 1558 } 1559 else if (((uiLevel * 2) < (1 << initialGolombRiceParameter)) && (currentGolombRiceStatistic > 0)) 1560 { 1561 currentGolombRiceStatistic--; 1562 } 1563 1564 updateGolombRiceStatistics = false; 1285 1565 } 1286 1566 } 1287 1567 1288 if(absCoeff[ idx ] >= 2) 1568 if(absCoeff[ idx ] >= 2) 1289 1569 { 1290 1570 iFirstCoeff2 = 0; … … 1303 1583 { 1304 1584 // Infer sign of 1st element. 1305 if (absSum&0x1) 1306 { 1307 pcCoef[ blkPos ] = -pcCoef[ blkPos ]; 1308 } 1585 if (absSum&0x1) pcCoef[ blkPos ] = -pcCoef[ blkPos ]; 1309 1586 } 1310 1587 else … … 1317 1594 } 1318 1595 } 1319 1596 1597 #if ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 1598 printSBACCoeffData(uiPosLastX, uiPosLastY, uiWidth, uiHeight, compID, uiAbsPartIdx, codingParameters.scanType, pcCoef); 1599 #endif 1600 1320 1601 return; 1321 1602 } 1322 1323 1603 1324 1604 Void TDecSbac::parseSaoMaxUvlc ( UInt& val, UInt maxSymbol ) … … 1332 1612 UInt code; 1333 1613 Int i; 1334 m_pcTDecBinIf->decodeBinEP( code );1614 m_pcTDecBinIf->decodeBinEP( code RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); 1335 1615 if ( code == 0 ) 1336 1616 { … … 1342 1622 while (1) 1343 1623 { 1344 m_pcTDecBinIf->decodeBinEP( code );1624 m_pcTDecBinIf->decodeBinEP( code RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); 1345 1625 if ( code == 0 ) 1346 1626 { … … 1348 1628 } 1349 1629 i++; 1350 if (i == maxSymbol) 1630 if (i == maxSymbol) 1351 1631 { 1352 1632 break; … … 1356 1636 val = i; 1357 1637 } 1638 1358 1639 Void TDecSbac::parseSaoUflc (UInt uiLength, UInt& riVal) 1359 1640 { 1360 m_pcTDecBinIf->decodeBinsEP ( riVal, uiLength ); 1361 } 1641 m_pcTDecBinIf->decodeBinsEP ( riVal, uiLength RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); 1642 } 1643 1362 1644 Void TDecSbac::parseSaoMerge (UInt& ruiVal) 1363 1645 { 1364 1646 UInt uiCode; 1365 m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeSCModel.get( 0, 0, 0 ) );1647 m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); 1366 1648 ruiVal = (Int)uiCode; 1367 1649 } 1650 1368 1651 Void TDecSbac::parseSaoTypeIdx (UInt& ruiVal) 1369 1652 { 1370 1653 UInt uiCode; 1371 m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) );1372 if (uiCode == 0) 1654 m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); 1655 if (uiCode == 0) 1373 1656 { 1374 1657 ruiVal = 0; … … 1376 1659 else 1377 1660 { 1378 m_pcTDecBinIf->decodeBinEP( uiCode );1661 m_pcTDecBinIf->decodeBinEP( uiCode RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); 1379 1662 if (uiCode == 0) 1380 1663 { … … 1390 1673 Void TDecSbac::parseSaoSign(UInt& val) 1391 1674 { 1392 m_pcTDecBinIf->decodeBinEP ( val );1675 m_pcTDecBinIf->decodeBinEP ( val RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__SAO) ); 1393 1676 } 1394 1677 … … 1421 1704 if(isLeftMerge || isAboveMerge) //merge mode 1422 1705 { 1423 saoBlkParam[SAO_Y].modeIdc = saoBlkParam[SAO_Cb].modeIdc = saoBlkParam[SAO_Cr].modeIdc = SAO_MODE_MERGE; 1424 saoBlkParam[SAO_Y].typeIdc = saoBlkParam[SAO_Cb].typeIdc = saoBlkParam[SAO_Cr].typeIdc = (isLeftMerge)?SAO_MERGE_LEFT:SAO_MERGE_ABOVE; 1706 for (UInt componentIndex = 0; componentIndex < MAX_NUM_COMPONENT; componentIndex++) 1707 { 1708 saoBlkParam[componentIndex].modeIdc = (sliceEnabled[componentIndex]) ? SAO_MODE_MERGE : SAO_MODE_OFF; 1709 saoBlkParam[componentIndex].typeIdc = (isLeftMerge)?SAO_MERGE_LEFT:SAO_MERGE_ABOVE; 1710 } 1425 1711 } 1426 1712 else //new or off mode 1427 { 1428 for(Int compIdx=0; compIdx < NUM_SAO_COMPONENTS; compIdx++) 1429 { 1713 { 1714 for(Int compId=COMPONENT_Y; compId < MAX_NUM_COMPONENT; compId++) 1715 { 1716 const ComponentID compIdx=ComponentID(compId); 1717 const ComponentID firstCompOfChType = getFirstComponentOfChannel(toChannelType(compIdx)); 1430 1718 SAOOffset& ctbParam = saoBlkParam[compIdx]; 1431 1719 … … 1438 1726 1439 1727 //type 1440 if(compIdx == SAO_Y || compIdx == SAO_Cb)1728 if(compIdx == firstCompOfChType) 1441 1729 { 1442 1730 parseSaoTypeIdx(uiSymbol); //sao_type_idx_luma or sao_type_idx_chroma … … 1462 1750 else //Cr, follow Cb SAO type 1463 1751 { 1464 ctbParam.modeIdc = saoBlkParam[ SAO_Cb].modeIdc;1465 ctbParam.typeIdc = saoBlkParam[ SAO_Cb].typeIdc;1752 ctbParam.modeIdc = saoBlkParam[COMPONENT_Cb].modeIdc; 1753 ctbParam.typeIdc = saoBlkParam[COMPONENT_Cb].typeIdc; 1466 1754 } 1467 1755 1468 1756 if(ctbParam.modeIdc == SAO_MODE_NEW) 1469 1757 { 1758 #if O0043_BEST_EFFORT_DECODING 1759 Int bitDepthOrig = g_bitDepthInStream[toChannelType(compIdx)]; 1760 Int forceBitDepthAdjust = bitDepthOrig - g_bitDepth[toChannelType(compIdx)]; 1761 #endif 1470 1762 Int offset[4]; 1471 1763 for(Int i=0; i< 4; i++) … … 1474 1766 parseSaoMaxUvlc(uiSymbol, saoMaxOffsetQVal[compIdx] ); //sao_offset_abs 1475 1767 #else 1768 #if O0043_BEST_EFFORT_DECODING 1769 Int saoMaxOffsetQVal = (1<<(min(bitDepthOrig, MAX_SAO_TRUNCATED_BITDEPTH)-5))-1; 1770 parseSaoMaxUvlc(uiSymbol, saoMaxOffsetQVal); //sao_offset_abs 1771 #else 1476 1772 parseSaoMaxUvlc(uiSymbol, g_saoMaxOffsetQVal[compIdx] ); //sao_offset_abs 1773 #endif 1477 1774 #endif 1478 1775 offset[i] = (Int)uiSymbol; … … 1488 1785 if(uiSymbol) 1489 1786 { 1787 #if O0043_BEST_EFFORT_DECODING 1788 offset[i] >>= forceBitDepthAdjust; 1789 #endif 1490 1790 offset[i] = -offset[i]; 1491 1791 } … … 1494 1794 parseSaoUflc(NUM_SAO_BO_CLASSES_LOG2, uiSymbol ); //sao_band_position 1495 1795 ctbParam.typeAuxInfo = uiSymbol; 1496 1796 1497 1797 for(Int i=0; i<4; i++) 1498 1798 { 1499 1799 ctbParam.offset[(ctbParam.typeAuxInfo+i)%MAX_NUM_SAO_CLASSES] = offset[i]; 1500 } 1501 1800 } 1801 1502 1802 } 1503 1803 else //EO … … 1505 1805 ctbParam.typeAuxInfo = 0; 1506 1806 1507 if( compIdx == SAO_Y || compIdx == SAO_Cb)1807 if(firstCompOfChType == compIdx) 1508 1808 { 1509 1809 parseSaoUflc(NUM_SAO_EO_TYPES_LOG2, uiSymbol ); //sao_eo_class_luma or sao_eo_class_chroma … … 1512 1812 else 1513 1813 { 1514 ctbParam.typeIdc = saoBlkParam[ SAO_Cb].typeIdc;1814 ctbParam.typeIdc = saoBlkParam[firstCompOfChType].typeIdc; 1515 1815 } 1516 1816 ctbParam.offset[SAO_CLASS_EO_FULL_VALLEY] = offset[0]; … … 1530 1830 \param pSrc Contexts to be copied. 1531 1831 */ 1532 Void TDecSbac::xCopyContextsFrom( TDecSbac* pSrc )1832 Void TDecSbac::xCopyContextsFrom( const TDecSbac* pSrc ) 1533 1833 { 1534 1834 memcpy(m_contextModels, pSrc->m_contextModels, m_numContextModels*sizeof(m_contextModels[0])); 1535 } 1536 1537 Void TDecSbac::xCopyFrom( TDecSbac* pSrc ) 1835 memcpy(m_golombRiceAdaptationStatistics, pSrc->m_golombRiceAdaptationStatistics, (sizeof(UInt) * RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS)); 1836 } 1837 1838 Void TDecSbac::xCopyFrom( const TDecSbac* pSrc ) 1538 1839 { 1539 1840 m_pcTDecBinIf->copyState( pSrc->m_pcTDecBinIf ); 1540 1541 m_uiLastQp = pSrc->m_uiLastQp;1542 1841 xCopyContextsFrom( pSrc ); 1543 1544 } 1545 1546 Void TDecSbac::load ( TDecSbac* pScr ) 1547 { 1548 xCopyFrom(pScr); 1549 } 1550 1551 Void TDecSbac::loadContexts ( TDecSbac* pScr ) 1552 { 1553 xCopyContextsFrom(pScr); 1554 } 1842 } 1843 1844 Void TDecSbac::load ( const TDecSbac* pSrc ) 1845 { 1846 xCopyFrom(pSrc); 1847 } 1848 1849 Void TDecSbac::loadContexts ( const TDecSbac* pSrc ) 1850 { 1851 xCopyContextsFrom(pSrc); 1852 } 1853 1854 /** Performs CABAC decoding of the explicit RDPCM mode 1855 * \param rTu current TU data structure 1856 * \param compID component identifier 1857 */ 1858 Void TDecSbac::parseExplicitRdpcmMode( TComTU &rTu, ComponentID compID ) 1859 { 1860 TComDataCU* cu = rTu.getCU(); 1861 const UInt absPartIdx=rTu.GetAbsPartIdxTU(compID); 1862 const TComRectangle &rect = rTu.getRect(compID); 1863 const UInt tuHeight = g_aucConvertToBit[rect.height]; 1864 const UInt tuWidth = g_aucConvertToBit[rect.width]; 1865 UInt code = 0; 1866 1867 assert(tuHeight == tuWidth); 1868 1869 #if RExt__DECODER_DEBUG_BIT_STATISTICS 1870 const TComCodingStatisticsClassType ctype(STATS__EXPLICIT_RDPCM_BITS, g_aucConvertToBit[g_uiMaxCUWidth>>rTu.GetTransformDepthTotal()]+2); 1871 #endif 1872 1873 m_pcTDecBinIf->decodeBin(code, m_explicitRdpcmFlagSCModel.get (0, toChannelType(compID), 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype)); 1874 1875 if(code == 0) 1876 { 1877 cu->setExplicitRdpcmModePartRange( RDPCM_OFF, compID, absPartIdx, rTu.GetAbsPartIdxNumParts(compID)); 1878 } 1879 else 1880 { 1881 m_pcTDecBinIf->decodeBin(code, m_explicitRdpcmDirSCModel.get (0, toChannelType(compID), 0) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(ctype)); 1882 if(code == 0) 1883 { 1884 cu->setExplicitRdpcmModePartRange( RDPCM_HOR, compID, absPartIdx, rTu.GetAbsPartIdxNumParts(compID)); 1885 } 1886 else 1887 { 1888 cu->setExplicitRdpcmModePartRange( RDPCM_VER, compID, absPartIdx, rTu.GetAbsPartIdxNumParts(compID)); 1889 } 1890 } 1891 } 1892 1893 1555 1894 //! \} -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecSbac.h
r713 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 58 58 // ==================================================================================================================== 59 59 60 class SEImessages; 61 60 62 /// SBAC decoder class 61 63 class TDecSbac : public TDecEntropyIf … … 64 66 TDecSbac(); 65 67 virtual ~TDecSbac(); 66 68 67 69 Void init ( TDecBinIf* p ) { m_pcTDecBinIf = p; } 68 70 Void uninit ( ) { m_pcTDecBinIf = 0; } 69 70 Void load ( TDecSbac* pScr);71 Void loadContexts ( TDecSbac* pScr);72 Void xCopyFrom (TDecSbac* pSrc );73 Void xCopyContextsFrom (TDecSbac* pSrc );71 72 Void load ( const TDecSbac* pSrc ); 73 Void loadContexts ( const TDecSbac* pSrc ); 74 Void xCopyFrom ( const TDecSbac* pSrc ); 75 Void xCopyContextsFrom ( const TDecSbac* pSrc ); 74 76 75 77 Void resetEntropy (TComSlice* pSlice ); 76 78 Void setBitstream ( TComInputBitstream* p ) { m_pcBitstream = p; m_pcTDecBinIf->init( p ); } 77 79 Void parseVPS ( TComVPS* /*pcVPS*/ ) {} 78 #if SVC_EXTENSION && !SPS_DPB_PARAMS79 Void parseSPS ( TComSPS* /*pcSPS*/, ParameterSetManagerDecoder * /*parameterSetManager*/ ) {}80 #else81 80 Void parseSPS ( TComSPS* /*pcSPS*/ ) {} 82 #endif83 81 Void parsePPS ( TComPPS* /*pcPPS*/ 84 82 #if Q0048_CGS_3D_ASYMLUT … … 87 85 ) {} 88 86 89 Void parseSliceHeader ( TComSlice* & /*rpcSlice*/, ParameterSetManagerDecoder* /*parameterSetManager*/) {}87 Void parseSliceHeader ( TComSlice* /*pcSlice*/, ParameterSetManagerDecoder* /*parameterSetManager*/) {} 90 88 Void parseTerminatingBit ( UInt& ruiBit ); 89 Void parseRemainingBytes ( Bool noTrailingBytesExpected); 91 90 Void parseMVPIdx ( Int& riMVPIdx ); 92 91 Void parseSaoMaxUvlc ( UInt& val, UInt maxSymbol ); 93 Void parseSaoMerge ( UInt& ruiVal );92 Void parseSaoMerge ( UInt& ruiVal ); 94 93 Void parseSaoTypeIdx ( UInt& ruiVal ); 95 94 Void parseSaoUflc ( UInt uiLength, UInt& ruiVal ); 96 95 97 96 #if SVC_EXTENSION 98 Void parseSAOBlkParam (SAOBlkParam& saoBlkParam, UInt* saoMaxOffsetQVal, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail );97 Void parseSAOBlkParam (SAOBlkParam& saoBlkParam, UInt* saoMaxOffsetQVal, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail ); 99 98 #else 100 Void parseSAOBlkParam (SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail);99 Void parseSAOBlkParam (SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail); 101 100 #endif 102 Void parseSaoSign(UInt& val); 101 Void parseSaoSign (UInt& val); 102 103 103 private: 104 #if RExt__DECODER_DEBUG_BIT_STATISTICS 105 Void xReadUnarySymbol ( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, const class TComCodingStatisticsClassType &whichStat ); 106 Void xReadUnaryMaxSymbol ( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol, const class TComCodingStatisticsClassType &whichStat ); 107 Void xReadEpExGolomb ( UInt& ruiSymbol, UInt uiCount, const class TComCodingStatisticsClassType &whichStat ); 108 Void xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam, const Bool useLimitedPrefixLength, const ChannelType channelType, const class TComCodingStatisticsClassType &whichStat ); 109 #else 104 110 Void xReadUnarySymbol ( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset ); 105 111 Void xReadUnaryMaxSymbol ( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol ); 106 112 Void xReadEpExGolomb ( UInt& ruiSymbol, UInt uiCount ); 107 Void xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam ); 113 Void xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam, const Bool useLimitedPrefixLength, const ChannelType channelType ); 114 #endif 108 115 private: 109 116 TComInputBitstream* m_pcBitstream; 110 117 TDecBinIf* m_pcTDecBinIf; 111 118 112 119 public: 113 120 114 121 Void parseSkipFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 115 122 Void parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); … … 119 126 Void parsePartSize ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 120 127 Void parsePredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 121 128 122 129 Void parseIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 123 124 130 Void parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 125 131 126 132 Void parseInterDir ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx ); 127 133 Void parseRefFrmIdx ( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList ); 128 134 Void parseMvd ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ); 129 135 136 Void parseCrossComponentPrediction ( class TComTU &rTu, ComponentID compID ); 137 130 138 Void parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ); 131 Void parseQtCbf ( TCom DataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth);139 Void parseQtCbf ( TComTU &rTu, const ComponentID compID, const Bool lowestLevel ); 132 140 Void parseQtRootCbf ( UInt uiAbsPartIdx, UInt& uiQtRootCbf ); 133 141 134 142 Void parseDeltaQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ); 135 143 Void parseChromaQpAdjustment( TComDataCU* cu, UInt absPartIdx, UInt depth ); 144 136 145 Void parseIPCMInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth); 137 146 138 Void parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, TextType eTType, UInt uiScanIdx ); 139 Void parseCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ); 140 Void parseTransformSkipFlags ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType); 141 142 Void updateContextTables( SliceType eSliceType, Int iQp ); 147 Void parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, Int width, Int height, ComponentID component, UInt uiScanIdx ); 148 Void parseCoeffNxN ( class TComTU &rTu, ComponentID compID ); 149 Void parseTransformSkipFlags ( class TComTU &rTu, ComponentID component ); 143 150 144 151 Void parseScalingList ( TComScalingList* /*scalingList*/ ) {} 145 152 153 Void parseExplicitRdpcmMode( TComTU &rTu, ComponentID compID ); 154 146 155 private: 147 UInt m_uiLastDQpNonZero;148 UInt m_uiLastQp;149 150 156 ContextModel m_contextModels[MAX_NUM_CTX_MOD]; 151 157 Int m_numContextModels; … … 165 171 ContextModel3DBuffer m_cCUTransSubdivFlagSCModel; 166 172 ContextModel3DBuffer m_cCUQtRootCbfSCModel; 167 173 168 174 ContextModel3DBuffer m_cCUSigCoeffGroupSCModel; 169 175 ContextModel3DBuffer m_cCUSigSCModel; … … 172 178 ContextModel3DBuffer m_cCUOneSCModel; 173 179 ContextModel3DBuffer m_cCUAbsSCModel; 174 180 175 181 ContextModel3DBuffer m_cMVPIdxSCModel; 176 182 177 183 ContextModel3DBuffer m_cSaoMergeSCModel; 178 184 ContextModel3DBuffer m_cSaoTypeIdxSCModel; 179 185 ContextModel3DBuffer m_cTransformSkipSCModel; 180 186 ContextModel3DBuffer m_CUTransquantBypassFlagSCModel; 187 ContextModel3DBuffer m_explicitRdpcmFlagSCModel; 188 ContextModel3DBuffer m_explicitRdpcmDirSCModel; 189 ContextModel3DBuffer m_cCrossComponentPredictionSCModel; 190 191 ContextModel3DBuffer m_ChromaQpAdjFlagSCModel; 192 ContextModel3DBuffer m_ChromaQpAdjIdcSCModel; 193 194 UInt m_golombRiceAdaptationStatistics[RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS]; 181 195 }; 182 196 -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecSlice.cpp
r880 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 53 53 TDecSlice::TDecSlice() 54 54 { 55 m_pcBufferSbacDecoders = NULL;56 m_pcBufferBinCABACs = NULL;57 m_pcBufferLowLatSbacDecoders = NULL;58 m_pcBufferLowLatBinCABACs = NULL;59 55 } 60 56 61 57 TDecSlice::~TDecSlice() 62 58 { 63 for (std::vector<TDecSbac*>::iterator i = CTXMem.begin(); i != CTXMem.end(); i++)64 {65 delete (*i);66 }67 CTXMem.clear();68 }69 70 Void TDecSlice::initCtxMem( UInt i )71 {72 for (std::vector<TDecSbac*>::iterator j = CTXMem.begin(); j != CTXMem.end(); j++)73 {74 delete (*j);75 }76 CTXMem.clear();77 CTXMem.resize(i);78 59 } 79 60 … … 84 65 Void TDecSlice::destroy() 85 66 { 86 if ( m_pcBufferSbacDecoders )87 {88 delete[] m_pcBufferSbacDecoders;89 m_pcBufferSbacDecoders = NULL;90 }91 if ( m_pcBufferBinCABACs )92 {93 delete[] m_pcBufferBinCABACs;94 m_pcBufferBinCABACs = NULL;95 }96 if ( m_pcBufferLowLatSbacDecoders )97 {98 delete[] m_pcBufferLowLatSbacDecoders;99 m_pcBufferLowLatSbacDecoders = NULL;100 }101 if ( m_pcBufferLowLatBinCABACs )102 {103 delete[] m_pcBufferLowLatBinCABACs;104 m_pcBufferLowLatBinCABACs = NULL;105 }106 67 } 107 68 … … 121 82 #endif 122 83 123 Void TDecSlice::decompressSlice(TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders) 124 { 125 TComDataCU* pcCU; 126 UInt uiIsLast = 0; 127 Int iStartCUEncOrder = max(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU(), rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr()/rpcPic->getNumPartInCU()); 128 Int iStartCUAddr = rpcPic->getPicSym()->getCUOrderMap(iStartCUEncOrder); 129 130 // decoder don't need prediction & residual frame buffer 131 rpcPic->setPicYuvPred( 0 ); 132 rpcPic->setPicYuvResi( 0 ); 133 84 Void TDecSlice::decompressSlice(TComInputBitstream** ppcSubstreams, TComPic* pcPic, TDecSbac* pcSbacDecoder) 85 { 86 TComSlice* pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); 87 88 const Int startCtuTsAddr = pcSlice->getSliceSegmentCurStartCtuTsAddr(); 89 const Int startCtuRsAddr = pcPic->getPicSym()->getCtuTsToRsAddrMap(startCtuTsAddr); 90 const UInt numCtusInFrame = pcPic->getNumberOfCtusInFrame(); 91 92 const UInt frameWidthInCtus = pcPic->getPicSym()->getFrameWidthInCtus(); 93 const Bool depSliceSegmentsEnabled = pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag(); 94 const Bool wavefrontsEnabled = pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag(); 95 96 m_pcEntropyDecoder->setEntropyDecoder ( pcSbacDecoder ); 97 m_pcEntropyDecoder->setBitstream ( ppcSubstreams[0] ); 98 m_pcEntropyDecoder->resetEntropy (pcSlice); 99 100 // decoder doesn't need prediction & residual frame buffer 101 pcPic->setPicYuvPred( 0 ); 102 pcPic->setPicYuvResi( 0 ); 103 134 104 #if ENC_DEC_TRACE 135 105 g_bJustDoIt = g_bEncDecTraceEnable; … … 137 107 DTRACE_CABAC_VL( g_nSymbolCounter++ ); 138 108 DTRACE_CABAC_T( "\tPOC: " ); 139 DTRACE_CABAC_V( rpcPic->getPOC() );109 DTRACE_CABAC_V( pcPic->getPOC() ); 140 110 DTRACE_CABAC_T( "\n" ); 141 111 … … 144 114 #endif 145 115 146 UInt uiTilesAcross = rpcPic->getPicSym()->getNumColumnsMinus1()+1; 147 TComSlice* pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx()); 148 #if !WPP_FIX 149 Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); 150 #endif 151 152 // delete decoders if already allocated in previous slice 153 if (m_pcBufferSbacDecoders) 154 { 155 delete [] m_pcBufferSbacDecoders; 156 } 157 if (m_pcBufferBinCABACs) 158 { 159 delete [] m_pcBufferBinCABACs; 160 } 161 // allocate new decoders based on tile numbaer 162 m_pcBufferSbacDecoders = new TDecSbac [uiTilesAcross]; 163 m_pcBufferBinCABACs = new TDecBinCABAC[uiTilesAcross]; 164 for (UInt ui = 0; ui < uiTilesAcross; ui++) 165 { 166 m_pcBufferSbacDecoders[ui].init(&m_pcBufferBinCABACs[ui]); 167 } 168 //save init. state 169 for (UInt ui = 0; ui < uiTilesAcross; ui++) 170 { 171 m_pcBufferSbacDecoders[ui].load(pcSbacDecoder); 172 } 173 174 // free memory if already allocated in previous call 175 if (m_pcBufferLowLatSbacDecoders) 176 { 177 delete [] m_pcBufferLowLatSbacDecoders; 178 } 179 if (m_pcBufferLowLatBinCABACs) 180 { 181 delete [] m_pcBufferLowLatBinCABACs; 182 } 183 m_pcBufferLowLatSbacDecoders = new TDecSbac [uiTilesAcross]; 184 m_pcBufferLowLatBinCABACs = new TDecBinCABAC[uiTilesAcross]; 185 for (UInt ui = 0; ui < uiTilesAcross; ui++) 186 { 187 m_pcBufferLowLatSbacDecoders[ui].init(&m_pcBufferLowLatBinCABACs[ui]); 188 } 189 //save init. state 190 for (UInt ui = 0; ui < uiTilesAcross; ui++) 191 { 192 m_pcBufferLowLatSbacDecoders[ui].load(pcSbacDecoder); 193 } 194 195 UInt uiWidthInLCUs = rpcPic->getPicSym()->getFrameWidthInCU(); 196 //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU(); 197 198 #if WPP_FIX 199 UInt uiTileCol; 200 UInt uiTileLCUX; 201 const Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag(); 202 const UInt startTileIdx=rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr); 203 TComTile *pCurrentTile=rpcPic->getPicSym()->getTComTile(startTileIdx); 204 UInt uiTileStartLCU = pCurrentTile->getFirstCUAddr(); // Code tidy 205 206 // The first LCU of the slice is the first coded substream, but the global substream number, as calculated by getSubstreamForLCUAddr may be higher. 116 // The first CTU of the slice is the first coded substream, but the global substream number, as calculated by getSubstreamForCtuAddr may be higher. 207 117 // This calculates the common offset for all substreams in this slice. 208 const UInt subStreamOffset=rpcPic->getSubstreamForLCUAddr(iStartCUAddr, true, pcSlice); 209 #else 210 UInt uiCol=0, uiLin=0, uiSubStrm=0; 211 212 UInt uiTileCol; 213 UInt uiTileStartLCU; 214 UInt uiTileLCUX; 215 Int iNumSubstreamsPerTile = 1; // if independent. 216 Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag(); 217 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr(); 218 #endif 219 if( depSliceSegmentsEnabled ) 220 { 221 #if WPP_FIX 222 if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) && iStartCUAddr != uiTileStartLCU) // Code tidy // Is this a dependent slice segment and not the start of a tile? 223 #else 224 if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) && 225 iStartCUAddr != rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr()) 226 #endif 227 { 228 if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) 229 { 230 #if WPP_FIX 231 uiTileCol = startTileIdx % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // Code tidy 232 #else 233 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); 234 #endif 235 m_pcBufferSbacDecoders[uiTileCol].loadContexts( CTXMem[1] );//2.LCU 236 #if WPP_FIX 237 if ( pCurrentTile->getTileWidth() < 2) 118 const UInt subStreamOffset=pcPic->getSubstreamForCtuAddr(startCtuRsAddr, true, pcSlice); 119 120 121 if (depSliceSegmentsEnabled) 122 { 123 // modify initial contexts with previous slice segment if this is a dependent slice. 124 const UInt startTileIdx=pcPic->getPicSym()->getTileIdxMap(startCtuRsAddr); 125 const TComTile *pCurrentTile=pcPic->getPicSym()->getTComTile(startTileIdx); 126 const UInt firstCtuRsAddrOfTile = pCurrentTile->getFirstCtuRsAddr(); 127 128 if( pcSlice->getDependentSliceSegmentFlag() && startCtuRsAddr != firstCtuRsAddrOfTile) 129 { 130 if ( pCurrentTile->getTileWidthInCtus() >= 2 || !wavefrontsEnabled) 131 { 132 pcSbacDecoder->loadContexts(&m_lastSliceSegmentEndContextState); 133 } 134 } 135 } 136 137 // for every CTU in the slice segment... 138 139 Bool isLastCtuOfSliceSegment = false; 140 for( UInt ctuTsAddr = startCtuTsAddr; !isLastCtuOfSliceSegment && ctuTsAddr < numCtusInFrame; ctuTsAddr++) 141 { 142 const UInt ctuRsAddr = pcPic->getPicSym()->getCtuTsToRsAddrMap(ctuTsAddr); 143 const TComTile ¤tTile = *(pcPic->getPicSym()->getTComTile(pcPic->getPicSym()->getTileIdxMap(ctuRsAddr))); 144 const UInt firstCtuRsAddrOfTile = currentTile.getFirstCtuRsAddr(); 145 const UInt tileXPosInCtus = firstCtuRsAddrOfTile % frameWidthInCtus; 146 const UInt tileYPosInCtus = firstCtuRsAddrOfTile / frameWidthInCtus; 147 const UInt ctuXPosInCtus = ctuRsAddr % frameWidthInCtus; 148 const UInt ctuYPosInCtus = ctuRsAddr / frameWidthInCtus; 149 const UInt uiSubStrm=pcPic->getSubstreamForCtuAddr(ctuRsAddr, true, pcSlice)-subStreamOffset; 150 TComDataCU* pCtu = pcPic->getCtu( ctuRsAddr ); 151 pCtu->initCtu( pcPic, ctuRsAddr ); 152 153 m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiSubStrm] ); 154 155 // set up CABAC contexts' state for this CTU 156 if (ctuRsAddr == firstCtuRsAddrOfTile) 157 { 158 if (ctuTsAddr != startCtuTsAddr) // if it is the first CTU, then the entropy coder has already been reset 159 { 160 m_pcEntropyDecoder->resetEntropy(pcSlice); 161 } 162 } 163 else if (ctuXPosInCtus == tileXPosInCtus && wavefrontsEnabled) 164 { 165 // Synchronize cabac probabilities with upper-right CTU if it's available and at the start of a line. 166 if (ctuTsAddr != startCtuTsAddr) // if it is the first CTU, then the entropy coder has already been reset 167 { 168 m_pcEntropyDecoder->resetEntropy(pcSlice); 169 } 170 TComDataCU *pCtuUp = pCtu->getCtuAbove(); 171 if ( pCtuUp && ((ctuRsAddr%frameWidthInCtus+1) < frameWidthInCtus) ) 172 { 173 TComDataCU *pCtuTR = pcPic->getCtu( ctuRsAddr - frameWidthInCtus + 1 ); 174 if ( pCtu->CUIsFromSameSliceAndTile(pCtuTR) ) 238 175 { 239 CTXMem[0]->loadContexts(pcSbacDecoder); // If tile width is less than 2, need to ensure CTX states get initialised to un-adapted CABAC. Set here, to load a few lines later (!) 176 // Top-right is available, so use it. 177 pcSbacDecoder->loadContexts( &m_entropyCodingSyncContextState ); 240 178 } 241 #else 242 if ( (iStartCUAddr%uiWidthInLCUs+1) >= uiWidthInLCUs ) 243 { 244 uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; 245 uiCol = iStartCUAddr % uiWidthInLCUs; 246 if(uiCol==uiTileLCUX) 247 { 248 CTXMem[0]->loadContexts(pcSbacDecoder); 249 } 250 } 251 #endif 252 } 253 pcSbacDecoder->loadContexts(CTXMem[0] ); //end of depSlice-1 254 #if WPP_FIX 255 pcSbacDecoders[0].loadContexts(pcSbacDecoder); // The first substream used for the slice will always be 0. (The original code was equivalent) 256 #else 257 pcSbacDecoders[uiSubStrm].loadContexts(pcSbacDecoder); 258 #endif 259 } 260 else 261 { 262 if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) 263 { 264 CTXMem[1]->loadContexts(pcSbacDecoder); 265 } 266 CTXMem[0]->loadContexts(pcSbacDecoder); 267 } 268 } 269 for( Int iCUAddr = iStartCUAddr; !uiIsLast && iCUAddr < rpcPic->getNumCUsInFrame(); iCUAddr = rpcPic->getPicSym()->xCalculateNxtCUAddr(iCUAddr) ) 270 { 271 pcCU = rpcPic->getCU( iCUAddr ); 272 pcCU->initCU( rpcPic, iCUAddr ); 273 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(iCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in? 274 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr(); 275 uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; 276 #if WPP_FIX 277 UInt uiCol = iCUAddr % uiWidthInLCUs; 278 UInt uiSubStrm=rpcPic->getSubstreamForLCUAddr(iCUAddr, true, pcSlice)-subStreamOffset; 279 #else 280 uiCol = iCUAddr % uiWidthInLCUs; 281 // The 'line' is now relative to the 1st line in the slice, not the 1st line in the picture. 282 uiLin = (iCUAddr/uiWidthInLCUs)-(iStartCUAddr/uiWidthInLCUs); 283 #endif 284 // inherit from TR if necessary, select substream to use. 285 if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( depSliceSegmentsEnabled && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) )) 286 { 287 #if !WPP_FIX 288 // independent tiles => substreams are "per tile". iNumSubstreams has already been multiplied. 289 iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles(); 290 uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(iCUAddr)*iNumSubstreamsPerTile 291 + uiLin%iNumSubstreamsPerTile; 292 #endif 293 m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiSubStrm] ); 294 // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line. 295 if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())) 296 { 297 // We'll sync if the TR is available. 298 TComDataCU *pcCUUp = pcCU->getCUAbove(); 299 UInt uiWidthInCU = rpcPic->getFrameWidthInCU(); 300 TComDataCU *pcCUTR = NULL; 301 if ( pcCUUp && ((iCUAddr%uiWidthInCU+1) < uiWidthInCU) ) 302 { 303 pcCUTR = rpcPic->getCU( iCUAddr - uiWidthInCU + 1 ); 304 } 305 UInt uiMaxParts = 1<<(pcSlice->getSPS()->getMaxCUDepth()<<1); 306 307 if ( (true/*bEnforceSliceRestriction*/ && 308 ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || 309 ((pcCUTR->getSCUAddr()+uiMaxParts-1) < pcSlice->getSliceCurStartCUAddr()) || 310 ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr))) 311 )) 312 ) 313 { 314 // TR not available. 315 } 316 else 317 { 318 // TR is available, we use it. 319 pcSbacDecoders[uiSubStrm].loadContexts( &m_pcBufferSbacDecoders[uiTileCol] ); 320 } 321 } 322 pcSbacDecoder->load(&pcSbacDecoders[uiSubStrm]); //this load is used to simplify the code (avoid to change all the call to pcSbacDecoders) 323 } 324 #if !WPP_FIX 325 else if ( pcSlice->getPPS()->getNumSubstreams() <= 1 ) 326 { 327 // Set variables to appropriate values to avoid later code change. 328 iNumSubstreamsPerTile = 1; 329 } 330 #endif 331 332 if ( (iCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr()) && // 1st in tile. 333 (iCUAddr!=0) && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr())/rpcPic->getNumPartInCU()) 334 && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr())/rpcPic->getNumPartInCU()) 335 ) // !1st in frame && !1st in slice 336 { 337 if (pcSlice->getPPS()->getNumSubstreams() > 1) 338 { 339 // We're crossing into another tile, tiles are independent. 340 // When tiles are independent, we have "substreams per tile". Each substream has already been terminated, and we no longer 341 // have to perform it here. 342 // For TILES_DECODER, there can be a header at the start of the 1st substream in a tile. These are read when the substreams 343 // are extracted, not here. 344 } 345 else 346 { 347 SliceType sliceType = pcSlice->getSliceType(); 348 if (pcSlice->getCabacInitFlag()) 349 { 350 switch (sliceType) 351 { 352 case P_SLICE: // change initialization table to B_SLICE intialization 353 sliceType = B_SLICE; 354 break; 355 case B_SLICE: // change initialization table to P_SLICE intialization 356 sliceType = P_SLICE; 357 break; 358 default : // should not occur 359 assert(0); 360 } 361 } 362 m_pcEntropyDecoder->updateContextTables( sliceType, pcSlice->getSliceQp() ); 363 } 364 179 } 365 180 } 366 181 … … 371 186 if ( pcSlice->getSPS()->getUseSAO() ) 372 187 { 373 SAOBlkParam& saoblkParam = (rpcPic->getPicSym()->getSAOBlkParam())[iCUAddr]; 374 if (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) 375 { 376 Bool sliceEnabled[NUM_SAO_COMPONENTS]; 377 sliceEnabled[SAO_Y] = pcSlice->getSaoEnabledFlag(); 378 sliceEnabled[SAO_Cb]= sliceEnabled[SAO_Cr]= pcSlice->getSaoEnabledFlagChroma(); 379 188 SAOBlkParam& saoblkParam = (pcPic->getPicSym()->getSAOBlkParam())[ctuRsAddr]; 189 Bool bIsSAOSliceEnabled = false; 190 Bool sliceEnabled[MAX_NUM_COMPONENT]; 191 for(Int comp=0; comp < MAX_NUM_COMPONENT; comp++) 192 { 193 ComponentID compId=ComponentID(comp); 194 sliceEnabled[compId] = pcSlice->getSaoEnabledFlag(toChannelType(compId)) && (comp < pcPic->getNumberValidComponents()); 195 if (sliceEnabled[compId]) bIsSAOSliceEnabled=true; 196 saoblkParam[compId].modeIdc = SAO_MODE_OFF; 197 } 198 if (bIsSAOSliceEnabled) 199 { 380 200 Bool leftMergeAvail = false; 381 201 Bool aboveMergeAvail= false; 382 202 383 203 //merge left condition 384 Int rx = ( iCUAddr % uiWidthInLCUs);204 Int rx = (ctuRsAddr % frameWidthInCtus); 385 205 if(rx > 0) 386 206 { 387 leftMergeAvail = rpcPic->getSAOMergeAvailability(iCUAddr, iCUAddr-1);207 leftMergeAvail = pcPic->getSAOMergeAvailability(ctuRsAddr, ctuRsAddr-1); 388 208 } 389 209 //merge up condition 390 Int ry = ( iCUAddr / uiWidthInLCUs);210 Int ry = (ctuRsAddr / frameWidthInCtus); 391 211 if(ry > 0) 392 212 { 393 aboveMergeAvail = rpcPic->getSAOMergeAvailability(iCUAddr, iCUAddr-uiWidthInLCUs);213 aboveMergeAvail = pcPic->getSAOMergeAvailability(ctuRsAddr, ctuRsAddr-frameWidthInCtus); 394 214 } 395 215 #if SVC_EXTENSION … … 397 217 #else 398 218 pcSbacDecoder->parseSAOBlkParam( saoblkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail); 399 #endif 400 } 401 else 402 { 403 saoblkParam[SAO_Y ].modeIdc = SAO_MODE_OFF; 404 saoblkParam[SAO_Cb].modeIdc = SAO_MODE_OFF; 405 saoblkParam[SAO_Cr].modeIdc = SAO_MODE_OFF; 406 } 407 } 408 409 m_pcCuDecoder->decodeCU ( pcCU, uiIsLast ); 410 m_pcCuDecoder->decompressCU ( pcCU ); 411 219 #endif 220 } 221 } 222 223 m_pcCuDecoder->decodeCtu ( pCtu, isLastCtuOfSliceSegment ); 224 m_pcCuDecoder->decompressCtu ( pCtu ); 225 412 226 #if ENC_DEC_TRACE 413 227 g_bJustDoIt = g_bEncDecTraceDisable; 414 228 #endif 415 pcSbacDecoders[uiSubStrm].load(pcSbacDecoder); 416 417 if ( uiCol == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getRightEdgePosInCU() 418 && pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() 419 && !uiIsLast ) 420 { 421 // Parse end_of_substream_one_bit for WPP case 229 230 //Store probabilities of second CTU in line into buffer 231 if ( ctuXPosInCtus == tileXPosInCtus+1 && wavefrontsEnabled) 232 { 233 m_entropyCodingSyncContextState.loadContexts( pcSbacDecoder ); 234 } 235 236 // Should the sub-stream/stream be terminated after this CTU? 237 // (end of slice-segment, end of tile, end of wavefront-CTU-row) 238 if (isLastCtuOfSliceSegment || 239 ( ctuXPosInCtus + 1 == tileXPosInCtus + currentTile.getTileWidthInCtus() && 240 ( ctuYPosInCtus + 1 == tileYPosInCtus + currentTile.getTileHeightInCtus() || wavefrontsEnabled) 241 ) 242 ) 243 { 422 244 UInt binVal; 423 245 pcSbacDecoder->parseTerminatingBit( binVal ); 424 246 assert( binVal ); 425 } 426 427 //Store probabilities of second LCU in line into buffer 428 if ( (uiCol == uiTileLCUX+1)&& (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) ) 429 { 430 m_pcBufferSbacDecoders[uiTileCol].loadContexts( &pcSbacDecoders[uiSubStrm] ); 431 } 432 if( uiIsLast && depSliceSegmentsEnabled ) 433 { 434 if (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) 435 { 436 CTXMem[1]->loadContexts( &m_pcBufferSbacDecoders[uiTileCol] );//ctx 2.LCU 437 } 438 CTXMem[0]->loadContexts( pcSbacDecoder );//ctx end of dep.slice 439 return; 440 } 441 } 247 #if DECODER_CHECK_SUBSTREAM_AND_SLICE_TRAILING_BYTES 248 pcSbacDecoder->parseRemainingBytes(!isLastCtuOfSliceSegment); 249 #endif 250 251 if (isLastCtuOfSliceSegment) 252 { 253 if(!pcSlice->getDependentSliceSegmentFlag()) 254 { 255 pcSlice->setSliceCurEndCtuTsAddr( ctuTsAddr+1 ); 256 } 257 pcSlice->setSliceSegmentCurEndCtuTsAddr( ctuTsAddr+1 ); 258 break; 259 } 260 } 261 } 262 263 assert(isLastCtuOfSliceSegment == true); 264 265 266 if( depSliceSegmentsEnabled ) 267 { 268 m_lastSliceSegmentEndContextState.loadContexts( pcSbacDecoder );//ctx end of dep.slice 269 } 270 442 271 } 443 272 -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecSlice.h
r834 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 66 66 TDecCu* m_pcCuDecoder; 67 67 68 TDecSbac* m_pcBufferSbacDecoders; ///< line to store temporary contexts, one per column of tiles. 69 TDecBinCABAC* m_pcBufferBinCABACs; 70 TDecSbac* m_pcBufferLowLatSbacDecoders; ///< dependent tiles: line to store temporary contexts, one per column of tiles. 71 TDecBinCABAC* m_pcBufferLowLatBinCABACs; 72 std::vector<TDecSbac*> CTXMem; 68 TDecSbac m_lastSliceSegmentEndContextState; ///< context storage for state at the end of the previous slice-segment (used for dependent slices only). 69 TDecSbac m_entropyCodingSyncContextState; ///< context storate for state of contexts at the wavefront/WPP/entropy-coding-sync second CTU of tile-row 70 73 71 #if SVC_EXTENSION 74 72 UInt* m_saoMaxOffsetQVal; 75 73 #endif 76 74 77 75 public: 78 76 TDecSlice(); … … 86 84 Void create (); 87 85 Void destroy (); 88 89 Void decompressSlice ( TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders ); 90 Void initCtxMem( UInt i ); 91 Void setCtxMem( TDecSbac* sb, Int b ) { CTXMem[b] = sb; } 92 Int getCtxMemSize( ) { return (Int)CTXMem.size(); } 86 87 Void decompressSlice ( TComInputBitstream** ppcSubstreams, TComPic* pcPic, TDecSbac* pcSbacDecoder ); 93 88 }; 94 89 … … 114 109 #else 115 110 ParameterSetMap<TComVPS> m_vpsBuffer; 116 ParameterSetMap<TComSPS> m_spsBuffer; 111 ParameterSetMap<TComSPS> m_spsBuffer; 117 112 ParameterSetMap<TComPPS> m_ppsBuffer; 118 113 #endif -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.cpp
r903 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 38 38 #include "NALread.h" 39 39 #include "TDecTop.h" 40 #if RExt__DECODER_DEBUG_BIT_STATISTICS 41 #include "TLibCommon/TComCodingStatistics.h" 42 #endif 40 43 41 44 #if SVC_EXTENSION … … 64 67 65 68 TDecTop::TDecTop() 69 : m_pDecodedSEIOutputStream(NULL) 66 70 { 67 71 m_pcPic = 0; 68 72 m_iMaxRefPicNum = 0; 69 73 #if ENC_DEC_TRACE 70 g_hTrace = fopen( "TraceDec.txt", "wb" ); 74 if (g_hTrace == NULL) 75 { 76 g_hTrace = fopen( "TraceDec.txt", "wb" ); 77 } 71 78 g_bJustDoIt = g_bEncDecTraceDisable; 72 79 g_nSymbolCounter = 0; … … 74 81 m_associatedIRAPType = NAL_UNIT_INVALID; 75 82 m_pocCRA = 0; 76 m_pocRandomAccess = MAX_INT; 83 m_pocRandomAccess = MAX_INT; 77 84 #if !SVC_EXTENSION 78 85 m_prevPOC = MAX_INT; … … 91 98 m_prevSliceSkipped = false; 92 99 m_skippedPOC = 0; 93 #if SETTING_NO_OUT_PIC_PRIOR94 100 m_bFirstSliceInBitstream = true; 95 101 m_lastPOCNoOutputPriorPics = -1; 96 102 m_craNoRaslOutputFlag = false; 97 103 m_isNoOutputPriorPics = false; 98 #endif99 104 #if Q0177_EOS_CHECKS 100 105 m_isLastNALWasEos = false; … … 129 134 { 130 135 #if ENC_DEC_TRACE 131 fclose( g_hTrace ); 136 if (g_hTrace != stdout) 137 { 138 fclose( g_hTrace ); 139 } 132 140 #endif 133 141 #if Q0048_CGS_3D_ASYMLUT … … 155 163 { 156 164 m_cGopDecoder.destroy(); 157 165 158 166 delete m_apcSlicePilot; 159 167 m_apcSlicePilot = NULL; 160 168 161 169 m_cSliceDecoder.destroy(); 162 170 #if SVC_EXTENSION … … 189 197 } 190 198 191 #if SVC_EXTENSION192 #if !REPN_FORMAT_IN_VPS193 Void TDecTop::xInitILRP(TComSPS *pcSPS)194 #else195 Void TDecTop::xInitILRP(TComSlice *slice)196 #endif197 {198 #if REPN_FORMAT_IN_VPS199 TComSPS* pcSPS = slice->getSPS();200 Int bitDepthY = slice->getBitDepthY();201 Int bitDepthC = slice->getBitDepthC();202 Int picWidth = slice->getPicWidthInLumaSamples();203 Int picHeight = slice->getPicHeightInLumaSamples();204 #endif205 if(m_layerId>0)206 {207 #if REPN_FORMAT_IN_VPS208 g_bitDepthY = bitDepthY;209 g_bitDepthC = bitDepthC;210 #else211 g_bitDepthY = pcSPS->getBitDepthY();212 g_bitDepthC = pcSPS->getBitDepthC();213 #endif214 g_uiMaxCUWidth = pcSPS->getMaxCUWidth();215 g_uiMaxCUHeight = pcSPS->getMaxCUHeight();216 g_uiMaxCUDepth = pcSPS->getMaxCUDepth();217 g_uiAddCUDepth = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() );218 219 Int numReorderPics[MAX_TLAYER];220 #if R0156_CONF_WINDOW_IN_REP_FORMAT221 Window &conformanceWindow = slice->getConformanceWindow();222 #else223 Window &conformanceWindow = pcSPS->getConformanceWindow();224 #endif225 Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window();226 227 for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++)228 {229 #if USE_DPB_SIZE_TABLE230 if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 )231 {232 assert( this->getLayerId() == 0 );233 numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer);234 }235 else236 {237 TComVPS *vps = slice->getVPS();238 // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures.239 numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer);240 }241 #else242 numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer);243 #endif244 }245 246 if (m_cIlpPic[0] == NULL)247 {248 for (Int j=0; j < m_numDirectRefLayers; j++)249 {250 251 m_cIlpPic[j] = new TComPic;252 253 #if AUXILIARY_PICTURES254 #if REPN_FORMAT_IN_VPS255 m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);256 #else257 m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), pcSPS->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);258 #endif259 #else260 #if REPN_FORMAT_IN_VPS261 m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);262 #else263 m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);264 #endif265 #endif266 for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++)267 {268 m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i);269 }270 }271 }272 }273 }274 #endif275 276 199 Void TDecTop::deletePicBuffer ( ) 277 200 { 278 201 TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); 279 202 Int iSize = Int( m_cListPic.size() ); 280 203 281 204 for (Int i = 0; i < iSize; i++ ) 282 205 { … … 292 215 #else 293 216 pcPic->destroy(); 294 217 295 218 delete pcPic; 296 219 pcPic = NULL; 297 220 #endif 298 221 } 299 222 300 223 m_cSAO.destroy(); 301 224 302 225 m_cLoopFilter. destroy(); 303 226 … … 318 241 Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window(); 319 242 320 for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) 243 for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) 321 244 { 322 245 #if USE_DPB_SIZE_TABLE … … 409 332 #if O0194_DIFFERENT_BITDEPTH_EL_BL 410 333 UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, i); 411 Bool sameBitDepths = ( g_bitDepth YLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );334 Bool sameBitDepths = ( g_bitDepthLayer[CHANNEL_TYPE_LUMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId] ) && ( g_bitDepthLayer[CHANNEL_TYPE_CHROMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_CHROMA][refLayerId] ); 412 335 413 336 #if REF_IDX_MFM 414 if( pcPicYuvRecBase->getWidth( ) == pcSlice->getPicWidthInLumaSamples() && pcPicYuvRecBase->getHeight() == pcSlice->getPicHeightInLumaSamples() && equalOffsets && zeroPhase )337 if( pcPicYuvRecBase->getWidth(COMPONENT_Y) == pcSlice->getPicWidthInLumaSamples() && pcPicYuvRecBase->getHeight(COMPONENT_Y) == pcSlice->getPicHeightInLumaSamples() && equalOffsets && zeroPhase ) 415 338 { 416 339 rpcPic->setEqualPictureSizeAndOffsetFlag( i, true ); … … 469 392 } 470 393 471 #if AUXILIARY_PICTURES472 394 #if REPN_FORMAT_IN_VPS 473 395 rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, … … 477 399 conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); 478 400 #endif 479 #else480 #if REPN_FORMAT_IN_VPS481 rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,482 conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);483 #else484 rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,485 conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);486 #endif487 #endif488 401 489 402 #else //SVC_EXTENSION 490 rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,403 rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, 491 404 conformanceWindow, defaultDisplayWindow, numReorderPics, true); 492 405 #endif //SVC_EXTENSION 493 406 494 407 m_cListPic.pushBack( rpcPic ); 495 408 496 409 return; 497 410 } 498 411 499 412 Bool bBufferIsAvailable = false; 500 413 TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); … … 520 433 } 521 434 } 522 435 523 436 if ( !bBufferIsAvailable ) 524 437 { … … 531 444 532 445 #if SVC_EXTENSION 533 #if AUXILIARY_PICTURES534 446 #if REPN_FORMAT_IN_VPS 535 447 rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, … … 539 451 conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); 540 452 #endif 541 #else542 #if REPN_FORMAT_IN_VPS543 rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,544 conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);545 546 #else547 rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,548 conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);549 #endif550 #endif551 453 #else //SVC_EXTENSION 552 rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,454 rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, 553 455 conformanceWindow, defaultDisplayWindow, numReorderPics, true); 554 456 #endif //SVC_EXTENSION … … 562 464 return; 563 465 } 564 565 TComPic* &pcPic = m_pcPic;466 467 TComPic* pcPic = m_pcPic; 566 468 567 469 // Execute Deblock + Cleanup 470 568 471 m_cGopDecoder.filterPicture(pcPic); 569 472 570 473 TComSlice::sortPicList( m_cListPic ); // sorting for application output 571 474 poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); 572 rpcListPic = &m_cListPic; 573 m_cCuDecoder.destroy(); 475 rpcListPic = &m_cListPic; 476 m_cCuDecoder.destroy(); 574 477 m_bFirstSliceInPicture = true; 575 478 … … 577 480 } 578 481 579 #if SETTING_NO_OUT_PIC_PRIOR 580 Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic) 482 Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>* pcListPic) 581 483 { 582 if (! rpcListPic || !m_isNoOutputPriorPics) return;583 584 TComList<TComPic*>::iterator iterPic = rpcListPic->begin();585 586 while (iterPic != rpcListPic->end())587 { 588 TComPic* &pcPicTmp = *(iterPic++);484 if (!pcListPic || !m_isNoOutputPriorPics) return; 485 486 TComList<TComPic*>::iterator iterPic = pcListPic->begin(); 487 488 while (iterPic != pcListPic->end()) 489 { 490 TComPic* pcPicTmp = *(iterPic++); 589 491 if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC()) 590 492 { … … 593 495 } 594 496 } 595 #endif 596 597 #if EARLY_REF_PIC_MARKING 598 Void TDecTop::earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdSet) 599 { 600 UInt currTid = m_pcPic->getTLayer(); 601 UInt highestTid = (maxTemporalLayer >= 0) ? maxTemporalLayer : (m_pcPic->getSlice(0)->getSPS()->getMaxTLayers() - 1); 602 UInt latestDecLayerId = m_layerId; 603 UInt numTargetDecLayers = 0; 604 Int targetDecLayerIdList[MAX_LAYERS]; 605 UInt latestDecIdx = 0; 606 TComSlice* pcSlice = m_pcPic->getSlice(0); 607 608 if ( currTid != highestTid ) // Marking process is only applicaple for highest decoded TLayer 609 { 610 return; 611 } 612 613 // currPic must be marked as "used for reference" and must be a sub-layer non-reference picture 614 if ( !((pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || 615 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || 616 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || 617 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || 618 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || 619 pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N10 || 620 pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N12 || 621 pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N14) && pcSlice->isReferenced())) 622 { 623 return; 624 } 625 626 if ( targetDecLayerIdSet.size() == 0 ) // Cannot mark if we don't know the number of scalable layers 627 { 628 return; 629 } 630 631 for (std::vector<Int>::iterator it = targetDecLayerIdSet.begin(); it != targetDecLayerIdSet.end(); it++) 632 { 633 if ( latestDecLayerId == (*it) ) 634 { 635 latestDecIdx = numTargetDecLayers; 636 } 637 targetDecLayerIdList[numTargetDecLayers++] = (*it); 638 } 639 640 Int remainingInterLayerReferencesFlag = 0; 641 #if O0225_MAX_TID_FOR_REF_LAYERS 642 for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) 643 { 644 Int jLidx = pcSlice->getVPS()->getLayerIdInVps(targetDecLayerIdList[j]); 645 if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId,jLidx) - 1 ) 646 { 647 #else 648 if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId) - 1 ) 649 { 650 for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) 651 { 652 #endif 653 for ( Int k = 0; k < m_ppcTDecTop[targetDecLayerIdList[j]]->getNumDirectRefLayers(); k++ ) 654 { 655 if ( latestDecIdx == m_ppcTDecTop[targetDecLayerIdList[j]]->getRefLayerId(k) ) 656 { 657 remainingInterLayerReferencesFlag = 1; 658 } 659 } 660 } 661 } 662 663 if ( remainingInterLayerReferencesFlag == 0 ) 664 { 665 pcSlice->setReferenced(false); 666 } 667 } 668 #endif 669 670 Void TDecTop::xCreateLostPicture(Int iLostPoc) 497 498 Void TDecTop::xCreateLostPicture(Int iLostPoc) 671 499 { 672 500 printf("\ninserting lost poc : %d\n",iLostPoc); … … 713 541 } 714 542 cFillPic->setCurrSliceIdx(0); 715 for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++)716 { 717 cFillPic->getC U(i)->initCU(cFillPic,i);543 for(Int ctuRsAddr=0; ctuRsAddr<cFillPic->getNumberOfCtusInFrame(); ctuRsAddr++) 544 { 545 cFillPic->getCtu(ctuRsAddr)->initCtu(cFillPic, ctuRsAddr); 718 546 } 719 547 cFillPic->getSlice(0)->setReferenced(true); … … 731 559 { 732 560 m_parameterSetManagerDecoder.applyPrefetchedPS(); 733 561 734 562 TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId()); 735 563 assert (pps != 0); … … 854 682 855 683 #if O0194_DIFFERENT_BITDEPTH_EL_BL 856 g_bitDepth YLayer[0] = repFormat->getBitDepthVpsLuma();857 g_bitDepth CLayer[0] = repFormat->getBitDepthVpsChroma();684 g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] = repFormat->getBitDepthVpsLuma(); 685 g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] = repFormat->getBitDepthVpsChroma(); 858 686 #endif 859 687 } … … 919 747 #endif 920 748 921 if( pps->getDependentSliceSegmentsEnabledFlag() ) 922 { 923 Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; 924 925 if (m_cSliceDecoder.getCtxMemSize() != NumCtx) 926 { 927 m_cSliceDecoder.initCtxMem(NumCtx); 928 for ( UInt st = 0; st < NumCtx; st++ ) 929 { 930 TDecSbac* ctx = NULL; 931 ctx = new TDecSbac; 932 ctx->init( &m_cBinCABAC ); 933 m_cSliceDecoder.setCtxMem( ctx, st ); 934 } 935 } 936 } 749 #if R0227_REP_FORMAT_CONSTRAINT //Conformance checking for rep format -- rep format of current picture of current layer shall never be greater rep format defined in VPS for the current layer 750 if ( activeVPS->getVpsExtensionFlag() == 1 && (m_apcSlicePilot->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) ) 751 { 752 UInt layerId = m_apcSlicePilot->getLayerId(); 753 assert( sps->getPicWidthInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getPicWidthVpsInLumaSamples() ); 754 assert( sps->getPicHeightInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getPicHeightVpsInLumaSamples() ); 755 assert( sps->getChromaFormatIdc() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getChromaFormatVpsIdc() ); 756 assert( sps->getBitDepth(CHANNEL_TYPE_LUMA) <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getBitDepthVpsLuma() ); 757 assert( sps->getBitDepth(CHANNEL_TYPE_CHROMA) <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId) )->getBitDepthVpsChroma() ); 758 } 759 else if ( activeVPS->getVpsExtensionFlag() == 1 ) 760 { 761 UInt layerId = m_apcSlicePilot->getLayerId(); 762 assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getPicWidthVpsInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getPicWidthVpsInLumaSamples()); 763 assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getPicHeightVpsInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getPicHeightVpsInLumaSamples()); 764 assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getChromaFormatVpsIdc() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getChromaFormatVpsIdc()); 765 assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getBitDepthVpsLuma() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getBitDepthVpsLuma()); 766 assert(activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId))->getBitDepthVpsChroma() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerId))->getBitDepthVpsChroma()); 767 } 768 #endif 937 769 938 770 m_apcSlicePilot->setPPS(pps); 939 771 m_apcSlicePilot->setSPS(sps); 940 772 pps->setSPS(sps); 773 pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : ((pps->getNumTileRowsMinus1() + 1)*(pps->getNumTileColumnsMinus1() + 1))); 774 pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); 775 pps->setMinCuChromaQpAdjSize( sps->getMaxCUWidth() >> ( pps->getMaxCuChromaQpAdjDepth()) ); 776 777 for (UInt channel = 0; channel < MAX_NUM_CHANNEL_TYPE; channel++) 778 { 941 779 #if REPN_FORMAT_IN_VPS 942 pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : 1); 943 #else 944 pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : 1); 945 #endif 946 pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); 947 948 #if REPN_FORMAT_IN_VPS 949 g_bitDepthY = m_apcSlicePilot->getBitDepthY(); 950 g_bitDepthC = m_apcSlicePilot->getBitDepthC(); 951 #else 952 g_bitDepthY = sps->getBitDepthY(); 953 g_bitDepthC = sps->getBitDepthC(); 954 #endif 780 g_bitDepth[channel] = isLuma(ChannelType(channel)) ? m_apcSlicePilot->getBitDepthY() : m_apcSlicePilot->getBitDepthC(); 781 #else 782 g_bitDepth[channel] = sps->getBitDepth(ChannelType(channel)); 783 #endif 784 785 if (sps->getUseExtendedPrecision()) g_maxTrDynamicRange[channel] = std::max<Int>(15, (g_bitDepth[channel] + 6)); 786 else g_maxTrDynamicRange[channel] = 15; 787 } 955 788 g_uiMaxCUWidth = sps->getMaxCUWidth(); 956 789 g_uiMaxCUHeight = sps->getMaxCUHeight(); 957 790 g_uiMaxCUDepth = sps->getMaxCUDepth(); 958 g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() );791 g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() + (Int)getMaxCUDepthOffset(sps->getChromaFormatIdc(), sps->getQuadtreeTULog2MinSize())); 959 792 960 793 for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++) … … 970 803 m_cSAO.destroy(); 971 804 #if REPN_FORMAT_IN_VPS 972 #if AUXILIARY_PICTURES 973 m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); 974 #else 975 m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); 976 #endif 977 #else 978 m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); 805 m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), pps->getSaoOffsetBitShift(CHANNEL_TYPE_LUMA), pps->getSaoOffsetBitShift(CHANNEL_TYPE_CHROMA) ); 979 806 #endif 980 807 m_cLoopFilter.create( sps->getMaxCUDepth() ); … … 991 818 #endif 992 819 { 993 TComPic*& pcPic = m_pcPic;994 820 #if SVC_EXTENSION 995 821 m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) ); … … 1009 835 if (m_bFirstSliceInPicture) 1010 836 { 1011 m_uiSliceIdx 837 m_uiSliceIdx = 0; 1012 838 } 1013 839 else 1014 840 { 1015 m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) );841 m_apcSlicePilot->copySliceInfo( m_pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); 1016 842 } 1017 843 m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); … … 1027 853 m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); 1028 854 m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); 1029 1030 855 m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS 1031 856 m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); 857 858 #if ENC_DEC_TRACE 859 const UInt64 originalSymbolCount = g_nSymbolCounter; 860 #endif 1032 861 1033 862 #if SVC_EXTENSION … … 1040 869 1041 870 // set POC for dependent slices in skipped pictures 1042 if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) 871 if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) 1043 872 { 1044 873 m_apcSlicePilot->setPOC(m_skippedPOC); … … 1048 877 m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); 1049 878 1050 #if SETTING_NO_OUT_PIC_PRIOR1051 879 //For inference of NoOutputOfPriorPicsFlag 1052 880 if (m_apcSlicePilot->getRapPicFlag()) … … 1086 914 } 1087 915 1088 //TODO: HENDRY -- Probably do the checking for max number of positive and negative pics here1089 1090 1091 916 //For inference of PicOutputFlag 1092 917 if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R) … … 1097 922 } 1098 923 } 1099 #endif 1100 1101 #if FIX_POC_CRA_NORASL_OUTPUT 924 1102 925 if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1 1103 926 { … … 1105 928 m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) ); 1106 929 } 1107 #endif1108 930 1109 931 // Skip pictures due to random access … … 1507 1329 #endif 1508 1330 #if POC_RESET_IDC_DECODER 1509 if ( m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId || m_parseIdc == 1) && !m_bFirstSliceInSequence )1510 #else 1511 if ( m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence )1331 if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (bNewPOC || m_layerId!=m_uiPrevLayerId || m_parseIdc == 1) && !m_bFirstSliceInSequence ) 1332 #else 1333 if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence ) 1512 1334 #endif 1513 1335 { … … 1547 1369 1548 1370 // actual decoding starts here 1549 1371 xActivateParameterSets(); 1550 1372 1551 1373 #if REPN_FORMAT_IN_VPS … … 1555 1377 xInitILRP(m_apcSlicePilot); 1556 1378 #endif 1557 if ( m_apcSlicePilot->isNextSlice())1379 if (!m_apcSlicePilot->getDependentSliceSegmentFlag()) 1558 1380 { 1559 1381 m_prevPOC = m_apcSlicePilot->getPOC(); … … 1562 1384 } 1563 1385 m_bFirstSliceInSequence = false; 1564 #if SETTING_NO_OUT_PIC_PRIOR1565 1386 m_bFirstSliceInBitstream = false; 1566 #endif1567 1387 #if POC_RESET_FLAG 1568 1388 // This operation would do the following: … … 1670 1490 #else //SVC_EXTENSION 1671 1491 //we should only get a different poc for a new picture (with CTU address==0) 1672 if ( m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCUAddr()!=0))1492 if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() != 0)) 1673 1493 { 1674 1494 printf ("Warning, the first slice of a picture might have been lost!\n"); 1675 1495 } 1496 1676 1497 // exit when a new picture is found 1677 if ( m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence)1498 if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() == 0 && !m_bFirstSliceInPicture) ) 1678 1499 { 1679 1500 if (m_prevPOC >= m_pocRandomAccess) 1680 1501 { 1681 1502 m_prevPOC = m_apcSlicePilot->getPOC(); 1503 #if ENC_DEC_TRACE 1504 //rewind the trace counter since we didn't actually decode the slice 1505 g_nSymbolCounter = originalSymbolCount; 1506 #endif 1682 1507 return true; 1683 1508 } … … 1688 1513 xActivateParameterSets(); 1689 1514 1690 if ( m_apcSlicePilot->isNextSlice())1515 if (!m_apcSlicePilot->getDependentSliceSegmentFlag()) 1691 1516 { 1692 1517 m_prevPOC = m_apcSlicePilot->getPOC(); 1693 1518 } 1694 1519 m_bFirstSliceInSequence = false; 1520 m_bFirstSliceInBitstream = false; 1695 1521 #endif //SVC_EXTENSION 1696 1522 //detect lost reference picture and insert copy of earlier frame. … … 1715 1541 if( pFile->good() ) 1716 1542 { 1717 Bool is16bit = g_bitDepth YLayer[0] > 8 || g_bitDepthCLayer[0] > 8;1718 UInt uiWidth = pBLPic->getPicYuvRec()->getWidth( );1719 UInt uiHeight = pBLPic->getPicYuvRec()->getHeight( );1543 Bool is16bit = g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] > 8 || g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] > 8; 1544 UInt uiWidth = pBLPic->getPicYuvRec()->getWidth(COMPONENT_Y); 1545 UInt uiHeight = pBLPic->getPicYuvRec()->getHeight(COMPONENT_Y); 1720 1546 1721 1547 Int len = uiWidth * (is16bit ? 2 : 1); … … 1731 1557 1732 1558 // read Y component 1733 Pel* pPel = pBLPic->getPicYuvRec()->get LumaAddr();1734 UInt uiStride = pBLPic->getPicYuvRec()->getStride( );1559 Pel* pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Y); 1560 UInt uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Y); 1735 1561 for( Int i = 0; i < uiHeight; i++ ) 1736 1562 { … … 1760 1586 1761 1587 // read Cb component 1762 pPel = pBLPic->getPicYuvRec()->get CbAddr();1763 uiStride = pBLPic->getPicYuvRec()->get CStride();1588 pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Cb); 1589 uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Cb); 1764 1590 for( Int i = 0; i < uiHeight; i++ ) 1765 1591 { … … 1785 1611 1786 1612 // read Cr component 1787 pPel = pBLPic->getPicYuvRec()->get CrAddr();1788 uiStride = pBLPic->getPicYuvRec()->get CStride();1613 pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Cr); 1614 uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Cr); 1789 1615 for( Int i = 0; i < uiHeight; i++ ) 1790 1616 { … … 1825 1651 #endif 1826 1652 // Buffer initialize for prediction. 1827 m_cPrediction.initTempBuff( );1653 m_cPrediction.initTempBuff(m_apcSlicePilot->getSPS()->getChromaFormatIdc()); 1828 1654 #if ALIGNED_BUMPING 1829 1655 m_apcSlicePilot->checkLeadingPictureRestrictions(m_cListPic); … … 1832 1658 #endif 1833 1659 // Get a new picture buffer 1834 xGetNewPicBuffer (m_apcSlicePilot, pcPic);1660 xGetNewPicBuffer (m_apcSlicePilot, m_pcPic); 1835 1661 1836 1662 #if POC_RESET_IDC_DECODER 1837 pcPic->setCurrAuFlag( true );1663 m_pcPic->setCurrAuFlag( true ); 1838 1664 #if POC_RESET_RESTRICTIONS 1839 if( pcPic->getLayerId() > 0 && m_apcSlicePilot->isIDR() && !m_nonBaseIdrPresentFlag )1665 if( m_pcPic->getLayerId() > 0 && m_apcSlicePilot->isIDR() && !m_nonBaseIdrPresentFlag ) 1840 1666 { 1841 1667 // IDR picture with nuh_layer_id > 0 present … … 1860 1686 m_checkPocRestrictionsForCurrAu = true; 1861 1687 m_pocResetIdcOrCurrAu = m_apcSlicePilot->getPocResetIdc(); 1862 if( pcPic->getLayerId() == 0 )1688 if( m_pcPic->getLayerId() == 0 ) 1863 1689 { 1864 1690 // Base layer picture is present … … 1941 1767 if (seiTMVPConstrainsList.size() > 0) 1942 1768 { 1943 assert ( pcPic->getTLayer() == 0 ); //this SEI can present only for AU with Tid equal to 01769 assert ( m_pcPic->getTLayer() == 0 ); //this SEI can present only for AU with Tid equal to 0 1944 1770 SEITMVPConstrains* tmvpConstraintSEI = (SEITMVPConstrains*) *(seiTMVPConstrainsList.begin()); 1945 1771 if ( tmvpConstraintSEI->prev_pics_not_used_flag == 1 ) … … 1950 1776 { 1951 1777 TComPic *refPic = *iterRefPic; 1952 if( ( refPic->getLayerId() == pcPic->getLayerId() ) && refPic->getReconMark() )1778 if( ( refPic->getLayerId() == m_pcPic->getLayerId() ) && refPic->getReconMark() ) 1953 1779 { 1954 1780 for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--) … … 1970 1796 1971 1797 // transfer any SEI messages that have been received to the picture 1972 pcPic->setSEIs(m_SEIs);1798 m_pcPic->setSEIs(m_SEIs); 1973 1799 m_SEIs.clear(); 1974 1800 1975 1801 // Recursive structure 1976 m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight );1802 m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getChromaFormatIdc() ); 1977 1803 #if SVC_EXTENSION 1978 1804 m_cCuDecoder.init ( m_ppcTDecTop,&m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, curLayerId ); … … 1990 1816 { 1991 1817 // Currently only decoding Unit SEI message occurring between VCL NALUs copied 1992 SEIMessages &picSEI = pcPic->getSEIs();1818 SEIMessages &picSEI = m_pcPic->getSEIs(); 1993 1819 SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); 1994 1820 picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); … … 1996 1822 } 1997 1823 } 1998 1824 1999 1825 // Set picture slice pointer 2000 1826 TComSlice* pcSlice = m_apcSlicePilot; 2001 Bool bNextSlice = pcSlice->isNextSlice(); 2002 2003 UInt i; 2004 pcPic->getPicSym()->initTiles(pcSlice->getPPS()); 2005 2006 //generate the Coding Order Map and Inverse Coding Order Map 2007 UInt uiEncCUAddr; 2008 for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) 2009 { 2010 pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr); 2011 pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i); 2012 } 2013 pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); 2014 pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); 2015 2016 //convert the start and end CU addresses of the slice and dependent slice into encoding order 2017 pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) ); 2018 pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) ); 2019 if(pcSlice->isNextSlice()) 2020 { 2021 pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr())); 2022 pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr())); 2023 } 2024 2025 if (m_bFirstSliceInPicture) 2026 { 2027 if(pcPic->getNumAllocatedSlice() != 1) 2028 { 2029 pcPic->clearSliceBuffer(); 1827 1828 m_pcPic->getPicSym()->initTiles(pcSlice->getPPS()); 1829 m_pcPic->getPicSym()->initCtuTsRsAddrMaps(); 1830 1831 // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses. 1832 // Now, having set up the maps, convert them to the correct form. 1833 pcSlice->setSliceSegmentCurStartCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()) ); 1834 pcSlice->setSliceSegmentCurEndCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurEndCtuTsAddr()) ); 1835 if(!pcSlice->getDependentSliceSegmentFlag()) 1836 { 1837 pcSlice->setSliceCurStartCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurStartCtuTsAddr())); 1838 pcSlice->setSliceCurEndCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurEndCtuTsAddr())); 1839 } 1840 1841 if (m_bFirstSliceInPicture) 1842 { 1843 if(m_pcPic->getNumAllocatedSlice() != 1) 1844 { 1845 m_pcPic->clearSliceBuffer(); 2030 1846 } 2031 1847 } 2032 1848 else 2033 1849 { 2034 pcPic->allocateNewSlice();2035 } 2036 assert( pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));2037 m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx);2038 pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx);2039 2040 pcPic->setTLayer(nalu.m_temporalId);1850 m_pcPic->allocateNewSlice(); 1851 } 1852 assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); 1853 m_apcSlicePilot = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx); 1854 m_pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); 1855 1856 m_pcPic->setTLayer(nalu.m_temporalId); 2041 1857 2042 1858 #if SVC_EXTENSION 2043 pcPic->setLayerId(nalu.m_layerId);1859 m_pcPic->setLayerId(nalu.m_layerId); 2044 1860 pcSlice->setLayerId(nalu.m_layerId); 2045 pcSlice->setPic( pcPic);2046 #endif 2047 2048 if ( bNextSlice)1861 pcSlice->setPic(m_pcPic); 1862 #endif 1863 1864 if (!pcSlice->getDependentSliceSegmentFlag()) 2049 1865 { 2050 1866 pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); … … 2063 1879 if( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || ( pcSlice->getVPS()->getSingleLayerForNonIrapFlag() && pcSlice->isIRAP() ) ) 2064 1880 #endif 2065 for( i = 0; i < pcSlice->getNumILRRefIdx(); i++ )1881 for( Int i = 0; i < pcSlice->getNumILRRefIdx(); i++ ) 2066 1882 { 2067 1883 UInt refLayerIdc = i; … … 2124 1940 #if REF_REGION_OFFSET 2125 1941 const Window &windowRL = pcSlice->getPPS()->getRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc)); 2126 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth( ) - windowRL.getWindowLeftOffset() - windowRL.getWindowRightOffset();2127 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight( ) - windowRL.getWindowTopOffset() - windowRL.getWindowBottomOffset();2128 #else 2129 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth( );2130 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight( );1942 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(COMPONENT_Y) - windowRL.getWindowLeftOffset() - windowRL.getWindowRightOffset(); 1943 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(COMPONENT_Y) - windowRL.getWindowTopOffset() - windowRL.getWindowBottomOffset(); 1944 #else 1945 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(COMPONENT_Y); 1946 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(COMPONENT_Y); 2131 1947 #if Q0200_CONFORMANCE_BL_SIZE 2132 1948 Int chromaFormatIdc = pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getChromaFormatIdc(); … … 2136 1952 #endif 2137 1953 #endif 2138 Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();2139 Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset();1954 Int widthEL = m_pcPic->getPicYuvRec()->getWidth(COMPONENT_Y) - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); 1955 Int heightEL = m_pcPic->getPicYuvRec()->getHeight(COMPONENT_Y) - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); 2140 1956 2141 1957 #if RESAMPLING_FIX … … 2188 2004 #endif 2189 2005 #if SVC_EXTENSION 2190 if( pcPic->isSpatialEnhLayer(refLayerIdc) )2006 if( m_pcPic->isSpatialEnhLayer(refLayerIdc) ) 2191 2007 { 2192 2008 // check for the sample prediction picture type … … 2196 2012 #if O0194_JOINT_US_BITSHIFT 2197 2013 #if Q0048_CGS_3D_ASYMLUT 2198 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec,pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );2199 #else 2200 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );2014 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() ); 2015 #else 2016 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() ); 2201 2017 #endif 2202 2018 #else 2203 2019 #if Q0048_CGS_3D_ASYMLUT 2204 2020 #if MOVE_SCALED_OFFSET_TO_PPS 2205 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec,pcPic->getPicYuvRec(), pcSlice->getPPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );2206 #else 2207 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec,pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );2208 #endif 2209 #else 2210 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );2021 m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), pcSlice->getPPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() ); 2022 #else 2023 m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() ); 2024 #endif 2025 #else 2026 m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() ); 2211 2027 #endif 2212 2028 #endif … … 2215 2031 #if Q0048_CGS_3D_ASYMLUT 2216 2032 #if REF_REGION_OFFSET 2217 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec,pcPic->getPicYuvRec(), scalEL, altRL );2218 #else 2219 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec,pcPic->getPicYuvRec(), scalEL );2220 #endif 2221 #else 2222 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),pcPic->getPicYuvRec(), scalEL );2033 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), scalEL, altRL ); 2034 #else 2035 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), scalEL ); 2036 #endif 2037 #else 2038 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), scalEL ); 2223 2039 #endif 2224 2040 #else 2225 2041 #if Q0048_CGS_3D_ASYMLUT 2226 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec,pcPic->getPicYuvRec(), scalEL );2227 #else 2228 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),pcPic->getPicYuvRec(), scalEL );2042 m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), scalEL ); 2043 #else 2044 m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), scalEL ); 2229 2045 #endif 2230 2046 #endif … … 2234 2050 else 2235 2051 { 2236 pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() );2237 } 2238 pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );2052 m_pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() ); 2053 } 2054 pcSlice->setFullPelBaseRec ( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc) ); 2239 2055 #endif //SVC_EXTENSION 2240 2056 } … … 2243 2059 if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) 2244 2060 { 2245 for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )2061 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 2246 2062 { 2247 2063 UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); … … 2275 2091 #endif 2276 2092 2277 pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );2093 pcSlice->setFullPelBaseRec ( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc) ); 2278 2094 } 2279 2095 … … 2374 2190 bLowDelay = false; 2375 2191 } 2376 } 2377 } 2378 2379 pcSlice->setCheckLDC(bLowDelay); 2192 } 2193 } 2194 2195 pcSlice->setCheckLDC(bLowDelay); 2380 2196 } 2381 2197 … … 2384 2200 } 2385 2201 2386 pcPic->setCurrSliceIdx(m_uiSliceIdx);2202 m_pcPic->setCurrSliceIdx(m_uiSliceIdx); 2387 2203 if(pcSlice->getSPS()->getScalingListFlag()) 2388 2204 { … … 2399 2215 pcSlice->setDefaultScalingList(); 2400 2216 } 2401 m_cTrQuant.setScalingListDec(pcSlice->getScalingList() );2217 m_cTrQuant.setScalingListDec(pcSlice->getScalingList(), pcSlice->getSPS()->getChromaFormatIdc()); 2402 2218 m_cTrQuant.setUseScalingList(true); 2403 2219 } 2404 2220 else 2405 2221 { 2406 m_cTrQuant.setFlatScalingList( );2222 m_cTrQuant.setFlatScalingList(pcSlice->getSPS()->getChromaFormatIdc()); 2407 2223 m_cTrQuant.setUseScalingList(false); 2408 2224 } 2409 2225 2410 2226 // Decode a picture 2411 m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic);2227 m_cGopDecoder.decompressSlice(nalu.m_Bitstream, m_pcPic); 2412 2228 2413 2229 #if P0297_VPS_POC_LSB_ALIGNED_FLAG … … 2424 2240 { 2425 2241 TComVPS* vps = new TComVPS(); 2426 2242 2427 2243 m_cEntropyDecoder.decodeVPS( vps ); 2428 m_parameterSetManagerDecoder.storePrefetchedVPS(vps); 2244 m_parameterSetManagerDecoder.storePrefetchedVPS(vps); 2429 2245 } 2430 2246 … … 2433 2249 { 2434 2250 TComSPS* sps = new TComSPS(); 2251 #if O0043_BEST_EFFORT_DECODING 2252 sps->setForceDecodeBitDepth(m_forceDecodeBitDepth); 2253 #endif 2435 2254 sps->setLayerId(m_layerId); 2436 2255 #if SPS_DPB_PARAMS … … 2471 2290 { 2472 2291 TComSPS* sps = new TComSPS(); 2292 #if O0043_BEST_EFFORT_DECODING 2293 sps->setForceDecodeBitDepth(m_forceDecodeBitDepth); 2294 #endif 2473 2295 m_cEntropyDecoder.decodeSPS( sps ); 2474 2296 m_parameterSetManagerDecoder.storePrefetchedSPS(sps); … … 2493 2315 } 2494 2316 #if LAYERS_NOT_PRESENT_SEI 2495 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );2496 #else 2497 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );2317 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2318 #else 2319 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2498 2320 #endif 2499 2321 } … … 2501 2323 { 2502 2324 #if LAYERS_NOT_PRESENT_SEI 2503 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );2504 #else 2505 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );2325 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2326 #else 2327 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2506 2328 #endif 2507 2329 SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); … … 2539 2361 { 2540 2362 #if LAYERS_NOT_PRESENT_SEI 2541 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); 2542 #else 2543 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); 2363 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2364 #else 2365 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2366 2544 2367 #endif 2545 2368 } … … 2547 2370 { 2548 2371 #if LAYERS_NOT_PRESENT_SEI 2549 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );2550 #else 2551 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );2372 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2373 #else 2374 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2552 2375 #endif 2553 2376 SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); … … 2590 2413 #endif 2591 2414 xDecodeVPS(); 2415 #if RExt__DECODER_DEBUG_BIT_STATISTICS 2416 TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0); 2417 #endif 2592 2418 #if Q0177_EOS_CHECKS 2593 2419 m_isLastNALWasEos = false; … … 2613 2439 #endif 2614 2440 return false; 2615 2441 2616 2442 case NAL_UNIT_SPS: 2617 2443 xDecodeSPS(); 2444 #if RExt__DECODER_DEBUG_BIT_STATISTICS 2445 TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0); 2446 #endif 2618 2447 return false; 2619 2448 … … 2624 2453 #endif 2625 2454 ); 2455 #if RExt__DECODER_DEBUG_BIT_STATISTICS 2456 TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0); 2457 #endif 2626 2458 return false; 2627 2459 2628 2460 case NAL_UNIT_PREFIX_SEI: 2629 2461 case NAL_UNIT_SUFFIX_SEI: … … 2673 2505 #endif 2674 2506 break; 2675 2507 2676 2508 case NAL_UNIT_EOS: 2677 2509 #if Q0177_EOS_CHECKS … … 2689 2521 m_pocRandomAccess = MAX_INT; 2690 2522 m_prevPOC = MAX_INT; 2691 m_bFirstSliceInPicture = true;2692 m_bFirstSliceInSequence = true;2693 2523 m_prevSliceSkipped = false; 2694 2524 m_skippedPOC = 0; 2695 2525 return false; 2696 2526 2697 2527 case NAL_UNIT_ACCESS_UNIT_DELIMITER: 2698 2528 // TODO: process AU delimiter 2699 2529 return false; 2700 2530 2701 2531 case NAL_UNIT_EOB: 2702 2532 #if P0130_EOB … … 2708 2538 #endif 2709 2539 return false; 2710 2540 2711 2541 case NAL_UNIT_FILLER_DATA: 2712 2542 #if Q0177_EOS_CHECKS … … 2714 2544 #endif 2715 2545 return false; 2716 2546 2717 2547 case NAL_UNIT_RESERVED_VCL_N10: 2718 2548 case NAL_UNIT_RESERVED_VCL_R11: … … 2721 2551 case NAL_UNIT_RESERVED_VCL_N14: 2722 2552 case NAL_UNIT_RESERVED_VCL_R15: 2723 2553 2724 2554 case NAL_UNIT_RESERVED_IRAP_VCL22: 2725 2555 case NAL_UNIT_RESERVED_IRAP_VCL23: 2726 2556 2727 2557 case NAL_UNIT_RESERVED_VCL24: 2728 2558 case NAL_UNIT_RESERVED_VCL25: … … 2733 2563 case NAL_UNIT_RESERVED_VCL30: 2734 2564 case NAL_UNIT_RESERVED_VCL31: 2735 2565 2736 2566 case NAL_UNIT_RESERVED_NVCL41: 2737 2567 case NAL_UNIT_RESERVED_NVCL42: … … 2760 2590 default: 2761 2591 assert (0); 2592 break; 2762 2593 } 2763 2594 … … 2773 2604 Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) 2774 2605 { 2775 if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) && 2606 if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) && 2776 2607 m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) 2777 2608 { … … 2791 2622 * If the random access point is CRA/CRANT/BLA/BLANT, TFD pictures with POC less than the POC of the random access point are skipped. 2792 2623 * If the random access point is IDR all pictures after the random access point are decoded. 2793 * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC 2794 * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random 2624 * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC 2625 * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random 2795 2626 * access point there is no guarantee that the decoder will not crash. 2796 2627 */ 2797 2628 Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) 2798 2629 { 2799 if (iSkipFrame) 2630 if (iSkipFrame) 2800 2631 { 2801 2632 iSkipFrame--; // decrement the counter … … 2816 2647 m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. 2817 2648 } 2818 else 2649 else 2819 2650 { 2820 2651 static Bool warningMessage = false; … … 2834 2665 } 2835 2666 // if we reach here, then the picture is not skipped. 2836 return false; 2667 return false; 2837 2668 } 2838 2669 2839 2670 #if SVC_EXTENSION 2671 #if !REPN_FORMAT_IN_VPS 2672 Void TDecTop::xInitILRP(TComSPS *pcSPS) 2673 #else 2674 Void TDecTop::xInitILRP(TComSlice *slice) 2675 #endif 2676 { 2677 #if REPN_FORMAT_IN_VPS 2678 TComSPS* pcSPS = slice->getSPS(); 2679 Int bitDepthY = slice->getBitDepthY(); 2680 Int bitDepthC = slice->getBitDepthC(); 2681 Int picWidth = slice->getPicWidthInLumaSamples(); 2682 Int picHeight = slice->getPicHeightInLumaSamples(); 2683 #endif 2684 if(m_layerId>0) 2685 { 2686 #if REPN_FORMAT_IN_VPS 2687 g_bitDepth[CHANNEL_TYPE_LUMA] = bitDepthY; 2688 g_bitDepth[CHANNEL_TYPE_CHROMA] = bitDepthC; 2689 #else 2690 g_bitDepth[CHANNEL_TYPE_LUMA] = pcSPS->getBitDepthY(); 2691 g_bitDepth[CHANNEL_TYPE_CHROMA] = pcSPS->getBitDepthC(); 2692 #endif 2693 g_uiMaxCUWidth = pcSPS->getMaxCUWidth(); 2694 g_uiMaxCUHeight = pcSPS->getMaxCUHeight(); 2695 g_uiMaxCUDepth = pcSPS->getMaxCUDepth(); 2696 g_uiAddCUDepth = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() ); 2697 2698 Int numReorderPics[MAX_TLAYER]; 2699 #if R0156_CONF_WINDOW_IN_REP_FORMAT 2700 Window &conformanceWindow = slice->getConformanceWindow(); 2701 #else 2702 Window &conformanceWindow = pcSPS->getConformanceWindow(); 2703 #endif 2704 Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window(); 2705 2706 for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) 2707 { 2708 #if USE_DPB_SIZE_TABLE 2709 if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 ) 2710 { 2711 assert( this->getLayerId() == 0 ); 2712 numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); 2713 } 2714 else 2715 { 2716 TComVPS *vps = slice->getVPS(); 2717 // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures. 2718 numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer); 2719 } 2720 #else 2721 numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); 2722 #endif 2723 } 2724 2725 if (m_cIlpPic[0] == NULL) 2726 { 2727 for (Int j=0; j < m_numDirectRefLayers; j++) 2728 { 2729 2730 m_cIlpPic[j] = new TComPic; 2731 2732 #if AUXILIARY_PICTURES 2733 #if REPN_FORMAT_IN_VPS 2734 m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); 2735 #else 2736 m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), pcSPS->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); 2737 #endif 2738 #else 2739 #if REPN_FORMAT_IN_VPS 2740 m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); 2741 #else 2742 m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); 2743 #endif 2744 #endif 2745 for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCtusInFrame(); i++) 2746 { 2747 m_cIlpPic[j]->getPicSym()->getCtu(i)->initCtu(m_cIlpPic[j], i); 2748 } 2749 } 2750 } 2751 } 2752 } 2753 2840 2754 #if VPS_EXTN_DIRECT_REF_LAYERS 2841 2755 TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdc ) … … 2902 2816 } 2903 2817 } 2904 2818 #endif 2819 2820 #if EARLY_REF_PIC_MARKING 2821 Void TDecTop::earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdSet) 2822 { 2823 UInt currTid = m_pcPic->getTLayer(); 2824 UInt highestTid = (maxTemporalLayer >= 0) ? maxTemporalLayer : (m_pcPic->getSlice(0)->getSPS()->getMaxTLayers() - 1); 2825 UInt latestDecLayerId = m_layerId; 2826 UInt numTargetDecLayers = 0; 2827 Int targetDecLayerIdList[MAX_LAYERS]; 2828 UInt latestDecIdx = 0; 2829 TComSlice* pcSlice = m_pcPic->getSlice(0); 2830 2831 if ( currTid != highestTid ) // Marking process is only applicaple for highest decoded TLayer 2832 { 2833 return; 2834 } 2835 2836 // currPic must be marked as "used for reference" and must be a sub-layer non-reference picture 2837 if ( !((pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || 2838 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || 2839 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || 2840 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || 2841 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || 2842 pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N10 || 2843 pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N12 || 2844 pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N14) && pcSlice->isReferenced())) 2845 { 2846 return; 2847 } 2848 2849 if ( targetDecLayerIdSet.size() == 0 ) // Cannot mark if we don't know the number of scalable layers 2850 { 2851 return; 2852 } 2853 2854 for (std::vector<Int>::iterator it = targetDecLayerIdSet.begin(); it != targetDecLayerIdSet.end(); it++) 2855 { 2856 if ( latestDecLayerId == (*it) ) 2857 { 2858 latestDecIdx = numTargetDecLayers; 2859 } 2860 targetDecLayerIdList[numTargetDecLayers++] = (*it); 2861 } 2862 2863 Int remainingInterLayerReferencesFlag = 0; 2864 #if O0225_MAX_TID_FOR_REF_LAYERS 2865 for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) 2866 { 2867 Int jLidx = pcSlice->getVPS()->getLayerIdInVps(targetDecLayerIdList[j]); 2868 if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId,jLidx) - 1 ) 2869 { 2870 #else 2871 if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId) - 1 ) 2872 { 2873 for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) 2874 { 2875 #endif 2876 for ( Int k = 0; k < m_ppcTDecTop[targetDecLayerIdList[j]]->getNumDirectRefLayers(); k++ ) 2877 { 2878 if ( latestDecIdx == m_ppcTDecTop[targetDecLayerIdList[j]]->getRefLayerId(k) ) 2879 { 2880 remainingInterLayerReferencesFlag = 1; 2881 } 2882 } 2883 } 2884 } 2885 2886 if ( remainingInterLayerReferencesFlag == 0 ) 2887 { 2888 pcSlice->setReferenced(false); 2889 } 2890 } 2905 2891 #endif 2906 2892 -
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecTop.h
r903 r916 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 69 69 private: 70 70 Int m_iMaxRefPicNum; 71 71 72 72 NalUnitType m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture 73 73 Int m_pocCRA; ///< POC number of the latest CRA picture … … 75 75 76 76 TComList<TComPic*> m_cListPic; // Dynamic buffer 77 ParameterSetManagerDecoder m_parameterSetManagerDecoder; // storage for parameter sets 77 ParameterSetManagerDecoder m_parameterSetManagerDecoder; // storage for parameter sets 78 78 TComSlice* m_apcSlicePilot; 79 79 … … 111 111 Bool m_prevSliceSkipped; 112 112 Int m_skippedPOC; 113 #if SETTING_NO_OUT_PIC_PRIOR114 113 Bool m_bFirstSliceInBitstream; 115 114 Int m_lastPOCNoOutputPriorPics; 116 115 Bool m_isNoOutputPriorPics; 117 116 Bool m_craNoRaslOutputFlag; //value of variable NoRaslOutputFlag of the last CRA pic 118 #endif 117 #if O0043_BEST_EFFORT_DECODING 118 UInt m_forceDecodeBitDepth; 119 #endif 120 std::ostream *m_pDecodedSEIOutputStream; 121 122 #if SVC_EXTENSION 119 123 #if Q0177_EOS_CHECKS 120 124 Bool m_isLastNALWasEos; 121 125 #endif 122 #if SVC_EXTENSION123 126 static UInt m_prevPOC; // POC of the previous slice 124 127 static UInt m_uiPrevLayerId; // LayerId of the previous slice … … 186 189 TDecTop(); 187 190 virtual ~TDecTop(); 188 191 189 192 Void create (); 190 193 Void destroy (); 191 194 192 void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }195 Void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } 193 196 #if Q0074_COLOUR_REMAPPING_SEI 194 197 void setColourRemappingInfoSEIEnabled(Bool enabled) { m_cGopDecoder.setColourRemappingInfoSEIEnabled(enabled); } … … 208 211 209 212 210 Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);211 #if SETTING_NO_OUT_PIC_PRIOR 212 Void checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic); 213 Bool getNoOutputPriorPicsFlag () 213 Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); 214 Void checkNoOutputPriorPics (TComList<TComPic*>* rpcListPic); 215 216 Bool getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; } 214 217 Void setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; } 215 #endif 218 Void setFirstSliceInPicture (bool val) { m_bFirstSliceInPicture = val; } 219 Bool getFirstSliceInSequence () { return m_bFirstSliceInSequence; } 220 Void setFirstSliceInSequence (bool val) { m_bFirstSliceInSequence = val; } 221 #if O0043_BEST_EFFORT_DECODING 222 Void setForceDecodeBitDepth(UInt bitDepth) { m_forceDecodeBitDepth = bitDepth; } 223 #endif 224 Void setDecodedSEIMessageOutputStream(std::ostream *pOpStream) { m_pDecodedSEIOutputStream = pOpStream; } 216 225 217 226 #if SVC_EXTENSION … … 337 346 338 347 339 340 348 //! \} 341 349
Note: See TracChangeset for help on using the changeset viewer.