Changeset 1029 in SHVCSoftware for branches/SHM-dev/source/Lib/TLibDecoder
- Timestamp:
- 26 Feb 2015, 00:21:54 (11 years ago)
- Location:
- branches/SHM-dev
- Files:
-
- 27 edited
-
. (modified) (1 prop)
-
source (modified) (1 prop)
-
source/Lib/TLibDecoder/AnnexBread.cpp (modified) (7 diffs)
-
source/Lib/TLibDecoder/AnnexBread.h (modified) (4 diffs)
-
source/Lib/TLibDecoder/NALread.cpp (modified) (8 diffs)
-
source/Lib/TLibDecoder/NALread.h (modified) (2 diffs)
-
source/Lib/TLibDecoder/SEIread.cpp (modified) (79 diffs)
-
source/Lib/TLibDecoder/SEIread.h (modified) (1 diff)
-
source/Lib/TLibDecoder/SyntaxElementParser.cpp (modified) (11 diffs)
-
source/Lib/TLibDecoder/SyntaxElementParser.h (modified) (5 diffs)
-
source/Lib/TLibDecoder/TDecBinCoder.h (modified) (3 diffs)
-
source/Lib/TLibDecoder/TDecBinCoderCABAC.cpp (modified) (14 diffs)
-
source/Lib/TLibDecoder/TDecBinCoderCABAC.h (modified) (3 diffs)
-
source/Lib/TLibDecoder/TDecCAVLC.cpp (modified) (35 diffs)
-
source/Lib/TLibDecoder/TDecCAVLC.h (modified) (6 diffs)
-
source/Lib/TLibDecoder/TDecCu.cpp (modified) (30 diffs)
-
source/Lib/TLibDecoder/TDecCu.h (modified) (5 diffs)
-
source/Lib/TLibDecoder/TDecEntropy.cpp (modified) (22 diffs)
-
source/Lib/TLibDecoder/TDecEntropy.h (modified) (7 diffs)
-
source/Lib/TLibDecoder/TDecGop.cpp (modified) (21 diffs)
-
source/Lib/TLibDecoder/TDecGop.h (modified) (4 diffs)
-
source/Lib/TLibDecoder/TDecSbac.cpp (modified) (77 diffs)
-
source/Lib/TLibDecoder/TDecSbac.h (modified) (7 diffs)
-
source/Lib/TLibDecoder/TDecSlice.cpp (modified) (8 diffs)
-
source/Lib/TLibDecoder/TDecSlice.h (modified) (4 diffs)
-
source/Lib/TLibDecoder/TDecTop.cpp (modified) (90 diffs)
-
source/Lib/TLibDecoder/TDecTop.h (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev
- Property svn:mergeinfo changed
-
branches/SHM-dev/source
- Property svn:mergeinfo changed
-
branches/SHM-dev/source/Lib/TLibDecoder/AnnexBread.cpp
r595 r1029 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-dev/source/Lib/TLibDecoder/AnnexBread.h
r713 r1029 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-dev/source/Lib/TLibDecoder/NALread.cpp
r815 r1029 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-dev/source/Lib/TLibDecoder/NALread.h
r595 r1029 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-dev/source/Lib/TLibDecoder/SEIread.cpp
r912 r1029 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-dev/source/Lib/TLibDecoder/SEIread.h
r912 r1029 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-dev/source/Lib/TLibDecoder/SyntaxElementParser.cpp
r912 r1029 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 … … 43 43 #include "TLibCommon/TComBitStream.h" 44 44 #include "SyntaxElementParser.h" 45 #if RExt__DECODER_DEBUG_BIT_STATISTICS 46 #include "TLibCommon/TComCodingStatistics.h" 47 #endif 45 48 46 49 #if ENC_DEC_TRACE … … 48 51 Void SyntaxElementParser::xReadCodeTr (UInt length, UInt& rValue, const Char *pSymbolName) 49 52 { 53 #if RExt__DECODER_DEBUG_BIT_STATISTICS 54 xReadCode (length, rValue, pSymbolName); 55 #else 50 56 xReadCode (length, rValue); 57 #endif 51 58 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 52 59 if (length < 10) 53 60 { 54 fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue ); 61 fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue ); 55 62 } 56 63 else … … 63 70 Void SyntaxElementParser::xReadUvlcTr (UInt& rValue, const Char *pSymbolName) 64 71 { 72 #if RExt__DECODER_DEBUG_BIT_STATISTICS 73 xReadUvlc (rValue, pSymbolName); 74 #else 65 75 xReadUvlc (rValue); 66 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 67 fprintf( g_hTrace, "%-50s ue(v) : %u\n", pSymbolName, rValue ); 76 #endif 77 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 78 fprintf( g_hTrace, "%-50s ue(v) : %u\n", pSymbolName, rValue ); 68 79 fflush ( g_hTrace ); 69 80 } … … 71 82 Void SyntaxElementParser::xReadSvlcTr (Int& rValue, const Char *pSymbolName) 72 83 { 73 xReadSvlc(rValue); 74 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 75 fprintf( g_hTrace, "%-50s se(v) : %d\n", pSymbolName, rValue ); 84 #if RExt__DECODER_DEBUG_BIT_STATISTICS 85 xReadSvlc (rValue, pSymbolName); 86 #else 87 xReadSvlc (rValue); 88 #endif 89 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 90 fprintf( g_hTrace, "%-50s se(v) : %d\n", pSymbolName, rValue ); 76 91 fflush ( g_hTrace ); 77 92 } … … 79 94 Void SyntaxElementParser::xReadFlagTr (UInt& rValue, const Char *pSymbolName) 80 95 { 81 xReadFlag(rValue); 82 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 83 fprintf( g_hTrace, "%-50s u(1) : %d\n", pSymbolName, rValue ); 96 #if RExt__DECODER_DEBUG_BIT_STATISTICS 97 xReadFlag (rValue, pSymbolName); 98 #else 99 xReadFlag (rValue); 100 #endif 101 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 102 fprintf( g_hTrace, "%-50s u(1) : %d\n", pSymbolName, rValue ); 84 103 fflush ( g_hTrace ); 85 104 } … … 101 120 // Protected member functions 102 121 // ==================================================================================================================== 103 122 #if RExt__DECODER_DEBUG_BIT_STATISTICS 123 Void SyntaxElementParser::xReadCode (UInt uiLength, UInt& ruiCode, const Char *pSymbolName) 124 #else 104 125 Void SyntaxElementParser::xReadCode (UInt uiLength, UInt& ruiCode) 126 #endif 105 127 { 106 128 assert ( uiLength > 0 ); 107 129 m_pcBitstream->read (uiLength, ruiCode); 108 } 109 130 #if RExt__DECODER_DEBUG_BIT_STATISTICS 131 TComCodingStatistics::IncrementStatisticEP(pSymbolName, uiLength, ruiCode); 132 #endif 133 } 134 135 #if RExt__DECODER_DEBUG_BIT_STATISTICS 136 Void SyntaxElementParser::xReadUvlc( UInt& ruiVal, const Char *pSymbolName) 137 #else 110 138 Void SyntaxElementParser::xReadUvlc( UInt& ruiVal) 139 #endif 111 140 { 112 141 UInt uiVal = 0; … … 114 143 UInt uiLength; 115 144 m_pcBitstream->read( 1, uiCode ); 145 #if RExt__DECODER_DEBUG_BIT_STATISTICS 146 UInt totalLen=1; 147 #endif 116 148 117 149 if( 0 == uiCode ) … … 128 160 129 161 uiVal += (1 << uiLength)-1; 162 #if RExt__DECODER_DEBUG_BIT_STATISTICS 163 totalLen+=uiLength+uiLength; 164 #endif 130 165 } 131 166 132 167 ruiVal = uiVal; 133 } 134 168 #if RExt__DECODER_DEBUG_BIT_STATISTICS 169 TComCodingStatistics::IncrementStatisticEP(pSymbolName, Int(totalLen), ruiVal); 170 #endif 171 } 172 173 #if RExt__DECODER_DEBUG_BIT_STATISTICS 174 Void SyntaxElementParser::xReadSvlc( Int& riVal, const Char *pSymbolName) 175 #else 135 176 Void SyntaxElementParser::xReadSvlc( Int& riVal) 177 #endif 136 178 { 137 179 UInt uiBits = 0; 138 180 m_pcBitstream->read( 1, uiBits ); 181 #if RExt__DECODER_DEBUG_BIT_STATISTICS 182 UInt totalLen=1; 183 #endif 139 184 if( 0 == uiBits ) 140 185 { … … 151 196 uiBits += (1 << uiLength); 152 197 riVal = ( uiBits & 1) ? -(Int)(uiBits>>1) : (Int)(uiBits>>1); 198 #if RExt__DECODER_DEBUG_BIT_STATISTICS 199 totalLen+=uiLength+uiLength; 200 #endif 153 201 } 154 202 else … … 156 204 riVal = 0; 157 205 } 158 } 159 206 #if RExt__DECODER_DEBUG_BIT_STATISTICS 207 TComCodingStatistics::IncrementStatisticEP(pSymbolName, Int(totalLen), riVal); 208 #endif 209 } 210 211 #if RExt__DECODER_DEBUG_BIT_STATISTICS 212 Void SyntaxElementParser::xReadFlag (UInt& ruiCode, const Char *pSymbolName) 213 #else 160 214 Void SyntaxElementParser::xReadFlag (UInt& ruiCode) 215 #endif 161 216 { 162 217 m_pcBitstream->read( 1, ruiCode ); 218 #if RExt__DECODER_DEBUG_BIT_STATISTICS 219 TComCodingStatistics::IncrementStatisticEP(pSymbolName, 1, Int(ruiCode)); 220 #endif 163 221 } 164 222 165 223 #if Q0096_OVERLAY_SEI 166 Void SyntaxElementParser::xReadString (UInt bufSize, UChar *pVal, UInt& rLength) 224 #if RExt__DECODER_DEBUG_BIT_STATISTICS 225 Void SyntaxElementParser::xReadString (UInt bufSize, UChar *pVal, UInt& rLength, const Char *pSymbolName) 226 #else 227 Void SyntaxElementParser::xReadString (UInt bufSize, UChar *pVal, UInt& rLength) 228 #endif 167 229 { 168 230 assert( m_pcBitstream->getNumBitsRead() % 8 == 0 ); //always start reading at a byte-aligned position -
branches/SHM-dev/source/Lib/TLibDecoder/SyntaxElementParser.h
r912 r1029 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) xReadString ( 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 xReadString (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-dev/source/Lib/TLibDecoder/TDecBinCoder.h
r595 r1029 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) = 0;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-dev/source/Lib/TLibDecoder/TDecBinCoderCABAC.cpp
r595 r1029 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-dev/source/Lib/TLibDecoder/TDecBinCoderCABAC.h
r595 r1029 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-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
r1025 r1029 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_CODE( 6, 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 UInt ppsExtension6bits = 0; 345 #endif 346 347 #if !R0042_PROFILE_INDICATION 348 #if POC_RESET_INFO_INFERENCE 349 pcPPS->setExtensionFlag( uiCode ? true : false ); 350 351 if( pcPPS->getExtensionFlag() ) 352 #else 353 if (uiCode) 354 #endif 355 { 356 #if P0166_MODIFIED_PPS_EXTENSION 357 UInt ppsExtensionTypeFlag[8]; 358 for (UInt i = 0; i < 8; i++) 359 { 360 READ_FLAG( ppsExtensionTypeFlag[i], "pps_extension_type_flag" ); 361 } 362 #if !POC_RESET_IDC 363 if (ppsExtensionTypeFlag[1]) 364 { 365 #else 366 if( ppsExtensionTypeFlag[0] ) 367 { 368 READ_FLAG( uiCode, "poc_reset_info_present_flag" ); 369 pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); 370 #if REF_REGION_OFFSET 371 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); 372 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 373 { 374 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); 375 READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); pcPPS->setScaledRefLayerOffsetPresentFlag( i, uiCode ); 376 if (uiCode) 377 { 378 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); 379 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 380 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 381 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 382 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 383 #if P0312_VERT_PHASE_ADJ 384 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); 385 #endif 386 } 387 READ_FLAG( uiCode, "ref_region_offset_present_flag" ); pcPPS->setRefRegionOffsetPresentFlag( i, uiCode ); 388 if (uiCode) 389 { 390 Window& refWindow = pcPPS->getRefLayerWindow(i); 391 READ_SVLC( iCode, "ref_region_left_offset" ); refWindow.setWindowLeftOffset (iCode << 1); 392 READ_SVLC( iCode, "ref_region_top_offset" ); refWindow.setWindowTopOffset (iCode << 1); 393 READ_SVLC( iCode, "ref_region_right_offset" ); refWindow.setWindowRightOffset (iCode << 1); 394 READ_SVLC( iCode, "ref_region_bottom_offset" ); refWindow.setWindowBottomOffset(iCode << 1); 395 } 396 #if R0209_GENERIC_PHASE 397 READ_FLAG( uiCode, "resample_phase_set_present_flag" ); pcPPS->setResamplePhaseSetPresentFlag( i, uiCode ); 398 if (uiCode) 399 { 400 READ_UVLC( uiCode, "phase_hor_luma" ); pcPPS->setPhaseHorLuma ( i, uiCode ); 401 READ_UVLC( uiCode, "phase_ver_luma" ); pcPPS->setPhaseVerLuma ( i, uiCode ); 402 READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); pcPPS->setPhaseHorChroma (i, uiCode - 8); 403 READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); pcPPS->setPhaseVerChroma (i, uiCode - 8); 404 } 405 #endif 406 } 407 #else 408 #if MOVE_SCALED_OFFSET_TO_PPS 409 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); 410 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 411 { 412 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); 413 #if O0098_SCALED_REF_LAYER_ID 414 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); 415 #endif 416 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 417 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 418 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 419 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 420 #if P0312_VERT_PHASE_ADJ 421 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); 422 #endif 423 } 424 #endif 425 #endif 426 #if Q0048_CGS_3D_ASYMLUT 427 READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); 428 pcPPS->setCGSFlag( uiCode ); 429 if( pcPPS->getCGSFlag() ) 430 { 431 xParse3DAsymLUT( pc3DAsymLUT ); 432 pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() ); 433 pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() ); 434 } 435 #endif 436 #endif 437 } 438 #if POC_RESET_INFO_INFERENCE 439 else // Extension type 0 absent 440 { 441 pcPPS->setPocResetInfoPresentFlag( false ); 442 } 443 #endif 444 if (ppsExtensionTypeFlag[7]) 445 { 446 #endif 447 448 while ( xMoreRbspData() ) 449 { 450 READ_FLAG( uiCode, "pps_extension_data_flag"); 451 } 452 #if P0166_MODIFIED_PPS_EXTENSION 453 } 454 #endif 455 } 456 #if POC_RESET_INFO_INFERENCE 457 if( !pcPPS->getExtensionFlag() ) 458 { 459 pcPPS->setPocResetInfoPresentFlag( false ); 460 } 461 #endif 462 #else 331 332 #if SVC_EXTENSION 463 333 pcPPS->setExtensionFlag( uiCode ? true : false ); 464 334 if( pcPPS->getExtensionFlag() ) 465 { 466 READ_FLAG( uiCode, "pps_range_extension_flag" ); 467 assert(uiCode == 0); 468 READ_FLAG( uiCode, "pps_multilayer_extension_flag" ); 469 assert(uiCode == 1); 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 470 394 #if SVC_EXTENSION 471 READ_CODE(6, ppsExtension6bits, "pps_extension_6bits"); 472 #else 473 READ_CODE(6, uiCode, "pps_extension_6bits"); 474 assert(uiCode == 0); 475 #endif 476 477 READ_FLAG( uiCode, "poc_reset_info_present_flag" ); 478 pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); 395 case PPS_EXT__MLAYER: 396 READ_FLAG( uiCode, "poc_reset_info_present_flag" ); 397 pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); 479 398 480 399 #if SCALINGLIST_INFERRING 481 READ_FLAG( uiCode, "pps_infer_scaling_list_flag" );482 pcPPS->setInferScalingListFlag( uiCode );483 484 if( pcPPS->getInferScalingListFlag() )485 {486 READ_CODE( 6, uiCode, "pps_scaling_list_ref_layer_id" );487 pcPPS->setScalingListRefLayerId( uiCode );488 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive489 assert( pcPPS->getScalingListRefLayerId() <= 62 );490 pcPPS->setScalingListPresentFlag( false );491 }400 READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); 401 pcPPS->setInferScalingListFlag( uiCode ); 402 403 if( pcPPS->getInferScalingListFlag() ) 404 { 405 READ_CODE( 6, 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 } 492 411 #endif 493 412 494 413 #if REF_REGION_OFFSET 495 READ_UVLC( uiCode, "num_ref_loc_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode);496 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)497 {498 READ_CODE( 6, uiCode, "ref_loc_offset_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode );499 READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); pcPPS->setScaledRefLayerOffsetPresentFlag( i, uiCode );500 if (uiCode)501 {502 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i);503 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1);504 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1);505 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1);506 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 k = 0; k < pcPPS->getNumScaledRefLayerOffsets(); k++) 416 { 417 READ_CODE( 6, uiCode, "ref_loc_offset_layer_id" ); pcPPS->setScaledRefLayerId( k, uiCode ); 418 READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); pcPPS->setScaledRefLayerOffsetPresentFlag( k, uiCode ); 419 if (uiCode) 420 { 421 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(k); 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); 507 426 #if P0312_VERT_PHASE_ADJ 508 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode);509 #endif 510 }511 READ_FLAG( uiCode, "ref_region_offset_present_flag" ); pcPPS->setRefRegionOffsetPresentFlag( i, uiCode );512 if (uiCode)513 {514 Window& refWindow = pcPPS->getRefLayerWindow(i);515 READ_SVLC( iCode, "ref_region_left_offset" ); refWindow.setWindowLeftOffset (iCode << 1);516 READ_SVLC( iCode, "ref_region_top_offset" ); refWindow.setWindowTopOffset (iCode << 1);517 READ_SVLC( iCode, "ref_region_right_offset" ); refWindow.setWindowRightOffset (iCode << 1);518 READ_SVLC( iCode, "ref_region_bottom_offset" ); refWindow.setWindowBottomOffset(iCode << 1);519 }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( k, uiCode ); 431 if (uiCode) 432 { 433 Window& refWindow = pcPPS->getRefLayerWindow(k); 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 } 520 439 #if R0209_GENERIC_PHASE 521 READ_FLAG( uiCode, "resample_phase_set_present_flag" ); pcPPS->setResamplePhaseSetPresentFlag( i, uiCode );522 if (uiCode)523 {524 READ_UVLC( uiCode, "phase_hor_luma" ); pcPPS->setPhaseHorLuma ( i, uiCode );525 READ_UVLC( uiCode, "phase_ver_luma" ); pcPPS->setPhaseVerLuma ( i, uiCode );526 READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); pcPPS->setPhaseHorChroma (i, uiCode - 8);527 READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); pcPPS->setPhaseVerChroma (i, uiCode - 8);528 }529 #endif 530 }440 READ_FLAG( uiCode, "resample_phase_set_present_flag" ); pcPPS->setResamplePhaseSetPresentFlag( k, uiCode ); 441 if (uiCode) 442 { 443 READ_UVLC( uiCode, "phase_hor_luma" ); pcPPS->setPhaseHorLuma ( k, uiCode ); 444 READ_UVLC( uiCode, "phase_ver_luma" ); pcPPS->setPhaseVerLuma ( k, uiCode ); 445 READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); pcPPS->setPhaseHorChroma (k, uiCode - 8); 446 READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); pcPPS->setPhaseVerChroma (k, uiCode - 8); 447 } 448 #endif 449 } 531 450 #else 532 451 #if MOVE_SCALED_OFFSET_TO_PPS 533 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode);534 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)535 {536 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i);452 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); 453 for(Int k = 0; k < pcPPS->getNumScaledRefLayerOffsets(); k++) 454 { 455 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(k); 537 456 #if O0098_SCALED_REF_LAYER_ID 538 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode );539 #endif 540 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1);541 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1);542 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1);543 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1);457 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( k, 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); 544 463 #if P0312_VERT_PHASE_ADJ 545 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode);546 #endif 547 }464 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(k), uiCode); 465 #endif 466 } 548 467 #endif 549 468 #endif 550 469 #if Q0048_CGS_3D_ASYMLUT 551 READ_FLAG( uiCode , "colour_mapping_enabled_flag" );552 pcPPS->setCGSFlag( uiCode );553 if( pcPPS->getCGSFlag() )554 {470 READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); 471 pcPPS->setCGSFlag( uiCode ); 472 if( pcPPS->getCGSFlag() ) 473 { 555 474 #if R0157_RESTRICT_PPSID_FOR_CGS_LUT 556 // when pps_pic_parameter_set_id greater than or equal to 8, colour_mapping_enabled_flag shall be equal to 0 557 assert( pcPPS->getPPSId() < 8 ); 558 #endif 559 xParse3DAsymLUT( pc3DAsymLUT ); 560 pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() ); 561 pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() ); 562 } 563 #endif 564 } 565 566 #if SVC_EXTENSION 567 if( ppsExtension6bits ) 568 { 569 while( xMoreRbspData() ) 570 { 571 READ_FLAG( uiCode, "pps_extension_data_flag" ); 572 } 573 } 574 #endif 575 #endif 576 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 } 577 499 } 578 500 … … 637 559 READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); 638 560 } 561 639 562 TimingInfo *timingInfo = pcVUI->getTimingInfo(); 640 563 READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); … … 654 577 READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); 655 578 } 579 656 580 READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); 657 581 if( pcVUI->getHrdParametersPresentFlag() ) … … 660 584 } 661 585 } 586 662 587 READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); 663 588 if (pcVUI->getBitstreamRestrictionFlag()) … … 722 647 hrd->setFixedPicRateWithinCvsFlag( i, true ); 723 648 } 649 724 650 hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present 725 651 hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present 652 726 653 if( hrd->getFixedPicRateWithinCvsFlag( i ) ) 727 654 { … … 736 663 READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); 737 664 } 665 738 666 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) 739 667 { 740 668 if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || 741 ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )669 ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) 742 670 { 743 671 for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) … … 757 685 } 758 686 759 #if SVC_EXTENSION && !SPS_DPB_PARAMS760 Void TDecCavlc::parseSPS(TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager)761 #else762 687 Void TDecCavlc::parseSPS(TComSPS* pcSPS) 763 #endif764 688 { 765 689 #if ENC_DEC_TRACE … … 767 691 #endif 768 692 769 #if R0042_PROFILE_INDICATION770 UInt uiTmp = 0;771 Bool bMultiLayerExtSpsFlag;772 #endif773 693 UInt uiCode; 774 694 READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); 695 775 696 #if SVC_EXTENSION 697 UInt uiTmp = 0; 698 776 699 if(pcSPS->getLayerId() == 0) 777 700 { 778 701 #endif 779 READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 );780 assert(uiCode <= 6);702 READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); 703 assert(uiCode <= 6); 781 704 #if SVC_EXTENSION 782 705 } 783 #if R0042_PROFILE_INDICATION784 706 else 785 707 { 786 708 READ_CODE( 3, uiCode, "sps_ext_or_max_sub_layers_minus1" ); uiTmp = uiCode; 787 if(!( pcSPS->getLayerId() != 0 && uiTmp == 7 )) 788 {789 pcSPS->setMaxTLayers(uiTmp+1);790 }791 }792 #endif 793 #if !SPS_DPB_PARAMS 794 if(pcSPS->getLayerId() != 0)795 { 796 pcSPS->setMaxTLayers ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers() );797 }798 #endif 799 #endif 800 709 710 if( uiTmp != 7 ) 711 { 712 pcSPS->setMaxTLayers(uiTmp + 1); 713 } 714 } 715 716 Bool V1CompatibleSPSFlag = !( pcSPS->getLayerId() != 0 && uiTmp == 7 ); 717 718 if( V1CompatibleSPSFlag ) 719 { 720 #endif 721 READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); 722 parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 801 723 #if SVC_EXTENSION 802 #if R0042_PROFILE_INDICATION 803 bMultiLayerExtSpsFlag = ( pcSPS->getLayerId() != 0 && uiTmp == 7 ); 804 #endif 805 #endif 806 807 #if SVC_EXTENSION 808 #if !R0042_PROFILE_INDICATION 809 if(pcSPS->getLayerId() == 0) 810 #else 811 if(!bMultiLayerExtSpsFlag) 812 #endif 813 { 814 #endif 815 READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); 816 #if SVC_EXTENSION 817 } 818 #if !SPS_DPB_PARAMS 819 else 820 { 821 pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() ); 822 } 823 #endif 824 #endif 825 826 #if !Q0177_SPS_TEMP_NESTING_FIX //This part is not needed anymore as it is already covered by implementation in TDecTop::xActivateParameterSets() 724 } 725 #else 827 726 if ( pcSPS->getMaxTLayers() == 1 ) 828 727 { 829 728 // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 830 #if SVC_EXTENSION831 #if !SPS_DPB_PARAMS832 assert( pcSPS->getTemporalIdNestingFlag() == true );833 #endif834 #else835 729 assert( uiCode == 1 ); 836 #endif 837 } 838 #endif 839 840 #ifdef SPS_PTL_FIX 841 #if !R0042_PROFILE_INDICATION 842 if ( pcSPS->getLayerId() == 0) 843 #else 844 if(!bMultiLayerExtSpsFlag) 845 #endif 846 { 847 parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 848 } 849 #else 850 parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 730 } 851 731 #endif 852 732 … … 854 734 assert(uiCode <= 15); 855 735 856 #if REPN_FORMAT_IN_VPS 857 #if !R0042_PROFILE_INDICATION 858 if( pcSPS->getLayerId() > 0 ) 859 #else 860 if( bMultiLayerExtSpsFlag) 861 #endif 736 #if SVC_EXTENSION 737 if( !V1CompatibleSPSFlag ) 862 738 { 863 739 READ_FLAG( uiCode, "update_rep_format_flag" ); 864 740 pcSPS->setUpdateRepFormatFlag( uiCode ? true : false ); 865 #if R0042_PROFILE_INDICATION866 if( bMultiLayerExtSpsFlag && uiCode)741 742 if( pcSPS->getUpdateRepFormatFlag() ) 867 743 { 868 744 READ_CODE(8, uiCode, "sps_rep_format_idx"); 869 745 pcSPS->setUpdateRepFormatIndex(uiCode); 870 746 } 871 #endif872 747 } 873 748 else 874 749 { 875 #if REP_FORMAT_FIX876 750 pcSPS->setUpdateRepFormatFlag( false ); 877 #else 878 pcSPS->setUpdateRepFormatFlag( true ); 879 #endif 880 } 881 882 #if R0042_PROFILE_INDICATION 883 if( !bMultiLayerExtSpsFlag ) 884 { 885 #else 886 #if O0096_REP_FORMAT_INDEX 887 if( pcSPS->getLayerId() == 0 ) 888 #else 889 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 890 #endif 891 #endif 892 { 893 #endif 894 #if AUXILIARY_PICTURES 895 READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); 896 #else 897 READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); 898 #endif 899 assert(uiCode <= 3); 900 // 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 901 assert (uiCode == 1); 902 if( uiCode == 3 ) 903 { 904 READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); 905 } 906 907 READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); 908 READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); 751 #endif 752 READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); 753 assert(uiCode <= 3); 754 755 if( pcSPS->getChromaFormatIdc() == CHROMA_444 ) 756 { 757 READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); 758 } 759 760 READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); 761 READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); 762 READ_FLAG( uiCode, "conformance_window_flag"); 763 if (uiCode != 0) 764 { 765 Window &conf = pcSPS->getConformanceWindow(); 909 766 #if REPN_FORMAT_IN_VPS 910 } 911 #if O0096_REP_FORMAT_INDEX 912 #if !R0042_PROFILE_INDICATION 913 else if ( pcSPS->getUpdateRepFormatFlag() ) 914 { 915 READ_CODE(8, uiCode, "update_rep_format_index"); 916 pcSPS->setUpdateRepFormatIndex(uiCode); 917 } 918 #endif 919 #endif 920 #endif 921 922 #if R0156_CONF_WINDOW_IN_REP_FORMAT 923 #if REPN_FORMAT_IN_VPS 924 #if !R0042_PROFILE_INDICATION 925 #if O0096_REP_FORMAT_INDEX 926 if( pcSPS->getLayerId() == 0 ) 927 #else 928 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 929 #endif 930 #endif 931 { 932 #endif 933 #endif 934 READ_FLAG( uiCode, "conformance_window_flag"); 935 if (uiCode != 0) 936 { 937 Window &conf = pcSPS->getConformanceWindow(); 938 #if REPN_FORMAT_IN_VPS 939 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); 940 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); 941 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); 942 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); 943 #else 944 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 945 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 946 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 947 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 948 #endif 949 } 950 #if R0156_CONF_WINDOW_IN_REP_FORMAT 951 #if REPN_FORMAT_IN_VPS 952 } 953 #endif 954 #endif 955 956 #if REPN_FORMAT_IN_VPS 957 #if !R0042_PROFILE_INDICATION 958 #if O0096_REP_FORMAT_INDEX 959 if( pcSPS->getLayerId() == 0 ) 960 #else 961 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 962 #endif 963 #endif 964 { 965 #endif 966 READ_UVLC( uiCode, "bit_depth_luma_minus8" ); 967 assert(uiCode <= 6); 968 pcSPS->setBitDepthY( uiCode + 8 ); 969 pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); 970 971 READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); 972 assert(uiCode <= 6); 973 pcSPS->setBitDepthC( uiCode + 8 ); 974 pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); 975 #if REPN_FORMAT_IN_VPS 976 } 977 #endif 978 #if R0042_PROFILE_INDICATION 979 } 980 #endif 767 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); 768 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); 769 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); 770 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); 771 #else 772 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 773 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 774 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 775 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 776 #endif 777 } 778 779 READ_UVLC( uiCode, "bit_depth_luma_minus8" ); 780 #if O0043_BEST_EFFORT_DECODING 781 const UInt forceDecodeBitDepth = pcSPS->getForceDecodeBitDepth(); 782 g_bitDepthInStream[CHANNEL_TYPE_LUMA] = 8 + uiCode; 783 if (forceDecodeBitDepth != 0) 784 { 785 uiCode = forceDecodeBitDepth - 8; 786 } 787 #endif 788 assert(uiCode <= 8); 789 790 pcSPS->setBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode); 791 #if O0043_BEST_EFFORT_DECODING 792 pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*(g_bitDepthInStream[CHANNEL_TYPE_LUMA]-8)) ); 793 #else 794 pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*uiCode) ); 795 #endif 796 797 READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); 798 #if O0043_BEST_EFFORT_DECODING 799 g_bitDepthInStream[CHANNEL_TYPE_CHROMA] = 8 + uiCode; 800 if (forceDecodeBitDepth != 0) 801 { 802 uiCode = forceDecodeBitDepth - 8; 803 } 804 #endif 805 assert(uiCode <= 8); 806 pcSPS->setBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode); 807 #if O0043_BEST_EFFORT_DECODING 808 pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*(g_bitDepthInStream[CHANNEL_TYPE_CHROMA]-8)) ); 809 #else 810 pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*uiCode) ); 811 #endif 812 813 #if SVC_EXTENSION 814 } 815 #endif 816 981 817 982 818 READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); 983 819 assert(uiCode <= 12); 984 820 985 #if SPS_DPB_PARAMS 986 #if !R0042_PROFILE_INDICATION 987 if( pcSPS->getLayerId() == 0 ) 988 { 989 #else 990 if( !bMultiLayerExtSpsFlag ) 991 { 992 #endif 993 #endif 994 UInt subLayerOrderingInfoPresentFlag; 995 READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); 996 997 for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) 998 { 999 READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); 1000 pcSPS->setMaxDecPicBuffering( uiCode + 1, i); 1001 READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" ); 1002 pcSPS->setNumReorderPics(uiCode, i); 1003 READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); 1004 pcSPS->setMaxLatencyIncrease( uiCode, i ); 1005 1006 if (!subLayerOrderingInfoPresentFlag) 1007 { 1008 for (i++; i <= pcSPS->getMaxTLayers()-1; i++) 1009 { 1010 pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); 1011 pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); 1012 pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); 1013 } 1014 break; 1015 } 1016 } 1017 #if SPS_DPB_PARAMS 821 #if SVC_EXTENSION 822 if( V1CompatibleSPSFlag ) 823 { 824 #endif 825 UInt subLayerOrderingInfoPresentFlag; 826 READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); 827 828 for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) 829 { 830 READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); 831 pcSPS->setMaxDecPicBuffering( uiCode + 1, i); 832 READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" ); 833 pcSPS->setNumReorderPics(uiCode, i); 834 READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); 835 pcSPS->setMaxLatencyIncrease( uiCode, i ); 836 837 if (!subLayerOrderingInfoPresentFlag) 838 { 839 for (i++; i <= pcSPS->getMaxTLayers()-1; i++) 840 { 841 pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); 842 pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); 843 pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); 844 } 845 break; 846 } 847 } 848 #if SVC_EXTENSION 1018 849 } 1019 850 #endif … … 1023 854 READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); 1024 855 pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); 1025 856 1026 857 if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) 1027 858 { 1028 859 assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); 1029 860 } 1030 861 1031 862 Int maxCUDepthDelta = uiCode; 1032 863 pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); … … 1041 872 1042 873 Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); 1043 pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); 874 pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth + getMaxCUDepthOffset(pcSPS->getChromaFormatIdc(), pcSPS->getQuadtreeTULog2MinSize()) ); 875 1044 876 READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); 1045 1046 877 if(pcSPS->getScalingListFlag()) 1047 878 { 1048 #if SCALINGLIST_INFERRING 1049 #if !R0042_PROFILE_INDICATION 1050 if( pcSPS->getLayerId() > 0 ) 1051 #else 1052 if( bMultiLayerExtSpsFlag ) 1053 #endif 879 #if SVC_EXTENSION 880 if( !V1CompatibleSPSFlag ) 1054 881 { 1055 882 READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setInferScalingListFlag( uiCode ); … … 1068 895 { 1069 896 #endif 1070 READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode );1071 if(pcSPS->getScalingListPresentFlag ())1072 {1073 parseScalingList( pcSPS->getScalingList() );1074 }1075 #if S CALINGLIST_INFERRING897 READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); 898 if(pcSPS->getScalingListPresentFlag ()) 899 { 900 parseScalingList( pcSPS->getScalingList() ); 901 } 902 #if SVC_EXTENSION 1076 903 } 1077 904 #endif … … 1083 910 if( pcSPS->getUsePCM() ) 1084 911 { 1085 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepth Luma (1 + uiCode );1086 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepth Chroma (1 + uiCode );912 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_LUMA, 1 + uiCode ); 913 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_CHROMA, 1 + uiCode ); 1087 914 READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); 1088 915 READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); … … 1116 943 } 1117 944 READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); 945 1118 946 READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); 1119 947 … … 1125 953 } 1126 954 1127 READ_FLAG( uiCode, "sps_extension_ flag");955 READ_FLAG( uiCode, "sps_extension_present_flag"); 1128 956 1129 957 #if SVC_EXTENSION 1130 958 pcSPS->setExtensionFlag( uiCode ? true : false ); 1131 UInt spsExtension6bits = 0;1132 959 1133 960 if( pcSPS->getExtensionFlag() ) 1134 { 1135 #if !R0042_PROFILE_INDICATION 1136 #if O0142_CONDITIONAL_SPS_EXTENSION 1137 UInt spsExtensionTypeFlag[8]; 1138 for (UInt i = 0; i < 8; i++) 1139 { 1140 READ_FLAG( spsExtensionTypeFlag[i], "sps_extension_type_flag" ); 1141 } 1142 if (spsExtensionTypeFlag[1]) 1143 { 1144 parseSPSExtension( pcSPS ); 1145 } 1146 if (spsExtensionTypeFlag[7]) 1147 { 1148 #else 1149 parseSPSExtension( pcSPS ); 1150 READ_FLAG( uiCode, "sps_extension2_flag"); 1151 if(uiCode) 1152 { 1153 #endif 961 #else 962 if (uiCode) 963 #endif 964 { 965 Bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS]; 966 for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) 967 { 968 READ_FLAG( uiCode, "sps_extension_flag[]" ); 969 sps_extension_flags[i] = uiCode!=0; 970 } 971 972 Bool bSkipTrailingExtensionBits=false; 973 for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. 974 { 975 if (sps_extension_flags[i]) 976 { 977 switch (SPSExtensionFlagIndex(i)) 978 { 979 case SPS_EXT__REXT: 980 assert(!bSkipTrailingExtensionBits); 981 982 READ_FLAG( uiCode, "transform_skip_rotation_enabled_flag"); pcSPS->setUseResidualRotation (uiCode != 0); 983 READ_FLAG( uiCode, "transform_skip_context_enabled_flag"); pcSPS->setUseSingleSignificanceMapContext (uiCode != 0); 984 READ_FLAG( uiCode, "residual_dpcm_implicit_enabled_flag"); pcSPS->setUseResidualDPCM(RDPCM_SIGNAL_IMPLICIT, (uiCode != 0)); 985 READ_FLAG( uiCode, "residual_dpcm_explicit_enabled_flag"); pcSPS->setUseResidualDPCM(RDPCM_SIGNAL_EXPLICIT, (uiCode != 0)); 986 READ_FLAG( uiCode, "extended_precision_processing_flag"); pcSPS->setUseExtendedPrecision (uiCode != 0); 987 READ_FLAG( uiCode, "intra_smoothing_disabled_flag"); pcSPS->setDisableIntraReferenceSmoothing (uiCode != 0); 988 READ_FLAG( uiCode, "high_precision_prediction_weighting_flag"); pcSPS->setUseHighPrecisionPredictionWeighting (uiCode != 0); 989 READ_FLAG( uiCode, "golomb_rice_parameter_adaptation_flag"); pcSPS->setUseGolombRiceParameterAdaptation (uiCode != 0); 990 READ_FLAG( uiCode, "cabac_bypass_alignment_enabled_flag"); pcSPS->setAlignCABACBeforeBypass (uiCode != 0); 991 break; 992 #if SVC_EXTENSION 993 case SPS_EXT__MLAYER: 994 parseSPSExtension( pcSPS ); 995 break; 996 #endif 997 default: 998 bSkipTrailingExtensionBits=true; 999 break; 1000 } 1001 } 1002 } 1003 if (bSkipTrailingExtensionBits) 1004 { 1154 1005 while ( xMoreRbspData() ) 1155 1006 { … … 1157 1008 } 1158 1009 } 1159 } 1160 #else 1161 READ_FLAG( uiCode, "sps_range_extension_flag" ); 1162 assert(uiCode == 0); 1163 READ_FLAG( uiCode, "sps_multilayer_extension_flag" ); 1164 assert(uiCode == 1); 1165 READ_CODE(6, spsExtension6bits, "sps_extension_6bits"); 1166 parseSPSExtension( pcSPS ); 1167 } 1168 #endif 1169 if( spsExtension6bits ) 1170 { 1171 while( xMoreRbspData() ) 1172 { 1173 READ_FLAG( uiCode, "sps_extension_data_flag" ); 1174 } 1175 } 1176 #else 1177 if (uiCode) 1178 { 1179 while ( xMoreRbspData() ) 1180 { 1181 READ_FLAG( uiCode, "sps_extension_data_flag"); 1182 } 1183 } 1184 #endif 1185 } 1186 1187 #if SVC_EXTENSION 1188 Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) 1189 { 1190 UInt uiCode; 1191 // more syntax elements to be parsed here 1192 1193 READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); 1194 // Vertical MV component restriction is not used in SHVC CTC 1195 assert( uiCode == 0 ); 1196 1197 #if !MOVE_SCALED_OFFSET_TO_PPS 1198 if( pcSPS->getLayerId() > 0 ) 1199 { 1200 Int iCode; 1201 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); 1202 for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) 1203 { 1204 Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); 1205 #if O0098_SCALED_REF_LAYER_ID 1206 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); 1207 #endif 1208 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 1209 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 1210 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 1211 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 1212 #if P0312_VERT_PHASE_ADJ 1213 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcSPS->setVertPhasePositionEnableFlag( pcSPS->getScaledRefLayerId(i), uiCode); 1214 #endif 1215 } 1216 } 1217 #endif 1218 } 1219 #endif 1010 } 1011 } 1220 1012 1221 1013 Void TDecCavlc::parseVPS(TComVPS* pcVPS) … … 1239 1031 READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( uiCode + 1 ); 1240 1032 #endif 1241 assert( pcVPS->getBaseLayerInternalFlag() || pcVPS->getMaxLayers() > 1);1033 assert( pcVPS->getBaseLayerInternalFlag() || pcVPS->getMaxLayers() > 1 ); 1242 1034 #else 1243 1035 READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); 1244 1036 #endif 1245 READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER);1037 READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER); 1246 1038 READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); 1247 1039 assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); … … 1319 1111 READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); 1320 1112 } 1113 1321 1114 READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); 1322 1115 … … 1383 1176 1384 1177 return; 1178 } 1179 1180 Void TDecCavlc::parseSliceHeader (TComSlice* pcSlice, ParameterSetManagerDecoder *parameterSetManager) 1181 { 1182 UInt uiCode; 1183 Int iCode; 1184 1185 #if ENC_DEC_TRACE 1186 xTraceSliceHeader(pcSlice); 1187 #endif 1188 TComPPS* pps = NULL; 1189 TComSPS* sps = NULL; 1190 1191 UInt firstSliceSegmentInPic; 1192 READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); 1193 if( pcSlice->getRapPicFlag()) 1194 { 1195 READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already 1196 pcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); 1197 } 1198 READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); pcSlice->setPPSId(uiCode); 1199 pps = parameterSetManager->getPrefetchedPPS(uiCode); 1200 //!KS: need to add error handling code here, if PPS is not available 1201 assert(pps!=0); 1202 sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); 1203 //!KS: need to add error handling code here, if SPS is not available 1204 assert(sps!=0); 1205 pcSlice->setSPS(sps); 1206 pcSlice->setPPS(pps); 1207 1208 const ChromaFormat chFmt = sps->getChromaFormatIdc(); 1209 const UInt numValidComp=getNumberValidComponents(chFmt); 1210 const Bool bChroma=(chFmt!=CHROMA_400); 1211 1212 if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) 1213 { 1214 READ_FLAG( uiCode, "dependent_slice_segment_flag" ); pcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); 1215 } 1216 else 1217 { 1218 pcSlice->setDependentSliceSegmentFlag(false); 1219 } 1220 #if REPN_FORMAT_IN_VPS 1221 Int numCTUs = ((pcSlice->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((pcSlice->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); 1222 #else 1223 Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); 1224 #endif 1225 UInt sliceSegmentAddress = 0; 1226 Int bitsSliceSegmentAddress = 0; 1227 while(numCTUs>(1<<bitsSliceSegmentAddress)) 1228 { 1229 bitsSliceSegmentAddress++; 1230 } 1231 1232 if(!firstSliceSegmentInPic) 1233 { 1234 READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); 1235 } 1236 //set uiCode to equal slice start address (or dependent slice start address) 1237 pcSlice->setSliceSegmentCurStartCtuTsAddr( sliceSegmentAddress );// this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet. 1238 pcSlice->setSliceSegmentCurEndCtuTsAddr(numCTUs); // Set end as the last CTU of the picture. 1239 1240 if (!pcSlice->getDependentSliceSegmentFlag()) 1241 { 1242 pcSlice->setSliceCurStartCtuTsAddr(sliceSegmentAddress); // this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet. 1243 pcSlice->setSliceCurEndCtuTsAddr(numCTUs); 1244 } 1245 1246 #if Q0142_POC_LSB_NOT_PRESENT 1247 #if SHM_FIX7 1248 Int iPOClsb = 0; 1249 #endif 1250 #endif 1251 1252 if(!pcSlice->getDependentSliceSegmentFlag()) 1253 { 1254 #if SVC_EXTENSION 1255 #if POC_RESET_FLAG 1256 Int iBits = 0; 1257 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1258 { 1259 READ_FLAG(uiCode, "poc_reset_flag"); pcSlice->setPocResetFlag( uiCode ? true : false ); 1260 iBits++; 1261 } 1262 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1263 { 1264 #if DISCARDABLE_PIC_RPS 1265 READ_FLAG(uiCode, "discardable_flag"); pcSlice->setDiscardableFlag( uiCode ? true : false ); 1266 #else 1267 READ_FLAG(uiCode, "discardable_flag"); // ignored 1268 #endif 1269 iBits++; 1270 } 1271 #if O0149_CROSS_LAYER_BLA_FLAG 1272 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1273 { 1274 READ_FLAG(uiCode, "cross_layer_bla_flag"); pcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); 1275 iBits++; 1276 } 1277 #endif 1278 for (; iBits < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 1279 { 1280 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 1281 } 1282 #else 1283 #if CROSS_LAYER_BLA_FLAG_FIX 1284 Int iBits = 0; 1285 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1286 #else 1287 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) 1288 #endif 1289 { 1290 READ_FLAG(uiCode, "discardable_flag"); // ignored 1291 #if NON_REF_NAL_TYPE_DISCARDABLE 1292 pcSlice->setDiscardableFlag( uiCode ? true : false ); 1293 if (uiCode) 1294 { 1295 assert(pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && 1296 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && 1297 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && 1298 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && 1299 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); 1300 } 1301 #endif 1302 #if CROSS_LAYER_BLA_FLAG_FIX 1303 iBits++; 1304 #endif 1305 } 1306 #if CROSS_LAYER_BLA_FLAG_FIX 1307 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1308 { 1309 READ_FLAG(uiCode, "cross_layer_bla_flag"); pcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); 1310 iBits++; 1311 } 1312 for ( ; iBits < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 1313 #else 1314 for (Int i = 1; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 1315 #endif 1316 { 1317 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 1318 } 1319 #endif 1320 #else //SVC_EXTENSION 1321 for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 1322 { 1323 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 1324 } 1325 #endif //SVC_EXTENSION 1326 1327 READ_UVLC ( uiCode, "slice_type" ); pcSlice->setSliceType((SliceType)uiCode); 1328 if( pps->getOutputFlagPresentFlag() ) 1329 { 1330 READ_FLAG( uiCode, "pic_output_flag" ); pcSlice->setPicOutputFlag( uiCode ? true : false ); 1331 } 1332 else 1333 { 1334 pcSlice->setPicOutputFlag( true ); 1335 } 1336 1337 if( pcSlice->getIdrPicFlag() ) 1338 { 1339 pcSlice->setPOC(0); 1340 TComReferencePictureSet* rps = pcSlice->getLocalRPS(); 1341 rps->setNumberOfNegativePictures(0); 1342 rps->setNumberOfPositivePictures(0); 1343 rps->setNumberOfLongtermPictures(0); 1344 rps->setNumberOfPictures(0); 1345 pcSlice->setRPS(rps); 1346 } 1347 #if N0065_LAYER_POC_ALIGNMENT 1348 #if O0062_POC_LSB_NOT_PRESENT_FLAG 1349 if( ( pcSlice->getLayerId() > 0 && !pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdInVps(pcSlice->getLayerId())) ) || !pcSlice->getIdrPicFlag() ) 1350 #else 1351 if( pcSlice->getLayerId() > 0 || !pcSlice->getIdrPicFlag() ) 1352 #endif 1353 #else 1354 else 1355 #endif 1356 { 1357 READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); 1358 #if POC_RESET_IDC_DECODER 1359 pcSlice->setPicOrderCntLsb( uiCode ); 1360 #endif 1361 #if SVC_EXTENSION 1362 iPOClsb = uiCode; 1363 #else 1364 Int iPOClsb = uiCode; 1365 #endif 1366 Int iPrevPOC = pcSlice->getPrevTid0POC(); 1367 Int iMaxPOClsb = 1<< sps->getBitsForPOC(); 1368 Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); 1369 Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; 1370 Int iPOCmsb; 1371 if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) 1372 { 1373 iPOCmsb = iPrevPOCmsb + iMaxPOClsb; 1374 } 1375 else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) 1376 { 1377 iPOCmsb = iPrevPOCmsb - iMaxPOClsb; 1378 } 1379 else 1380 { 1381 iPOCmsb = iPrevPOCmsb; 1382 } 1383 if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 1384 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 1385 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 1386 { 1387 // For BLA picture types, POCmsb is set to 0. 1388 iPOCmsb = 0; 1389 } 1390 pcSlice->setPOC (iPOCmsb+iPOClsb); 1391 1392 #if N0065_LAYER_POC_ALIGNMENT 1393 } 1394 #if POC_RESET_IDC_DECODER 1395 else 1396 { 1397 pcSlice->setPicOrderCntLsb( 0 ); 1398 } 1399 #endif 1400 if( !pcSlice->getIdrPicFlag() ) 1401 { 1402 #endif 1403 TComReferencePictureSet* rps; 1404 rps = pcSlice->getLocalRPS(); 1405 pcSlice->setRPS(rps); 1406 READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); 1407 if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header 1408 { 1409 parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); 1410 } 1411 else // use reference to short-term reference picture set in PPS 1412 { 1413 Int numBits = 0; 1414 while ((1 << numBits) < pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) 1415 { 1416 numBits++; 1417 } 1418 if (numBits > 0) 1419 { 1420 READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); 1421 } 1422 else 1423 { 1424 uiCode = 0; 1425 1426 } 1427 *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); 1428 } 1429 if(sps->getLongTermRefsPresent()) 1430 { 1431 Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); 1432 UInt numOfLtrp = 0; 1433 UInt numLtrpInSPS = 0; 1434 if (pcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) 1435 { 1436 READ_UVLC( uiCode, "num_long_term_sps"); 1437 numLtrpInSPS = uiCode; 1438 numOfLtrp += numLtrpInSPS; 1439 rps->setNumberOfLongtermPictures(numOfLtrp); 1440 } 1441 Int bitsForLtrpInSPS = 0; 1442 while (pcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) 1443 { 1444 bitsForLtrpInSPS++; 1445 } 1446 READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); 1447 numOfLtrp += uiCode; 1448 rps->setNumberOfLongtermPictures(numOfLtrp); 1449 Int maxPicOrderCntLSB = 1 << pcSlice->getSPS()->getBitsForPOC(); 1450 Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0; 1451 for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) 1452 { 1453 Int pocLsbLt; 1454 if (k < numLtrpInSPS) 1455 { 1456 uiCode = 0; 1457 if (bitsForLtrpInSPS > 0) 1458 { 1459 READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); 1460 } 1461 Int usedByCurrFromSPS=pcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); 1462 1463 pocLsbLt = pcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); 1464 rps->setUsed(j,usedByCurrFromSPS); 1465 } 1466 else 1467 { 1468 READ_CODE(pcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; 1469 READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); 1470 } 1471 READ_FLAG(uiCode,"delta_poc_msb_present_flag"); 1472 Bool mSBPresentFlag = uiCode ? true : false; 1473 if(mSBPresentFlag) 1474 { 1475 READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); 1476 Bool deltaFlag = false; 1477 // First LTRP || First LTRP from SH 1478 if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) 1479 { 1480 deltaFlag = true; 1481 } 1482 if(deltaFlag) 1483 { 1484 deltaPocMSBCycleLT = uiCode; 1485 } 1486 else 1487 { 1488 deltaPocMSBCycleLT = uiCode + prevDeltaMSB; 1489 } 1490 1491 Int pocLTCurr = pcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB 1492 - iPOClsb + pocLsbLt; 1493 rps->setPOC (j, pocLTCurr); 1494 rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLTCurr); 1495 rps->setCheckLTMSBPresent(j,true); 1496 } 1497 else 1498 { 1499 rps->setPOC (j, pocLsbLt); 1500 rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLsbLt); 1501 rps->setCheckLTMSBPresent(j,false); 1502 1503 // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present 1504 if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) 1505 { 1506 deltaPocMSBCycleLT = 0; 1507 } 1508 } 1509 prevDeltaMSB = deltaPocMSBCycleLT; 1510 } 1511 offset += rps->getNumberOfLongtermPictures(); 1512 rps->setNumberOfPictures(offset); 1513 } 1514 #if DPB_CONSTRAINTS 1515 if(pcSlice->getVPS()->getVpsExtensionFlag()==1) 1516 { 1517 #if Q0078_ADD_LAYER_SETS 1518 for (Int ii = 1; ii < (pcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++) // prevent assert error when num_add_layer_sets > 0 1519 #else 1520 for (Int ii=1; ii< pcSlice->getVPS()->getNumOutputLayerSets(); ii++ ) 1521 #endif 1522 { 1523 Int layerSetIdxForOutputLayerSet = pcSlice->getVPS()->getOutputLayerSetIdx( ii ); 1524 Int chkAssert=0; 1525 for(Int kk = 0; kk < pcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++) 1526 { 1527 #if R0235_SMALLEST_LAYER_ID 1528 if( pcSlice->getVPS()->getNecessaryLayerFlag(ii, kk) && pcSlice->getLayerId() == pcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk) ) 1529 #else 1530 if(pcSlice->getLayerId() == pcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk)) 1531 #endif 1532 { 1533 chkAssert=1; 1534 } 1535 } 1536 if(chkAssert) 1537 { 1538 // There may be something wrong here (layer id assumed to be layer idx?) 1539 assert(rps->getNumberOfNegativePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 1540 assert(rps->getNumberOfPositivePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); 1541 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 1542 } 1543 } 1544 1545 1546 } 1547 if(pcSlice->getLayerId() == 0) 1548 { 1549 assert(rps->getNumberOfNegativePictures() <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1) ); 1550 assert(rps->getNumberOfPositivePictures() <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures()); 1551 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1)); 1552 } 1553 #endif 1554 if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 1555 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 1556 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 1557 { 1558 // In the case of BLA picture types, rps data is read from slice header but ignored 1559 rps = pcSlice->getLocalRPS(); 1560 rps->setNumberOfNegativePictures(0); 1561 rps->setNumberOfPositivePictures(0); 1562 rps->setNumberOfLongtermPictures(0); 1563 rps->setNumberOfPictures(0); 1564 pcSlice->setRPS(rps); 1565 } 1566 if (pcSlice->getSPS()->getTMVPFlagsPresent()) 1567 { 1568 READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); 1569 pcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); 1570 } 1571 else 1572 { 1573 pcSlice->setEnableTMVPFlag(false); 1574 } 1575 } 1576 1577 #if SVC_EXTENSION 1578 pcSlice->setActiveNumILRRefIdx(0); 1579 if((pcSlice->getLayerId() > 0) && !(pcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (pcSlice->getNumILRRefIdx() > 0) ) 1580 { 1581 READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); 1582 pcSlice->setInterLayerPredEnabledFlag(uiCode); 1583 if( pcSlice->getInterLayerPredEnabledFlag()) 1584 { 1585 if(pcSlice->getNumILRRefIdx() > 1) 1586 { 1587 Int numBits = 1; 1588 while ((1 << numBits) < pcSlice->getNumILRRefIdx()) 1589 { 1590 numBits++; 1591 } 1592 if( !pcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) 1593 { 1594 READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); 1595 pcSlice->setActiveNumILRRefIdx(uiCode + 1); 1596 } 1597 else 1598 { 1599 #if P0079_DERIVE_NUMACTIVE_REF_PICS 1600 for( Int i = 0; i < pcSlice->getNumILRRefIdx(); i++ ) 1601 { 1602 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 1603 if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0) && 1604 (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) 1605 #else 1606 if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() && 1607 (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) 1608 #endif 1609 { 1610 pcSlice->setActiveNumILRRefIdx(1); 1611 break; 1612 } 1613 } 1614 #else 1615 pcSlice->setActiveNumILRRefIdx(1); 1616 #endif 1617 } 1618 1619 if( pcSlice->getActiveNumILRRefIdx() == pcSlice->getNumILRRefIdx() ) 1620 { 1621 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1622 { 1623 pcSlice->setInterLayerPredLayerIdc(i,i); 1624 } 1625 } 1626 else 1627 { 1628 for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1629 { 1630 READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); 1631 pcSlice->setInterLayerPredLayerIdc(uiCode,i); 1632 } 1633 } 1634 } 1635 else 1636 { 1637 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 1638 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 1639 if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,pcSlice->getLayerId()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0) && 1640 (pcSlice->getVPS()->getMaxTSLayersMinus1(0) >= pcSlice->getTLayer()) ) 1641 #else 1642 if( (pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,pcSlice->getLayerId()) > pcSlice->getTLayer()) && 1643 (pcSlice->getVPS()->getMaxTSLayersMinus1(0) >= pcSlice->getTLayer()) ) 1644 #endif 1645 { 1646 #endif 1647 pcSlice->setActiveNumILRRefIdx(1); 1648 pcSlice->setInterLayerPredLayerIdc(0,0); 1649 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 1650 } 1651 #endif 1652 } 1653 } 1654 } 1655 else if( pcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true && (pcSlice->getLayerId() > 0 )) 1656 { 1657 pcSlice->setInterLayerPredEnabledFlag(true); 1658 1659 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 1660 Int numRefLayerPics = 0; 1661 Int i = 0; 1662 Int refLayerPicIdc [MAX_VPS_LAYER_ID_PLUS1]; 1663 for(i = 0, numRefLayerPics = 0; i < pcSlice->getNumILRRefIdx(); i++ ) 1664 { 1665 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 1666 if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0) && 1667 (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) 1668 #else 1669 if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() && 1670 (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) 1671 #endif 1672 { 1673 refLayerPicIdc[ numRefLayerPics++ ] = i; 1674 } 1675 } 1676 pcSlice->setActiveNumILRRefIdx(numRefLayerPics); 1677 for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1678 { 1679 pcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i); 1680 } 1681 #else 1682 pcSlice->setActiveNumILRRefIdx(pcSlice->getNumILRRefIdx()); 1683 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1684 { 1685 pcSlice->setInterLayerPredLayerIdc(i,i); 1686 } 1687 #endif 1688 } 1689 #if P0312_VERT_PHASE_ADJ 1690 for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1691 { 1692 UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); 1693 #if !MOVE_SCALED_OFFSET_TO_PPS 1694 if( pcSlice->getSPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 1695 #else 1696 if( pcSlice->getPPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 1697 #endif 1698 { 1699 READ_FLAG( uiCode, "vert_phase_position_flag" ); pcSlice->setVertPhasePositionFlag( uiCode? true : false, refLayerIdc ); 1700 } 1701 } 1702 #endif 1703 #endif //SVC_EXTENSION 1704 1705 if(sps->getUseSAO()) 1706 { 1707 READ_FLAG(uiCode, "slice_sao_luma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, (Bool)uiCode); 1708 #if SVC_EXTENSION 1709 ChromaFormat format; 1710 if( sps->getLayerId() == 0 ) 1711 { 1712 format = sps->getChromaFormatIdc(); 1713 } 1714 else 1715 { 1716 format = pcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : pcSlice->getVPS()->getVpsRepFormatIdx( pcSlice->getVPS()->getLayerIdInVps(sps->getLayerId()) ) )->getChromaFormatVpsIdc(); 1717 #if Q0195_REP_FORMAT_CLEANUP 1718 assert( (sps->getUpdateRepFormatFlag()==false && pcSlice->getVPS()->getVpsNumRepFormats()==1) || pcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check 1719 #endif 1720 } 1721 if (format != CHROMA_400) 1722 #else 1723 if (bChroma) 1724 #endif 1725 { 1726 READ_FLAG(uiCode, "slice_sao_chroma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, (Bool)uiCode); 1727 } 1728 #if SVC_EXTENSION 1729 else 1730 { 1731 pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, false); 1732 } 1733 #endif 1734 } 1735 1736 if (pcSlice->getIdrPicFlag()) 1737 { 1738 pcSlice->setEnableTMVPFlag(false); 1739 } 1740 if (!pcSlice->isIntra()) 1741 { 1742 1743 READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); 1744 if (uiCode) 1745 { 1746 READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); 1747 if (pcSlice->isInterB()) 1748 { 1749 READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); 1750 } 1751 else 1752 { 1753 pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); 1754 } 1755 } 1756 else 1757 { 1758 pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getPPS()->getNumRefIdxL0DefaultActive()); 1759 if (pcSlice->isInterB()) 1760 { 1761 pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getPPS()->getNumRefIdxL1DefaultActive()); 1762 } 1763 else 1764 { 1765 pcSlice->setNumRefIdx(REF_PIC_LIST_1,0); 1766 } 1767 } 1768 } 1769 // } 1770 TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); 1771 if(!pcSlice->isIntra()) 1772 { 1773 if( !pcSlice->getPPS()->getListsModificationPresentFlag() || pcSlice->getNumRpsCurrTempList() <= 1 ) 1774 { 1775 refPicListModification->setRefPicListModificationFlagL0( 0 ); 1776 } 1777 else 1778 { 1779 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); 1780 } 1781 1782 if(refPicListModification->getRefPicListModificationFlagL0()) 1783 { 1784 uiCode = 0; 1785 Int i = 0; 1786 Int numRpsCurrTempList0 = pcSlice->getNumRpsCurrTempList(); 1787 if ( numRpsCurrTempList0 > 1 ) 1788 { 1789 Int length = 1; 1790 numRpsCurrTempList0 --; 1791 while ( numRpsCurrTempList0 >>= 1) 1792 { 1793 length ++; 1794 } 1795 for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 1796 { 1797 READ_CODE( length, uiCode, "list_entry_l0" ); 1798 refPicListModification->setRefPicSetIdxL0(i, uiCode ); 1799 } 1800 } 1801 else 1802 { 1803 for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 1804 { 1805 refPicListModification->setRefPicSetIdxL0(i, 0 ); 1806 } 1807 } 1808 } 1809 } 1810 else 1811 { 1812 refPicListModification->setRefPicListModificationFlagL0(0); 1813 } 1814 if(pcSlice->isInterB()) 1815 { 1816 if( !pcSlice->getPPS()->getListsModificationPresentFlag() || pcSlice->getNumRpsCurrTempList() <= 1 ) 1817 { 1818 refPicListModification->setRefPicListModificationFlagL1( 0 ); 1819 } 1820 else 1821 { 1822 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); 1823 } 1824 if(refPicListModification->getRefPicListModificationFlagL1()) 1825 { 1826 uiCode = 0; 1827 Int i = 0; 1828 Int numRpsCurrTempList1 = pcSlice->getNumRpsCurrTempList(); 1829 if ( numRpsCurrTempList1 > 1 ) 1830 { 1831 Int length = 1; 1832 numRpsCurrTempList1 --; 1833 while ( numRpsCurrTempList1 >>= 1) 1834 { 1835 length ++; 1836 } 1837 for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 1838 { 1839 READ_CODE( length, uiCode, "list_entry_l1" ); 1840 refPicListModification->setRefPicSetIdxL1(i, uiCode ); 1841 } 1842 } 1843 else 1844 { 1845 for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 1846 { 1847 refPicListModification->setRefPicSetIdxL1(i, 0 ); 1848 } 1849 } 1850 } 1851 } 1852 else 1853 { 1854 refPicListModification->setRefPicListModificationFlagL1(0); 1855 } 1856 if (pcSlice->isInterB()) 1857 { 1858 READ_FLAG( uiCode, "mvd_l1_zero_flag" ); pcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); 1859 } 1860 1861 pcSlice->setCabacInitFlag( false ); // default 1862 if(pps->getCabacInitPresentFlag() && !pcSlice->isIntra()) 1863 { 1864 READ_FLAG(uiCode, "cabac_init_flag"); 1865 pcSlice->setCabacInitFlag( uiCode ? true : false ); 1866 } 1867 1868 if ( pcSlice->getEnableTMVPFlag() ) 1869 { 1870 #if SVC_EXTENSION && REF_IDX_MFM 1871 // set motion mapping flag 1872 pcSlice->setMFMEnabledFlag( ( pcSlice->getNumMotionPredRefLayers() > 0 && pcSlice->getActiveNumILRRefIdx() && !pcSlice->isIntra() ) ? true : false ); 1873 #endif 1874 if ( pcSlice->getSliceType() == B_SLICE ) 1875 { 1876 READ_FLAG( uiCode, "collocated_from_l0_flag" ); 1877 pcSlice->setColFromL0Flag(uiCode); 1878 } 1879 else 1880 { 1881 pcSlice->setColFromL0Flag( 1 ); 1882 } 1883 1884 if ( pcSlice->getSliceType() != I_SLICE && 1885 ((pcSlice->getColFromL0Flag() == 1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| 1886 (pcSlice->getColFromL0Flag() == 0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) 1887 { 1888 READ_UVLC( uiCode, "collocated_ref_idx" ); 1889 pcSlice->setColRefIdx(uiCode); 1890 } 1891 else 1892 { 1893 pcSlice->setColRefIdx(0); 1894 } 1895 } 1896 if ( (pps->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) ) 1897 { 1898 xParsePredWeightTable(pcSlice); 1899 pcSlice->initWpScaling(); 1900 } 1901 if (!pcSlice->isIntra()) 1902 { 1903 READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); 1904 pcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); 1905 } 1906 1907 READ_SVLC( iCode, "slice_qp_delta" ); 1908 pcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); 1909 1910 #if REPN_FORMAT_IN_VPS 1911 #if O0194_DIFFERENT_BITDEPTH_EL_BL 1912 g_bitDepthLayer[CHANNEL_TYPE_LUMA][pcSlice->getLayerId()] = pcSlice->getBitDepthY(); 1913 g_bitDepthLayer[CHANNEL_TYPE_CHROMA][pcSlice->getLayerId()] = pcSlice->getBitDepthC(); 1914 #endif 1915 assert( pcSlice->getSliceQp() >= -pcSlice->getQpBDOffsetY() ); 1916 #else 1917 assert( pcSlice->getSliceQp() >= -sps->getQpBDOffset(CHANNEL_TYPE_LUMA) ); 1918 #endif 1919 assert( pcSlice->getSliceQp() <= 51 ); 1920 1921 if (pcSlice->getPPS()->getSliceChromaQpFlag()) 1922 { 1923 if (numValidComp>COMPONENT_Cb) 1924 { 1925 READ_SVLC( iCode, "slice_qp_delta_cb" ); 1926 pcSlice->setSliceChromaQpDelta(COMPONENT_Cb, iCode ); 1927 assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) >= -12 ); 1928 assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) <= 12 ); 1929 assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) >= -12 ); 1930 assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) <= 12 ); 1931 } 1932 1933 if (numValidComp>COMPONENT_Cr) 1934 { 1935 READ_SVLC( iCode, "slice_qp_delta_cr" ); 1936 pcSlice->setSliceChromaQpDelta(COMPONENT_Cr, iCode ); 1937 assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) >= -12 ); 1938 assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) <= 12 ); 1939 assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) >= -12 ); 1940 assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) <= 12 ); 1941 } 1942 } 1943 1944 if (pcSlice->getPPS()->getChromaQpAdjTableSize() > 0) 1945 { 1946 READ_FLAG(uiCode, "slice_chroma_qp_adjustment_enabled_flag"); pcSlice->setUseChromaQpAdj(uiCode != 0); 1947 } 1948 else pcSlice->setUseChromaQpAdj(false); 1949 1950 if (pcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) 1951 { 1952 if(pcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) 1953 { 1954 READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); pcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); 1955 } 1956 else 1957 { 1958 pcSlice->setDeblockingFilterOverrideFlag(0); 1959 } 1960 if(pcSlice->getDeblockingFilterOverrideFlag()) 1961 { 1962 READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); pcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); 1963 if(!pcSlice->getDeblockingFilterDisable()) 1964 { 1965 READ_SVLC( iCode, "slice_beta_offset_div2" ); pcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); 1966 assert(pcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && 1967 pcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); 1968 READ_SVLC( iCode, "slice_tc_offset_div2" ); pcSlice->setDeblockingFilterTcOffsetDiv2(iCode); 1969 assert(pcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && 1970 pcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); 1971 } 1972 } 1973 else 1974 { 1975 pcSlice->setDeblockingFilterDisable ( pcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); 1976 pcSlice->setDeblockingFilterBetaOffsetDiv2( pcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); 1977 pcSlice->setDeblockingFilterTcOffsetDiv2 ( pcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); 1978 } 1979 } 1980 else 1981 { 1982 pcSlice->setDeblockingFilterDisable ( false ); 1983 pcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); 1984 pcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); 1985 } 1986 1987 Bool isSAOEnabled = pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA) || (bChroma && pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA))); 1988 Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable()); 1989 1990 if(pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) 1991 { 1992 READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); 1993 } 1994 else 1995 { 1996 uiCode = pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; 1997 } 1998 pcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); 1999 2000 } 2001 2002 std::vector<UInt> entryPointOffset; 2003 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 2004 { 2005 UInt numEntryPointOffsets; 2006 UInt offsetLenMinus1; 2007 READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); 2008 if (numEntryPointOffsets>0) 2009 { 2010 READ_UVLC(offsetLenMinus1, "offset_len_minus1"); 2011 entryPointOffset.resize(numEntryPointOffsets); 2012 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 2013 { 2014 READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); 2015 entryPointOffset[ idx ] = uiCode + 1; 2016 } 2017 } 2018 } 2019 2020 #if POC_RESET_IDC_SIGNALLING 2021 Int sliceHeaderExtensionLength = 0; 2022 if(pps->getSliceHeaderExtensionPresentFlag()) 2023 { 2024 READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode; 2025 } 2026 else 2027 { 2028 sliceHeaderExtensionLength = 0; 2029 #if INFERENCE_POC_MSB_VAL_PRESENT 2030 pcSlice->setPocMsbValPresentFlag( false ); 2031 #endif 2032 } 2033 UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits 2034 if( sliceHeaderExtensionLength > 0 ) 2035 { 2036 if( pcSlice->getPPS()->getPocResetInfoPresentFlag() ) 2037 { 2038 READ_CODE( 2, uiCode, "poc_reset_idc"); pcSlice->setPocResetIdc(uiCode); 2039 #if POC_RESET_RESTRICTIONS 2040 /* The value of poc_reset_idc shall not be equal to 1 or 2 for a RASL picture, a RADL picture, 2041 a sub-layer non-reference picture, or a picture that has TemporalId greater than 0, 2042 or a picture that has discardable_flag equal to 1. */ 2043 if( pcSlice->getPocResetIdc() == 1 || pcSlice->getPocResetIdc() == 2 ) 2044 { 2045 assert( !pcSlice->isRASL() ); 2046 assert( !pcSlice->isRADL() ); 2047 assert( !pcSlice->isSLNR() ); 2048 assert( pcSlice->getTLayer() == 0 ); 2049 assert( pcSlice->getDiscardableFlag() == 0 ); 2050 } 2051 2052 // The value of poc_reset_idc of a CRA or BLA picture shall be less than 3. 2053 if( pcSlice->getPocResetIdc() == 3) 2054 { 2055 assert( ! ( pcSlice->isCRA() || pcSlice->isBLA() ) ); 2056 } 2057 #endif 2058 } 2059 else 2060 { 2061 pcSlice->setPocResetIdc( 0 ); 2062 } 2063 #if Q0142_POC_LSB_NOT_PRESENT 2064 if ( pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdInVps(pcSlice->getLayerId()) ) && iPOClsb > 0 ) 2065 { 2066 assert( pcSlice->getPocResetIdc() != 2 ); 2067 } 2068 #endif 2069 if( pcSlice->getPocResetIdc() > 0 ) 2070 { 2071 READ_CODE(6, uiCode, "poc_reset_period_id"); pcSlice->setPocResetPeriodId(uiCode); 2072 } 2073 else 2074 { 2075 2076 pcSlice->setPocResetPeriodId( 0 ); 2077 } 2078 2079 if (pcSlice->getPocResetIdc() == 3) 2080 { 2081 READ_FLAG( uiCode, "full_poc_reset_flag"); pcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); 2082 READ_CODE(pcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); pcSlice->setPocLsbVal(uiCode); 2083 #if Q0142_POC_LSB_NOT_PRESENT 2084 if ( pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdInVps(pcSlice->getLayerId()) ) && pcSlice->getFullPocResetFlag() ) 2085 { 2086 assert( pcSlice->getPocLsbVal() == 0 ); 2087 } 2088 #endif 2089 } 2090 2091 // Derive the value of PocMsbValRequiredFlag 2092 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2093 pcSlice->setPocMsbValRequiredFlag( (pcSlice->getCraPicFlag() || pcSlice->getBlaPicFlag()) 2094 && (!pcSlice->getVPS()->getVpsPocLsbAlignedFlag() || 2095 (pcSlice->getVPS()->getVpsPocLsbAlignedFlag() && pcSlice->getVPS()->getNumDirectRefLayers(pcSlice->getLayerId()) == 0)) 2096 ); 2097 #else 2098 pcSlice->setPocMsbValRequiredFlag( pcSlice->getCraPicFlag() || pcSlice->getBlaPicFlag() ); 2099 #endif 2100 2101 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2102 if (!pcSlice->getPocMsbValRequiredFlag() && pcSlice->getVPS()->getVpsPocLsbAlignedFlag()) 2103 #else 2104 if (!pcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */) 2105 #endif 2106 { 2107 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2108 READ_FLAG(uiCode, "poc_msb_cycle_val_present_flag"); pcSlice->setPocMsbValPresentFlag(uiCode ? true : false); 2109 #else 2110 READ_FLAG(uiCode, "poc_msb_val_present_flag"); pcSlice->setPocMsbValPresentFlag(uiCode ? true : false); 2111 #endif 2112 } 2113 else 2114 { 2115 #if POC_MSB_VAL_PRESENT_FLAG_SEM 2116 if( sliceHeaderExtensionLength == 0 ) 2117 { 2118 pcSlice->setPocMsbValPresentFlag( false ); 2119 } 2120 else if( pcSlice->getPocMsbValRequiredFlag() ) 2121 #else 2122 if( pcSlice->getPocMsbValRequiredFlag() ) 2123 #endif 2124 { 2125 pcSlice->setPocMsbValPresentFlag( true ); 2126 } 2127 else 2128 { 2129 pcSlice->setPocMsbValPresentFlag( false ); 2130 } 2131 } 2132 2133 #if !POC_RESET_IDC_DECODER 2134 Int maxPocLsb = 1 << pcSlice->getSPS()->getBitsForPOC(); 2135 #endif 2136 if( pcSlice->getPocMsbValPresentFlag() ) 2137 { 2138 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2139 READ_UVLC( uiCode, "poc_msb_cycle_val"); pcSlice->setPocMsbVal( uiCode ); 2140 #else 2141 READ_UVLC( uiCode, "poc_msb_val"); pcSlice->setPocMsbVal( uiCode ); 2142 #endif 2143 2144 #if !POC_RESET_IDC_DECODER 2145 // Update POC of the slice based on this MSB val 2146 Int pocLsb = pcSlice->getPOC() % maxPocLsb; 2147 pcSlice->setPOC((pcSlice->getPocMsbVal() * maxPocLsb) + pocLsb); 2148 } 2149 else 2150 { 2151 pcSlice->setPocMsbVal( pcSlice->getPOC() / maxPocLsb ); 2152 #endif 2153 } 2154 2155 // Read remaining bits in the slice header extension. 2156 UInt endBits = m_pcBitstream->getNumBitsRead(); 2157 Int counter = (endBits - startBits) % 8; 2158 if( counter ) 2159 { 2160 counter = 8 - counter; 2161 } 2162 2163 while( counter ) 2164 { 2165 #if Q0146_SSH_EXT_DATA_BIT 2166 READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); 2167 #else 2168 READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 ); 2169 #endif 2170 counter--; 2171 } 2172 } 2173 #else 2174 if(pps->getSliceHeaderExtensionPresentFlag()) 2175 { 2176 READ_UVLC(uiCode,"slice_header_extension_length"); 2177 for(Int i=0; i<uiCode; i++) 2178 { 2179 UInt ignore; 2180 READ_CODE(8,ignore,"slice_header_extension_data_byte"); 2181 } 2182 } 2183 #endif 2184 #if RExt__DECODER_DEBUG_BIT_STATISTICS 2185 TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,m_pcBitstream->readByteAlignment(),0); 2186 #else 2187 m_pcBitstream->readByteAlignment(); 2188 #endif 2189 2190 pcSlice->clearSubstreamSizes(); 2191 2192 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 2193 { 2194 Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); 2195 2196 // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header 2197 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 2198 { 2199 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) 2200 { 2201 endOfSliceHeaderLocation++; 2202 } 2203 } 2204 2205 Int curEntryPointOffset = 0; 2206 Int prevEntryPointOffset = 0; 2207 for (UInt idx=0; idx<entryPointOffset.size(); idx++) 2208 { 2209 curEntryPointOffset += entryPointOffset[ idx ]; 2210 2211 Int emulationPreventionByteCount = 0; 2212 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 2213 { 2214 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && 2215 m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) 2216 { 2217 emulationPreventionByteCount++; 2218 } 2219 } 2220 2221 entryPointOffset[ idx ] -= emulationPreventionByteCount; 2222 prevEntryPointOffset = curEntryPointOffset; 2223 pcSlice->addSubstreamSize(entryPointOffset [ idx ] ); 2224 } 2225 } 2226 2227 return; 2228 } 2229 2230 Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) 2231 { 2232 UInt uiCode; 2233 if(profilePresentFlag) 2234 { 2235 parseProfileTier(rpcPTL->getGeneralPTL()); 2236 } 2237 READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(Level::Name(uiCode)); 2238 2239 for (Int i = 0; i < maxNumSubLayersMinus1; i++) 2240 { 2241 #if MULTIPLE_PTL_SUPPORT 2242 READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); 2243 #else 2244 if(profilePresentFlag) 2245 { 2246 READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); 2247 } 2248 #endif 2249 READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); 2250 } 2251 2252 if (maxNumSubLayersMinus1 > 0) 2253 { 2254 for (Int i = maxNumSubLayersMinus1; i < 8; i++) 2255 { 2256 READ_CODE(2, uiCode, "reserved_zero_2bits"); 2257 assert(uiCode == 0); 2258 } 2259 } 2260 2261 for(Int i = 0; i < maxNumSubLayersMinus1; i++) 2262 { 2263 #if MULTIPLE_PTL_SUPPORT 2264 if( rpcPTL->getSubLayerProfilePresentFlag(i) ) 2265 #else 2266 if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) 2267 #endif 2268 { 2269 parseProfileTier(rpcPTL->getSubLayerPTL(i)); 2270 } 2271 if(rpcPTL->getSubLayerLevelPresentFlag(i)) 2272 { 2273 READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(Level::Name(uiCode)); 2274 } 2275 } 2276 } 2277 2278 Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) 2279 { 2280 UInt uiCode; 2281 READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); 2282 READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? Level::HIGH : Level::MAIN); 2283 READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (Profile::Name(uiCode)); 2284 for(Int j = 0; j < 32; j++) 2285 { 2286 READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); 2287 } 2288 READ_FLAG(uiCode, "general_progressive_source_flag"); 2289 ptl->setProgressiveSourceFlag(uiCode ? true : false); 2290 2291 READ_FLAG(uiCode, "general_interlaced_source_flag"); 2292 ptl->setInterlacedSourceFlag(uiCode ? true : false); 2293 2294 READ_FLAG(uiCode, "general_non_packed_constraint_flag"); 2295 ptl->setNonPackedConstraintFlag(uiCode ? true : false); 2296 2297 READ_FLAG(uiCode, "general_frame_only_constraint_flag"); 2298 ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); 2299 2300 if (ptl->getProfileIdc() == Profile::MAINREXT || ptl->getProfileIdc() == Profile::HIGHTHROUGHPUTREXT ) 2301 { 2302 UInt maxBitDepth=16; 2303 READ_FLAG( uiCode, "general_max_12bit_constraint_flag" ); if (uiCode) maxBitDepth=12; 2304 READ_FLAG( uiCode, "general_max_10bit_constraint_flag" ); if (uiCode) maxBitDepth=10; 2305 READ_FLAG( uiCode, "general_max_8bit_constraint_flag" ); if (uiCode) maxBitDepth=8; 2306 ptl->setBitDepthConstraint(maxBitDepth); 2307 ChromaFormat chromaFmtConstraint=CHROMA_444; 2308 READ_FLAG( uiCode, "general_max_422chroma_constraint_flag" ); if (uiCode) chromaFmtConstraint=CHROMA_422; 2309 READ_FLAG( uiCode, "general_max_420chroma_constraint_flag" ); if (uiCode) chromaFmtConstraint=CHROMA_420; 2310 READ_FLAG( uiCode, "general_max_monochrome_constraint_flag" ); if (uiCode) chromaFmtConstraint=CHROMA_400; 2311 ptl->setChromaFormatConstraint(chromaFmtConstraint); 2312 READ_FLAG( uiCode, "general_intra_constraint_flag"); ptl->setIntraConstraintFlag(uiCode != 0); 2313 READ_FLAG( uiCode, "general_one_picture_only_constraint_flag"); 2314 READ_FLAG( uiCode, "general_lower_bit_rate_constraint_flag"); ptl->setLowerBitRateConstraintFlag(uiCode != 0); 2315 #if MULTIPLE_PTL_SUPPORT 2316 READ_CODE(32, uiCode, "general_reserved_zero_34bits"); READ_CODE(2, uiCode, "general_reserved_zero_34bits"); 2317 } 2318 else if( ptl->getProfileIdc() == Profile::SCALABLEMAIN ) 2319 { 2320 READ_FLAG( uiCode, "general_max_12bit_constraint_flag" ); assert (uiCode == 1); 2321 READ_FLAG( uiCode, "general_max_10bit_constraint_flag" ); assert (uiCode == 1); 2322 READ_FLAG( uiCode, "general_max_8bit_constraint_flag" ); ptl->setProfileIdc ((uiCode) ? Profile::SCALABLEMAIN : Profile::SCALABLEMAIN10); 2323 READ_FLAG( uiCode, "general_max_422chroma_constraint_flag" ); assert (uiCode == 1); 2324 READ_FLAG( uiCode, "general_max_420chroma_constraint_flag" ); assert (uiCode == 1); 2325 READ_FLAG( uiCode, "general_max_monochrome_constraint_flag" ); assert (uiCode == 0); 2326 READ_FLAG( uiCode, "general_intra_constraint_flag"); assert (uiCode == 0); 2327 READ_FLAG( uiCode, "general_one_picture_only_constraint_flag"); assert (uiCode == 0); 2328 READ_FLAG( uiCode, "general_lower_bit_rate_constraint_flag"); assert (uiCode == 1); 2329 READ_CODE(32, uiCode, "general_reserved_zero_34bits"); READ_CODE(2, uiCode, "general_reserved_zero_34bits"); 2330 } 2331 else 2332 { 2333 ptl->setBitDepthConstraint((ptl->getProfileIdc() == Profile::MAIN10)?10:8); 2334 ptl->setChromaFormatConstraint(CHROMA_420); 2335 ptl->setIntraConstraintFlag(false); 2336 ptl->setLowerBitRateConstraintFlag(true); 2337 READ_CODE(32, uiCode, "general_reserved_zero_43bits"); READ_CODE(11, uiCode, "general_reserved_zero_43bits"); 2338 } 2339 2340 if( ( ptl->getProfileIdc() >= 1 && ptl->getProfileIdc() <= 5 ) || 2341 ptl->getProfileCompatibilityFlag(1) || ptl->getProfileCompatibilityFlag(2) || 2342 ptl->getProfileCompatibilityFlag(3) || ptl->getProfileCompatibilityFlag(4) || 2343 ptl->getProfileCompatibilityFlag(5) ) 2344 { 2345 READ_FLAG(uiCode, "general_inbld_flag"); 2346 } 2347 else 2348 { 2349 READ_FLAG(uiCode, "general_reserved_zero_bit"); 2350 } 2351 #else 2352 READ_CODE(16, uiCode, "XXX_reserved_zero_35bits[0..15]"); 2353 READ_CODE(16, uiCode, "XXX_reserved_zero_35bits[16..31]"); 2354 READ_CODE(3, uiCode, "XXX_reserved_zero_35bits[32..34]"); 2355 } 2356 else 2357 { 2358 ptl->setBitDepthConstraint((ptl->getProfileIdc() == Profile::MAIN10)?10:8); 2359 ptl->setChromaFormatConstraint(CHROMA_420); 2360 ptl->setIntraConstraintFlag(false); 2361 ptl->setLowerBitRateConstraintFlag(true); 2362 READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); 2363 READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); 2364 READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); 2365 } 2366 #endif 2367 } 2368 2369 Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) 2370 { 2371 ruiBit = false; 2372 Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); 2373 if(iBitsLeft <= 8) 2374 { 2375 UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); 2376 if (uiPeekValue == (1<<(iBitsLeft-1))) 2377 { 2378 ruiBit = true; 2379 } 2380 } 2381 } 2382 2383 Void TDecCavlc::parseRemainingBytes( Bool noTrailingBytesExpected ) 2384 { 2385 if (noTrailingBytesExpected) 2386 { 2387 const UInt numberOfRemainingSubstreamBytes=m_pcBitstream->getNumBitsLeft(); 2388 assert (numberOfRemainingSubstreamBytes == 0); 2389 } 2390 else 2391 { 2392 while (m_pcBitstream->getNumBitsLeft()) 2393 { 2394 UInt trailingNullByte=m_pcBitstream->readByte(); 2395 if (trailingNullByte!=0) 2396 { 2397 printf("Trailing byte should be 0, but has value %02x\n", trailingNullByte); 2398 assert(trailingNullByte==0); 2399 } 2400 } 2401 } 2402 } 2403 2404 Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2405 { 2406 assert(0); 2407 } 2408 2409 Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2410 { 2411 assert(0); 2412 } 2413 2414 Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) 2415 { 2416 assert(0); 2417 } 2418 2419 Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2420 { 2421 assert(0); 2422 } 2423 2424 Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2425 { 2426 assert(0); 2427 } 2428 2429 Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2430 { 2431 assert(0); 2432 } 2433 2434 /** Parse I_PCM information. 2435 * \param pcCU pointer to CU 2436 * \param uiAbsPartIdx CU index 2437 * \param uiDepth CU depth 2438 * \returns Void 2439 * 2440 * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. 2441 */ 2442 Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2443 { 2444 assert(0); 2445 } 2446 2447 Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2448 { 2449 assert(0); 2450 } 2451 2452 Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2453 { 2454 assert(0); 2455 } 2456 2457 Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) 2458 { 2459 assert(0); 2460 } 2461 2462 Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) 2463 { 2464 assert(0); 2465 } 2466 2467 Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) 2468 { 2469 assert(0); 2470 } 2471 2472 Void TDecCavlc::parseCrossComponentPrediction( class TComTU& /*rTu*/, ComponentID /*compID*/ ) 2473 { 2474 assert(0); 2475 } 2476 2477 Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 2478 { 2479 Int qp; 2480 Int iDQp; 2481 2482 #if RExt__DECODER_DEBUG_BIT_STATISTICS 2483 READ_SVLC(iDQp, "delta_qp"); 2484 #else 2485 xReadSvlc( iDQp ); 2486 #endif 2487 2488 #if REPN_FORMAT_IN_VPS 2489 Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); 2490 #else 2491 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); 2492 #endif 2493 qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; 2494 2495 UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; 2496 UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; 2497 2498 pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); 2499 } 2500 2501 Void TDecCavlc::parseChromaQpAdjustment( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2502 { 2503 assert(0); 2504 } 2505 2506 Void TDecCavlc::parseCoeffNxN( TComTU &/*rTu*/, ComponentID /*compID*/ ) 2507 { 2508 assert(0); 2509 } 2510 2511 Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) 2512 { 2513 assert(0); 2514 } 2515 2516 Void TDecCavlc::parseQtCbf( TComTU &/*rTu*/, const ComponentID /*compID*/, const Bool /*lowestLevel*/ ) 2517 { 2518 assert(0); 2519 } 2520 2521 Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) 2522 { 2523 assert(0); 2524 } 2525 2526 Void TDecCavlc::parseTransformSkipFlags (TComTU &/*rTu*/, ComponentID /*component*/) 2527 { 2528 assert(0); 2529 } 2530 2531 Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) 2532 { 2533 assert(0); 2534 } 2535 2536 Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) 2537 { 2538 assert(0); 2539 } 2540 2541 // ==================================================================================================================== 2542 // Protected member functions 2543 // ==================================================================================================================== 2544 2545 /** parse explicit wp tables 2546 * \param TComSlice* pcSlice 2547 * \returns Void 2548 */ 2549 Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) 2550 { 2551 WPScalingParam *wp; 2552 TComSPS *sps = pcSlice->getSPS(); 2553 const ChromaFormat chFmt = sps->getChromaFormatIdc(); 2554 const Int numValidComp = Int(getNumberValidComponents(chFmt)); 2555 const Bool bChroma = (chFmt!=CHROMA_400); 2556 const SliceType eSliceType = pcSlice->getSliceType(); 2557 const Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); 2558 UInt uiLog2WeightDenomLuma=0, uiLog2WeightDenomChroma=0; 2559 UInt uiTotalSignalledWeightFlags = 0; 2560 2561 Int iDeltaDenom; 2562 // decode delta_luma_log2_weight_denom : 2563 READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom 2564 assert( uiLog2WeightDenomLuma <= 7 ); 2565 if( bChroma ) 2566 { 2567 READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom 2568 assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); 2569 assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); 2570 uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); 2571 } 2572 2573 for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) 2574 { 2575 RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 2576 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2577 { 2578 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2579 2580 wp[COMPONENT_Y].uiLog2WeightDenom = uiLog2WeightDenomLuma; 2581 for(Int j=1; j<numValidComp; j++) 2582 { 2583 wp[j].uiLog2WeightDenom = uiLog2WeightDenomChroma; 2584 } 2585 2586 UInt uiCode; 2587 READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag 2588 wp[COMPONENT_Y].bPresentFlag = ( uiCode == 1 ); 2589 uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag; 2590 } 2591 if ( bChroma ) 2592 { 2593 UInt uiCode; 2594 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2595 { 2596 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2597 READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag 2598 for(Int j=1; j<numValidComp; j++) 2599 { 2600 wp[j].bPresentFlag = ( uiCode == 1 ); 2601 } 2602 uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag; 2603 } 2604 } 2605 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2606 { 2607 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2608 if ( wp[COMPONENT_Y].bPresentFlag ) 2609 { 2610 Int iDeltaWeight; 2611 READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] 2612 assert( iDeltaWeight >= -128 ); 2613 assert( iDeltaWeight <= 127 ); 2614 wp[COMPONENT_Y].iWeight = (iDeltaWeight + (1<<wp[COMPONENT_Y].uiLog2WeightDenom)); 2615 READ_SVLC( wp[COMPONENT_Y].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] 2616 Int range=sps->getUseHighPrecisionPredictionWeighting() ? (1<<g_bitDepth[CHANNEL_TYPE_LUMA])/2 : 128; 2617 assert( wp[0].iOffset >= -range ); 2618 assert( wp[0].iOffset < range ); 2619 } 2620 else 2621 { 2622 wp[COMPONENT_Y].iWeight = (1 << wp[COMPONENT_Y].uiLog2WeightDenom); 2623 wp[COMPONENT_Y].iOffset = 0; 2624 } 2625 if ( bChroma ) 2626 { 2627 if ( wp[COMPONENT_Cb].bPresentFlag ) 2628 { 2629 Int range=sps->getUseHighPrecisionPredictionWeighting() ? (1<<g_bitDepth[CHANNEL_TYPE_CHROMA])/2 : 128; 2630 for ( Int j=1 ; j<numValidComp ; j++ ) 2631 { 2632 Int iDeltaWeight; 2633 READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] 2634 assert( iDeltaWeight >= -128 ); 2635 assert( iDeltaWeight <= 127 ); 2636 wp[j].iWeight = (iDeltaWeight + (1<<wp[j].uiLog2WeightDenom)); 2637 2638 Int iDeltaChroma; 2639 READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] 2640 assert( iDeltaChroma >= -4*range); 2641 assert( iDeltaChroma < 4*range); 2642 Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); 2643 wp[j].iOffset = Clip3(-range, range-1, (iDeltaChroma + pred) ); 2644 } 2645 } 2646 else 2647 { 2648 for ( Int j=1 ; j<numValidComp ; j++ ) 2649 { 2650 wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); 2651 wp[j].iOffset = 0; 2652 } 2653 } 2654 } 2655 } 2656 2657 for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) 2658 { 2659 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2660 2661 wp[0].bPresentFlag = false; 2662 wp[1].bPresentFlag = false; 2663 wp[2].bPresentFlag = false; 2664 } 2665 } 2666 assert(uiTotalSignalledWeightFlags<=24); 2667 } 2668 2669 /** decode quantization matrix 2670 * \param scalingList quantization matrix information 2671 */ 2672 Void TDecCavlc::parseScalingList(TComScalingList* scalingList) 2673 { 2674 UInt code, sizeId, listId; 2675 Bool scalingListPredModeFlag; 2676 //for each size 2677 for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) 2678 { 2679 for(listId = 0; listId < SCALING_LIST_NUM; listId++) 2680 { 2681 if ((sizeId==SCALING_LIST_32x32) && (listId%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) != 0)) 2682 { 2683 Int *src = scalingList->getScalingListAddress(sizeId, listId); 2684 const Int size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); 2685 const Int *srcNextSmallerSize = scalingList->getScalingListAddress(sizeId-1, listId); 2686 for(Int i=0; i<size; i++) 2687 { 2688 src[i] = srcNextSmallerSize[i]; 2689 } 2690 scalingList->setScalingListDC(sizeId,listId,(sizeId > SCALING_LIST_8x8) ? scalingList->getScalingListDC(sizeId-1, listId) : src[0]); 2691 } 2692 else 2693 { 2694 READ_FLAG( code, "scaling_list_pred_mode_flag"); 2695 scalingListPredModeFlag = (code) ? true : false; 2696 if(!scalingListPredModeFlag) //Copy Mode 2697 { 2698 READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); 2699 2700 if (sizeId==SCALING_LIST_32x32) 2701 code*=(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES); // Adjust the decoded code for this size, to cope with the missing 32x32 chroma entries. 2702 2703 scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); 2704 if( sizeId > SCALING_LIST_8x8 ) 2705 { 2706 scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); 2707 } 2708 scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); 2709 2710 } 2711 else //DPCM Mode 2712 { 2713 xDecodeScalingList(scalingList, sizeId, listId); 2714 } 2715 } 2716 } 2717 } 2718 2719 return; 2720 } 2721 /** decode DPCM 2722 * \param scalingList quantization matrix information 2723 * \param sizeId size index 2724 * \param listId list index 2725 */ 2726 Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) 2727 { 2728 Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); 2729 Int data; 2730 Int scalingListDcCoefMinus8 = 0; 2731 Int nextCoef = SCALING_LIST_START_VALUE; 2732 UInt* scan = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][sizeId==0 ? 2 : 3][sizeId==0 ? 2 : 3]; 2733 Int *dst = scalingList->getScalingListAddress(sizeId, listId); 2734 2735 if( sizeId > SCALING_LIST_8x8 ) 2736 { 2737 READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); 2738 scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); 2739 nextCoef = scalingList->getScalingListDC(sizeId,listId); 2740 } 2741 2742 for(i = 0; i < coefNum; i++) 2743 { 2744 READ_SVLC( data, "scaling_list_delta_coef"); 2745 nextCoef = (nextCoef + data + 256 ) % 256; 2746 dst[scan[i]] = nextCoef; 2747 } 2748 } 2749 2750 Bool TDecCavlc::xMoreRbspData() 2751 { 2752 Int bitsLeft = m_pcBitstream->getNumBitsLeft(); 2753 2754 // if there are more than 8 bits, it cannot be rbsp_trailing_bits 2755 if (bitsLeft > 8) 2756 { 2757 return true; 2758 } 2759 2760 UChar lastByte = m_pcBitstream->peekBits(bitsLeft); 2761 Int cnt = bitsLeft; 2762 2763 // remove trailing bits equal to zero 2764 while ((cnt>0) && ((lastByte & 1) == 0)) 2765 { 2766 lastByte >>= 1; 2767 cnt--; 2768 } 2769 // remove bit equal to one 2770 cnt--; 2771 2772 // we should not have a negative number of bits 2773 assert (cnt>=0); 2774 2775 // we have more data, if cnt is not zero 2776 return (cnt>0); 2777 } 2778 2779 Void TDecCavlc::parseExplicitRdpcmMode( TComTU &rTu, ComponentID compID ) 2780 { 2781 assert(0); 1385 2782 } 1386 2783 … … 1638 3035 #if !MULTIPLE_PTL_SUPPORT 1639 3036 vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel()); 1640 #endif 3037 #endif 1641 3038 #if LIST_OF_PTL 1642 3039 for(Int idx = vps->getBaseLayerInternalFlag() ? 2 : 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) … … 1645 3042 #endif 1646 3043 { 1647 READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); 1648 vps->setProfilePresentFlag(idx, uiCode ? true : false); 3044 READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false); 1649 3045 if( !vps->getProfilePresentFlag(idx) ) 1650 3046 { … … 1715 3111 if( vps->getNumLayerSets() > 1 ) 1716 3112 { 1717 READ_UVLC( uiCode, "num_add_olss" ); vps->setNumAddOutputLayerSets( uiCode );3113 READ_UVLC( uiCode, "num_add_olss" ); vps->setNumAddOutputLayerSets( uiCode ); 1718 3114 READ_CODE( 2, uiCode, "default_output_layer_idc" ); vps->setDefaultTargetOutputLayerIdc( uiCode ); 1719 3115 } … … 1830 3226 #endif 1831 3227 { 1832 READ_CODE( numBitsForPtlIdx, uiCode, "profile_ level_tier_idx[i]" );3228 READ_CODE( numBitsForPtlIdx, uiCode, "profile_tier_level_idx[i]" ); 1833 3229 vps->setProfileLevelTierIdx(i, j, uiCode ); 3230 1834 3231 #if MULTIPLE_PTL_SUPPORT 1835 3232 //For conformance checking … … 1862 3259 numBits++; 1863 3260 } 1864 READ_CODE( numBits, uiCode, "profile_ level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode);3261 READ_CODE( numBits, uiCode, "profile_tier_level_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); 1865 3262 #endif 1866 3263 #if P0300_ALT_OUTPUT_LAYER_FLAG … … 2167 3564 } 2168 3565 #endif 3566 2169 3567 #if VPS_FIX_TO_MATCH_SPEC 2170 for (i = vps->getBaseLayerInternalFlag() ? 1 : 2; i < vps->getMaxLayers(); i++)2171 #else 2172 for (i = 1; i < vps->getMaxLayers(); i++)3568 for( i = vps->getBaseLayerInternalFlag() ? 1 : 2; i < vps->getMaxLayers(); i++ ) 3569 #else 3570 for(i = 1; i < vps->getMaxLayers(); i++) 2173 3571 #endif 2174 3572 { 2175 3573 #if VPS_FIX_TO_MATCH_SPEC 2176 for (j = vps->getBaseLayerInternalFlag() ? 0 : 1; j < i; j++)2177 #else 2178 for (j = 0; j < i; j++)3574 for( j = vps->getBaseLayerInternalFlag() ? 0 : 1; j < i; j++ ) 3575 #else 3576 for(j = 0; j < i; j++) 2179 3577 #endif 2180 3578 { … … 3053 4451 } 3054 4452 3055 #endif //SVC_EXTENSION 3056 3057 Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) 3058 { 3059 UInt uiCode; 3060 Int iCode; 3061 3062 #if ENC_DEC_TRACE 3063 xTraceSliceHeader(rpcSlice); 3064 #endif 3065 TComPPS* pps = NULL; 3066 TComSPS* sps = NULL; 3067 3068 UInt firstSliceSegmentInPic; 3069 READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); 3070 if( rpcSlice->getRapPicFlag()) 3071 { 3072 READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already 3073 #if SETTING_NO_OUT_PIC_PRIOR 3074 rpcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); 3075 #else 3076 rpcSlice->setNoOutputPicPrior( false ); 3077 #endif 3078 } 3079 READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); 3080 pps = parameterSetManager->getPrefetchedPPS(uiCode); 3081 //!KS: need to add error handling code here, if PPS is not available 3082 assert(pps!=0); 3083 sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); 3084 //!KS: need to add error handling code here, if SPS is not available 3085 assert(sps!=0); 3086 rpcSlice->setSPS(sps); 3087 rpcSlice->setPPS(pps); 3088 3089 #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 3090 TComVPS* vps = NULL; 3091 vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId()); 3092 UInt layerIdx = vps->getLayerIdInVps(rpcSlice->getLayerId()); 3093 #if R0279_REP_FORMAT_INBL 3094 if ( vps->getVpsExtensionFlag() == 1 && (rpcSlice->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) ) 3095 { 3096 assert( sps->getPicWidthInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getPicWidthVpsInLumaSamples() ); 3097 assert( sps->getPicHeightInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getPicHeightVpsInLumaSamples() ); 3098 assert( sps->getChromaFormatIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getChromaFormatVpsIdc() ); 3099 assert( sps->getBitDepthY() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getBitDepthVpsLuma() ); 3100 assert( sps->getBitDepthC() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerIdx) )->getBitDepthVpsChroma() ); 3101 #else 3102 if ( rpcSlice->getLayerId() == 0 && vps->getVpsExtensionFlag() == 1 ) 3103 { 3104 assert( sps->getPicWidthInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getPicWidthVpsInLumaSamples() ); 3105 assert( sps->getPicHeightInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getPicHeightVpsInLumaSamples() ); 3106 assert( sps->getChromaFormatIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getChromaFormatVpsIdc() ); 3107 assert( sps->getBitDepthY() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getBitDepthVpsLuma() ); 3108 assert( sps->getBitDepthC() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getBitDepthVpsChroma() ); 3109 #endif 3110 } 3111 else if ( vps->getVpsExtensionFlag() == 1 ) 3112 { 3113 assert(vps->getVpsRepFormat(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getPicWidthVpsInLumaSamples() <= vps->getVpsRepFormat(vps->getVpsRepFormatIdx(layerIdx))->getPicWidthVpsInLumaSamples()); 3114 assert(vps->getVpsRepFormat(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getPicHeightVpsInLumaSamples() <= vps->getVpsRepFormat(vps->getVpsRepFormatIdx(layerIdx))->getPicHeightVpsInLumaSamples()); 3115 assert(vps->getVpsRepFormat(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getChromaFormatVpsIdc() <= vps->getVpsRepFormat(vps->getVpsRepFormatIdx(layerIdx))->getChromaFormatVpsIdc()); 3116 assert(vps->getVpsRepFormat(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsLuma() <= vps->getVpsRepFormat(vps->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsLuma()); 3117 assert(vps->getVpsRepFormat(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsChroma() <= vps->getVpsRepFormat(vps->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsChroma()); 3118 } 3119 #endif 3120 3121 if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) 3122 { 3123 READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); 3124 } 3125 else 3126 { 3127 rpcSlice->setDependentSliceSegmentFlag(false); 3128 } 3129 #if REPN_FORMAT_IN_VPS 3130 Int numCTUs = ((rpcSlice->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((rpcSlice->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); 3131 #else 3132 Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); 3133 #endif 3134 Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); 3135 UInt sliceSegmentAddress = 0; 3136 Int bitsSliceSegmentAddress = 0; 3137 while(numCTUs>(1<<bitsSliceSegmentAddress)) 3138 { 3139 bitsSliceSegmentAddress++; 3140 } 3141 3142 if(!firstSliceSegmentInPic) 3143 { 3144 READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); 3145 } 3146 //set uiCode to equal slice start address (or dependent slice start address) 3147 Int startCuAddress = maxParts*sliceSegmentAddress; 3148 rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); 3149 rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); 3150 3151 if (rpcSlice->getDependentSliceSegmentFlag()) 3152 { 3153 rpcSlice->setNextSlice ( false ); 3154 rpcSlice->setNextSliceSegment ( true ); 3155 } 3156 else 3157 { 3158 rpcSlice->setNextSlice ( true ); 3159 rpcSlice->setNextSliceSegment ( false ); 3160 3161 rpcSlice->setSliceCurStartCUAddr(startCuAddress); 3162 rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); 3163 } 3164 3165 #if Q0142_POC_LSB_NOT_PRESENT 3166 #if SHM_FIX7 3167 Int iPOClsb = 0; 3168 #endif 3169 #endif 3170 3171 if(!rpcSlice->getDependentSliceSegmentFlag()) 3172 { 3173 #if SVC_EXTENSION 3174 #if POC_RESET_FLAG 3175 Int iBits = 0; 3176 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3177 { 3178 READ_FLAG(uiCode, "poc_reset_flag"); rpcSlice->setPocResetFlag( uiCode ? true : false ); 3179 iBits++; 3180 } 3181 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3182 { 3183 #if DISCARDABLE_PIC_RPS 3184 READ_FLAG(uiCode, "discardable_flag"); rpcSlice->setDiscardableFlag( uiCode ? true : false ); 3185 #else 3186 READ_FLAG(uiCode, "discardable_flag"); // ignored 3187 #endif 3188 iBits++; 3189 } 3190 #if O0149_CROSS_LAYER_BLA_FLAG 3191 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3192 { 3193 READ_FLAG(uiCode, "cross_layer_bla_flag"); rpcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); 3194 iBits++; 3195 } 3196 #endif 3197 for (; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 3198 { 3199 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 3200 } 3201 #else 3202 #if CROSS_LAYER_BLA_FLAG_FIX 3203 Int iBits = 0; 3204 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3205 #else 3206 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) 3207 #endif 3208 { 3209 READ_FLAG(uiCode, "discardable_flag"); // ignored 3210 #if NON_REF_NAL_TYPE_DISCARDABLE 3211 rpcSlice->setDiscardableFlag( uiCode ? true : false ); 3212 if (uiCode) 3213 { 3214 assert(rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && 3215 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && 3216 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && 3217 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && 3218 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); 3219 } 3220 #endif 3221 #if CROSS_LAYER_BLA_FLAG_FIX 3222 iBits++; 3223 #endif 3224 } 3225 #if CROSS_LAYER_BLA_FLAG_FIX 3226 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3227 { 3228 READ_FLAG(uiCode, "cross_layer_bla_flag"); rpcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); 3229 iBits++; 3230 } 3231 for ( ; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 3232 #else 3233 for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 3234 #endif 3235 { 3236 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 3237 } 3238 #endif 3239 #else //SVC_EXTENSION 3240 for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 3241 { 3242 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 3243 } 3244 #endif //SVC_EXTENSION 3245 3246 READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); 3247 if( pps->getOutputFlagPresentFlag() ) 3248 { 3249 READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); 3250 } 3251 else 3252 { 3253 rpcSlice->setPicOutputFlag( true ); 3254 } 3255 // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present 3256 assert (sps->getChromaFormatIdc() == 1 ); 3257 // if( separate_colour_plane_flag == 1 ) 3258 // colour_plane_id u(2) 3259 3260 if( rpcSlice->getIdrPicFlag() ) 3261 { 3262 rpcSlice->setPOC(0); 3263 TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); 3264 rps->setNumberOfNegativePictures(0); 3265 rps->setNumberOfPositivePictures(0); 3266 rps->setNumberOfLongtermPictures(0); 3267 rps->setNumberOfPictures(0); 3268 rpcSlice->setRPS(rps); 3269 } 3270 #if N0065_LAYER_POC_ALIGNMENT 3271 #if !Q0142_POC_LSB_NOT_PRESENT 3272 #if SHM_FIX7 3273 Int iPOClsb = 0; 3274 #endif 3275 #endif 3276 #if O0062_POC_LSB_NOT_PRESENT_FLAG 3277 if( ( rpcSlice->getLayerId() > 0 && !rpcSlice->getVPS()->getPocLsbNotPresentFlag( rpcSlice->getVPS()->getLayerIdInVps(rpcSlice->getLayerId())) ) || !rpcSlice->getIdrPicFlag()) 3278 #else 3279 if( rpcSlice->getLayerId() > 0 || !rpcSlice->getIdrPicFlag() ) 3280 #endif 3281 #else 3282 else 3283 #endif 3284 { 3285 READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); 3286 #if POC_RESET_IDC_DECODER 3287 rpcSlice->setPicOrderCntLsb( uiCode ); 3288 #endif 3289 #if SHM_FIX7 3290 iPOClsb = uiCode; 3291 #else 3292 Int iPOClsb = uiCode; 3293 #endif 3294 Int iPrevPOC = rpcSlice->getPrevTid0POC(); 3295 Int iMaxPOClsb = 1<< sps->getBitsForPOC(); 3296 Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); 3297 Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; 3298 Int iPOCmsb; 3299 if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) 3300 { 3301 iPOCmsb = iPrevPOCmsb + iMaxPOClsb; 3302 } 3303 else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) 3304 { 3305 iPOCmsb = iPrevPOCmsb - iMaxPOClsb; 3306 } 3307 else 3308 { 3309 iPOCmsb = iPrevPOCmsb; 3310 } 3311 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 3312 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 3313 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 3314 { 3315 // For BLA picture types, POCmsb is set to 0. 3316 iPOCmsb = 0; 3317 } 3318 rpcSlice->setPOC (iPOCmsb+iPOClsb); 3319 3320 #if N0065_LAYER_POC_ALIGNMENT 3321 #if SHM_FIX7 3322 } 3323 #endif 3324 #if POC_RESET_IDC_DECODER 3325 else 3326 { 3327 rpcSlice->setPicOrderCntLsb( 0 ); 3328 } 3329 #endif 3330 if( !rpcSlice->getIdrPicFlag() ) 3331 { 3332 #endif 3333 TComReferencePictureSet* rps; 3334 rps = rpcSlice->getLocalRPS(); 3335 rpcSlice->setRPS(rps); 3336 READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); 3337 if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header 3338 { 3339 parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); 3340 } 3341 else // use reference to short-term reference picture set in PPS 3342 { 3343 Int numBits = 0; 3344 while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) 3345 { 3346 numBits++; 3347 } 3348 if (numBits > 0) 3349 { 3350 READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); 3351 } 3352 else 3353 { 3354 uiCode = 0; 3355 } 3356 *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); 3357 } 3358 if(sps->getLongTermRefsPresent()) 3359 { 3360 Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); 3361 UInt numOfLtrp = 0; 3362 UInt numLtrpInSPS = 0; 3363 if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) 3364 { 3365 READ_UVLC( uiCode, "num_long_term_sps"); 3366 numLtrpInSPS = uiCode; 3367 numOfLtrp += numLtrpInSPS; 3368 rps->setNumberOfLongtermPictures(numOfLtrp); 3369 } 3370 Int bitsForLtrpInSPS = 0; 3371 while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) 3372 { 3373 bitsForLtrpInSPS++; 3374 } 3375 READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); 3376 numOfLtrp += uiCode; 3377 rps->setNumberOfLongtermPictures(numOfLtrp); 3378 Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); 3379 Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; 3380 for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) 3381 { 3382 Int pocLsbLt; 3383 if (k < numLtrpInSPS) 3384 { 3385 uiCode = 0; 3386 if (bitsForLtrpInSPS > 0) 3387 { 3388 READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); 3389 } 3390 Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); 3391 3392 pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); 3393 rps->setUsed(j,usedByCurrFromSPS); 3394 } 3395 else 3396 { 3397 READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; 3398 READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); 3399 } 3400 READ_FLAG(uiCode,"delta_poc_msb_present_flag"); 3401 Bool mSBPresentFlag = uiCode ? true : false; 3402 if(mSBPresentFlag) 3403 { 3404 READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); 3405 Bool deltaFlag = false; 3406 // First LTRP || First LTRP from SH 3407 if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) 3408 { 3409 deltaFlag = true; 3410 } 3411 if(deltaFlag) 3412 { 3413 deltaPocMSBCycleLT = uiCode; 3414 } 3415 else 3416 { 3417 deltaPocMSBCycleLT = uiCode + prevDeltaMSB; 3418 } 3419 3420 Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB 3421 - iPOClsb + pocLsbLt; 3422 rps->setPOC (j, pocLTCurr); 3423 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); 3424 rps->setCheckLTMSBPresent(j,true); 3425 } 3426 else 3427 { 3428 rps->setPOC (j, pocLsbLt); 3429 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); 3430 rps->setCheckLTMSBPresent(j,false); 3431 3432 // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present 3433 if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) 3434 { 3435 deltaPocMSBCycleLT = 0; 3436 } 3437 } 3438 prevDeltaMSB = deltaPocMSBCycleLT; 3439 } 3440 offset += rps->getNumberOfLongtermPictures(); 3441 rps->setNumberOfPictures(offset); 3442 } 3443 #if DPB_CONSTRAINTS 3444 if(rpcSlice->getVPS()->getVpsExtensionFlag()==1) 3445 { 3446 #if Q0078_ADD_LAYER_SETS 3447 for (Int ii = 1; ii < (rpcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++) // prevent assert error when num_add_layer_sets > 0 3448 #else 3449 for (Int ii=1; ii< rpcSlice->getVPS()->getNumOutputLayerSets(); ii++ ) 3450 #endif 3451 { 3452 Int layerSetIdxForOutputLayerSet = rpcSlice->getVPS()->getOutputLayerSetIdx( ii ); 3453 Int chkAssert=0; 3454 for(Int kk = 0; kk < rpcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++) 3455 { 3456 #if R0235_SMALLEST_LAYER_ID 3457 if(vps->getNecessaryLayerFlag(ii, kk) && rpcSlice->getLayerId()==rpcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk)) 3458 #else 3459 if(rpcSlice->getLayerId()==rpcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk)) 3460 #endif 3461 { 3462 chkAssert=1; 3463 } 3464 } 3465 if(chkAssert) 3466 { 3467 // There may be something wrong here (layer id assumed to be layer idx?) 3468 assert(rps->getNumberOfNegativePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 3469 assert(rps->getNumberOfPositivePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); 3470 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 3471 } 3472 } 3473 3474 3475 } 3476 if(rpcSlice->getLayerId() == 0) 3477 { 3478 assert(rps->getNumberOfNegativePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) ); 3479 assert(rps->getNumberOfPositivePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures()); 3480 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1)); 3481 } 3482 #endif 3483 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 3484 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 3485 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 3486 { 3487 // In the case of BLA picture types, rps data is read from slice header but ignored 3488 rps = rpcSlice->getLocalRPS(); 3489 rps->setNumberOfNegativePictures(0); 3490 rps->setNumberOfPositivePictures(0); 3491 rps->setNumberOfLongtermPictures(0); 3492 rps->setNumberOfPictures(0); 3493 rpcSlice->setRPS(rps); 3494 } 3495 if (rpcSlice->getSPS()->getTMVPFlagsPresent()) 3496 { 3497 #if R0226_SLICE_TMVP 3498 READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" ); 3499 #else 3500 READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); 3501 #endif 3502 rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); 3503 } 3504 else 3505 { 3506 rpcSlice->setEnableTMVPFlag(false); 3507 } 3508 #if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX7 3509 } 3510 #endif 3511 } 3512 3513 #if SVC_EXTENSION 3514 rpcSlice->setActiveNumILRRefIdx(0); 3515 if((rpcSlice->getLayerId() > 0) && !(rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (rpcSlice->getNumILRRefIdx() > 0) ) 3516 { 3517 READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); 3518 rpcSlice->setInterLayerPredEnabledFlag(uiCode); 3519 if( rpcSlice->getInterLayerPredEnabledFlag()) 3520 { 3521 if(rpcSlice->getNumILRRefIdx() > 1) 3522 { 3523 Int numBits = 1; 3524 while ((1 << numBits) < rpcSlice->getNumILRRefIdx()) 3525 { 3526 numBits++; 3527 } 3528 if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) 3529 { 3530 READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); 3531 rpcSlice->setActiveNumILRRefIdx(uiCode + 1); 3532 } 3533 else 3534 { 3535 #if P0079_DERIVE_NUMACTIVE_REF_PICS 3536 for( Int i = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) 3537 { 3538 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 3539 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 3540 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 3541 #else 3542 if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && 3543 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 3544 #endif 3545 { 3546 rpcSlice->setActiveNumILRRefIdx(1); 3547 break; 3548 } 3549 } 3550 #else 3551 rpcSlice->setActiveNumILRRefIdx(1); 3552 #endif 3553 } 3554 3555 if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() ) 3556 { 3557 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3558 { 3559 rpcSlice->setInterLayerPredLayerIdc(i,i); 3560 } 3561 } 3562 else 3563 { 3564 for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3565 { 3566 READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); 3567 rpcSlice->setInterLayerPredLayerIdc(uiCode,i); 3568 } 3569 } 3570 } 3571 else 3572 { 3573 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 3574 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 3575 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 3576 (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) 3577 #else 3578 if( (rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer()) && 3579 (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) 3580 #endif 3581 { 3582 #endif 3583 rpcSlice->setActiveNumILRRefIdx(1); 3584 rpcSlice->setInterLayerPredLayerIdc(0,0); 3585 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 3586 } 3587 #endif 3588 } 3589 } 3590 } 3591 else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true && (rpcSlice->getLayerId() > 0 )) 3592 { 3593 rpcSlice->setInterLayerPredEnabledFlag(true); 3594 3595 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 3596 Int numRefLayerPics = 0; 3597 Int i = 0; 3598 Int refLayerPicIdc [MAX_VPS_LAYER_ID_PLUS1]; 3599 for(i = 0, numRefLayerPics = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) 3600 { 3601 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 3602 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 3603 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 3604 #else 3605 if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && 3606 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 3607 #endif 3608 { 3609 refLayerPicIdc[ numRefLayerPics++ ] = i; 3610 } 3611 } 3612 rpcSlice->setActiveNumILRRefIdx(numRefLayerPics); 3613 for( i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3614 { 3615 rpcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i); 3616 } 3617 #else 3618 rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx()); 3619 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3620 { 3621 rpcSlice->setInterLayerPredLayerIdc(i,i); 3622 } 3623 #endif 3624 } 4453 Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) 4454 { 4455 UInt uiCode; 4456 // more syntax elements to be parsed here 4457 4458 READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); 4459 // Vertical MV component restriction is not used in SHVC CTC 4460 assert( uiCode == 0 ); 4461 4462 #if !MOVE_SCALED_OFFSET_TO_PPS 4463 if( pcSPS->getLayerId() > 0 ) 4464 { 4465 Int iCode; 4466 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); 4467 for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) 4468 { 4469 Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); 4470 #if O0098_SCALED_REF_LAYER_ID 4471 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); 4472 #endif 4473 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 4474 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 4475 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 4476 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 3625 4477 #if P0312_VERT_PHASE_ADJ 3626 for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3627 { 3628 UInt refLayerIdc = rpcSlice->getInterLayerPredLayerIdc(i); 3629 #if !MOVE_SCALED_OFFSET_TO_PPS 3630 if( rpcSlice->getSPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 3631 #else 3632 if( rpcSlice->getPPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 3633 #endif 3634 { 3635 READ_FLAG( uiCode, "vert_phase_position_flag" ); rpcSlice->setVertPhasePositionFlag( uiCode? true : false, refLayerIdc ); 3636 } 3637 } 3638 #endif 3639 #endif //SVC_EXTENSION 3640 3641 if(sps->getUseSAO()) 3642 { 3643 READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); 3644 #if AUXILIARY_PICTURES 3645 ChromaFormat format; 3646 #if REPN_FORMAT_IN_VPS 3647 #if O0096_REP_FORMAT_INDEX 3648 if( sps->getLayerId() == 0 ) 3649 { 3650 format = sps->getChromaFormatIdc(); 3651 } 3652 else 3653 { 3654 format = rpcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getVPS()->getVpsRepFormatIdx( rpcSlice->getVPS()->getLayerIdInVps(sps->getLayerId()) ) )->getChromaFormatVpsIdc(); 3655 #if Q0195_REP_FORMAT_CLEANUP 3656 assert( (sps->getUpdateRepFormatFlag()==false && rpcSlice->getVPS()->getVpsNumRepFormats()==1) || rpcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check 3657 #endif 3658 } 3659 #else 3660 if( ( sps->getLayerId() == 0 ) || sps->getUpdateRepFormatFlag() ) 3661 { 3662 format = sps->getChromaFormatIdc(); 3663 } 3664 else 3665 { 3666 format = rpcSlice->getVPS()->getVpsRepFormat( rpcSlice->getVPS()->getVpsRepFormatIdx( rpcSlice->getVPS()->getLayerIdInVps(sps->getLayerId()) ) )->getChromaFormatVpsIdc(); 3667 } 3668 #endif 3669 #else 3670 format = sps->getChromaFormatIdc(); 3671 #endif 3672 if (format != CHROMA_400) 3673 { 3674 #endif 3675 READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); 3676 #if AUXILIARY_PICTURES 3677 } 3678 else 3679 { 3680 rpcSlice->setSaoEnabledFlagChroma(false); 3681 } 3682 #endif 3683 } 3684 3685 if (rpcSlice->getIdrPicFlag()) 3686 { 3687 rpcSlice->setEnableTMVPFlag(false); 3688 } 3689 if (!rpcSlice->isIntra()) 3690 { 3691 3692 READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); 3693 if (uiCode) 3694 { 3695 READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); 3696 if (rpcSlice->isInterB()) 3697 { 3698 READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); 3699 } 3700 else 3701 { 3702 rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); 3703 } 3704 } 3705 else 3706 { 3707 rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); 3708 if (rpcSlice->isInterB()) 3709 { 3710 rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); 3711 } 3712 else 3713 { 3714 rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); 3715 } 3716 } 3717 } 3718 // } 3719 TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); 3720 if(!rpcSlice->isIntra()) 3721 { 3722 if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) 3723 { 3724 refPicListModification->setRefPicListModificationFlagL0( 0 ); 3725 } 3726 else 3727 { 3728 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); 3729 } 3730 3731 if(refPicListModification->getRefPicListModificationFlagL0()) 3732 { 3733 uiCode = 0; 3734 Int i = 0; 3735 Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); 3736 if ( numRpsCurrTempList0 > 1 ) 3737 { 3738 Int length = 1; 3739 numRpsCurrTempList0 --; 3740 while ( numRpsCurrTempList0 >>= 1) 3741 { 3742 length ++; 3743 } 3744 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 3745 { 3746 READ_CODE( length, uiCode, "list_entry_l0" ); 3747 refPicListModification->setRefPicSetIdxL0(i, uiCode ); 3748 } 3749 } 3750 else 3751 { 3752 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 3753 { 3754 refPicListModification->setRefPicSetIdxL0(i, 0 ); 3755 } 3756 } 3757 } 3758 } 3759 else 3760 { 3761 refPicListModification->setRefPicListModificationFlagL0(0); 3762 } 3763 if(rpcSlice->isInterB()) 3764 { 3765 if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) 3766 { 3767 refPicListModification->setRefPicListModificationFlagL1( 0 ); 3768 } 3769 else 3770 { 3771 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); 3772 } 3773 if(refPicListModification->getRefPicListModificationFlagL1()) 3774 { 3775 uiCode = 0; 3776 Int i = 0; 3777 Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); 3778 if ( numRpsCurrTempList1 > 1 ) 3779 { 3780 Int length = 1; 3781 numRpsCurrTempList1 --; 3782 while ( numRpsCurrTempList1 >>= 1) 3783 { 3784 length ++; 3785 } 3786 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 3787 { 3788 READ_CODE( length, uiCode, "list_entry_l1" ); 3789 refPicListModification->setRefPicSetIdxL1(i, uiCode ); 3790 } 3791 } 3792 else 3793 { 3794 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 3795 { 3796 refPicListModification->setRefPicSetIdxL1(i, 0 ); 3797 } 3798 } 3799 } 3800 } 3801 else 3802 { 3803 refPicListModification->setRefPicListModificationFlagL1(0); 3804 } 3805 if (rpcSlice->isInterB()) 3806 { 3807 READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); 3808 } 3809 3810 rpcSlice->setCabacInitFlag( false ); // default 3811 if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) 3812 { 3813 READ_FLAG(uiCode, "cabac_init_flag"); 3814 rpcSlice->setCabacInitFlag( uiCode ? true : false ); 3815 } 3816 3817 if ( rpcSlice->getEnableTMVPFlag() ) 3818 { 3819 #if SVC_EXTENSION && REF_IDX_MFM 3820 // set motion mapping flag 3821 rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() && !rpcSlice->isIntra() ) ? true : false ); 3822 #endif 3823 if ( rpcSlice->getSliceType() == B_SLICE ) 3824 { 3825 READ_FLAG( uiCode, "collocated_from_l0_flag" ); 3826 rpcSlice->setColFromL0Flag(uiCode); 3827 } 3828 else 3829 { 3830 rpcSlice->setColFromL0Flag( 1 ); 3831 } 3832 3833 if ( rpcSlice->getSliceType() != I_SLICE && 3834 ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| 3835 (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) 3836 { 3837 READ_UVLC( uiCode, "collocated_ref_idx" ); 3838 rpcSlice->setColRefIdx(uiCode); 3839 } 3840 else 3841 { 3842 rpcSlice->setColRefIdx(0); 3843 } 3844 } 3845 if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) 3846 { 3847 xParsePredWeightTable(rpcSlice); 3848 rpcSlice->initWpScaling(); 3849 } 3850 if (!rpcSlice->isIntra()) 3851 { 3852 READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); 3853 rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); 3854 } 3855 3856 READ_SVLC( iCode, "slice_qp_delta" ); 3857 rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); 3858 3859 #if REPN_FORMAT_IN_VPS 3860 #if O0194_DIFFERENT_BITDEPTH_EL_BL 3861 g_bitDepthYLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthY(); 3862 g_bitDepthCLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthC(); 3863 #endif 3864 assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() ); 3865 #else 3866 assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); 3867 #endif 3868 assert( rpcSlice->getSliceQp() <= 51 ); 3869 3870 if (rpcSlice->getPPS()->getSliceChromaQpFlag()) 3871 { 3872 READ_SVLC( iCode, "slice_qp_delta_cb" ); 3873 rpcSlice->setSliceQpDeltaCb( iCode ); 3874 assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); 3875 assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); 3876 assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); 3877 assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); 3878 3879 READ_SVLC( iCode, "slice_qp_delta_cr" ); 3880 rpcSlice->setSliceQpDeltaCr( iCode ); 3881 assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); 3882 assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); 3883 assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); 3884 assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); 3885 } 3886 3887 if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) 3888 { 3889 if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) 3890 { 3891 READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); 3892 } 3893 else 3894 { 3895 rpcSlice->setDeblockingFilterOverrideFlag(0); 3896 } 3897 if(rpcSlice->getDeblockingFilterOverrideFlag()) 3898 { 3899 READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); 3900 if(!rpcSlice->getDeblockingFilterDisable()) 3901 { 3902 READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); 3903 assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && 3904 rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); 3905 READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); 3906 assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && 3907 rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); 3908 } 3909 } 3910 else 3911 { 3912 rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); 3913 rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); 3914 rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); 3915 } 3916 } 3917 else 3918 { 3919 rpcSlice->setDeblockingFilterDisable ( false ); 3920 rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); 3921 rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); 3922 } 3923 3924 Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); 3925 Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); 3926 3927 if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) 3928 { 3929 READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); 3930 } 3931 else 3932 { 3933 uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; 3934 } 3935 rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); 3936 3937 } 3938 3939 UInt *entryPointOffset = NULL; 3940 UInt numEntryPointOffsets, offsetLenMinus1; 3941 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 3942 { 3943 READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); 3944 if (numEntryPointOffsets>0) 3945 { 3946 READ_UVLC(offsetLenMinus1, "offset_len_minus1"); 3947 } 3948 entryPointOffset = new UInt[numEntryPointOffsets]; 3949 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 3950 { 3951 READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); 3952 entryPointOffset[ idx ] = uiCode + 1; 3953 } 3954 } 3955 else 3956 { 3957 rpcSlice->setNumEntryPointOffsets ( 0 ); 3958 } 3959 3960 #if POC_RESET_IDC_SIGNALLING 3961 Int sliceHeaderExtensionLength = 0; 3962 if(pps->getSliceHeaderExtensionPresentFlag()) 3963 { 3964 READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode; 3965 } 3966 else 3967 { 3968 sliceHeaderExtensionLength = 0; 3969 #if INFERENCE_POC_MSB_VAL_PRESENT 3970 rpcSlice->setPocMsbValPresentFlag( false ); 3971 #endif 3972 } 3973 UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits 3974 if( sliceHeaderExtensionLength > 0 ) 3975 { 3976 if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() ) 3977 { 3978 READ_CODE( 2, uiCode, "poc_reset_idc"); rpcSlice->setPocResetIdc(uiCode); 3979 #if POC_RESET_RESTRICTIONS 3980 /* The value of poc_reset_idc shall not be equal to 1 or 2 for a RASL picture, a RADL picture, 3981 a sub-layer non-reference picture, or a picture that has TemporalId greater than 0, 3982 or a picture that has discardable_flag equal to 1. */ 3983 if( rpcSlice->getPocResetIdc() == 1 || rpcSlice->getPocResetIdc() == 2 ) 3984 { 3985 assert( !rpcSlice->isRASL() ); 3986 assert( !rpcSlice->isRADL() ); 3987 assert( !rpcSlice->isSLNR() ); 3988 assert( rpcSlice->getTLayer() == 0 ); 3989 assert( rpcSlice->getDiscardableFlag() == 0 ); 3990 } 3991 3992 // The value of poc_reset_idc of a CRA or BLA picture shall be less than 3. 3993 if( rpcSlice->getPocResetIdc() == 3) 3994 { 3995 assert( ! ( rpcSlice->isCRA() || rpcSlice->isBLA() ) ); 3996 } 3997 #endif 3998 } 3999 else 4000 { 4001 rpcSlice->setPocResetIdc( 0 ); 4002 } 4003 #if Q0142_POC_LSB_NOT_PRESENT 4004 if ( vps->getPocLsbNotPresentFlag(layerIdx) && iPOClsb > 0 ) 4005 { 4006 assert( rpcSlice->getPocResetIdc() != 2 ); 4007 } 4008 #endif 4009 if( rpcSlice->getPocResetIdc() > 0 ) 4010 { 4011 READ_CODE(6, uiCode, "poc_reset_period_id"); rpcSlice->setPocResetPeriodId(uiCode); 4012 } 4013 else 4014 { 4015 4016 rpcSlice->setPocResetPeriodId( 0 ); 4017 } 4018 4019 if (rpcSlice->getPocResetIdc() == 3) 4020 { 4021 READ_FLAG( uiCode, "full_poc_reset_flag"); rpcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); 4022 READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); rpcSlice->setPocLsbVal(uiCode); 4023 #if Q0142_POC_LSB_NOT_PRESENT 4024 if ( vps->getPocLsbNotPresentFlag(layerIdx) && rpcSlice->getFullPocResetFlag() ) 4025 { 4026 assert( rpcSlice->getPocLsbVal() == 0 ); 4027 } 4028 #endif 4029 } 4030 4031 // Derive the value of PocMsbValRequiredFlag 4032 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 4033 rpcSlice->setPocMsbValRequiredFlag( (rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag()) 4034 && (!rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() || 4035 (rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() && rpcSlice->getVPS()->getNumDirectRefLayers(rpcSlice->getLayerId()) == 0)) 4036 ); 4037 #else 4038 rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag() ); 4039 #endif 4040 4041 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 4042 if (!rpcSlice->getPocMsbValRequiredFlag() && rpcSlice->getVPS()->getVpsPocLsbAlignedFlag()) 4043 #else 4044 if (!rpcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */) 4045 #endif 4046 { 4047 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 4048 READ_FLAG(uiCode, "poc_msb_cycle_val_present_flag"); rpcSlice->setPocMsbValPresentFlag(uiCode ? true : false); 4049 #else 4050 READ_FLAG(uiCode, "poc_msb_val_present_flag"); rpcSlice->setPocMsbValPresentFlag(uiCode ? true : false); 4051 #endif 4052 } 4053 else 4054 { 4055 #if POC_MSB_VAL_PRESENT_FLAG_SEM 4056 if( sliceHeaderExtensionLength == 0 ) 4057 { 4058 rpcSlice->setPocMsbValPresentFlag( false ); 4059 } 4060 else if( rpcSlice->getPocMsbValRequiredFlag() ) 4061 #else 4062 if( rpcSlice->getPocMsbValRequiredFlag() ) 4063 #endif 4064 { 4065 rpcSlice->setPocMsbValPresentFlag( true ); 4066 } 4067 else 4068 { 4069 rpcSlice->setPocMsbValPresentFlag( false ); 4070 } 4071 } 4072 4073 #if !POC_RESET_IDC_DECODER 4074 Int maxPocLsb = 1 << rpcSlice->getSPS()->getBitsForPOC(); 4075 #endif 4076 if( rpcSlice->getPocMsbValPresentFlag() ) 4077 { 4078 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 4079 READ_UVLC( uiCode, "poc_msb_cycle_val"); rpcSlice->setPocMsbVal( uiCode ); 4080 #else 4081 READ_UVLC( uiCode, "poc_msb_val"); rpcSlice->setPocMsbVal( uiCode ); 4082 #endif 4083 4084 #if !POC_RESET_IDC_DECODER 4085 // Update POC of the slice based on this MSB val 4086 Int pocLsb = rpcSlice->getPOC() % maxPocLsb; 4087 rpcSlice->setPOC((rpcSlice->getPocMsbVal() * maxPocLsb) + pocLsb); 4088 } 4089 else 4090 { 4091 rpcSlice->setPocMsbVal( rpcSlice->getPOC() / maxPocLsb ); 4092 #endif 4093 } 4094 4095 // Read remaining bits in the slice header extension. 4096 UInt endBits = m_pcBitstream->getNumBitsRead(); 4097 Int counter = (endBits - startBits) % 8; 4098 if( counter ) 4099 { 4100 counter = 8 - counter; 4101 } 4102 4103 while( counter ) 4104 { 4105 #if Q0146_SSH_EXT_DATA_BIT 4106 READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); 4107 #else 4108 READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 ); 4109 #endif 4110 counter--; 4111 } 4112 } 4113 #else 4114 if(pps->getSliceHeaderExtensionPresentFlag()) 4115 { 4116 READ_UVLC(uiCode,"slice_header_extension_length"); 4117 for(Int i=0; i<uiCode; i++) 4118 { 4119 UInt ignore; 4120 READ_CODE(8,ignore,"slice_header_extension_data_byte"); 4121 } 4122 } 4123 #endif 4124 m_pcBitstream->readByteAlignment(); 4125 4126 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 4127 { 4128 Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); 4129 4130 // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header 4131 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 4132 { 4133 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) 4134 { 4135 endOfSliceHeaderLocation++; 4136 } 4137 } 4138 4139 Int curEntryPointOffset = 0; 4140 Int prevEntryPointOffset = 0; 4141 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 4142 { 4143 curEntryPointOffset += entryPointOffset[ idx ]; 4144 4145 Int emulationPreventionByteCount = 0; 4146 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 4147 { 4148 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && 4149 m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) 4150 { 4151 emulationPreventionByteCount++; 4152 } 4153 } 4154 4155 entryPointOffset[ idx ] -= emulationPreventionByteCount; 4156 prevEntryPointOffset = curEntryPointOffset; 4157 } 4158 4159 if ( pps->getTilesEnabledFlag() ) 4160 { 4161 rpcSlice->setTileLocationCount( numEntryPointOffsets ); 4162 4163 UInt prevPos = 0; 4164 for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) 4165 { 4166 rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); 4167 prevPos += entryPointOffset[ idx ]; 4168 } 4169 } 4170 else if ( pps->getEntropyCodingSyncEnabledFlag() ) 4171 { 4172 Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; 4173 rpcSlice->allocSubstreamSizes(numSubstreams); 4174 UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); 4175 for (Int idx=0; idx<numSubstreams-1; idx++) 4176 { 4177 if ( idx < numEntryPointOffsets ) 4178 { 4179 pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; 4180 } 4181 else 4182 { 4183 pSubstreamSizes[ idx ] = 0; 4184 } 4185 } 4186 } 4187 4188 if (entryPointOffset) 4189 { 4190 delete [] entryPointOffset; 4191 } 4192 } 4193 4194 return; 4195 } 4196 4197 Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) 4198 { 4199 UInt uiCode; 4200 if(profilePresentFlag) 4201 { 4202 parseProfileTier(rpcPTL->getGeneralPTL()); 4203 } 4204 READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); 4205 4206 for (Int i = 0; i < maxNumSubLayersMinus1; i++) 4207 { 4208 #if MULTIPLE_PTL_SUPPORT 4209 READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); 4210 #else 4211 if(profilePresentFlag) 4212 { 4213 READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); 4214 } 4215 #endif 4216 READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); 4217 } 4218 4219 if (maxNumSubLayersMinus1 > 0) 4220 { 4221 for (Int i = maxNumSubLayersMinus1; i < 8; i++) 4222 { 4223 READ_CODE(2, uiCode, "reserved_zero_2bits"); 4224 assert(uiCode == 0); 4225 } 4226 } 4227 4228 for(Int i = 0; i < maxNumSubLayersMinus1; i++) 4229 { 4230 #if MULTIPLE_PTL_SUPPORT 4231 if( rpcPTL->getSubLayerProfilePresentFlag(i) ) 4232 #else 4233 if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) 4234 #endif 4235 { 4236 parseProfileTier(rpcPTL->getSubLayerPTL(i)); 4237 } 4238 if(rpcPTL->getSubLayerLevelPresentFlag(i)) 4239 { 4240 READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); 4241 } 4242 } 4243 } 4244 4245 Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) 4246 { 4247 UInt uiCode; 4248 READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); 4249 READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); 4250 READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); 4251 for(Int j = 0; j < 32; j++) 4252 { 4253 READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); 4254 } 4255 READ_FLAG(uiCode, "general_progressive_source_flag"); 4256 ptl->setProgressiveSourceFlag(uiCode ? true : false); 4257 4258 READ_FLAG(uiCode, "general_interlaced_source_flag"); 4259 ptl->setInterlacedSourceFlag(uiCode ? true : false); 4260 4261 READ_FLAG(uiCode, "general_non_packed_constraint_flag"); 4262 ptl->setNonPackedConstraintFlag(uiCode ? true : false); 4263 4264 READ_FLAG(uiCode, "general_frame_only_constraint_flag"); 4265 ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); 4266 4267 #if MULTIPLE_PTL_SUPPORT 4268 if( ptl->getProfileIdc() == 4 || ptl->getProfileCompatibilityFlag(4) || 4269 ptl->getProfileIdc() == 5 || ptl->getProfileCompatibilityFlag(5) || 4270 ptl->getProfileIdc() == 6 || ptl->getProfileCompatibilityFlag(6) || 4271 ptl->getProfileIdc() == 7 || ptl->getProfileCompatibilityFlag(7) ) 4272 { 4273 READ_FLAG( uiCode, "general_max_12bit_constraint_flag" ); assert (uiCode == 1); 4274 READ_FLAG( uiCode, "general_max_10bit_constraint_flag" ); assert (uiCode == 1); 4275 READ_FLAG( uiCode, "general_max_8bit_constraint_flag" ); ptl->setProfileIdc ((uiCode) ? Profile::SCALABLEMAIN : Profile::SCALABLEMAIN10); 4276 READ_FLAG( uiCode, "general_max_422chroma_constraint_flag" ); assert (uiCode == 1); 4277 READ_FLAG( uiCode, "general_max_420chroma_constraint_flag" ); assert (uiCode == 1); 4278 READ_FLAG( uiCode, "general_max_monochrome_constraint_flag" ); assert (uiCode == 0); 4279 READ_FLAG( uiCode, "general_intra_constraint_flag"); assert (uiCode == 0); 4280 READ_FLAG( uiCode, "general_one_picture_only_constraint_flag"); assert (uiCode == 0); 4281 READ_FLAG( uiCode, "general_lower_bit_rate_constraint_flag"); assert (uiCode == 1); 4282 READ_CODE(32, uiCode, "general_reserved_zero_34bits"); READ_CODE(2, uiCode, "general_reserved_zero_34bits"); 4283 } 4284 else 4285 { 4286 READ_CODE(32, uiCode, "general_reserved_zero_43bits"); READ_CODE(11, uiCode, "general_reserved_zero_43bits"); 4287 } 4288 4289 if( ( ptl->getProfileIdc() >= 1 && ptl->getProfileIdc() <= 5 ) || 4290 ptl->getProfileCompatibilityFlag(1) || ptl->getProfileCompatibilityFlag(2) || 4291 ptl->getProfileCompatibilityFlag(3) || ptl->getProfileCompatibilityFlag(4) || 4292 ptl->getProfileCompatibilityFlag(5) ) 4293 { 4294 READ_FLAG(uiCode, "general_inbld_flag"); 4295 } 4296 else 4297 { 4298 READ_FLAG(uiCode, "general_reserved_zero_bit"); 4299 } 4300 #else 4301 READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); 4302 READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); 4303 READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); 4304 #endif 4305 } 4306 4307 Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) 4308 { 4309 ruiBit = false; 4310 Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); 4311 if(iBitsLeft <= 8) 4312 { 4313 UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); 4314 if (uiPeekValue == (1<<(iBitsLeft-1))) 4315 { 4316 ruiBit = true; 4317 } 4318 } 4319 } 4320 4321 Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4322 { 4323 assert(0); 4324 } 4325 4326 Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4327 { 4328 assert(0); 4329 } 4330 4331 Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) 4332 { 4333 assert(0); 4334 } 4335 4336 Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4337 { 4338 assert(0); 4339 } 4340 4341 Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4342 { 4343 assert(0); 4344 } 4345 4346 Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4347 { 4348 assert(0); 4349 } 4350 4351 /** Parse I_PCM information. 4352 * \param pcCU pointer to CU 4353 * \param uiAbsPartIdx CU index 4354 * \param uiDepth CU depth 4355 * \returns Void 4356 * 4357 * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. 4358 */ 4359 Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4360 { 4361 assert(0); 4362 } 4363 4364 Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4365 { 4366 assert(0); 4367 } 4368 4369 Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4370 { 4371 assert(0); 4372 } 4373 4374 Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) 4375 { 4376 assert(0); 4377 } 4378 4379 Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) 4380 { 4381 assert(0); 4382 } 4383 4384 Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) 4385 { 4386 assert(0); 4387 } 4388 4389 Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 4390 { 4391 Int qp; 4392 Int iDQp; 4393 4394 xReadSvlc( iDQp ); 4395 4396 #if REPN_FORMAT_IN_VPS 4397 Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); 4398 #else 4399 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); 4400 #endif 4401 qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; 4402 4403 UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; 4404 UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; 4405 4406 pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); 4407 } 4408 4409 Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) 4410 { 4411 assert(0); 4412 } 4413 4414 Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) 4415 { 4416 assert(0); 4417 } 4418 4419 Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) 4420 { 4421 assert(0); 4422 } 4423 4424 Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) 4425 { 4426 assert(0); 4427 } 4428 4429 Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) 4430 { 4431 assert(0); 4432 } 4433 4434 Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) 4435 { 4436 assert(0); 4437 } 4438 4439 Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) 4440 { 4441 assert(0); 4442 } 4443 4444 // ==================================================================================================================== 4445 // Protected member functions 4446 // ==================================================================================================================== 4447 4448 /** parse explicit wp tables 4449 * \param TComSlice* pcSlice 4450 * \returns Void 4451 */ 4452 Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) 4453 { 4454 wpScalingParam *wp; 4455 Bool bChroma = true; // color always present in HEVC ? 4456 SliceType eSliceType = pcSlice->getSliceType(); 4457 Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); 4458 #if SVC_EXTENSION 4459 UInt uiLog2WeightDenomLuma = 0, uiLog2WeightDenomChroma = 0; 4460 #else 4461 UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; 4462 #endif 4463 UInt uiTotalSignalledWeightFlags = 0; 4464 4465 Int iDeltaDenom; 4466 #if AUXILIARY_PICTURES 4467 if (pcSlice->getChromaFormatIdc() == CHROMA_400) 4468 { 4469 bChroma = false; 4470 } 4471 #endif 4472 // decode delta_luma_log2_weight_denom : 4473 READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom 4474 assert( uiLog2WeightDenomLuma <= 7 ); 4475 if( bChroma ) 4476 { 4477 READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom 4478 assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); 4479 assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); 4480 uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); 4481 } 4482 4483 for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) 4484 { 4485 RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 4486 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 4487 { 4488 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 4489 4490 wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; 4491 #if AUXILIARY_PICTURES 4492 if (!bChroma) 4493 { 4494 wp[1].uiLog2WeightDenom = 0; 4495 wp[2].uiLog2WeightDenom = 0; 4496 } 4497 else 4498 { 4499 #endif 4500 wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; 4501 wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; 4502 #if AUXILIARY_PICTURES 4503 } 4504 #endif 4505 4506 UInt uiCode; 4507 READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag 4508 wp[0].bPresentFlag = ( uiCode == 1 ); 4509 uiTotalSignalledWeightFlags += wp[0].bPresentFlag; 4510 } 4511 if ( bChroma ) 4512 { 4513 UInt uiCode; 4514 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 4515 { 4516 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 4517 READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag 4518 wp[1].bPresentFlag = ( uiCode == 1 ); 4519 wp[2].bPresentFlag = ( uiCode == 1 ); 4520 uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; 4521 } 4522 } 4523 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 4524 { 4525 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 4526 if ( wp[0].bPresentFlag ) 4527 { 4528 Int iDeltaWeight; 4529 READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] 4530 assert( iDeltaWeight >= -128 ); 4531 assert( iDeltaWeight <= 127 ); 4532 wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); 4533 READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] 4534 assert( wp[0].iOffset >= -128 ); 4535 assert( wp[0].iOffset <= 127 ); 4536 } 4537 else 4538 { 4539 wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); 4540 wp[0].iOffset = 0; 4541 } 4542 if ( bChroma ) 4543 { 4544 if ( wp[1].bPresentFlag ) 4545 { 4546 for ( Int j=1 ; j<3 ; j++ ) 4547 { 4548 Int iDeltaWeight; 4549 READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] 4550 assert( iDeltaWeight >= -128 ); 4551 assert( iDeltaWeight <= 127 ); 4552 wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); 4553 4554 Int iDeltaChroma; 4555 READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] 4556 assert( iDeltaChroma >= -512 ); 4557 assert( iDeltaChroma <= 511 ); 4558 Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); 4559 wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); 4560 } 4561 } 4562 else 4563 { 4564 for ( Int j=1 ; j<3 ; j++ ) 4565 { 4566 wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); 4567 wp[j].iOffset = 0; 4568 } 4569 } 4570 } 4571 } 4572 4573 for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) 4574 { 4575 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 4576 4577 wp[0].bPresentFlag = false; 4578 wp[1].bPresentFlag = false; 4579 wp[2].bPresentFlag = false; 4580 } 4581 } 4582 assert(uiTotalSignalledWeightFlags<=24); 4583 } 4584 4585 /** decode quantization matrix 4586 * \param scalingList quantization matrix information 4587 */ 4588 Void TDecCavlc::parseScalingList(TComScalingList* scalingList) 4589 { 4590 UInt code, sizeId, listId; 4591 Bool scalingListPredModeFlag; 4592 //for each size 4593 for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) 4594 { 4595 for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) 4596 { 4597 READ_FLAG( code, "scaling_list_pred_mode_flag"); 4598 scalingListPredModeFlag = (code) ? true : false; 4599 if(!scalingListPredModeFlag) //Copy Mode 4600 { 4601 READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); 4602 scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); 4603 if( sizeId > SCALING_LIST_8x8 ) 4604 { 4605 scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); 4606 } 4607 scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); 4608 4609 } 4610 else //DPCM Mode 4611 { 4612 xDecodeScalingList(scalingList, sizeId, listId); 4613 } 4614 } 4615 } 4616 4617 return; 4618 } 4619 /** decode DPCM 4620 * \param scalingList quantization matrix information 4621 * \param sizeId size index 4622 * \param listId list index 4623 */ 4624 Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) 4625 { 4626 Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); 4627 Int data; 4628 Int scalingListDcCoefMinus8 = 0; 4629 Int nextCoef = SCALING_LIST_START_VALUE; 4630 UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; 4631 Int *dst = scalingList->getScalingListAddress(sizeId, listId); 4632 4633 if( sizeId > SCALING_LIST_8x8 ) 4634 { 4635 READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); 4636 scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); 4637 nextCoef = scalingList->getScalingListDC(sizeId,listId); 4638 } 4639 4640 for(i = 0; i < coefNum; i++) 4641 { 4642 READ_SVLC( data, "scaling_list_delta_coef"); 4643 nextCoef = (nextCoef + data + 256 ) % 256; 4644 dst[scan[i]] = nextCoef; 4645 } 4646 } 4647 4648 Bool TDecCavlc::xMoreRbspData() 4649 { 4650 Int bitsLeft = m_pcBitstream->getNumBitsLeft(); 4651 4652 // if there are more than 8 bits, it cannot be rbsp_trailing_bits 4653 if (bitsLeft > 8) 4654 { 4655 return true; 4656 } 4657 4658 UChar lastByte = m_pcBitstream->peekBits(bitsLeft); 4659 Int cnt = bitsLeft; 4660 4661 // remove trailing bits equal to zero 4662 while ((cnt>0) && ((lastByte & 1) == 0)) 4663 { 4664 lastByte >>= 1; 4665 cnt--; 4666 } 4667 // remove bit equal to one 4668 cnt--; 4669 4670 // we should not have a negative number of bits 4671 assert (cnt>=0); 4672 4673 // we have more data, if cnt is not zero 4674 return (cnt>0); 4675 } 4478 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcSPS->setVertPhasePositionEnableFlag( pcSPS->getScaledRefLayerId(i), uiCode); 4479 #endif 4480 } 4481 } 4482 #endif 4483 } 4484 #endif 4676 4485 4677 4486 #if Q0048_CGS_3D_ASYMLUT … … 4962 4771 if( vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams() > 1 ) 4963 4772 { 4964 #endif4965 #if VPS_FIX_TO_MATCH_SPEC4966 4773 Int numBits = 1; 4967 4774 while ((1 << numBits) < (vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams())) … … 4970 4777 } 4971 4778 READ_CODE(numBits, uiCode, "bsp_comb_hrd_idx[h][i][t][j][k]"); vps->setBspHrdIdx(h, i, t, j, k, uiCode); 4972 #else4973 READ_UVLC(uiCode, "bsp_comb_hrd_idx[h][i][t][j][k]"); vps->setBspHrdIdx(h, i, t, j, k, uiCode);4974 #endif4975 #if VPS_FIX_TO_MATCH_SPEC4976 4779 } 4780 #else 4781 READ_UVLC(uiCode, "bsp_comb_hrd_idx[h][i][t][j][k]"); vps->setBspHrdIdx(h, i, t, j, k, uiCode); 4977 4782 #endif 4978 4783 READ_UVLC(uiCode, "bsp_comb_sched_idx[h][i][t][j][k]"); vps->setBspSchedIdx(h, i, t, j, k, uiCode); -
branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.h
r894 r1029 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-dev/source/Lib/TLibDecoder/TDecCu.cpp
r713 r1029 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->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-dev/source/Lib/TLibDecoder/TDecCu.h
r595 r1029 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-dev/source/Lib/TLibDecoder/TDecEntropy.cpp
r595 r1029 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 > quadtreeTULog2MinSizeInCU);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-dev/source/Lib/TLibDecoder/TDecEntropy.h
r713 r1029 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-dev/source/Lib/TLibDecoder/TDecGop.cpp
r930 r1029 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 #if SVC_EXTENSION 46 46 #include "TDecTop.h" 47 # endif47 #if CONFORMANCE_BITSTREAM_MODE 48 48 #include <algorithm> 49 #endif 50 #endif 51 49 52 #include <time.h> 50 53 … … 57 60 } 58 61 #endif 62 59 63 //! \ingroup TLibDecoder 60 64 //! \{ 61 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI);65 static Void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI); 62 66 #if Q0074_COLOUR_REMAPPING_SEI 63 67 static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* colourRemappingInfoSEI, UInt layerId=0 ); … … 71 75 { 72 76 m_dDecTime = 0; 73 m_pcSbacDecoders = NULL;74 m_pcBinCABACs = NULL;75 77 } 76 78 77 79 TDecGop::~TDecGop() 78 80 { 79 81 80 82 } 81 83 … … 88 90 Void TDecGop::create() 89 91 { 90 92 91 93 } 92 94 #endif … … 95 97 { 96 98 } 97 #if SVC_EXTENSION 98 Void TDecGop::init(TDecTop** ppcDecTop, 99 TDecEntropy* pcEntropyDecoder, 100 #else 101 Void TDecGop::init( TDecEntropy* pcEntropyDecoder, 102 #endif 103 TDecSbac* pcSbacDecoder, 99 100 #if SVC_EXTENSION 101 Void TDecGop::init( TDecTop** ppcDecTop, 102 TDecEntropy* pcEntropyDecoder, 103 #else 104 Void TDecGop::init( TDecEntropy* pcEntropyDecoder, 105 #endif 106 TDecSbac* pcSbacDecoder, 104 107 TDecBinCABAC* pcBinCABAC, 105 TDecCavlc* pcCavlcDecoder, 106 TDecSlice* pcSliceDecoder, 108 TDecCavlc* pcCavlcDecoder, 109 TDecSlice* pcSliceDecoder, 107 110 TComLoopFilter* pcLoopFilter, 108 111 TComSampleAdaptiveOffset* pcSAO … … 129 132 // ==================================================================================================================== 130 133 131 Void TDecGop::decompressSlice(TComInputBitstream* pcBitstream, TComPic* & rpcPic)132 { 133 TComSlice* pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx());134 Void TDecGop::decompressSlice(TComInputBitstream* pcBitstream, TComPic* pcPic) 135 { 136 TComSlice* pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); 134 137 // Table of extracted substreams. 135 138 // These must be deallocated AND their internal fifos, too. … … 137 140 138 141 //-- For time output for each slice 139 longiBeforeTime = clock();142 clock_t iBeforeTime = clock(); 140 143 m_pcSbacDecoder->init( (TDecBinIf*)m_pcBinCABAC ); 141 144 m_pcEntropyDecoder->setEntropyDecoder (m_pcSbacDecoder); 142 145 143 UInt uiNumSubstreams = pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() ? pcSlice->getNumEntryPointOffsets()+1 : pcSlice->getPPS()->getNumSubstreams(); 146 const UInt uiNumSubstreams = pcSlice->getNumberOfSubstreamSizes()+1; 147 // const UInt uiNumSubstreams = pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() ? pcSlice->getNumberOfSubstreamSizes()+1 : pcSlice->getPPS()->getNumSubstreams(); 144 148 145 149 // init each couple {EntropyDecoder, Substream} 146 UInt *puiSubstreamSizes = pcSlice->getSubstreamSizes();147 150 ppcSubstreams = new TComInputBitstream*[uiNumSubstreams]; 148 m_pcSbacDecoders = new TDecSbac[uiNumSubstreams];149 m_pcBinCABACs = new TDecBinCABAC[uiNumSubstreams];150 151 for ( UInt ui = 0 ; ui < uiNumSubstreams ; ui++ ) 151 152 { 152 m_pcSbacDecoders[ui].init(&m_pcBinCABACs[ui]); 153 ppcSubstreams[ui] = pcBitstream->extractSubstream(ui+1 < uiNumSubstreams ? puiSubstreamSizes[ui] : pcBitstream->getNumBitsLeft()); 154 } 155 156 for ( UInt ui = 0 ; ui+1 < uiNumSubstreams; ui++ ) 157 { 158 m_pcEntropyDecoder->setEntropyDecoder ( &m_pcSbacDecoders[uiNumSubstreams - 1 - ui] ); 159 m_pcEntropyDecoder->setBitstream ( ppcSubstreams [uiNumSubstreams - 1 - ui] ); 160 m_pcEntropyDecoder->resetEntropy (pcSlice); 161 } 162 163 m_pcEntropyDecoder->setEntropyDecoder ( m_pcSbacDecoder ); 164 m_pcEntropyDecoder->setBitstream ( ppcSubstreams[0] ); 165 m_pcEntropyDecoder->resetEntropy (pcSlice); 166 m_pcSbacDecoders[0].load(m_pcSbacDecoder); 167 m_pcSliceDecoder->decompressSlice( ppcSubstreams, rpcPic, m_pcSbacDecoder, m_pcSbacDecoders); 168 m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiNumSubstreams-1] ); 153 ppcSubstreams[ui] = pcBitstream->extractSubstream(ui+1 < uiNumSubstreams ? (pcSlice->getSubstreamSize(ui)<<3) : pcBitstream->getNumBitsLeft()); 154 } 155 156 m_pcSliceDecoder->decompressSlice( ppcSubstreams, pcPic, m_pcSbacDecoder); 169 157 // deallocate all created substreams, including internal buffers. 170 158 for (UInt ui = 0; ui < uiNumSubstreams; ui++) … … 174 162 } 175 163 delete[] ppcSubstreams; 176 delete[] m_pcSbacDecoders; m_pcSbacDecoders = NULL;177 delete[] m_pcBinCABACs; m_pcBinCABACs = NULL;178 164 179 165 m_dDecTime += (Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC; 180 166 } 181 167 182 Void TDecGop::filterPicture(TComPic* & rpcPic)183 { 184 TComSlice* pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx());168 Void TDecGop::filterPicture(TComPic* pcPic) 169 { 170 TComSlice* pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); 185 171 186 172 //-- For time output for each slice 187 longiBeforeTime = clock();173 clock_t iBeforeTime = clock(); 188 174 189 175 // deblocking filter 190 176 Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag(); 191 177 m_pcLoopFilter->setCfg(bLFCrossTileBoundary); 192 m_pcLoopFilter->loopFilterPic( rpcPic ); 178 m_pcLoopFilter->loopFilterPic( pcPic ); 179 193 180 if( pcSlice->getSPS()->getUseSAO() ) 194 181 { 195 m_pcSAO->reconstructBlkSAOParams(rpcPic, rpcPic->getPicSym()->getSAOBlkParam()); 196 m_pcSAO->SAOProcess(rpcPic); 197 m_pcSAO->PCMLFDisableProcess(rpcPic); 198 } 199 rpcPic->compressMotion(); 182 m_pcSAO->reconstructBlkSAOParams(pcPic, pcPic->getPicSym()->getSAOBlkParam()); 183 m_pcSAO->SAOProcess(pcPic); 184 m_pcSAO->PCMLFDisableProcess(pcPic); 185 } 186 187 pcPic->compressMotion(); 200 188 Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B'); 201 189 if (!pcSlice->isReferenced()) c += 32; … … 203 191 //-- For time output for each slice 204 192 #if SVC_EXTENSION 205 printf(" \nPOC %4d LId: %1d TId: %1d ( %c-SLICE %s, QP%3d ) ", pcSlice->getPOC(),206 rpcPic->getLayerId(),193 printf("POC %4d LId: %1d TId: %1d ( %c-SLICE %s, QP%3d ) ", pcSlice->getPOC(), 194 pcPic->getLayerId(), 207 195 pcSlice->getTLayer(), 208 196 c, … … 210 198 pcSlice->getSliceQp() ); 211 199 #else 212 printf("\nPOC %4d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getPOC(), 213 pcSlice->getTLayer(), 214 c, 215 pcSlice->getSliceQp() ); 200 printf("POC %4d TId: %1d ( %c-SLICE, QP%3d ) ", pcSlice->getPOC(), 201 pcSlice->getTLayer(), 202 c, 203 pcSlice->getSliceQp() ); 204 216 205 #endif 217 206 m_dDecTime += (Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC; … … 254 243 if (m_decodedPictureHashSEIEnabled) 255 244 { 256 SEIMessages pictureHashes = getSeisByType( rpcPic->getSEIs(), SEI::DECODED_PICTURE_HASH );245 SEIMessages pictureHashes = getSeisByType(pcPic->getSEIs(), SEI::DECODED_PICTURE_HASH ); 257 246 const SEIDecodedPictureHash *hash = ( pictureHashes.size() > 0 ) ? (SEIDecodedPictureHash*) *(pictureHashes.begin()) : NULL; 258 247 if (pictureHashes.size() > 1) … … 260 249 printf ("Warning: Got multiple decoded picture hash SEI messages. Using first."); 261 250 } 262 calcAndPrintHashStatus(* rpcPic->getPicYuvRec(), hash);251 calcAndPrintHashStatus(*(pcPic->getPicYuvRec()), hash); 263 252 } 264 253 #if CONFORMANCE_BITSTREAM_MODE 265 if( this->getLayerDec( rpcPic->getLayerId())->getConfModeFlag() )254 if( this->getLayerDec(pcPic->getLayerId())->getConfModeFlag() ) 266 255 { 267 256 // Add this reconstructed picture to the parallel buffer. 268 std::vector<TComPic> *thisLayerBuffer = (this->getLayerDec( rpcPic->getLayerId()))->getConfListPic();269 thisLayerBuffer->push_back(* rpcPic);257 std::vector<TComPic> *thisLayerBuffer = (this->getLayerDec(pcPic->getLayerId()))->getConfListPic(); 258 thisLayerBuffer->push_back(*pcPic); 270 259 std::sort( thisLayerBuffer->begin(), thisLayerBuffer->end(), pocCompareFunction ); 271 260 } … … 274 263 if (m_colourRemapSEIEnabled) 275 264 { 276 SEIMessages colourRemappingInfo = getSeisByType( rpcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO );265 SEIMessages colourRemappingInfo = getSeisByType(pcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO ); 277 266 const SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL; 278 267 if (colourRemappingInfo.size() > 1) … … 280 269 printf ("Warning: Got multiple Colour Remapping Information SEI messages. Using first."); 281 270 } 282 applyColourRemapping(* rpcPic->getPicYuvRec(), seiColourRemappingInfo283 #if SVC_EXTENSION 284 , rpcPic->getLayerId()271 applyColourRemapping(*pcPic->getPicYuvRec(), seiColourRemappingInfo 272 #if SVC_EXTENSION 273 , pcPic->getLayerId() 285 274 #endif 286 275 ); … … 288 277 #endif 289 278 290 #if SETTING_PIC_OUTPUT_MARK 291 rpcPic->setOutputMark(rpcPic->getSlice(0)->getPicOutputFlag() ? true : false); 292 #else 293 rpcPic->setOutputMark(true); 294 #endif 295 rpcPic->setReconMark(true); 279 printf("\n"); 280 281 pcPic->setOutputMark(pcPic->getSlice(0)->getPicOutputFlag() ? true : false); 282 pcPic->setReconMark(true); 296 283 } 297 284 … … 307 294 * unk - no SEI message was available for comparison 308 295 */ 309 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI)296 static Void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI) 310 297 { 311 298 /* calculate MD5sum for entire reconstructed picture */ 312 UChar recon_digest[3][16];299 TComDigest recon_digest; 313 300 Int numChar=0; 314 301 const Char* hashType = "\0"; … … 318 305 switch (pictureHashSEI->method) 319 306 { 320 case SEIDecodedPictureHash::MD5: 321 { 322 hashType = "MD5"; 323 calcMD5(pic, recon_digest); 324 numChar = 16; 325 break; 326 } 327 case SEIDecodedPictureHash::CRC: 328 { 329 hashType = "CRC"; 330 calcCRC(pic, recon_digest); 331 numChar = 2; 332 break; 333 } 334 case SEIDecodedPictureHash::CHECKSUM: 335 { 336 hashType = "Checksum"; 337 calcChecksum(pic, recon_digest); 338 numChar = 4; 339 break; 340 } 341 default: 342 { 343 assert (!"unknown hash type"); 344 } 307 case SEIDecodedPictureHash::MD5: 308 { 309 hashType = "MD5"; 310 numChar = calcMD5(pic, recon_digest); 311 break; 312 } 313 case SEIDecodedPictureHash::CRC: 314 { 315 hashType = "CRC"; 316 numChar = calcCRC(pic, recon_digest); 317 break; 318 } 319 case SEIDecodedPictureHash::CHECKSUM: 320 { 321 hashType = "Checksum"; 322 numChar = calcChecksum(pic, recon_digest); 323 break; 324 } 325 default: 326 { 327 assert (!"unknown hash type"); 328 break; 329 } 345 330 } 346 331 } … … 353 338 { 354 339 ok = "(OK)"; 355 for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++) 356 { 357 for (UInt i = 0; i < numChar; i++) 358 { 359 if (recon_digest[yuvIdx][i] != pictureHashSEI->digest[yuvIdx][i]) 360 { 361 ok = "(***ERROR***)"; 362 mismatch = true; 363 } 364 } 365 } 366 } 367 368 printf("[%s:%s,%s] ", hashType, digestToString(recon_digest, numChar), ok); 340 if (recon_digest != pictureHashSEI->m_digest) 341 { 342 ok = "(***ERROR***)"; 343 mismatch = true; 344 } 345 } 346 347 printf("[%s:%s,%s] ", hashType, digestToString(recon_digest, numChar).c_str(), ok); 369 348 370 349 if (mismatch) 371 350 { 372 351 g_md5_mismatch = true; 373 printf("[rx%s:%s] ", hashType, digestToString(pictureHashSEI-> digest, numChar));352 printf("[rx%s:%s] ", hashType, digestToString(pictureHashSEI->m_digest, numChar).c_str()); 374 353 } 375 354 } … … 433 412 } 434 413 435 static void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, UInt layerId )414 static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, UInt layerId ) 436 415 { 437 416 if( !storeCriSEI.size() ) … … 447 426 if( !storeCriSEI[layerId].m_colourRemapCancelFlag ) 448 427 { 449 Int iHeight = pic.getHeight( );450 Int iWidth = pic.getWidth( );451 Int iStride = pic.getStride( );452 Int iCStride = pic.get CStride();428 Int iHeight = pic.getHeight(COMPONENT_Y); 429 Int iWidth = pic.getWidth(COMPONENT_Y); 430 Int iStride = pic.getStride(COMPONENT_Y); 431 Int iCStride = pic.getStride(COMPONENT_Cb); 453 432 454 433 Pel *YUVIn[3], *YUVOut[3]; 455 YUVIn[0] = pic.get LumaAddr();456 YUVIn[1] = pic.get CbAddr();457 YUVIn[2] = pic.get CrAddr();434 YUVIn[0] = pic.getAddr(COMPONENT_Y); 435 YUVIn[1] = pic.getAddr(COMPONENT_Cb); 436 YUVIn[2] = pic.getAddr(COMPONENT_Cr); 458 437 459 438 TComPicYuv picColourRemapped; 460 439 #if SVC_EXTENSION 461 #if AUXILIARY_PICTURES 462 picColourRemapped.create( pic.getWidth(), pic.getHeight(), pic.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); 463 #else 464 picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); 465 #endif 466 #else 467 picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 440 picColourRemapped.create( pic.getWidth(COMPONENT_Y), pic.getHeight(COMPONENT_Y), pic.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); 441 #else 442 picColourRemapped.create( pic.getWidth(COMPONENT_Y), pic.getHeight(COMPONENT_Y), pic.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 468 443 #endif 469 YUVOut[0] = picColourRemapped.get LumaAddr();470 YUVOut[1] = picColourRemapped.get CbAddr();471 YUVOut[2] = picColourRemapped.get CrAddr();472 473 #if SVC_EXTENSION 474 Int bitDepthY = g_bitDepth YLayer[layerId];475 Int bitDepthC = g_bitDepth CLayer[layerId];476 477 assert( g_bitDepth Y== bitDepthY );478 assert( g_bitDepth C== bitDepthC );479 #else 480 Int bitDepthY = g_bitDepth Y;481 Int bitDepthC = g_bitDepth C;444 YUVOut[0] = picColourRemapped.getAddr(COMPONENT_Y); 445 YUVOut[1] = picColourRemapped.getAddr(COMPONENT_Cb); 446 YUVOut[2] = picColourRemapped.getAddr(COMPONENT_Cr); 447 448 #if SVC_EXTENSION 449 Int bitDepthY = g_bitDepthLayer[CHANNEL_TYPE_LUMA][layerId]; 450 Int bitDepthC = g_bitDepthLayer[CHANNEL_TYPE_CHROMA][layerId]; 451 452 assert( g_bitDepth[CHANNEL_TYPE_LUMA] == bitDepthY ); 453 assert( g_bitDepth[CHANNEL_TYPE_CHROMA] == bitDepthC ); 454 #else 455 Int bitDepthY = g_bitDepth[CHANNEL_TYPE_LUMA]; 456 Int bitDepthC = g_bitDepth[CHANNEL_TYPE_CHROMA]; 482 457 #endif 483 458 -
branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.h
r930 r1029 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 115 Void setDecodedPictureHashSEIEnabled(Int enabled) { m_decodedPictureHashSEIEnabled = enabled; } -
branches/SHM-dev/source/Lib/TLibDecoder/TDecSbac.cpp
r644 r1029 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 m_pcTDecBinIf->decodeBinTrm(uiSymbol);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-dev/source/Lib/TLibDecoder/TDecSbac.h
r713 r1029 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-dev/source/Lib/TLibDecoder/TDecSlice.cpp
r880 r1029 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-dev/source/Lib/TLibDecoder/TDecSlice.h
r834 r1029 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-dev/source/Lib/TLibDecoder/TDecTop.cpp
r1015 r1029 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; … … 94 101 m_prevSliceSkipped = false; 95 102 m_skippedPOC = 0; 96 #if SETTING_NO_OUT_PIC_PRIOR97 103 m_bFirstSliceInBitstream = true; 98 104 m_lastPOCNoOutputPriorPics = -1; 99 105 m_craNoRaslOutputFlag = false; 100 106 m_isNoOutputPriorPics = false; 101 #endif102 107 #if Q0177_EOS_CHECKS 103 108 m_isLastNALWasEos = false; … … 141 146 { 142 147 #if ENC_DEC_TRACE 143 fclose( g_hTrace ); 148 if (g_hTrace != stdout) 149 { 150 fclose( g_hTrace ); 151 } 144 152 #endif 145 153 #if Q0048_CGS_3D_ASYMLUT … … 167 175 { 168 176 m_cGopDecoder.destroy(); 169 177 170 178 delete m_apcSlicePilot; 171 179 m_apcSlicePilot = NULL; 172 180 173 181 m_cSliceDecoder.destroy(); 174 182 #if SVC_EXTENSION … … 201 209 } 202 210 203 #if SVC_EXTENSION204 #if !REPN_FORMAT_IN_VPS205 Void TDecTop::xInitILRP(TComSPS *pcSPS)206 #else207 Void TDecTop::xInitILRP(TComSlice *slice)208 #endif209 {210 #if REPN_FORMAT_IN_VPS211 TComSPS* pcSPS = slice->getSPS();212 Int bitDepthY = slice->getBitDepthY();213 Int bitDepthC = slice->getBitDepthC();214 Int picWidth = slice->getPicWidthInLumaSamples();215 Int picHeight = slice->getPicHeightInLumaSamples();216 #endif217 if(m_layerId>0)218 {219 #if REPN_FORMAT_IN_VPS220 g_bitDepthY = bitDepthY;221 g_bitDepthC = bitDepthC;222 #else223 g_bitDepthY = pcSPS->getBitDepthY();224 g_bitDepthC = pcSPS->getBitDepthC();225 #endif226 g_uiMaxCUWidth = pcSPS->getMaxCUWidth();227 g_uiMaxCUHeight = pcSPS->getMaxCUHeight();228 g_uiMaxCUDepth = pcSPS->getMaxCUDepth();229 g_uiAddCUDepth = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() );230 231 Int numReorderPics[MAX_TLAYER];232 #if R0156_CONF_WINDOW_IN_REP_FORMAT233 Window &conformanceWindow = slice->getConformanceWindow();234 #else235 Window &conformanceWindow = pcSPS->getConformanceWindow();236 #endif237 Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window();238 239 for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++)240 {241 #if USE_DPB_SIZE_TABLE242 if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 )243 {244 assert( this->getLayerId() == 0 );245 numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer);246 }247 else248 {249 TComVPS *vps = slice->getVPS();250 // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures.251 numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer);252 }253 #else254 numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer);255 #endif256 }257 258 if (m_cIlpPic[0] == NULL)259 {260 for (Int j=0; j < m_numDirectRefLayers; j++)261 {262 263 m_cIlpPic[j] = new TComPic;264 265 #if AUXILIARY_PICTURES266 #if REPN_FORMAT_IN_VPS267 m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);268 #else269 m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), pcSPS->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);270 #endif271 #else272 #if REPN_FORMAT_IN_VPS273 m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);274 #else275 m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);276 #endif277 #endif278 for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++)279 {280 m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i);281 }282 }283 }284 }285 }286 #endif287 288 211 Void TDecTop::deletePicBuffer ( ) 289 212 { 290 213 TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); 291 214 Int iSize = Int( m_cListPic.size() ); 292 215 293 216 for (Int i = 0; i < iSize; i++ ) 294 217 { … … 304 227 #else 305 228 pcPic->destroy(); 306 229 307 230 delete pcPic; 308 231 pcPic = NULL; 309 232 #endif 310 233 } 311 234 312 235 m_cSAO.destroy(); 313 236 314 237 m_cLoopFilter. destroy(); 315 238 … … 330 253 Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window(); 331 254 332 for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) 255 for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) 333 256 { 334 257 #if USE_DPB_SIZE_TABLE … … 420 343 #if O0194_DIFFERENT_BITDEPTH_EL_BL 421 344 UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, i); 422 Bool sameBitDepths = ( g_bitDepth YLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );345 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] ); 423 346 424 347 #if REF_IDX_MFM 425 if( pcPicYuvRecBase->getWidth( ) == pcSlice->getPicWidthInLumaSamples() && pcPicYuvRecBase->getHeight() == pcSlice->getPicHeightInLumaSamples() && equalOffsets && zeroPhase )348 if( pcPicYuvRecBase->getWidth(COMPONENT_Y) == pcSlice->getPicWidthInLumaSamples() && pcPicYuvRecBase->getHeight(COMPONENT_Y) == pcSlice->getPicHeightInLumaSamples() && equalOffsets && zeroPhase ) 426 349 { 427 350 rpcPic->setEqualPictureSizeAndOffsetFlag( i, true ); … … 480 403 } 481 404 482 #if AUXILIARY_PICTURES483 405 #if REPN_FORMAT_IN_VPS 484 406 rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, … … 488 410 conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); 489 411 #endif 490 #else491 #if REPN_FORMAT_IN_VPS492 rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,493 conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);494 #else495 rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,496 conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);497 #endif498 #endif499 412 500 413 #else //SVC_EXTENSION 501 rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,414 rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, 502 415 conformanceWindow, defaultDisplayWindow, numReorderPics, true); 503 416 #endif //SVC_EXTENSION 504 417 505 418 m_cListPic.pushBack( rpcPic ); 506 419 507 420 return; 508 421 } 509 422 510 423 Bool bBufferIsAvailable = false; 511 424 TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); … … 531 444 } 532 445 } 533 446 534 447 if ( !bBufferIsAvailable ) 535 448 { … … 542 455 543 456 #if SVC_EXTENSION 544 #if AUXILIARY_PICTURES545 457 #if REPN_FORMAT_IN_VPS 546 458 rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, … … 550 462 conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); 551 463 #endif 552 #else553 #if REPN_FORMAT_IN_VPS554 rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,555 conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);556 557 #else558 rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,559 conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);560 #endif561 #endif562 464 #else //SVC_EXTENSION 563 rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,465 rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, 564 466 conformanceWindow, defaultDisplayWindow, numReorderPics, true); 565 467 #endif //SVC_EXTENSION … … 573 475 return; 574 476 } 575 576 TComPic* &pcPic = m_pcPic;477 478 TComPic* pcPic = m_pcPic; 577 479 578 480 // Execute Deblock + Cleanup 481 579 482 m_cGopDecoder.filterPicture(pcPic); 580 483 … … 588 491 TComSlice::sortPicList( m_cListPic ); // sorting for application output 589 492 poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); 590 rpcListPic = &m_cListPic; 591 m_cCuDecoder.destroy(); 493 rpcListPic = &m_cListPic; 494 m_cCuDecoder.destroy(); 592 495 m_bFirstSliceInPicture = true; 593 496 … … 595 498 } 596 499 597 #if SETTING_NO_OUT_PIC_PRIOR 598 Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic) 500 Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>* pcListPic) 599 501 { 600 if (! rpcListPic || !m_isNoOutputPriorPics) return;601 602 TComList<TComPic*>::iterator iterPic = rpcListPic->begin();603 604 while (iterPic != rpcListPic->end())605 { 606 TComPic* &pcPicTmp = *(iterPic++);502 if (!pcListPic || !m_isNoOutputPriorPics) return; 503 504 TComList<TComPic*>::iterator iterPic = pcListPic->begin(); 505 506 while (iterPic != pcListPic->end()) 507 { 508 TComPic* pcPicTmp = *(iterPic++); 607 509 if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC()) 608 510 { … … 611 513 } 612 514 } 613 #endif 614 615 #if EARLY_REF_PIC_MARKING 616 Void TDecTop::earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdSet) 617 { 618 UInt currTid = m_pcPic->getTLayer(); 619 UInt highestTid = (maxTemporalLayer >= 0) ? maxTemporalLayer : (m_pcPic->getSlice(0)->getSPS()->getMaxTLayers() - 1); 620 UInt latestDecLayerId = m_layerId; 621 UInt numTargetDecLayers = 0; 622 Int targetDecLayerIdList[MAX_LAYERS]; 623 UInt latestDecIdx = 0; 624 TComSlice* pcSlice = m_pcPic->getSlice(0); 625 626 if ( currTid != highestTid ) // Marking process is only applicaple for highest decoded TLayer 627 { 628 return; 629 } 630 631 // currPic must be marked as "used for reference" and must be a sub-layer non-reference picture 632 if ( !((pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || 633 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || 634 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || 635 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || 636 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || 637 pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N10 || 638 pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N12 || 639 pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N14) && pcSlice->isReferenced())) 640 { 641 return; 642 } 643 644 if ( targetDecLayerIdSet.size() == 0 ) // Cannot mark if we don't know the number of scalable layers 645 { 646 return; 647 } 648 649 for (std::vector<Int>::iterator it = targetDecLayerIdSet.begin(); it != targetDecLayerIdSet.end(); it++) 650 { 651 if ( latestDecLayerId == (*it) ) 652 { 653 latestDecIdx = numTargetDecLayers; 654 } 655 targetDecLayerIdList[numTargetDecLayers++] = (*it); 656 } 657 658 Int remainingInterLayerReferencesFlag = 0; 659 #if O0225_MAX_TID_FOR_REF_LAYERS 660 for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) 661 { 662 Int jLidx = pcSlice->getVPS()->getLayerIdInVps(targetDecLayerIdList[j]); 663 if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId,jLidx) - 1 ) 664 { 665 #else 666 if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId) - 1 ) 667 { 668 for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) 669 { 670 #endif 671 for ( Int k = 0; k < m_ppcTDecTop[targetDecLayerIdList[j]]->getNumDirectRefLayers(); k++ ) 672 { 673 if ( latestDecIdx == m_ppcTDecTop[targetDecLayerIdList[j]]->getRefLayerId(k) ) 674 { 675 remainingInterLayerReferencesFlag = 1; 676 } 677 } 678 } 679 } 680 681 if ( remainingInterLayerReferencesFlag == 0 ) 682 { 683 pcSlice->setReferenced(false); 684 } 685 } 686 #endif 687 688 Void TDecTop::xCreateLostPicture(Int iLostPoc) 515 516 Void TDecTop::xCreateLostPicture(Int iLostPoc) 689 517 { 690 518 printf("\ninserting lost poc : %d\n",iLostPoc); … … 731 559 } 732 560 cFillPic->setCurrSliceIdx(0); 733 for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++)734 { 735 cFillPic->getC U(i)->initCU(cFillPic,i);561 for(Int ctuRsAddr=0; ctuRsAddr<cFillPic->getNumberOfCtusInFrame(); ctuRsAddr++) 562 { 563 cFillPic->getCtu(ctuRsAddr)->initCtu(cFillPic, ctuRsAddr); 736 564 } 737 565 cFillPic->getSlice(0)->setReferenced(true); … … 749 577 { 750 578 m_parameterSetManagerDecoder.applyPrefetchedPS(); 751 579 752 580 TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId()); 753 581 assert (pps != 0); … … 872 700 873 701 #if O0194_DIFFERENT_BITDEPTH_EL_BL 874 g_bitDepth YLayer[0] = repFormat->getBitDepthVpsLuma();875 g_bitDepth CLayer[0] = repFormat->getBitDepthVpsChroma();702 g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] = repFormat->getBitDepthVpsLuma(); 703 g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] = repFormat->getBitDepthVpsChroma(); 876 704 #endif 877 705 } … … 934 762 #endif 935 763 } 936 764 937 765 #if P0182_VPS_VUI_PS_FLAG 938 766 UInt layerIdx = activeVPS->getLayerIdInVps( m_layerId ); … … 948 776 assert( repFormat->getPicHeightVpsInLumaSamples() == sps->getPicHeightInLumaSamples() ); 949 777 assert( repFormat->getPicWidthVpsInLumaSamples() == sps->getPicWidthInLumaSamples() ); 950 assert( repFormat->getBitDepthVpsLuma() == sps->getBitDepth Y() );951 assert( repFormat->getBitDepthVpsChroma() == sps->getBitDepth C() );778 assert( repFormat->getBitDepthVpsLuma() == sps->getBitDepth(CHANNEL_TYPE_LUMA) ); 779 assert( repFormat->getBitDepthVpsChroma() == sps->getBitDepth(CHANNEL_TYPE_CHROMA) ); 952 780 assert( repFormat->getConformanceWindowVps().getWindowLeftOffset() == sps->getConformanceWindow().getWindowLeftOffset() ); 953 781 assert( repFormat->getConformanceWindowVps().getWindowRightOffset() == sps->getConformanceWindow().getWindowRightOffset() ); … … 959 787 #endif 960 788 961 if( pps->getDependentSliceSegmentsEnabledFlag() ) 962 { 963 Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; 964 965 if (m_cSliceDecoder.getCtxMemSize() != NumCtx) 966 { 967 m_cSliceDecoder.initCtxMem(NumCtx); 968 for ( UInt st = 0; st < NumCtx; st++ ) 969 { 970 TDecSbac* ctx = NULL; 971 ctx = new TDecSbac; 972 ctx->init( &m_cBinCABAC ); 973 m_cSliceDecoder.setCtxMem( ctx, st ); 974 } 975 } 976 } 789 #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 790 UInt layerIdx = activeVPS->getLayerIdInVps(m_apcSlicePilot->getLayerId()); 791 792 if ( activeVPS->getVpsExtensionFlag() == 1 && (m_apcSlicePilot->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) ) 793 { 794 assert( sps->getPicWidthInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getPicWidthVpsInLumaSamples() ); 795 assert( sps->getPicHeightInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getPicHeightVpsInLumaSamples() ); 796 assert( sps->getChromaFormatIdc() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getChromaFormatVpsIdc() ); 797 assert( sps->getBitDepth(CHANNEL_TYPE_LUMA) <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getBitDepthVpsLuma() ); 798 assert( sps->getBitDepth(CHANNEL_TYPE_CHROMA) <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx) )->getBitDepthVpsChroma() ); 799 } 800 else if ( activeVPS->getVpsExtensionFlag() == 1 ) 801 { 802 assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getPicWidthVpsInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getPicWidthVpsInLumaSamples()); 803 assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getPicHeightVpsInLumaSamples() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getPicHeightVpsInLumaSamples()); 804 assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getChromaFormatVpsIdc() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getChromaFormatVpsIdc()); 805 assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsLuma() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsLuma()); 806 assert( activeVPS->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : activeVPS->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsChroma() <= activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(layerIdx))->getBitDepthVpsChroma()); 807 } 808 #endif 977 809 978 810 m_apcSlicePilot->setPPS(pps); 979 811 m_apcSlicePilot->setSPS(sps); 980 812 pps->setSPS(sps); 813 pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : ((pps->getNumTileRowsMinus1() + 1)*(pps->getNumTileColumnsMinus1() + 1))); 814 pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); 815 pps->setMinCuChromaQpAdjSize( sps->getMaxCUWidth() >> ( pps->getMaxCuChromaQpAdjDepth()) ); 816 817 for (UInt channel = 0; channel < MAX_NUM_CHANNEL_TYPE; channel++) 818 { 981 819 #if REPN_FORMAT_IN_VPS 982 pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : 1); 983 #else 984 pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : 1); 985 #endif 986 pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); 987 988 #if REPN_FORMAT_IN_VPS 989 g_bitDepthY = m_apcSlicePilot->getBitDepthY(); 990 g_bitDepthC = m_apcSlicePilot->getBitDepthC(); 991 #else 992 g_bitDepthY = sps->getBitDepthY(); 993 g_bitDepthC = sps->getBitDepthC(); 994 #endif 820 g_bitDepth[channel] = isLuma(ChannelType(channel)) ? m_apcSlicePilot->getBitDepthY() : m_apcSlicePilot->getBitDepthC(); 821 #else 822 g_bitDepth[channel] = sps->getBitDepth(ChannelType(channel)); 823 #endif 824 825 if (sps->getUseExtendedPrecision()) g_maxTrDynamicRange[channel] = std::max<Int>(15, (g_bitDepth[channel] + 6)); 826 else g_maxTrDynamicRange[channel] = 15; 827 } 995 828 g_uiMaxCUWidth = sps->getMaxCUWidth(); 996 829 g_uiMaxCUHeight = sps->getMaxCUHeight(); 997 830 g_uiMaxCUDepth = sps->getMaxCUDepth(); 998 g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() );831 g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() + (Int)getMaxCUDepthOffset(sps->getChromaFormatIdc(), sps->getQuadtreeTULog2MinSize())); 999 832 1000 833 for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++) … … 1010 843 m_cSAO.destroy(); 1011 844 #if REPN_FORMAT_IN_VPS 1012 #if AUXILIARY_PICTURES 1013 m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); 1014 #else 1015 m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); 1016 #endif 1017 #else 1018 m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); 845 m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth(), pps->getSaoOffsetBitShift(CHANNEL_TYPE_LUMA), pps->getSaoOffsetBitShift(CHANNEL_TYPE_CHROMA) ); 846 #else 847 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) ); 1019 848 #endif 1020 849 m_cLoopFilter.create( sps->getMaxCUDepth() ); … … 1031 860 #endif 1032 861 { 1033 TComPic*& pcPic = m_pcPic;1034 862 #if SVC_EXTENSION 1035 863 m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) ); … … 1046 874 assert(layerIdx > m_apcSlicePilot->getVPS()->getVpsNumLayerSetsMinus1()); 1047 875 } 1048 } 1049 #else 1050 checkValueOfTargetOutputLayerSetIdx( m_apcSlicePilot->getVPS());876 } 877 #else 878 checkValueOfTargetOutputLayerSetIdx( m_apcSlicePilot->getVPS()); 1051 879 #endif 1052 880 #endif … … 1062 890 if (m_bFirstSliceInPicture) 1063 891 { 1064 m_uiSliceIdx = 0;892 m_uiSliceIdx = 0; 1065 893 } 1066 894 else 1067 895 { 1068 m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) );896 m_apcSlicePilot->copySliceInfo( m_pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); 1069 897 } 1070 898 m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); … … 1080 908 m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); 1081 909 m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); 1082 1083 910 m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS 1084 911 m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); 912 913 #if ENC_DEC_TRACE 914 const UInt64 originalSymbolCount = g_nSymbolCounter; 915 #endif 1085 916 1086 917 #if SVC_EXTENSION … … 1093 924 1094 925 // set POC for dependent slices in skipped pictures 1095 if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) 926 if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) 1096 927 { 1097 928 m_apcSlicePilot->setPOC(m_skippedPOC); … … 1101 932 m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); 1102 933 1103 #if SETTING_NO_OUT_PIC_PRIOR1104 934 //For inference of NoOutputOfPriorPicsFlag 1105 935 if (m_apcSlicePilot->getRapPicFlag()) … … 1147 977 } 1148 978 } 1149 #endif 1150 1151 #if FIX_POC_CRA_NORASL_OUTPUT 979 1152 980 if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1 1153 981 { … … 1155 983 m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) ); 1156 984 } 1157 #endif1158 985 1159 986 // Skip pictures due to random access … … 1192 1019 } 1193 1020 #if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS 1194 else if (m_lastPicHasEos)1021 else if( m_lastPicHasEos ) 1195 1022 { 1196 1023 setNoClrasOutputFlag(true); … … 1571 1398 #endif 1572 1399 #if POC_RESET_IDC_DECODER 1573 if ( m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId || m_parseIdc == 1) && !m_bFirstSliceInSequence )1574 #else 1575 if ( m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence )1400 if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (bNewPOC || m_layerId!=m_uiPrevLayerId || m_parseIdc == 1) && !m_bFirstSliceInSequence ) 1401 #else 1402 if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence ) 1576 1403 #endif 1577 1404 { … … 1611 1438 1612 1439 // actual decoding starts here 1613 xActivateParameterSets();1440 xActivateParameterSets(); 1614 1441 1615 1442 #if REPN_FORMAT_IN_VPS … … 1619 1446 xInitILRP(m_apcSlicePilot); 1620 1447 #endif 1621 if ( m_apcSlicePilot->isNextSlice())1448 if (!m_apcSlicePilot->getDependentSliceSegmentFlag()) 1622 1449 { 1623 1450 m_prevPOC = m_apcSlicePilot->getPOC(); … … 1626 1453 } 1627 1454 m_bFirstSliceInSequence = false; 1628 #if SETTING_NO_OUT_PIC_PRIOR1629 1455 m_bFirstSliceInBitstream = false; 1630 #endif1631 1456 #if POC_RESET_FLAG 1632 1457 // This operation would do the following: … … 1734 1559 #else //SVC_EXTENSION 1735 1560 //we should only get a different poc for a new picture (with CTU address==0) 1736 if ( m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCUAddr()!=0))1561 if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() != 0)) 1737 1562 { 1738 1563 printf ("Warning, the first slice of a picture might have been lost!\n"); 1739 1564 } 1565 1740 1566 // exit when a new picture is found 1741 if ( m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence)1567 if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() == 0 && !m_bFirstSliceInPicture) ) 1742 1568 { 1743 1569 if (m_prevPOC >= m_pocRandomAccess) 1744 1570 { 1745 1571 m_prevPOC = m_apcSlicePilot->getPOC(); 1572 #if ENC_DEC_TRACE 1573 //rewind the trace counter since we didn't actually decode the slice 1574 g_nSymbolCounter = originalSymbolCount; 1575 #endif 1746 1576 return true; 1747 1577 } … … 1752 1582 xActivateParameterSets(); 1753 1583 1754 if ( m_apcSlicePilot->isNextSlice())1584 if (!m_apcSlicePilot->getDependentSliceSegmentFlag()) 1755 1585 { 1756 1586 m_prevPOC = m_apcSlicePilot->getPOC(); 1757 1587 } 1758 1588 m_bFirstSliceInSequence = false; 1589 m_bFirstSliceInBitstream = false; 1759 1590 #endif //SVC_EXTENSION 1760 1591 //detect lost reference picture and insert copy of earlier frame. … … 1779 1610 if( pFile->good() ) 1780 1611 { 1781 Bool is16bit = g_bitDepth YLayer[0] > 8 || g_bitDepthCLayer[0] > 8;1782 UInt uiWidth = pBLPic->getPicYuvRec()->getWidth( );1783 UInt uiHeight = pBLPic->getPicYuvRec()->getHeight( );1612 Bool is16bit = g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] > 8 || g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] > 8; 1613 UInt uiWidth = pBLPic->getPicYuvRec()->getWidth(COMPONENT_Y); 1614 UInt uiHeight = pBLPic->getPicYuvRec()->getHeight(COMPONENT_Y); 1784 1615 1785 1616 Int len = uiWidth * (is16bit ? 2 : 1); … … 1795 1626 1796 1627 // read Y component 1797 Pel* pPel = pBLPic->getPicYuvRec()->get LumaAddr();1798 UInt uiStride = pBLPic->getPicYuvRec()->getStride( );1628 Pel* pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Y); 1629 UInt uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Y); 1799 1630 for( Int i = 0; i < uiHeight; i++ ) 1800 1631 { … … 1824 1655 1825 1656 // read Cb component 1826 pPel = pBLPic->getPicYuvRec()->get CbAddr();1827 uiStride = pBLPic->getPicYuvRec()->get CStride();1657 pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Cb); 1658 uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Cb); 1828 1659 for( Int i = 0; i < uiHeight; i++ ) 1829 1660 { … … 1849 1680 1850 1681 // read Cr component 1851 pPel = pBLPic->getPicYuvRec()->get CrAddr();1852 uiStride = pBLPic->getPicYuvRec()->get CStride();1682 pPel = pBLPic->getPicYuvRec()->getAddr(COMPONENT_Cr); 1683 uiStride = pBLPic->getPicYuvRec()->getStride(COMPONENT_Cr); 1853 1684 for( Int i = 0; i < uiHeight; i++ ) 1854 1685 { … … 1893 1724 #endif 1894 1725 // Buffer initialize for prediction. 1895 m_cPrediction.initTempBuff( );1726 m_cPrediction.initTempBuff(m_apcSlicePilot->getSPS()->getChromaFormatIdc()); 1896 1727 #if ALIGNED_BUMPING 1897 1728 m_apcSlicePilot->checkLeadingPictureRestrictions(m_cListPic); … … 1900 1731 #endif 1901 1732 // Get a new picture buffer 1902 xGetNewPicBuffer (m_apcSlicePilot, pcPic);1733 xGetNewPicBuffer (m_apcSlicePilot, m_pcPic); 1903 1734 1904 1735 #if POC_RESET_IDC_DECODER 1905 pcPic->setCurrAuFlag( true );1736 m_pcPic->setCurrAuFlag( true ); 1906 1737 #if POC_RESET_RESTRICTIONS 1907 if( pcPic->getLayerId() > 0 && m_apcSlicePilot->isIDR() && !m_nonBaseIdrPresentFlag )1738 if( m_pcPic->getLayerId() > 0 && m_apcSlicePilot->isIDR() && !m_nonBaseIdrPresentFlag ) 1908 1739 { 1909 1740 // IDR picture with nuh_layer_id > 0 present … … 1928 1759 m_checkPocRestrictionsForCurrAu = true; 1929 1760 m_pocResetIdcOrCurrAu = m_apcSlicePilot->getPocResetIdc(); 1930 if( pcPic->getLayerId() == 0 )1761 if( m_pcPic->getLayerId() == 0 ) 1931 1762 { 1932 1763 // Base layer picture is present … … 2009 1840 if (seiTMVPConstrainsList.size() > 0) 2010 1841 { 2011 assert ( pcPic->getTLayer() == 0 ); //this SEI can present only for AU with Tid equal to 01842 assert ( m_pcPic->getTLayer() == 0 ); //this SEI can present only for AU with Tid equal to 0 2012 1843 SEITMVPConstrains* tmvpConstraintSEI = (SEITMVPConstrains*) *(seiTMVPConstrainsList.begin()); 2013 1844 if ( tmvpConstraintSEI->prev_pics_not_used_flag == 1 ) … … 2018 1849 { 2019 1850 TComPic *refPic = *iterRefPic; 2020 if( ( refPic->getLayerId() == pcPic->getLayerId() ) && refPic->getReconMark() )1851 if( ( refPic->getLayerId() == m_pcPic->getLayerId() ) && refPic->getReconMark() ) 2021 1852 { 2022 1853 for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--) … … 2038 1869 2039 1870 // transfer any SEI messages that have been received to the picture 2040 pcPic->setSEIs(m_SEIs);1871 m_pcPic->setSEIs(m_SEIs); 2041 1872 m_SEIs.clear(); 2042 1873 2043 1874 // Recursive structure 2044 m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight );1875 m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getChromaFormatIdc() ); 2045 1876 #if SVC_EXTENSION 2046 1877 m_cCuDecoder.init ( m_ppcTDecTop,&m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, curLayerId ); … … 2058 1889 { 2059 1890 // Currently only decoding Unit SEI message occurring between VCL NALUs copied 2060 SEIMessages &picSEI = pcPic->getSEIs();1891 SEIMessages &picSEI = m_pcPic->getSEIs(); 2061 1892 SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); 2062 1893 picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); … … 2064 1895 } 2065 1896 } 2066 1897 2067 1898 // Set picture slice pointer 2068 1899 TComSlice* pcSlice = m_apcSlicePilot; 2069 Bool bNextSlice = pcSlice->isNextSlice(); 2070 2071 UInt i; 2072 pcPic->getPicSym()->initTiles(pcSlice->getPPS()); 2073 2074 //generate the Coding Order Map and Inverse Coding Order Map 2075 UInt uiEncCUAddr; 2076 for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) 2077 { 2078 pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr); 2079 pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i); 2080 } 2081 pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); 2082 pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); 2083 2084 //convert the start and end CU addresses of the slice and dependent slice into encoding order 2085 pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) ); 2086 pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) ); 2087 if(pcSlice->isNextSlice()) 2088 { 2089 pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr())); 2090 pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr())); 2091 } 2092 2093 if (m_bFirstSliceInPicture) 2094 { 2095 if(pcPic->getNumAllocatedSlice() != 1) 2096 { 2097 pcPic->clearSliceBuffer(); 1900 1901 m_pcPic->getPicSym()->initTiles(pcSlice->getPPS()); 1902 m_pcPic->getPicSym()->initCtuTsRsAddrMaps(); 1903 1904 // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses. 1905 // Now, having set up the maps, convert them to the correct form. 1906 pcSlice->setSliceSegmentCurStartCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()) ); 1907 pcSlice->setSliceSegmentCurEndCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurEndCtuTsAddr()) ); 1908 if(!pcSlice->getDependentSliceSegmentFlag()) 1909 { 1910 pcSlice->setSliceCurStartCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurStartCtuTsAddr())); 1911 pcSlice->setSliceCurEndCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurEndCtuTsAddr())); 1912 } 1913 1914 if (m_bFirstSliceInPicture) 1915 { 1916 if(m_pcPic->getNumAllocatedSlice() != 1) 1917 { 1918 m_pcPic->clearSliceBuffer(); 2098 1919 } 2099 1920 } 2100 1921 else 2101 1922 { 2102 pcPic->allocateNewSlice();2103 } 2104 assert( pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1));2105 m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx);2106 pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx);2107 2108 pcPic->setTLayer(nalu.m_temporalId);1923 m_pcPic->allocateNewSlice(); 1924 } 1925 assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); 1926 m_apcSlicePilot = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx); 1927 m_pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); 1928 1929 m_pcPic->setTLayer(nalu.m_temporalId); 2109 1930 2110 1931 #if SVC_EXTENSION 2111 pcPic->setLayerId(nalu.m_layerId);1932 m_pcPic->setLayerId(nalu.m_layerId); 2112 1933 pcSlice->setLayerId(nalu.m_layerId); 2113 pcSlice->setPic( pcPic);2114 #endif 2115 2116 if ( bNextSlice)1934 pcSlice->setPic(m_pcPic); 1935 #endif 1936 1937 if (!pcSlice->getDependentSliceSegmentFlag()) 2117 1938 { 2118 1939 pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); … … 2131 1952 if( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || ( pcSlice->getVPS()->getSingleLayerForNonIrapFlag() && pcSlice->isIRAP() ) ) 2132 1953 #endif 2133 for( i = 0; i < pcSlice->getNumILRRefIdx(); i++ )1954 for( Int i = 0; i < pcSlice->getNumILRRefIdx(); i++ ) 2134 1955 { 2135 1956 UInt refLayerIdc = i; … … 2192 2013 #if REF_REGION_OFFSET 2193 2014 const Window &windowRL = pcSlice->getPPS()->getRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc)); 2194 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth( ) - windowRL.getWindowLeftOffset() - windowRL.getWindowRightOffset();2195 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight( ) - windowRL.getWindowTopOffset() - windowRL.getWindowBottomOffset();2196 #else 2197 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth( );2198 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight( );2015 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(COMPONENT_Y) - windowRL.getWindowLeftOffset() - windowRL.getWindowRightOffset(); 2016 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(COMPONENT_Y) - windowRL.getWindowTopOffset() - windowRL.getWindowBottomOffset(); 2017 #else 2018 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(COMPONENT_Y); 2019 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(COMPONENT_Y); 2199 2020 #if Q0200_CONFORMANCE_BL_SIZE 2200 2021 Int chromaFormatIdc = pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getChromaFormatIdc(); … … 2204 2025 #endif 2205 2026 #endif 2206 Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();2207 Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset();2027 Int widthEL = m_pcPic->getPicYuvRec()->getWidth(COMPONENT_Y) - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); 2028 Int heightEL = m_pcPic->getPicYuvRec()->getHeight(COMPONENT_Y) - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); 2208 2029 2209 2030 #if RESAMPLING_FIX … … 2256 2077 #endif 2257 2078 #if SVC_EXTENSION 2258 if( pcPic->isSpatialEnhLayer(refLayerIdc) )2079 if( m_pcPic->isSpatialEnhLayer(refLayerIdc) ) 2259 2080 { 2260 2081 // check for the sample prediction picture type … … 2262 2083 { 2263 2084 #if O0215_PHASE_ALIGNMENT_REMOVAL 2264 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec,pcPic->getPicYuvRec());2085 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec()); 2265 2086 #else 2266 2087 #if O0215_PHASE_ALIGNMENT 2267 2088 #if O0194_JOINT_US_BITSHIFT 2268 2089 #if Q0048_CGS_3D_ASYMLUT 2269 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec,pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );2270 #else 2271 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );2090 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() ); 2091 #else 2092 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() ); 2272 2093 #endif 2273 2094 #else 2274 2095 #if Q0048_CGS_3D_ASYMLUT 2275 2096 #if MOVE_SCALED_OFFSET_TO_PPS 2276 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec,pcPic->getPicYuvRec(), pcSlice->getPPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );2277 #else 2278 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec,pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );2279 #endif 2280 #else 2281 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );2097 m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), pcSlice->getPPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() ); 2098 #else 2099 m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() ); 2100 #endif 2101 #else 2102 m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() ); 2282 2103 #endif 2283 2104 #endif … … 2286 2107 #if Q0048_CGS_3D_ASYMLUT 2287 2108 #if REF_REGION_OFFSET 2288 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec,pcPic->getPicYuvRec(), scalEL, altRL );2289 #else 2290 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec,pcPic->getPicYuvRec(), scalEL );2291 #endif 2292 #else 2293 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),pcPic->getPicYuvRec(), scalEL );2109 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), scalEL, altRL ); 2110 #else 2111 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), scalEL ); 2112 #endif 2113 #else 2114 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), scalEL ); 2294 2115 #endif 2295 2116 #else 2296 2117 #if Q0048_CGS_3D_ASYMLUT 2297 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec,pcPic->getPicYuvRec(), scalEL );2298 #else 2299 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),pcPic->getPicYuvRec(), scalEL );2118 m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), scalEL ); 2119 #else 2120 m_cPrediction.upsampleBasePic( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pcPic->getPicYuvRec(), scalEL ); 2300 2121 #endif 2301 2122 #endif … … 2306 2127 else 2307 2128 { 2308 pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() );2309 } 2310 pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );2129 m_pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() ); 2130 } 2131 pcSlice->setFullPelBaseRec ( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc) ); 2311 2132 #endif //SVC_EXTENSION 2312 2133 } … … 2315 2136 if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) 2316 2137 { 2317 for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )2138 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 2318 2139 { 2319 2140 UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); … … 2347 2168 #endif 2348 2169 2349 pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );2170 pcSlice->setFullPelBaseRec ( refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc) ); 2350 2171 } 2351 2172 … … 2446 2267 bLowDelay = false; 2447 2268 } 2448 } 2449 } 2450 2451 pcSlice->setCheckLDC(bLowDelay); 2269 } 2270 } 2271 2272 pcSlice->setCheckLDC(bLowDelay); 2452 2273 } 2453 2274 … … 2456 2277 } 2457 2278 2458 pcPic->setCurrSliceIdx(m_uiSliceIdx);2279 m_pcPic->setCurrSliceIdx(m_uiSliceIdx); 2459 2280 if(pcSlice->getSPS()->getScalingListFlag()) 2460 2281 { … … 2476 2297 pcSlice->setDefaultScalingList(); 2477 2298 } 2478 m_cTrQuant.setScalingListDec(pcSlice->getScalingList() );2299 m_cTrQuant.setScalingListDec(pcSlice->getScalingList(), pcSlice->getSPS()->getChromaFormatIdc()); 2479 2300 m_cTrQuant.setUseScalingList(true); 2480 2301 } 2481 2302 else 2482 2303 { 2483 m_cTrQuant.setFlatScalingList( );2304 m_cTrQuant.setFlatScalingList(pcSlice->getSPS()->getChromaFormatIdc()); 2484 2305 m_cTrQuant.setUseScalingList(false); 2485 2306 } 2486 2307 2487 2308 // Decode a picture 2488 m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic);2309 m_cGopDecoder.decompressSlice(nalu.m_Bitstream, m_pcPic); 2489 2310 2490 2311 #if P0297_VPS_POC_LSB_ALIGNED_FLAG … … 2504 2325 { 2505 2326 TComVPS* vps = new TComVPS(); 2506 2327 2507 2328 m_cEntropyDecoder.decodeVPS( vps ); 2508 2329 m_parameterSetManagerDecoder.storePrefetchedVPS(vps); … … 2516 2337 { 2517 2338 TComSPS* sps = new TComSPS(); 2339 #if O0043_BEST_EFFORT_DECODING 2340 sps->setForceDecodeBitDepth(m_forceDecodeBitDepth); 2341 #endif 2518 2342 sps->setLayerId(m_layerId); 2519 2343 #if SPS_DPB_PARAMS … … 2554 2378 { 2555 2379 TComSPS* sps = new TComSPS(); 2380 #if O0043_BEST_EFFORT_DECODING 2381 sps->setForceDecodeBitDepth(m_forceDecodeBitDepth); 2382 #endif 2556 2383 m_cEntropyDecoder.decodeSPS( sps ); 2557 2384 m_parameterSetManagerDecoder.storePrefetchedSPS(sps); … … 2576 2403 } 2577 2404 #if LAYERS_NOT_PRESENT_SEI 2578 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );2579 #else 2580 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );2405 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2406 #else 2407 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2581 2408 #endif 2582 2409 } … … 2584 2411 { 2585 2412 #if LAYERS_NOT_PRESENT_SEI 2586 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );2587 #else 2588 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );2413 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2414 #else 2415 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2589 2416 #endif 2590 2417 SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); … … 2622 2449 { 2623 2450 #if LAYERS_NOT_PRESENT_SEI 2624 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); 2625 #else 2626 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); 2451 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2452 #else 2453 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2454 2627 2455 #endif 2628 2456 } … … 2630 2458 { 2631 2459 #if LAYERS_NOT_PRESENT_SEI 2632 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );2633 #else 2634 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );2460 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2461 #else 2462 m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS(), m_pDecodedSEIOutputStream ); 2635 2463 #endif 2636 2464 SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); … … 2673 2501 #endif 2674 2502 xDecodeVPS(); 2503 #if RExt__DECODER_DEBUG_BIT_STATISTICS 2504 TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0); 2505 #endif 2675 2506 #if Q0177_EOS_CHECKS 2676 2507 m_isLastNALWasEos = false; … … 2699 2530 #endif 2700 2531 return false; 2701 2532 2702 2533 case NAL_UNIT_SPS: 2703 2534 xDecodeSPS(); 2535 #if RExt__DECODER_DEBUG_BIT_STATISTICS 2536 TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0); 2537 #endif 2704 2538 return false; 2705 2539 … … 2710 2544 #endif 2711 2545 ); 2546 #if RExt__DECODER_DEBUG_BIT_STATISTICS 2547 TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,nalu.m_Bitstream->readByteAlignment(),0); 2548 #endif 2712 2549 return false; 2713 2550 2714 2551 case NAL_UNIT_PREFIX_SEI: 2715 2552 case NAL_UNIT_SUFFIX_SEI: … … 2759 2596 #endif 2760 2597 break; 2761 2598 2762 2599 case NAL_UNIT_EOS: 2763 2600 #if Q0177_EOS_CHECKS … … 2780 2617 m_pocRandomAccess = MAX_INT; 2781 2618 m_prevPOC = MAX_INT; 2782 m_bFirstSliceInPicture = true;2783 m_bFirstSliceInSequence = true;2784 2619 m_prevSliceSkipped = false; 2785 2620 m_skippedPOC = 0; 2786 2621 return false; 2787 2622 2788 2623 case NAL_UNIT_ACCESS_UNIT_DELIMITER: 2789 2624 // TODO: process AU delimiter 2790 2625 return false; 2791 2626 2792 2627 case NAL_UNIT_EOB: 2793 2628 #if P0130_EOB … … 2799 2634 #endif 2800 2635 return false; 2801 2636 2802 2637 case NAL_UNIT_FILLER_DATA: 2803 2638 #if Q0177_EOS_CHECKS … … 2805 2640 #endif 2806 2641 return false; 2807 2642 2808 2643 case NAL_UNIT_RESERVED_VCL_N10: 2809 2644 case NAL_UNIT_RESERVED_VCL_R11: … … 2812 2647 case NAL_UNIT_RESERVED_VCL_N14: 2813 2648 case NAL_UNIT_RESERVED_VCL_R15: 2814 2649 2815 2650 case NAL_UNIT_RESERVED_IRAP_VCL22: 2816 2651 case NAL_UNIT_RESERVED_IRAP_VCL23: 2817 2652 2818 2653 case NAL_UNIT_RESERVED_VCL24: 2819 2654 case NAL_UNIT_RESERVED_VCL25: … … 2824 2659 case NAL_UNIT_RESERVED_VCL30: 2825 2660 case NAL_UNIT_RESERVED_VCL31: 2826 2661 2827 2662 case NAL_UNIT_RESERVED_NVCL41: 2828 2663 case NAL_UNIT_RESERVED_NVCL42: … … 2851 2686 default: 2852 2687 assert (0); 2688 break; 2853 2689 } 2854 2690 … … 2864 2700 Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) 2865 2701 { 2866 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) && 2702 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) && 2867 2703 m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) 2868 2704 { … … 2882 2718 * 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. 2883 2719 * If the random access point is IDR all pictures after the random access point are decoded. 2884 * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC 2885 * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random 2720 * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC 2721 * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random 2886 2722 * access point there is no guarantee that the decoder will not crash. 2887 2723 */ 2888 2724 Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) 2889 2725 { 2890 if (iSkipFrame) 2726 if (iSkipFrame) 2891 2727 { 2892 2728 iSkipFrame--; // decrement the counter … … 2907 2743 m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. 2908 2744 } 2909 else 2745 else 2910 2746 { 2911 2747 static Bool warningMessage = false; … … 2925 2761 } 2926 2762 // if we reach here, then the picture is not skipped. 2927 return false; 2763 return false; 2928 2764 } 2929 2765 2930 2766 #if SVC_EXTENSION 2767 #if !REPN_FORMAT_IN_VPS 2768 Void TDecTop::xInitILRP(TComSPS *pcSPS) 2769 #else 2770 Void TDecTop::xInitILRP(TComSlice *slice) 2771 #endif 2772 { 2773 #if REPN_FORMAT_IN_VPS 2774 TComSPS* pcSPS = slice->getSPS(); 2775 Int bitDepthY = slice->getBitDepthY(); 2776 Int bitDepthC = slice->getBitDepthC(); 2777 Int picWidth = slice->getPicWidthInLumaSamples(); 2778 Int picHeight = slice->getPicHeightInLumaSamples(); 2779 #endif 2780 if(m_layerId>0) 2781 { 2782 #if REPN_FORMAT_IN_VPS 2783 g_bitDepth[CHANNEL_TYPE_LUMA] = bitDepthY; 2784 g_bitDepth[CHANNEL_TYPE_CHROMA] = bitDepthC; 2785 #else 2786 g_bitDepth[CHANNEL_TYPE_LUMA] = pcSPS->getBitDepthY(); 2787 g_bitDepth[CHANNEL_TYPE_CHROMA] = pcSPS->getBitDepthC(); 2788 #endif 2789 g_uiMaxCUWidth = pcSPS->getMaxCUWidth(); 2790 g_uiMaxCUHeight = pcSPS->getMaxCUHeight(); 2791 g_uiMaxCUDepth = pcSPS->getMaxCUDepth(); 2792 g_uiAddCUDepth = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() ); 2793 2794 Int numReorderPics[MAX_TLAYER]; 2795 #if R0156_CONF_WINDOW_IN_REP_FORMAT 2796 Window &conformanceWindow = slice->getConformanceWindow(); 2797 #else 2798 Window &conformanceWindow = pcSPS->getConformanceWindow(); 2799 #endif 2800 Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window(); 2801 2802 for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) 2803 { 2804 #if USE_DPB_SIZE_TABLE 2805 if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 ) 2806 { 2807 assert( this->getLayerId() == 0 ); 2808 numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); 2809 } 2810 else 2811 { 2812 TComVPS *vps = slice->getVPS(); 2813 // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures. 2814 numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer); 2815 } 2816 #else 2817 numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); 2818 #endif 2819 } 2820 2821 if (m_cIlpPic[0] == NULL) 2822 { 2823 for (Int j=0; j < m_numDirectRefLayers; j++) 2824 { 2825 2826 m_cIlpPic[j] = new TComPic; 2827 2828 #if AUXILIARY_PICTURES 2829 #if REPN_FORMAT_IN_VPS 2830 m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); 2831 #else 2832 m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), pcSPS->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); 2833 #endif 2834 #else 2835 #if REPN_FORMAT_IN_VPS 2836 m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); 2837 #else 2838 m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); 2839 #endif 2840 #endif 2841 for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCtusInFrame(); i++) 2842 { 2843 m_cIlpPic[j]->getPicSym()->getCtu(i)->initCtu(m_cIlpPic[j], i); 2844 } 2845 } 2846 } 2847 } 2848 } 2849 2931 2850 #if VPS_EXTN_DIRECT_REF_LAYERS 2932 2851 TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdc ) … … 2993 2912 } 2994 2913 } 2995 2914 #endif 2915 2916 #if EARLY_REF_PIC_MARKING 2917 Void TDecTop::earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdSet) 2918 { 2919 UInt currTid = m_pcPic->getTLayer(); 2920 UInt highestTid = (maxTemporalLayer >= 0) ? maxTemporalLayer : (m_pcPic->getSlice(0)->getSPS()->getMaxTLayers() - 1); 2921 UInt latestDecLayerId = m_layerId; 2922 UInt numTargetDecLayers = 0; 2923 Int targetDecLayerIdList[MAX_LAYERS]; 2924 UInt latestDecIdx = 0; 2925 TComSlice* pcSlice = m_pcPic->getSlice(0); 2926 2927 if ( currTid != highestTid ) // Marking process is only applicaple for highest decoded TLayer 2928 { 2929 return; 2930 } 2931 2932 // currPic must be marked as "used for reference" and must be a sub-layer non-reference picture 2933 if ( !((pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || 2934 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || 2935 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || 2936 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || 2937 pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || 2938 pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N10 || 2939 pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N12 || 2940 pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N14) && pcSlice->isReferenced())) 2941 { 2942 return; 2943 } 2944 2945 if ( targetDecLayerIdSet.size() == 0 ) // Cannot mark if we don't know the number of scalable layers 2946 { 2947 return; 2948 } 2949 2950 for (std::vector<Int>::iterator it = targetDecLayerIdSet.begin(); it != targetDecLayerIdSet.end(); it++) 2951 { 2952 if ( latestDecLayerId == (*it) ) 2953 { 2954 latestDecIdx = numTargetDecLayers; 2955 } 2956 targetDecLayerIdList[numTargetDecLayers++] = (*it); 2957 } 2958 2959 Int remainingInterLayerReferencesFlag = 0; 2960 #if O0225_MAX_TID_FOR_REF_LAYERS 2961 for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) 2962 { 2963 Int jLidx = pcSlice->getVPS()->getLayerIdInVps(targetDecLayerIdList[j]); 2964 if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId,jLidx) - 1 ) 2965 { 2966 #else 2967 if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId) - 1 ) 2968 { 2969 for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) 2970 { 2971 #endif 2972 for ( Int k = 0; k < m_ppcTDecTop[targetDecLayerIdList[j]]->getNumDirectRefLayers(); k++ ) 2973 { 2974 if ( latestDecIdx == m_ppcTDecTop[targetDecLayerIdList[j]]->getRefLayerId(k) ) 2975 { 2976 remainingInterLayerReferencesFlag = 1; 2977 } 2978 } 2979 } 2980 } 2981 2982 if ( remainingInterLayerReferencesFlag == 0 ) 2983 { 2984 pcSlice->setReferenced(false); 2985 } 2986 } 2996 2987 #endif 2997 2988 … … 3077 3068 assert( params->getTargetLayerId() == vps->getNumLayersInIdList( layerSetIdx ) - 1); 3078 3069 #endif 3070 3079 3071 #if !R0235_SMALLEST_LAYER_ID 3080 3072 Bool layerSetMatchFlag = true; … … 3279 3271 { 3280 3272 UInt smallestLayerId; 3281 Int targetOlsIdx = getCommonDecoderParams()->getTargetOutputLayerSetIdx();3273 Int targetOlsIdx = m_commonDecoderParams->getTargetOutputLayerSetIdx(); 3282 3274 assert( targetOlsIdx >= 0 ); 3283 3275 -
branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h
r1005 r1029 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; … … 123 127 Bool m_lastPicHasEos; 124 128 #endif 125 #if SVC_EXTENSION126 129 static UInt m_prevPOC; // POC of the previous slice 127 130 static UInt m_uiPrevLayerId; // LayerId of the previous slice … … 199 202 TDecTop(); 200 203 virtual ~TDecTop(); 201 204 202 205 Void create (); 203 206 Void destroy (); 204 207 205 void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }208 Void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } 206 209 #if Q0074_COLOUR_REMAPPING_SEI 207 210 void setColourRemappingInfoSEIEnabled(Bool enabled) { m_cGopDecoder.setColourRemappingInfoSEIEnabled(enabled); } … … 221 224 222 225 223 Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);224 #if SETTING_NO_OUT_PIC_PRIOR 225 Void checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic); 226 Bool getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; }226 Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic); 227 Void checkNoOutputPriorPics (TComList<TComPic*>* rpcListPic); 228 229 Bool getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; } 227 230 Void setNoOutputPriorPicsFlag (Bool val) { m_isNoOutputPriorPics = val; } 228 #endif 231 Void setFirstSliceInPicture (bool val) { m_bFirstSliceInPicture = val; } 232 Bool getFirstSliceInSequence () { return m_bFirstSliceInSequence; } 233 Void setFirstSliceInSequence (bool val) { m_bFirstSliceInSequence = val; } 234 #if O0043_BEST_EFFORT_DECODING 235 Void setForceDecodeBitDepth(UInt bitDepth) { m_forceDecodeBitDepth = bitDepth; } 236 #endif 237 Void setDecodedSEIMessageOutputStream(std::ostream *pOpStream) { m_pDecodedSEIOutputStream = pOpStream; } 229 238 230 239 #if SVC_EXTENSION … … 314 323 std::vector<TComPic>* getConfListPic() {return &m_confListPic; } 315 324 // std::string const getDecodedYuvLayerFileName(Int layerId) { return m_decodedYuvLayerFileName[layerId]; } 325 Bool const getConfModeFlag() { return m_confModeFlag; } 326 Void setConfModeFlag(Bool x) { m_confModeFlag = x; } 316 327 #endif 317 328 #endif //SVC_EXTENSION … … 354 365 Void resetPocRestrictionCheckParameters(); 355 366 #endif 356 public:357 #if CONFORMANCE_BITSTREAM_MODE358 Bool const getConfModeFlag() { return m_confModeFlag; }359 Void setConfModeFlag(Bool x) { m_confModeFlag = x; }360 #endif361 367 #if R0071_IRAP_EOS_CROSS_LAYER_IMPACTS 362 368 Void xCheckLayerReset(); … … 367 373 368 374 369 370 375 //! \} 371 376
Note: See TracChangeset for help on using the changeset viewer.