Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibDecoder
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- Location:
- trunk/source/Lib/TLibDecoder
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibDecoder/AnnexBread.cpp
r1179 r1313 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 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++; -
trunk/source/Lib/TLibDecoder/AnnexBread.h
r1179 r1313 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 39 39 #pragma once 40 40 41 #ifndef __ANNEXBREAD__ 42 #define __ANNEXBREAD__ 43 41 44 #include <stdint.h> 42 45 #include <istream> 43 46 #include <vector> 44 47 45 #include " ../TLibCommon/TypeDef.h"48 #include "TLibCommon/CommonDef.h" 46 49 47 50 //! \ingroup TLibDecoder … … 72 75 * modified externally to this class 73 76 */ 74 void reset()77 Void reset() 75 78 { 76 79 m_NumFutureBytes = 0; … … 86 89 assert(n <= 4); 87 90 if (m_NumFutureBytes >= n) 91 { 88 92 return false; 93 } 89 94 90 95 n -= m_NumFutureBytes; … … 150 155 uint32_t val = 0; 151 156 for (UInt i = 0; i < n; i++) 157 { 152 158 val = (val << 8) | readByte(); 159 } 153 160 return val; 154 161 } 162 163 #if RExt__DECODER_DEBUG_BIT_STATISTICS 164 UInt GetNumBufferedBytes() const { return m_NumFutureBytes; } 165 #endif 155 166 156 167 private: … … 185 196 186 197 //! \} 198 199 #endif -
trunk/source/Lib/TLibDecoder/NALread.cpp
r1179 r1313 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 34 34 /** 35 35 \file NALread.cpp 36 \brief reading fun tionality for NAL units36 \brief reading functionality for NAL units 37 37 */ 38 38 … … 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 50 #if ENC_DEC_TRACE && DEC_NUH_TRACE 51 #include "TLibCommon/TComRom.h" 52 #endif 47 53 48 54 using namespace std; … … 50 56 //! \ingroup TLibDecoder 51 57 //! \{ 52 static void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, TComInputBitstream *bitstream, Bool isVclNalUnit)58 static Void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, TComInputBitstream *bitstream, Bool isVclNalUnit) 53 59 { 54 60 UInt zeroCount = 0; … … 66 72 it_read++; 67 73 zeroCount = 0; 74 #if RExt__DECODER_DEBUG_BIT_STATISTICS 75 TComCodingStatistics::IncrementStatisticEP(STATS__EMULATION_PREVENTION_3_BYTES, 8, 0); 76 #endif 68 77 if (it_read == nalUnitBuf.end()) 69 78 { … … 76 85 } 77 86 assert(zeroCount == 0); 78 87 79 88 if (isVclNalUnit) 80 89 { 81 90 // Remove cabac_zero_word from payload if present 82 91 Int n = 0; 83 92 84 93 while (it_write[-1] == 0x00) 85 94 { … … 87 96 n++; 88 97 } 89 98 90 99 if (n > 0) 91 100 { 92 printf("\nDetected %d instances of cabac_zero_word ", n/2);101 printf("\nDetected %d instances of cabac_zero_word\n", n/2); 93 102 } 94 103 } … … 97 106 } 98 107 108 #if ENC_DEC_TRACE && DEC_NUH_TRACE 109 void xTraceNalUnitHeader(InputNALUnit& nalu) 110 { 111 fprintf( g_hTrace, "*********** NAL UNIT (%s) ***********\n", nalUnitTypeToString(nalu.m_nalUnitType) ); 112 113 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 114 fprintf( g_hTrace, "%-50s u(%d) : %u\n", "forbidden_zero_bit", 1, 0 ); 115 116 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 117 fprintf( g_hTrace, "%-50s u(%d) : %u\n", "nal_unit_type", 6, nalu.m_nalUnitType ); 118 119 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 120 fprintf( g_hTrace, "%-50s u(%d) : %u\n", "nuh_layer_id", 6, nalu.m_nuhLayerId ); 121 122 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 123 fprintf( g_hTrace, "%-50s u(%d) : %u\n", "nuh_temporal_id_plus1", 3, nalu.m_temporalId + 1 ); 124 125 fflush ( g_hTrace ); 126 } 127 #endif 128 99 129 Void readNalUnitHeader(InputNALUnit& nalu) 100 130 { 101 TComInputBitstream& bs = *nalu.m_Bitstream;131 TComInputBitstream& bs = nalu.getBitstream(); 102 132 103 133 Bool forbidden_zero_bit = bs.read(1); // forbidden_zero_bit 104 134 assert(forbidden_zero_bit == 0); 105 135 nalu.m_nalUnitType = (NalUnitType) bs.read(6); // nal_unit_type 106 #if H_MV107 nalu.m_ layerId = bs.read(6); // layerId136 #if NH_MV 137 nalu.m_nuhLayerId = bs.read(6); // layerId 108 138 #else 109 nalu.m_reservedZero6Bits = bs.read(6); // nuh_reserved_zero_6bits 110 assert(nalu.m_reservedZero6Bits == 0); 139 nalu.m_nuhLayerId = bs.read(6); // nuh_layer_id 111 140 #endif 112 141 nalu.m_temporalId = bs.read(3) - 1; // nuh_temporal_id_plus1 113 114 if ( nalu.m_temporalId ) 142 #if RExt__DECODER_DEBUG_BIT_STATISTICS 143 TComCodingStatistics::IncrementStatisticEP(STATS__NAL_UNIT_HEADER_BITS, 1+6+6+3, 0); 144 #endif 145 146 #if ENC_DEC_TRACE && DEC_NUH_TRACE 147 xTraceNalUnitHeader(nalu); 148 #endif 149 150 // only check these rules for base layer 151 if (nalu.m_nuhLayerId == 0) 115 152 { 116 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_LP 117 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_RADL 118 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_N_LP 119 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_W_RADL 120 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_N_LP 121 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA 122 && nalu.m_nalUnitType != NAL_UNIT_VPS 123 && nalu.m_nalUnitType != NAL_UNIT_SPS 124 && nalu.m_nalUnitType != NAL_UNIT_EOS 125 && nalu.m_nalUnitType != NAL_UNIT_EOB ); 126 } 127 else 128 { 129 #if H_MV 130 153 if ( nalu.m_temporalId ) 154 { 155 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_LP 156 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_W_RADL 157 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_N_LP 158 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_W_RADL 159 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_N_LP 160 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA 161 && nalu.m_nalUnitType != NAL_UNIT_VPS 162 && nalu.m_nalUnitType != NAL_UNIT_SPS 163 && nalu.m_nalUnitType != NAL_UNIT_EOS 164 && nalu.m_nalUnitType != NAL_UNIT_EOB ); 165 } 166 else 167 { 168 #if NH_MV 131 169 // If nal_unit_type is in the range of BLA_W_LP to RSV_IRAP_VCL23, inclusive, i.e. the coded 132 170 // slice segment belongs to an IRAP picture, TemporalId shall be equal to 0. … … 139 177 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N ); 140 178 141 assert( nalu.m_ layerId > 0179 assert( nalu.m_nuhLayerId > 0 142 180 || ( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R 143 181 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N ) ); 144 182 #else 145 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_R 146 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N 147 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R 148 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N ); 149 #endif 183 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_R 184 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N 185 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R 186 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N ); 187 #endif 188 } 150 189 } 151 190 } … … 154 193 * a bitstream 155 194 */ 156 void read(InputNALUnit& nalu, vector<uint8_t>& nalUnitBuf) 157 { 158 /* perform anti-emulation prevention */ 159 TComInputBitstream *pcBitstream = new TComInputBitstream(NULL); 160 convertPayloadToRBSP(nalUnitBuf, pcBitstream, (nalUnitBuf[0] & 64) == 0); 161 162 nalu.m_Bitstream = new TComInputBitstream(&nalUnitBuf); 163 nalu.m_Bitstream->setEmulationPreventionByteLocation(pcBitstream->getEmulationPreventionByteLocation()); 164 delete pcBitstream; 195 Void read(InputNALUnit& nalu) 196 { 197 TComInputBitstream &bitstream = nalu.getBitstream(); 198 vector<uint8_t>& nalUnitBuf=bitstream.getFifo(); 199 // perform anti-emulation prevention 200 convertPayloadToRBSP(nalUnitBuf, &bitstream, (nalUnitBuf[0] & 64) == 0); 201 bitstream.resetToStart(); 165 202 readNalUnitHeader(nalu); 166 203 } -
trunk/source/Lib/TLibDecoder/NALread.h
r1179 r1313 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 34 34 /** 35 35 \file NALread.h 36 \brief reading fun tionality for NAL units36 \brief reading functionality for NAL units 37 37 */ 38 38 39 39 #pragma once 40 40 41 #include "../TLibCommon/TypeDef.h" 42 #include "../TLibCommon/TComBitStream.h" 43 #include "../TLibCommon/NAL.h" 44 41 #ifndef __NALREAD__ 42 #define __NALREAD__ 43 #include "TLibCommon/CommonDef.h" 44 #include "TLibCommon/TComBitStream.h" 45 #include "TLibCommon/NAL.h" 45 46 //! \ingroup TLibDecoder 46 47 //! \{ … … 50 51 * bitstream object. 51 52 */ 52 structInputNALUnit : public NALUnit53 class InputNALUnit : public NALUnit 53 54 { 54 InputNALUnit() : m_Bitstream(0) {};55 ~InputNALUnit() { delete m_Bitstream; }55 private: 56 TComInputBitstream m_Bitstream; 56 57 57 TComInputBitstream* m_Bitstream; 58 public: 59 InputNALUnit(const InputNALUnit &src) : NALUnit(src), m_Bitstream(src.m_Bitstream) {}; 60 InputNALUnit() : m_Bitstream() {}; 61 virtual ~InputNALUnit() { } 62 const TComInputBitstream &getBitstream() const { return m_Bitstream; } 63 TComInputBitstream &getBitstream() { return m_Bitstream; } 58 64 }; 59 65 60 void read(InputNALUnit& nalu, std::vector<uint8_t>& nalUnitBuf); 66 Void read(InputNALUnit& nalu); 67 Void readNalUnitHeader(InputNALUnit& nalu); 61 68 62 69 //! \} 70 71 #endif -
trunk/source/Lib/TLibDecoder/SEIread.cpp
r1179 r1313 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 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 case SEI::SOP_DESCRIPTION: 96 fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n"); 97 break; 98 case SEI::SCALABLE_NESTING: 99 fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n"); 100 break; 101 #if H_MV 102 case SEI::SUB_BITSTREAM_PROPERTY: 103 fprintf( g_hTrace, "=========== Sub-bitstream property SEI message ===========\n"); 104 break; 61 fprintf( g_hTrace, "=========== %s SEI message ===========\n", SEI::getSEIMessageString(payloadType)); 62 } 105 63 #endif 106 default: 107 fprintf( g_hTrace, "=========== Unknown SEI message ===========\n"); 108 break; 109 } 110 } 111 #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) 69 { 70 (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; 71 } 72 } 73 74 Void SEIReader::sei_read_uvlc(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName) 75 { 76 READ_UVLC(ruiCode, pSymbolName); 77 if (pOS) 78 { 79 (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; 80 } 81 } 82 83 Void SEIReader::sei_read_svlc(std::ostream *pOS, Int& ruiCode, const Char *pSymbolName) 84 { 85 READ_SVLC(ruiCode, pSymbolName); 86 if (pOS) 87 { 88 (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; 89 } 90 } 91 92 Void SEIReader::sei_read_flag(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName) 93 { 94 READ_FLAG(ruiCode, pSymbolName); 95 if (pOS) 96 { 97 (*pOS) << " " << std::setw(55) << pSymbolName << ": " << (ruiCode?1:0) << "\n"; 98 } 99 } 100 101 static inline Void output_sei_message_header(SEI &sei, std::ostream *pDecodedMessageOutputStream, UInt payloadSize) 102 { 103 if (pDecodedMessageOutputStream) 104 { 105 std::string seiMessageHdr(SEI::getSEIMessageString(sei.payloadType())); seiMessageHdr+=" SEI message"; 106 (*pDecodedMessageOutputStream) << std::setfill('-') << std::setw(seiMessageHdr.size()) << "-" << std::setfill(' ') << "\n" << seiMessageHdr << " (" << payloadSize << " bytes)"<< "\n"; 107 } 108 } 109 110 #undef READ_CODE 111 #undef READ_SVLC 112 #undef READ_UVLC 113 #undef READ_FLAG 114 112 115 113 116 /** 114 117 * unmarshal a single SEI message from bitstream bs 115 118 */ 116 void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps)119 Void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 117 120 { 118 121 setBitstream(bs); … … 121 124 do 122 125 { 123 xReadSEImessage(seis, nalUnitType, sps); 126 xReadSEImessage(seis, nalUnitType, sps, pDecodedMessageOutputStream); 127 124 128 /* SEI messages are an integer number of bytes, something has failed 125 129 * in the parsing if bitstream not byte-aligned */ 126 130 assert(!m_pcBitstream->getNumBitsUntilByteAligned()); 127 } while (m_pcBitstream->getNumBitsLeft() > 8); 128 129 UInt rbspTrailingBits; 130 READ_CODE(8, rbspTrailingBits, "rbsp_trailing_bits"); 131 assert(rbspTrailingBits == 0x80); 132 } 133 134 Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps) 131 } 132 while (m_pcBitstream->getNumBitsLeft() > 8); 133 134 xReadRbspTrailingBits(); 135 } 136 137 Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 135 138 { 136 139 #if ENC_DEC_TRACE … … 142 145 do 143 146 { 144 READ_CODE (8, val, "payload_type");147 sei_read_code(NULL, 8, val, "payload_type"); 145 148 payloadType += val; 146 149 } while (val==0xFF); … … 149 152 do 150 153 { 151 READ_CODE (8, val, "payload_size");154 sei_read_code(NULL, 8, val, "payload_size"); 152 155 payloadSize += val; 153 156 } while (val==0xFF); … … 174 177 case SEI::USER_DATA_UNREGISTERED: 175 178 sei = new SEIuserDataUnregistered; 176 xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize );179 xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream); 177 180 break; 178 181 case SEI::ACTIVE_PARAMETER_SETS: 179 sei = new SEIActiveParameterSets; 180 xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize );181 break; 182 sei = new SEIActiveParameterSets; 183 xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize, pDecodedMessageOutputStream); 184 break; 182 185 case SEI::DECODING_UNIT_INFO: 183 186 if (!sps) … … 187 190 else 188 191 { 189 sei = new SEIDecodingUnitInfo; 190 xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps );191 } 192 break; 192 sei = new SEIDecodingUnitInfo; 193 xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, pDecodedMessageOutputStream); 194 } 195 break; 193 196 case SEI::BUFFERING_PERIOD: 194 197 if (!sps) … … 199 202 { 200 203 sei = new SEIBufferingPeriod; 201 xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps );204 xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, pDecodedMessageOutputStream); 202 205 } 203 206 break; … … 210 213 { 211 214 sei = new SEIPictureTiming; 212 xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps );215 xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, pDecodedMessageOutputStream); 213 216 } 214 217 break; 215 218 case SEI::RECOVERY_POINT: 216 219 sei = new SEIRecoveryPoint; 217 xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize );220 xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize, pDecodedMessageOutputStream); 218 221 break; 219 222 case SEI::FRAME_PACKING: 220 223 sei = new SEIFramePacking; 221 xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize); 224 xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream); 225 break; 226 case SEI::SEGM_RECT_FRAME_PACKING: 227 sei = new SEISegmentedRectFramePacking; 228 xParseSEISegmentedRectFramePacking((SEISegmentedRectFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream); 222 229 break; 223 230 case SEI::DISPLAY_ORIENTATION: 224 231 sei = new SEIDisplayOrientation; 225 xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize );232 xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize, pDecodedMessageOutputStream); 226 233 break; 227 234 case SEI::TEMPORAL_LEVEL0_INDEX: 228 235 sei = new SEITemporalLevel0Index; 229 xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize );236 xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize, pDecodedMessageOutputStream); 230 237 break; 231 238 case SEI::REGION_REFRESH_INFO: 232 239 sei = new SEIGradualDecodingRefreshInfo; 233 xParseSEIGradualDecodingRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize); 240 xParseSEIRegionRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize, pDecodedMessageOutputStream); 241 break; 242 case SEI::NO_DISPLAY: 243 sei = new SEINoDisplay; 244 xParseSEINoDisplay((SEINoDisplay&) *sei, payloadSize, pDecodedMessageOutputStream); 234 245 break; 235 246 case SEI::TONE_MAPPING_INFO: 236 247 sei = new SEIToneMappingInfo; 237 xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize );248 xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream); 238 249 break; 239 250 case SEI::SOP_DESCRIPTION: 240 251 sei = new SEISOPDescription; 241 xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize );252 xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize, pDecodedMessageOutputStream); 242 253 break; 243 254 case SEI::SCALABLE_NESTING: 244 255 sei = new SEIScalableNesting; 245 xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps); 246 break; 247 #if H_MV 248 case SEI::SUB_BITSTREAM_PROPERTY: 249 sei = new SEISubBitstreamProperty; 250 xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei); 251 break; 256 xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps, pDecodedMessageOutputStream); 257 break; 258 case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS: 259 sei = new SEITempMotionConstrainedTileSets; 260 xParseSEITempMotionConstraintsTileSets((SEITempMotionConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream); 261 break; 262 case SEI::TIME_CODE: 263 sei = new SEITimeCode; 264 xParseSEITimeCode((SEITimeCode&) *sei, payloadSize, pDecodedMessageOutputStream); 265 break; 266 case SEI::CHROMA_SAMPLING_FILTER_HINT: 267 sei = new SEIChromaSamplingFilterHint; 268 xParseSEIChromaSamplingFilterHint((SEIChromaSamplingFilterHint&) *sei, payloadSize/*, sps*/, pDecodedMessageOutputStream); 269 //} 270 break; 271 case SEI::KNEE_FUNCTION_INFO: 272 sei = new SEIKneeFunctionInfo; 273 xParseSEIKneeFunctionInfo((SEIKneeFunctionInfo&) *sei, payloadSize, pDecodedMessageOutputStream); 274 break; 275 case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: 276 sei = new SEIMasteringDisplayColourVolume; 277 xParseSEIMasteringDisplayColourVolume((SEIMasteringDisplayColourVolume&) *sei, payloadSize, pDecodedMessageOutputStream); 278 break; 279 #if NH_MV 280 case SEI::SUB_BITSTREAM_PROPERTY: 281 sei = new SEISubBitstreamProperty; 282 xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, payloadSize, pDecodedMessageOutputStream ); 283 break; 252 284 #endif 253 285 default: … … 255 287 { 256 288 UInt seiByte; 257 READ_CODE (8, seiByte, "unknown prefix SEI payload byte");289 sei_read_code (NULL, 8, seiByte, "unknown prefix SEI payload byte"); 258 290 } 259 291 printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType); 292 if (pDecodedMessageOutputStream) 293 { 294 (*pDecodedMessageOutputStream) << "Unknown prefix SEI message (payloadType = " << payloadType << ") was found!\n"; 295 } 296 break; 260 297 } 261 298 } … … 266 303 case SEI::USER_DATA_UNREGISTERED: 267 304 sei = new SEIuserDataUnregistered; 268 xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize );305 xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream); 269 306 break; 270 307 case SEI::DECODED_PICTURE_HASH: 271 308 sei = new SEIDecodedPictureHash; 272 xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize );309 xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize, pDecodedMessageOutputStream); 273 310 break; 274 311 default: … … 276 313 { 277 314 UInt seiByte; 278 READ_CODE (8, seiByte, "unknown suffix SEI payload byte");315 sei_read_code( NULL, 8, seiByte, "unknown suffix SEI payload byte"); 279 316 } 280 317 printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType); 281 } 282 } 318 if (pDecodedMessageOutputStream) 319 { 320 (*pDecodedMessageOutputStream) << "Unknown suffix SEI message (payloadType = " << payloadType << ") was found!\n"; 321 } 322 break; 323 } 324 } 325 283 326 if (sei != NULL) 284 327 { … … 299 342 { 300 343 UInt reservedPayloadExtensionData; 301 READ_CODE (1, reservedPayloadExtensionData, "reserved_payload_extension_data");344 sei_read_code ( pDecodedMessageOutputStream, 1, reservedPayloadExtensionData, "reserved_payload_extension_data"); 302 345 } 303 346 … … 314 357 { 315 358 UInt reservedPayloadExtensionData; 316 READ_FLAG (reservedPayloadExtensionData, "reserved_payload_extension_data");359 sei_read_flag ( 0, reservedPayloadExtensionData, "reserved_payload_extension_data"); 317 360 } 318 361 319 362 UInt dummy; 320 READ_FLAG (dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--;363 sei_read_flag( 0, dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--; 321 364 while (payloadBitsRemaining) 322 365 { 323 READ_FLAG (dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--;366 sei_read_flag( 0, dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--; 324 367 } 325 368 } 326 369 327 370 /* restore primary bitstream for sei_message */ 328 getBitstream()->deleteFifo();329 371 delete getBitstream(); 330 372 setBitstream(bs); … … 335 377 * of payloasSize bytes into sei. 336 378 */ 337 Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize) 338 { 339 assert(payloadSize >= 16); 379 380 Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 381 { 382 assert(payloadSize >= ISO_IEC_11578_LEN); 340 383 UInt val; 341 342 for (UInt i = 0; i < 16; i++) 343 { 344 READ_CODE (8, val, "uuid_iso_iec_11578"); 384 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 385 386 for (UInt i = 0; i < ISO_IEC_11578_LEN; i++) 387 { 388 sei_read_code( pDecodedMessageOutputStream, 8, val, "uuid_iso_iec_11578"); 345 389 sei.uuid_iso_iec_11578[i] = val; 346 390 } 347 391 348 sei.userDataLength = payloadSize - 16;392 sei.userDataLength = payloadSize - ISO_IEC_11578_LEN; 349 393 if (!sei.userDataLength) 350 394 { … … 356 400 for (UInt i = 0; i < sei.userDataLength; i++) 357 401 { 358 READ_CODE (8, val, "user_data" );402 sei_read_code( NULL, 8, val, "user_data_payload_byte" ); 359 403 sei.userData[i] = val; 404 } 405 if (pDecodedMessageOutputStream) 406 { 407 (*pDecodedMessageOutputStream) << " User data payload size: " << sei.userDataLength << "\n"; 360 408 } 361 409 } … … 365 413 * of payloadSize bytes into sei. 366 414 */ 367 Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt /*payloadSize*/) 368 { 415 Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 416 { 417 UInt bytesRead = 0; 418 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 419 369 420 UInt val; 370 READ_CODE (8, val, "hash_type"); 371 sei.method = static_cast<SEIDecodedPictureHash::Method>(val); 372 for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++) 373 { 374 if(SEIDecodedPictureHash::MD5 == sei.method) 375 { 376 for (UInt i = 0; i < 16; i++) 377 { 378 READ_CODE(8, val, "picture_md5"); 379 sei.digest[yuvIdx][i] = val; 380 } 381 } 382 else if(SEIDecodedPictureHash::CRC == sei.method) 383 { 384 READ_CODE(16, val, "picture_crc"); 385 sei.digest[yuvIdx][0] = val >> 8 & 0xFF; 386 sei.digest[yuvIdx][1] = val & 0xFF; 387 } 388 else if(SEIDecodedPictureHash::CHECKSUM == sei.method) 389 { 390 READ_CODE(32, val, "picture_checksum"); 391 sei.digest[yuvIdx][0] = (val>>24) & 0xff; 392 sei.digest[yuvIdx][1] = (val>>16) & 0xff; 393 sei.digest[yuvIdx][2] = (val>>8) & 0xff; 394 sei.digest[yuvIdx][3] = val & 0xff; 395 } 396 } 397 } 398 Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt /*payloadSize*/) 421 sei_read_code( pDecodedMessageOutputStream, 8, val, "hash_type"); 422 sei.method = static_cast<SEIDecodedPictureHash::Method>(val); bytesRead++; 423 424 const Char *traceString="\0"; 425 switch (sei.method) 426 { 427 case SEIDecodedPictureHash::MD5: traceString="picture_md5"; break; 428 case SEIDecodedPictureHash::CRC: traceString="picture_crc"; break; 429 case SEIDecodedPictureHash::CHECKSUM: traceString="picture_checksum"; break; 430 default: assert(false); break; 431 } 432 433 if (pDecodedMessageOutputStream) 434 { 435 (*pDecodedMessageOutputStream) << " " << std::setw(55) << traceString << ": " << std::hex << std::setfill('0'); 436 } 437 438 sei.m_pictureHash.hash.clear(); 439 for(;bytesRead < payloadSize; bytesRead++) 440 { 441 sei_read_code( NULL, 8, val, traceString); 442 sei.m_pictureHash.hash.push_back((UChar)val); 443 if (pDecodedMessageOutputStream) 444 { 445 (*pDecodedMessageOutputStream) << std::setw(2) << val; 446 } 447 } 448 449 if (pDecodedMessageOutputStream) 450 { 451 (*pDecodedMessageOutputStream) << std::dec << std::setfill(' ') << "\n"; 452 } 453 } 454 455 Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 399 456 { 400 457 UInt val; 401 READ_CODE(4, val, "active_video_parameter_set_id"); sei.activeVPSId = val; 402 READ_FLAG( val, "self_contained_cvs_flag"); sei.m_selfContainedCvsFlag = val ? true : false; 403 READ_FLAG( val, "no_parameter_set_update_flag"); sei.m_noParameterSetUpdateFlag = val ? true : false; 404 READ_UVLC( val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; 458 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 459 460 sei_read_code( pDecodedMessageOutputStream, 4, val, "active_video_parameter_set_id"); sei.activeVPSId = val; 461 sei_read_flag( pDecodedMessageOutputStream, val, "self_contained_cvs_flag"); sei.m_selfContainedCvsFlag = (val != 0); 462 sei_read_flag( pDecodedMessageOutputStream, val, "no_parameter_set_update_flag"); sei.m_noParameterSetUpdateFlag = (val != 0); 463 sei_read_uvlc( pDecodedMessageOutputStream, val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; 405 464 406 465 sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1); 407 466 for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++) 408 467 { 409 READ_UVLC(val, "active_seq_parameter_set_id"); sei.activeSeqParameterSetId[i] = val; 410 } 411 412 xParseByteAlign(); 413 } 414 415 Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps) 468 sei_read_uvlc( pDecodedMessageOutputStream, val, "active_seq_parameter_set_id[i]"); sei.activeSeqParameterSetId[i] = val; 469 } 470 } 471 472 Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 416 473 { 417 474 UInt val; 418 READ_UVLC(val, "decoding_unit_idx"); 475 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 476 sei_read_uvlc( pDecodedMessageOutputStream, val, "decoding_unit_idx"); 419 477 sei.m_decodingUnitIdx = val; 420 478 421 TComVUI *vui = sps->getVuiParameters();479 const TComVUI *vui = sps->getVuiParameters(); 422 480 if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag()) 423 481 { 424 READ_CODE( ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay");482 sei_read_code( pDecodedMessageOutputStream, ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay_increment"); 425 483 sei.m_duSptCpbRemovalDelay = val; 426 484 } … … 429 487 sei.m_duSptCpbRemovalDelay = 0; 430 488 } 431 READ_FLAG( val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = val ? true : false;489 sei_read_flag( pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0); 432 490 if(sei.m_dpbOutputDuDelayPresentFlag) 433 491 { 434 READ_CODE(vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay");492 sei_read_code( pDecodedMessageOutputStream, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); 435 493 sei.m_picSptDpbOutputDuDelay = val; 436 494 } 437 xParseByteAlign(); 438 } 439 440 Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps) 495 } 496 497 Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 441 498 { 442 499 Int i, nalOrVcl; 443 500 UInt code; 444 501 445 TComVUI *pVUI = sps->getVuiParameters(); 446 TComHRD *pHRD = pVUI->getHrdParameters(); 447 448 READ_UVLC( code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; 502 const TComVUI *pVUI = sps->getVuiParameters(); 503 const TComHRD *pHRD = pVUI->getHrdParameters(); 504 505 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 506 507 sei_read_uvlc( pDecodedMessageOutputStream, code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; 449 508 if( !pHRD->getSubPicCpbParamsPresentFlag() ) 450 509 { 451 READ_FLAG(code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code;510 sei_read_flag( pDecodedMessageOutputStream, code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code; 452 511 } 453 512 if( sei.m_rapCpbParamsPresentFlag ) 454 513 { 455 READ_CODE( pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; 456 READ_CODE( pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; 457 } 514 sei_read_code( pDecodedMessageOutputStream, pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; 515 sei_read_code( pDecodedMessageOutputStream, pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; 516 } 517 458 518 //read splicing flag and cpb_removal_delay_delta 459 READ_FLAG( code, "concatenation_flag");519 sei_read_flag( pDecodedMessageOutputStream, code, "concatenation_flag"); 460 520 sei.m_concatenationFlag = code; 461 READ_CODE(( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" );521 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" ); 462 522 sei.m_auCpbRemovalDelayDelta = code + 1; 523 463 524 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) 464 525 { … … 468 529 for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ ) 469 530 { 470 READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay" );531 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_delay":"nal_initial_cpb_removal_delay" ); 471 532 sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code; 472 READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay_offset" );533 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_offset":"vcl_initial_cpb_removal_offset" ); 473 534 sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code; 474 535 if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag ) 475 536 { 476 READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay" );537 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_delay":"vcl_initial_alt_cpb_removal_delay" ); 477 538 sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code; 478 READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay_offset" );539 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_offset":"vcl_initial_alt_cpb_removal_offset" ); 479 540 sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code; 480 541 } … … 482 543 } 483 544 } 484 xParseByteAlign(); 485 } 486 Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps)545 } 546 547 Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 487 548 { 488 549 Int i; 489 550 UInt code; 490 551 491 TComVUI *vui = sps->getVuiParameters(); 492 TComHRD *hrd = vui->getHrdParameters(); 552 const TComVUI *vui = sps->getVuiParameters(); 553 const TComHRD *hrd = vui->getHrdParameters(); 554 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 493 555 494 556 if( vui->getFrameFieldInfoPresentFlag() ) 495 557 { 496 READ_CODE(4, code, "pic_struct" ); sei.m_picStruct = code;497 READ_CODE( 2, code, "source_scan_type" ); sei.m_sourceScanType= code;498 READ_FLAG( code, "duplicate_flag" ); sei.m_duplicateFlag = ( code == 1 ? true : false);558 sei_read_code( pDecodedMessageOutputStream, 4, code, "pic_struct" ); sei.m_picStruct = code; 559 sei_read_code( pDecodedMessageOutputStream, 2, code, "source_scan_type" ); sei.m_sourceScanType = code; 560 sei_read_flag( pDecodedMessageOutputStream, code, "duplicate_flag" ); sei.m_duplicateFlag = (code == 1); 499 561 } 500 562 501 563 if( hrd->getCpbDpbDelaysPresentFlag()) 502 564 { 503 READ_CODE(( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" );565 sei_read_code( pDecodedMessageOutputStream, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" ); 504 566 sei.m_auCpbRemovalDelay = code + 1; 505 READ_CODE(( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" );567 sei_read_code( pDecodedMessageOutputStream, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" ); 506 568 sei.m_picDpbOutputDelay = code; 507 569 508 570 if(hrd->getSubPicCpbParamsPresentFlag()) 509 571 { 510 READ_CODE(hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" );572 sei_read_code( pDecodedMessageOutputStream, hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" ); 511 573 sei.m_picDpbOutputDuDelay = code; 512 574 } 575 513 576 if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) 514 577 { 515 READ_UVLC(code, "num_decoding_units_minus1");578 sei_read_uvlc( pDecodedMessageOutputStream, code, "num_decoding_units_minus1"); 516 579 sei.m_numDecodingUnitsMinus1 = code; 517 READ_FLAG(code, "du_common_cpb_removal_delay_flag" );580 sei_read_flag( pDecodedMessageOutputStream, code, "du_common_cpb_removal_delay_flag" ); 518 581 sei.m_duCommonCpbRemovalDelayFlag = code; 519 582 if( sei.m_duCommonCpbRemovalDelayFlag ) 520 583 { 521 READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_minus1" );584 sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_increment_minus1" ); 522 585 sei.m_duCommonCpbRemovalDelayMinus1 = code; 523 586 } 524 if( sei.m_numNalusInDuMinus1 != NULL ) 525 { 526 delete sei.m_numNalusInDuMinus1; 527 } 528 sei.m_numNalusInDuMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; 529 if( sei.m_duCpbRemovalDelayMinus1 != NULL ) 530 { 531 delete sei.m_duCpbRemovalDelayMinus1; 532 } 533 sei.m_duCpbRemovalDelayMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; 587 sei.m_numNalusInDuMinus1.resize(sei.m_numDecodingUnitsMinus1 + 1 ); 588 sei.m_duCpbRemovalDelayMinus1.resize( sei.m_numDecodingUnitsMinus1 + 1 ); 534 589 535 590 for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ ) 536 591 { 537 READ_UVLC( code, "num_nalus_in_du_minus1");592 sei_read_uvlc( pDecodedMessageOutputStream, code, "num_nalus_in_du_minus1[i]"); 538 593 sei.m_numNalusInDuMinus1[ i ] = code; 539 594 if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) ) 540 595 { 541 READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1" );596 sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1[i]" ); 542 597 sei.m_duCpbRemovalDelayMinus1[ i ] = code; 543 598 } … … 545 600 } 546 601 } 547 xParseByteAlign(); 548 } 549 Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt /*payloadSize*/)602 } 603 604 Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 550 605 { 551 606 Int iCode; 552 607 UInt uiCode; 553 READ_SVLC( iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; 554 READ_FLAG( uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; 555 READ_FLAG( uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; 556 xParseByteAlign(); 557 } 558 Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt /*payloadSize*/) 608 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 609 610 sei_read_svlc( pDecodedMessageOutputStream, iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; 611 sei_read_flag( pDecodedMessageOutputStream, uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; 612 sei_read_flag( pDecodedMessageOutputStream, uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; 613 } 614 615 Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 559 616 { 560 617 UInt val; 561 READ_UVLC( val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; 562 READ_FLAG( val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; 618 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 619 620 sei_read_uvlc( pDecodedMessageOutputStream, val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; 621 sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; 563 622 564 623 if ( !sei.m_arrangementCancelFlag ) 565 624 { 566 READ_CODE(7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val;625 sei_read_code( pDecodedMessageOutputStream, 7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val; 567 626 assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) ); 568 READ_FLAG( val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; 569 570 READ_CODE( 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; 571 READ_FLAG( val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; 572 READ_FLAG( val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; 573 READ_FLAG( val, "field_views_flag" ); sei.m_fieldViewsFlag = val; 574 READ_FLAG( val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; 575 READ_FLAG( val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; 576 READ_FLAG( val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; 627 628 sei_read_flag( pDecodedMessageOutputStream, val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; 629 630 sei_read_code( pDecodedMessageOutputStream, 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; 631 sei_read_flag( pDecodedMessageOutputStream, val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; 632 sei_read_flag( pDecodedMessageOutputStream, val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; 633 sei_read_flag( pDecodedMessageOutputStream, val, "field_views_flag" ); sei.m_fieldViewsFlag = val; 634 sei_read_flag( pDecodedMessageOutputStream, val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; 635 sei_read_flag( pDecodedMessageOutputStream, val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; 636 sei_read_flag( pDecodedMessageOutputStream, val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; 577 637 578 638 if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) 579 639 { 580 READ_CODE( 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; 581 READ_CODE( 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; 582 READ_CODE( 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; 583 READ_CODE( 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; 584 } 585 586 READ_CODE( 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; 587 READ_FLAG( val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = val ? true : false; 588 } 589 READ_FLAG( val, "upsampled_aspect_ratio" ); sei.m_upsampledAspectRatio = val; 590 591 xParseByteAlign(); 592 } 593 594 Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt /*payloadSize*/) 640 sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; 641 sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; 642 sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; 643 sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; 644 } 645 646 sei_read_code( pDecodedMessageOutputStream, 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; 647 sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = (val != 0); 648 } 649 sei_read_flag( pDecodedMessageOutputStream, val, "upsampled_aspect_ratio_flag" ); sei.m_upsampledAspectRatio = val; 650 } 651 652 Void SEIReader::xParseSEISegmentedRectFramePacking(SEISegmentedRectFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 595 653 { 596 654 UInt val; 597 READ_FLAG( val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; 598 if( !sei.cancelFlag ) 599 { 600 READ_FLAG( val, "hor_flip" ); sei.horFlip = val; 601 READ_FLAG( val, "ver_flip" ); sei.verFlip = val; 602 READ_CODE( 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; 603 READ_FLAG( val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; 604 } 605 xParseByteAlign(); 606 } 607 608 Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt /*payloadSize*/) 655 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 656 sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; 657 if( !sei.m_arrangementCancelFlag ) 658 { 659 sei_read_code( pDecodedMessageOutputStream, 2, val, "segmented_rect_content_interpretation_type" ); sei.m_contentInterpretationType = val; 660 sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_persistence" ); sei.m_arrangementPersistenceFlag = val; 661 } 662 } 663 664 Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 609 665 { 610 666 UInt val; 611 READ_CODE ( 8, val, "tl0_idx" ); sei.tl0Idx = val; 612 READ_CODE ( 8, val, "rap_idx" ); sei.rapIdx = val; 613 xParseByteAlign(); 614 } 615 616 Void SEIReader::xParseSEIGradualDecodingRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt /*payloadSize*/) 667 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 668 sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; 669 if( !sei.cancelFlag ) 670 { 671 sei_read_flag( pDecodedMessageOutputStream, val, "hor_flip" ); sei.horFlip = val; 672 sei_read_flag( pDecodedMessageOutputStream, val, "ver_flip" ); sei.verFlip = val; 673 sei_read_code( pDecodedMessageOutputStream, 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; 674 sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; 675 } 676 } 677 678 Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 617 679 { 618 680 UInt val; 619 READ_FLAG( val, "gdr_foreground_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; 620 xParseByteAlign(); 621 } 622 623 Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt /*payloadSize*/) 681 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 682 sei_read_code( pDecodedMessageOutputStream, 8, val, "temporal_sub_layer_zero_idx" ); sei.tl0Idx = val; 683 sei_read_code( pDecodedMessageOutputStream, 8, val, "irap_pic_id" ); sei.rapIdx = val; 684 } 685 686 Void SEIReader::xParseSEIRegionRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 687 { 688 UInt val; 689 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 690 sei_read_flag( pDecodedMessageOutputStream, val, "refreshed_region_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; 691 } 692 693 Void SEIReader::xParseSEINoDisplay(SEINoDisplay& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 694 { 695 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 696 sei.m_noDisplay = true; 697 } 698 699 Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 624 700 { 625 701 Int i; 626 702 UInt val; 627 READ_UVLC( val, "tone_map_id" ); sei.m_toneMapId = val; 628 READ_FLAG( val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; 703 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 704 sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_id" ); sei.m_toneMapId = val; 705 sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; 629 706 630 707 if ( !sei.m_toneMapCancelFlag ) 631 708 { 632 READ_FLAG( val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val;633 READ_CODE(8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val;634 READ_CODE(8, val, "target_bit_depth" ); sei.m_targetBitDepth = val;635 READ_UVLC( val, "model_id" ); sei.m_modelId = val;709 sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val; 710 sei_read_code( pDecodedMessageOutputStream, 8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val; 711 sei_read_code( pDecodedMessageOutputStream, 8, val, "target_bit_depth" ); sei.m_targetBitDepth = val; 712 sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_model_id" ); sei.m_modelId = val; 636 713 switch(sei.m_modelId) 637 714 { 638 715 case 0: 639 716 { 640 READ_CODE(32, val, "min_value" ); sei.m_minValue = val;641 READ_CODE(32, val, "max_value" ); sei.m_maxValue = val;717 sei_read_code( pDecodedMessageOutputStream, 32, val, "min_value" ); sei.m_minValue = val; 718 sei_read_code( pDecodedMessageOutputStream, 32, val, "max_value" ); sei.m_maxValue = val; 642 719 break; 643 720 } 644 721 case 1: 645 722 { 646 READ_CODE(32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val;647 READ_CODE(32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val;723 sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val; 724 sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val; 648 725 break; 649 726 } … … 654 731 for(i = 0; i < num; i++) 655 732 { 656 READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval" );733 sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval[i]" ); 657 734 sei.m_startOfCodedInterval[i] = val; 658 735 } … … 662 739 case 3: 663 740 { 664 READ_CODE(16, val, "num_pivots" ); sei.m_numPivots = val;741 sei_read_code( pDecodedMessageOutputStream, 16, val, "num_pivots" ); sei.m_numPivots = val; 665 742 sei.m_codedPivotValue.resize(sei.m_numPivots); 666 743 sei.m_targetPivotValue.resize(sei.m_numPivots); 667 744 for(i = 0; i < sei.m_numPivots; i++ ) 668 745 { 669 READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value" );746 sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value[i]" ); 670 747 sei.m_codedPivotValue[i] = val; 671 READ_CODE( ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value" );748 sei_read_code( pDecodedMessageOutputStream, ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value[i]" ); 672 749 sei.m_targetPivotValue[i] = val; 673 750 } … … 676 753 case 4: 677 754 { 678 READ_CODE(8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedIdc = val;755 sei_read_code( pDecodedMessageOutputStream, 8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedIdc = val; 679 756 if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO 680 757 { 681 READ_CODE(32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val;682 } 683 READ_CODE(8, val, "exposure_index_idc" ); sei.m_exposureIndexIdc = val;758 sei_read_code( pDecodedMessageOutputStream, 32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val; 759 } 760 sei_read_code( pDecodedMessageOutputStream, 8, val, "exposure_index_idc" ); sei.m_exposureIndexIdc = val; 684 761 if( sei.m_exposureIndexIdc == 255) //Extended_ISO 685 762 { 686 READ_CODE(32, val, "exposure_index_value" ); sei.m_exposureIndexValue = val;687 } 688 READ_FLAG(val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val;689 READ_CODE(16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val;690 READ_CODE(16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val;691 READ_CODE(32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val;692 READ_CODE(32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val;693 READ_CODE( 16, val, "nominal_black_level_luma_code_value" );sei.m_nominalBlackLevelLumaCodeValue = val;694 READ_CODE( 16, val, "nominal_white_level_luma_code_value" );sei.m_nominalWhiteLevelLumaCodeValue= val;695 READ_CODE( 16, val, "extended_white_level_luma_code_value" );sei.m_extendedWhiteLevelLumaCodeValue = val;763 sei_read_code( pDecodedMessageOutputStream, 32, val, "exposure_index_value" ); sei.m_exposureIndexValue = val; 764 } 765 sei_read_flag( pDecodedMessageOutputStream, val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val; 766 sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val; 767 sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val; 768 sei_read_code( pDecodedMessageOutputStream, 32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val; 769 sei_read_code( pDecodedMessageOutputStream, 32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val; 770 sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_black_level_code_value" ); sei.m_nominalBlackLevelLumaCodeValue = val; 771 sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_white_level_code_value" ); sei.m_nominalWhiteLevelLumaCodeValue= val; 772 sei_read_code( pDecodedMessageOutputStream, 16, val, "extended_white_level_code_value" ); sei.m_extendedWhiteLevelLumaCodeValue = val; 696 773 break; 697 774 } … … 702 779 } 703 780 }//switch model id 704 }// if(!sei.m_toneMapCancelFlag) 705 706 xParseByteAlign(); 707 } 708 709 Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize) 781 }// if(!sei.m_toneMapCancelFlag) 782 } 783 784 Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 710 785 { 711 786 Int iCode; 712 787 UInt uiCode; 713 714 READ_UVLC( uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; 715 READ_UVLC( uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; 788 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 789 790 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; 791 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; 716 792 for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) 717 793 { 718 READ_CODE( 6, uiCode, "sop_desc_vcl_nalu_type" ); sei.m_sopDescVclNaluType[i] = uiCode;719 READ_CODE( 3, sei.m_sopDescTemporalId[i], "sop_desc_temporal_id" ); sei.m_sopDescTemporalId[i] = uiCode;794 sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "sop_vcl_nut[i]" ); sei.m_sopDescVclNaluType[i] = uiCode; 795 sei_read_code( pDecodedMessageOutputStream, 3, sei.m_sopDescTemporalId[i], "sop_temporal_id[i]" ); sei.m_sopDescTemporalId[i] = uiCode; 720 796 if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) 721 797 { 722 READ_UVLC( sei.m_sopDescStRpsIdx[i], "sop_desc_st_rps_idx" ); sei.m_sopDescStRpsIdx[i] = uiCode;798 sei_read_uvlc( pDecodedMessageOutputStream, sei.m_sopDescStRpsIdx[i], "sop_short_term_rps_idx[i]" ); sei.m_sopDescStRpsIdx[i] = uiCode; 723 799 } 724 800 if (i > 0) 725 801 { 726 READ_SVLC( iCode, "sop_desc_poc_delta" ); sei.m_sopDescPocDelta[i] = iCode; 727 } 728 } 729 730 xParseByteAlign(); 731 } 732 733 Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps) 802 sei_read_svlc( pDecodedMessageOutputStream, iCode, "sop_poc_delta[i]" ); sei.m_sopDescPocDelta[i] = iCode; 803 } 804 } 805 } 806 807 Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 734 808 { 735 809 UInt uiCode; 736 810 SEIMessages seis; 737 738 READ_FLAG( uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; 739 READ_FLAG( uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; 811 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 812 813 sei_read_flag( pDecodedMessageOutputStream, uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; 814 sei_read_flag( pDecodedMessageOutputStream, uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; 740 815 if (sei.m_nestingOpFlag) 741 816 { 742 READ_FLAG(uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode;743 READ_UVLC(uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode;817 sei_read_flag( pDecodedMessageOutputStream, uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode; 818 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode; 744 819 for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++) 745 820 { 746 READ_CODE( 3, uiCode, "nesting_max_temporal_id_plus1" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode;747 READ_UVLC( uiCode, "nesting_op_idx" ); sei.m_nestingOpIdx[i] = uiCode;821 sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_max_temporal_id_plus1[i]" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode; 822 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_op_idx[i]" ); sei.m_nestingOpIdx[i] = uiCode; 748 823 } 749 824 } 750 825 else 751 826 { 752 READ_FLAG(uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode;827 sei_read_flag( pDecodedMessageOutputStream, uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode; 753 828 if (!sei.m_allLayersFlag) 754 829 { 755 READ_CODE(3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode;756 READ_UVLC(uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode;830 sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode; 831 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode; 757 832 for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) 758 833 { 759 READ_CODE( 6, uiCode, "nesting_layer_id" ); sei.m_nestingLayerId[i] = uiCode;834 sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "nesting_layer_id[i]" ); sei.m_nestingLayerId[i] = uiCode; 760 835 } 761 836 } … … 766 841 { 767 842 UInt code; 768 READ_FLAG( code, "nesting_zero_bit" ); 769 } 770 771 sei.m_callerOwnsSEIs = false; 843 sei_read_flag( pDecodedMessageOutputStream, code, "nesting_zero_bit" ); 844 } 772 845 773 846 // read nested SEI messages 774 do { 775 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps); 847 do 848 { 849 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream); 776 850 } while (m_pcBitstream->getNumBitsLeft() > 8); 777 851 778 } 779 #if H_MV 780 Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei) 781 { 782 UInt uiCode; 783 READ_CODE( 4, uiCode, "active_vps_id" ); sei.m_activeVpsId = uiCode; 784 READ_UVLC( uiCode, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreams = uiCode + 1; 852 if (pDecodedMessageOutputStream) 853 { 854 (*pDecodedMessageOutputStream) << "End of scalable nesting SEI message\n"; 855 } 856 } 857 858 #if NH_MV 859 Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream ) 860 { 861 UInt code; 862 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 863 sei_read_code( pDecodedMessageOutputStream, 4, code, "active_vps_id" ); sei.m_activeVpsId = code; 864 sei_read_uvlc( pDecodedMessageOutputStream, code, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreams = code + 1; 785 865 786 866 xResizeSubBitstreamPropertySeiArrays(sei); 787 867 for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ ) 788 868 { 789 READ_CODE( 2, uiCode, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = uiCode;790 READ_UVLC( uiCode, "output_layer_set_idx_to_vps[i]" ); sei.m_outputLayerSetIdxToVps[i] = uiCode;791 READ_CODE( 3, uiCode, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = uiCode;792 READ_CODE( 16, uiCode, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = uiCode;793 READ_CODE( 16, uiCode, "max_bit_rate[i]" ); sei.m_maxBitRate[i] = uiCode;794 } 795 xParseByteAlign(); 796 } 869 sei_read_code( pDecodedMessageOutputStream, 2, code, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = code; 870 sei_read_uvlc( pDecodedMessageOutputStream, code, "output_layer_set_idx_to_vps[i]" ); sei.m_outputLayerSetIdxToVps[i] = code; 871 sei_read_code( pDecodedMessageOutputStream, 3, code, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = code; 872 sei_read_code( pDecodedMessageOutputStream, 16, code, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = code; 873 sei_read_code( pDecodedMessageOutputStream, 16, code, "max_bit_rate[i]" ); sei.m_maxBitRate[i] = code; 874 } 875 } 876 797 877 Void SEIReader::xResizeSubBitstreamPropertySeiArrays(SEISubBitstreamProperty &sei) 798 878 { … … 805 885 #endif 806 886 807 Void SEIReader::xParseByteAlign() 887 888 Void SEIReader::xParseSEITempMotionConstraintsTileSets(SEITempMotionConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 808 889 { 809 890 UInt code; 810 if( m_pcBitstream->getNumBitsRead() % 8 != 0 ) 811 { 812 READ_FLAG( code, "bit_equal_to_one" ); assert( code == 1 ); 813 } 814 while( m_pcBitstream->getNumBitsRead() % 8 != 0 ) 815 { 816 READ_FLAG( code, "bit_equal_to_zero" ); assert( code == 0 ); 817 } 818 } 891 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 892 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); 893 sei_read_flag( pDecodedMessageOutputStream, code, "each_tile_one_tile_set_flag"); sei.m_each_tile_one_tile_set_flag = (code != 0); 894 895 if(!sei.m_each_tile_one_tile_set_flag) 896 { 897 sei_read_flag( pDecodedMessageOutputStream, code, "limited_tile_set_display_flag"); sei.m_limited_tile_set_display_flag = (code != 0); 898 sei_read_uvlc( pDecodedMessageOutputStream, code, "num_sets_in_message_minus1"); sei.setNumberOfTileSets(code + 1); 899 900 if(sei.getNumberOfTileSets() != 0) 901 { 902 for(Int i = 0; i < sei.getNumberOfTileSets(); i++) 903 { 904 sei_read_uvlc( pDecodedMessageOutputStream, code, "mcts_id"); sei.tileSetData(i).m_mcts_id = code; 905 906 if(sei.m_limited_tile_set_display_flag) 907 { 908 sei_read_flag( pDecodedMessageOutputStream, code, "display_tile_set_flag"); sei.tileSetData(i).m_display_tile_set_flag = (code != 1); 909 } 910 911 sei_read_uvlc( pDecodedMessageOutputStream, code, "num_tile_rects_in_set_minus1"); sei.tileSetData(i).setNumberOfTileRects(code + 1); 912 913 for(Int j=0; j<sei.tileSetData(i).getNumberOfTileRects(); j++) 914 { 915 sei_read_uvlc( pDecodedMessageOutputStream, code, "top_left_tile_index"); sei.tileSetData(i).topLeftTileIndex(j) = code; 916 sei_read_uvlc( pDecodedMessageOutputStream, code, "bottom_right_tile_index"); sei.tileSetData(i).bottomRightTileIndex(j) = code; 917 } 918 919 if(!sei.m_mc_all_tiles_exact_sample_value_match_flag) 920 { 921 sei_read_flag( pDecodedMessageOutputStream, code, "exact_sample_value_match_flag"); sei.tileSetData(i).m_exact_sample_value_match_flag = (code != 0); 922 } 923 sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_level_idc_present_flag"); sei.tileSetData(i).m_mcts_tier_level_idc_present_flag = (code != 0); 924 925 if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag) 926 { 927 sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_flag"); sei.tileSetData(i).m_mcts_tier_flag = (code != 0); 928 sei_read_code( pDecodedMessageOutputStream, 8, code, "mcts_level_idc"); sei.tileSetData(i).m_mcts_level_idc = code; 929 } 930 } 931 } 932 } 933 else 934 { 935 sei_read_flag( pDecodedMessageOutputStream, code, "max_mcs_tier_level_idc_present_flag"); sei.m_max_mcs_tier_level_idc_present_flag = code; 936 if(sei.m_max_mcs_tier_level_idc_present_flag) 937 { 938 sei_read_flag( pDecodedMessageOutputStream, code, "max_mcts_tier_flag"); sei.m_max_mcts_tier_flag = code; 939 sei_read_code( pDecodedMessageOutputStream, 8, code, "max_mcts_level_idc"); sei.m_max_mcts_level_idc = code; 940 } 941 } 942 } 943 944 Void SEIReader::xParseSEITimeCode(SEITimeCode& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 945 { 946 UInt code; 947 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 948 sei_read_code( pDecodedMessageOutputStream, 2, code, "num_clock_ts"); sei.numClockTs = code; 949 for(Int i = 0; i < sei.numClockTs; i++) 950 { 951 TComSEITimeSet currentTimeSet; 952 sei_read_flag( pDecodedMessageOutputStream, code, "clock_time_stamp_flag[i]"); currentTimeSet.clockTimeStampFlag = code; 953 if(currentTimeSet.clockTimeStampFlag) 954 { 955 sei_read_flag( pDecodedMessageOutputStream, code, "nuit_field_based_flag"); currentTimeSet.numUnitFieldBasedFlag = code; 956 sei_read_code( pDecodedMessageOutputStream, 5, code, "counting_type"); currentTimeSet.countingType = code; 957 sei_read_flag( pDecodedMessageOutputStream, code, "full_timestamp_flag"); currentTimeSet.fullTimeStampFlag = code; 958 sei_read_flag( pDecodedMessageOutputStream, code, "discontinuity_flag"); currentTimeSet.discontinuityFlag = code; 959 sei_read_flag( pDecodedMessageOutputStream, code, "cnt_dropped_flag"); currentTimeSet.cntDroppedFlag = code; 960 sei_read_code( pDecodedMessageOutputStream, 9, code, "n_frames"); currentTimeSet.numberOfFrames = code; 961 if(currentTimeSet.fullTimeStampFlag) 962 { 963 sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code; 964 sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code; 965 sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code; 966 } 967 else 968 { 969 sei_read_flag( pDecodedMessageOutputStream, code, "seconds_flag"); currentTimeSet.secondsFlag = code; 970 if(currentTimeSet.secondsFlag) 971 { 972 sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code; 973 sei_read_flag( pDecodedMessageOutputStream, code, "minutes_flag"); currentTimeSet.minutesFlag = code; 974 if(currentTimeSet.minutesFlag) 975 { 976 sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code; 977 sei_read_flag( pDecodedMessageOutputStream, code, "hours_flag"); currentTimeSet.hoursFlag = code; 978 if(currentTimeSet.hoursFlag) 979 { 980 sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code; 981 } 982 } 983 } 984 } 985 sei_read_code( pDecodedMessageOutputStream, 5, code, "time_offset_length"); currentTimeSet.timeOffsetLength = code; 986 if(currentTimeSet.timeOffsetLength > 0) 987 { 988 sei_read_code( pDecodedMessageOutputStream, currentTimeSet.timeOffsetLength, code, "time_offset_value"); 989 if((code & (1 << (currentTimeSet.timeOffsetLength-1))) == 0) 990 { 991 currentTimeSet.timeOffsetValue = code; 992 } 993 else 994 { 995 code &= (1<< (currentTimeSet.timeOffsetLength-1)) - 1; 996 currentTimeSet.timeOffsetValue = ~code + 1; 997 } 998 } 999 } 1000 sei.timeSetArray[i] = currentTimeSet; 1001 } 1002 } 1003 1004 Void SEIReader::xParseSEIChromaSamplingFilterHint(SEIChromaSamplingFilterHint& sei, UInt payloadSize/*, TComSPS* sps*/, std::ostream *pDecodedMessageOutputStream) 1005 { 1006 UInt uiCode; 1007 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1008 1009 sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "ver_chroma_filter_idc"); sei.m_verChromaFilterIdc = uiCode; 1010 sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "hor_chroma_filter_idc"); sei.m_horChromaFilterIdc = uiCode; 1011 sei_read_flag( pDecodedMessageOutputStream, uiCode, "ver_filtering_process_flag"); sei.m_verFilteringProcessFlag = uiCode; 1012 if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1) 1013 { 1014 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "target_format_idc"); sei.m_targetFormatIdc = uiCode; 1015 if(sei.m_verChromaFilterIdc == 1) 1016 { 1017 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_vertical_filters"); sei.m_numVerticalFilters = uiCode; 1018 if(sei.m_numVerticalFilters > 0) 1019 { 1020 sei.m_verTapLengthMinus1 = (Int*)malloc(sei.m_numVerticalFilters * sizeof(Int)); 1021 sei.m_verFilterCoeff = (Int**)malloc(sei.m_numVerticalFilters * sizeof(Int*)); 1022 for(Int i = 0; i < sei.m_numVerticalFilters; i ++) 1023 { 1024 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ver_tap_length_minus_1"); sei.m_verTapLengthMinus1[i] = uiCode; 1025 sei.m_verFilterCoeff[i] = (Int*)malloc(sei.m_verTapLengthMinus1[i] * sizeof(Int)); 1026 for(Int j = 0; j < sei.m_verTapLengthMinus1[i]; j ++) 1027 { 1028 sei_read_svlc( pDecodedMessageOutputStream, sei.m_verFilterCoeff[i][j], "ver_filter_coeff"); 1029 } 1030 } 1031 } 1032 } 1033 if(sei.m_horChromaFilterIdc == 1) 1034 { 1035 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_horizontal_filters"); sei.m_numHorizontalFilters = uiCode; 1036 if(sei.m_numHorizontalFilters > 0) 1037 { 1038 sei.m_horTapLengthMinus1 = (Int*)malloc(sei.m_numHorizontalFilters * sizeof(Int)); 1039 sei.m_horFilterCoeff = (Int**)malloc(sei.m_numHorizontalFilters * sizeof(Int*)); 1040 for(Int i = 0; i < sei.m_numHorizontalFilters; i ++) 1041 { 1042 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "hor_tap_length_minus_1"); sei.m_horTapLengthMinus1[i] = uiCode; 1043 sei.m_horFilterCoeff[i] = (Int*)malloc(sei.m_horTapLengthMinus1[i] * sizeof(Int)); 1044 for(Int j = 0; j < sei.m_horTapLengthMinus1[i]; j ++) 1045 { 1046 sei_read_svlc( pDecodedMessageOutputStream, sei.m_horFilterCoeff[i][j], "hor_filter_coeff"); 1047 } 1048 } 1049 } 1050 } 1051 } 1052 } 1053 1054 Void SEIReader::xParseSEIKneeFunctionInfo(SEIKneeFunctionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 1055 { 1056 Int i; 1057 UInt val; 1058 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1059 1060 sei_read_uvlc( pDecodedMessageOutputStream, val, "knee_function_id" ); sei.m_kneeId = val; 1061 sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_cancel_flag" ); sei.m_kneeCancelFlag = val; 1062 if ( !sei.m_kneeCancelFlag ) 1063 { 1064 sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_persistence_flag" ); sei.m_kneePersistenceFlag = val; 1065 sei_read_code( pDecodedMessageOutputStream, 32, val, "input_d_range" ); sei.m_kneeInputDrange = val; 1066 sei_read_code( pDecodedMessageOutputStream, 32, val, "input_disp_luminance" ); sei.m_kneeInputDispLuminance = val; 1067 sei_read_code( pDecodedMessageOutputStream, 32, val, "output_d_range" ); sei.m_kneeOutputDrange = val; 1068 sei_read_code( pDecodedMessageOutputStream, 32, val, "output_disp_luminance" ); sei.m_kneeOutputDispLuminance = val; 1069 sei_read_uvlc( pDecodedMessageOutputStream, val, "num_knee_points_minus1" ); sei.m_kneeNumKneePointsMinus1 = val; 1070 assert( sei.m_kneeNumKneePointsMinus1 > 0 ); 1071 sei.m_kneeInputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); 1072 sei.m_kneeOutputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); 1073 for(i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ ) 1074 { 1075 sei_read_code( pDecodedMessageOutputStream, 10, val, "input_knee_point" ); sei.m_kneeInputKneePoint[i] = val; 1076 sei_read_code( pDecodedMessageOutputStream, 10, val, "output_knee_point" ); sei.m_kneeOutputKneePoint[i] = val; 1077 } 1078 } 1079 } 1080 1081 Void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 1082 { 1083 UInt code; 1084 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1085 1086 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[0]" ); sei.values.primaries[0][0] = code; 1087 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[0]" ); sei.values.primaries[0][1] = code; 1088 1089 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[1]" ); sei.values.primaries[1][0] = code; 1090 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[1]" ); sei.values.primaries[1][1] = code; 1091 1092 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[2]" ); sei.values.primaries[2][0] = code; 1093 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[2]" ); sei.values.primaries[2][1] = code; 1094 1095 1096 sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_x" ); sei.values.whitePoint[0] = code; 1097 sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_y" ); sei.values.whitePoint[1] = code; 1098 1099 sei_read_code( pDecodedMessageOutputStream, 32, code, "max_display_mastering_luminance" ); sei.values.maxLuminance = code; 1100 sei_read_code( pDecodedMessageOutputStream, 32, code, "min_display_mastering_luminance" ); sei.values.minLuminance = code; 1101 } 1102 819 1103 //! \} -
trunk/source/Lib/TLibDecoder/SEIread.h
r1179 r1313 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 56 56 SEIReader() {}; 57 57 virtual ~SEIReader() {}; 58 Void parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps);58 Void parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 59 59 protected: 60 Void xReadSEImessage (SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps); 61 Void xParseSEIuserDataUnregistered (SEIuserDataUnregistered &sei, UInt payloadSize); 62 Void xParseSEIActiveParameterSets (SEIActiveParameterSets &sei, UInt payloadSize); 63 Void xParseSEIDecodingUnitInfo (SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps); 64 Void xParseSEIDecodedPictureHash (SEIDecodedPictureHash& sei, UInt payloadSize); 65 Void xParseSEIBufferingPeriod (SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps); 66 Void xParseSEIPictureTiming (SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps); 67 Void xParseSEIRecoveryPoint (SEIRecoveryPoint& sei, UInt payloadSize); 68 Void xParseSEIFramePacking (SEIFramePacking& sei, UInt payloadSize); 69 Void xParseSEIDisplayOrientation (SEIDisplayOrientation &sei, UInt payloadSize); 70 Void xParseSEITemporalLevel0Index (SEITemporalLevel0Index &sei, UInt payloadSize); 71 Void xParseSEIGradualDecodingRefreshInfo (SEIGradualDecodingRefreshInfo &sei, UInt payloadSize); 72 Void xParseSEIToneMappingInfo (SEIToneMappingInfo& sei, UInt payloadSize); 73 Void xParseSEISOPDescription (SEISOPDescription &sei, UInt payloadSize); 74 Void xParseSEIScalableNesting (SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps); 75 #if H_MV 76 Void xParseSEISubBitstreamProperty (SEISubBitstreamProperty &sei); 77 Void xResizeSubBitstreamPropertySeiArrays(SEISubBitstreamProperty &sei); 60 Void xReadSEImessage (SEIMessages& seis, const NalUnitType nalUnitType, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 61 Void xParseSEIuserDataUnregistered (SEIuserDataUnregistered &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 62 Void xParseSEIActiveParameterSets (SEIActiveParameterSets &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 63 Void xParseSEIDecodingUnitInfo (SEIDecodingUnitInfo& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 64 Void xParseSEIDecodedPictureHash (SEIDecodedPictureHash& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 65 Void xParseSEIBufferingPeriod (SEIBufferingPeriod& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 66 Void xParseSEIPictureTiming (SEIPictureTiming& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 67 Void xParseSEIRecoveryPoint (SEIRecoveryPoint& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 68 Void xParseSEIFramePacking (SEIFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 69 Void xParseSEISegmentedRectFramePacking (SEISegmentedRectFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 70 Void xParseSEIDisplayOrientation (SEIDisplayOrientation &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 71 Void xParseSEITemporalLevel0Index (SEITemporalLevel0Index &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 72 Void xParseSEIRegionRefreshInfo (SEIGradualDecodingRefreshInfo &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 73 Void xParseSEINoDisplay (SEINoDisplay &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 74 Void xParseSEIToneMappingInfo (SEIToneMappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 75 Void xParseSEISOPDescription (SEISOPDescription &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 76 Void xParseSEIScalableNesting (SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream); 77 Void xParseSEITempMotionConstraintsTileSets (SEITempMotionConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 78 Void xParseSEITimeCode (SEITimeCode& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 79 Void xParseSEIChromaSamplingFilterHint (SEIChromaSamplingFilterHint& sei, UInt payloadSize/*,TComSPS* */, std::ostream *pDecodedMessageOutputStream); 80 Void xParseSEIKneeFunctionInfo (SEIKneeFunctionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 81 Void xParseSEIMasteringDisplayColourVolume (SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 82 #if NH_MV 83 Void xParseSEISubBitstreamProperty (SEISubBitstreamProperty &sei , UInt payloadSize, std::ostream *pDecodedMessageOutputStream); 84 Void xResizeSubBitstreamPropertySeiArrays (SEISubBitstreamProperty &sei); 78 85 #endif 79 Void xParseByteAlign(); 86 87 Void sei_read_code(std::ostream *pOS, UInt uiLength, UInt& ruiCode, const Char *pSymbolName); 88 Void sei_read_uvlc(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName); 89 Void sei_read_svlc(std::ostream *pOS, Int& ruiCode, const Char *pSymbolName); 90 Void sei_read_flag(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName); 80 91 }; 81 92 -
trunk/source/Lib/TLibDecoder/SyntaxElementParser.cpp
r1179 r1313 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-2015, 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 #if H_MV_ENC_DEC_TRAC 52 59 if ( g_disableHLSTrace || !g_HLSTraceEnable ) … … 56 63 if ( !g_disableNumbering ) 57 64 { 58 #endif 65 incSymbolCounter(); 66 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter ); 67 } 68 #else 69 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 70 #endif 71 if (length < 10) 72 { 73 fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue ); 74 } 75 else 76 { 77 fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue ); 78 } 79 fflush ( g_hTrace ); 80 } 81 82 Void SyntaxElementParser::xReadUvlcTr (UInt& rValue, const Char *pSymbolName) 83 { 84 #if RExt__DECODER_DEBUG_BIT_STATISTICS 85 xReadUvlc (rValue, pSymbolName); 86 #else 87 xReadUvlc (rValue); 88 #endif 89 #if H_MV_ENC_DEC_TRAC 90 if ( g_disableHLSTrace || !g_HLSTraceEnable ) 91 { 92 return; 93 } 94 if ( !g_disableNumbering ) 95 { 96 incSymbolCounter(); 97 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter ); 98 } 99 #else 59 100 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 101 #endif 102 fprintf( g_hTrace, "%-50s ue(v) : %u\n", pSymbolName, rValue ); 103 fflush ( g_hTrace ); 104 } 105 106 Void SyntaxElementParser::xReadSvlcTr (Int& rValue, const Char *pSymbolName) 107 { 108 #if RExt__DECODER_DEBUG_BIT_STATISTICS 109 xReadSvlc (rValue, pSymbolName); 110 #else 111 xReadSvlc (rValue); 112 #endif 60 113 #if H_MV_ENC_DEC_TRAC 61 } 62 #endif 63 64 if (length < 10) 65 { 66 fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue ); 67 } 68 else 69 { 70 fprintf( g_hTrace, "%-50s u(%d) : %u\n", pSymbolName, length, rValue ); 71 } 114 if ( g_disableHLSTrace || !g_HLSTraceEnable ) 115 { 116 return; 117 } 118 if ( !g_disableNumbering ) 119 { 120 incSymbolCounter(); 121 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter ); 122 } 123 #else 124 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 125 #endif 126 fprintf( g_hTrace, "%-50s se(v) : %d\n", pSymbolName, rValue ); 72 127 fflush ( g_hTrace ); 73 128 } 74 129 75 Void SyntaxElementParser::xReadUvlcTr (UInt& rValue, const Char *pSymbolName) 76 { 77 xReadUvlc (rValue); 130 Void SyntaxElementParser::xReadFlagTr (UInt& rValue, const Char *pSymbolName) 131 { 132 #if RExt__DECODER_DEBUG_BIT_STATISTICS 133 xReadFlag (rValue, pSymbolName); 134 #else 135 xReadFlag (rValue); 136 #endif 78 137 #if H_MV_ENC_DEC_TRAC 79 if ( g_disableHLSTrace 138 if ( g_disableHLSTrace || !g_HLSTraceEnable ) 80 139 { 81 140 return; … … 83 142 if ( !g_disableNumbering ) 84 143 { 85 #endif 144 incSymbolCounter(); 145 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter ); 146 } 147 #else 86 148 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 87 #if H_MV_ENC_DEC_TRAC 88 } 89 #endif 90 fprintf( g_hTrace, "%-50s ue(v) : %u\n", pSymbolName, rValue ); 149 #endif 150 fprintf( g_hTrace, "%-50s u(1) : %d\n", pSymbolName, rValue ); 91 151 fflush ( g_hTrace ); 92 152 } 93 153 94 Void SyntaxElementParser::xReadSvlcTr (Int& rValue, const Char *pSymbolName) 95 { 96 xReadSvlc(rValue); 97 #if H_MV_ENC_DEC_TRAC 98 if ( g_disableHLSTrace || !g_HLSTraceEnable ) 99 { 100 return; 101 } 102 if ( !g_disableNumbering ) 103 { 104 #endif 105 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 106 #if H_MV_ENC_DEC_TRAC 107 } 108 #endif 109 110 fprintf( g_hTrace, "%-50s se(v) : %d\n", pSymbolName, rValue ); 111 fflush ( g_hTrace ); 112 } 113 114 Void SyntaxElementParser::xReadFlagTr (UInt& rValue, const Char *pSymbolName) 115 { 116 xReadFlag(rValue); 117 #if H_MV_ENC_DEC_TRAC 118 if ( g_disableHLSTrace || !g_HLSTraceEnable ) 119 { 120 return; 121 } 122 if ( !g_disableNumbering ) 123 { 124 #endif 125 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); 126 #if H_MV_ENC_DEC_TRAC 127 } 128 #endif 129 fprintf( g_hTrace, "%-50s u(1) : %d\n", pSymbolName, rValue ); 130 fflush ( g_hTrace ); 154 Void xTraceAccessUnitDelimiter () 155 { 156 fprintf( g_hTrace, "=========== Access Unit Delimiter ===========\n"); 157 } 158 159 Void xTraceFillerData () 160 { 161 fprintf( g_hTrace, "=========== Filler Data ===========\n"); 131 162 } 132 163 … … 137 168 // Protected member functions 138 169 // ==================================================================================================================== 139 170 #if RExt__DECODER_DEBUG_BIT_STATISTICS 171 Void SyntaxElementParser::xReadCode (UInt uiLength, UInt& ruiCode, const Char *pSymbolName) 172 #else 140 173 Void SyntaxElementParser::xReadCode (UInt uiLength, UInt& ruiCode) 174 #endif 141 175 { 142 176 assert ( uiLength > 0 ); 143 177 m_pcBitstream->read (uiLength, ruiCode); 144 } 145 178 #if RExt__DECODER_DEBUG_BIT_STATISTICS 179 TComCodingStatistics::IncrementStatisticEP(pSymbolName, uiLength, ruiCode); 180 #endif 181 } 182 183 #if RExt__DECODER_DEBUG_BIT_STATISTICS 184 Void SyntaxElementParser::xReadUvlc( UInt& ruiVal, const Char *pSymbolName) 185 #else 146 186 Void SyntaxElementParser::xReadUvlc( UInt& ruiVal) 187 #endif 147 188 { 148 189 UInt uiVal = 0; … … 150 191 UInt uiLength; 151 192 m_pcBitstream->read( 1, uiCode ); 193 #if RExt__DECODER_DEBUG_BIT_STATISTICS 194 UInt totalLen=1; 195 #endif 152 196 153 197 if( 0 == uiCode ) … … 164 208 165 209 uiVal += (1 << uiLength)-1; 210 #if RExt__DECODER_DEBUG_BIT_STATISTICS 211 totalLen+=uiLength+uiLength; 212 #endif 166 213 } 167 214 168 215 ruiVal = uiVal; 169 } 170 216 #if RExt__DECODER_DEBUG_BIT_STATISTICS 217 TComCodingStatistics::IncrementStatisticEP(pSymbolName, Int(totalLen), ruiVal); 218 #endif 219 } 220 221 #if RExt__DECODER_DEBUG_BIT_STATISTICS 222 Void SyntaxElementParser::xReadSvlc( Int& riVal, const Char *pSymbolName) 223 #else 171 224 Void SyntaxElementParser::xReadSvlc( Int& riVal) 225 #endif 172 226 { 173 227 UInt uiBits = 0; 174 228 m_pcBitstream->read( 1, uiBits ); 229 #if RExt__DECODER_DEBUG_BIT_STATISTICS 230 UInt totalLen=1; 231 #endif 175 232 if( 0 == uiBits ) 176 233 { … … 187 244 uiBits += (1 << uiLength); 188 245 riVal = ( uiBits & 1) ? -(Int)(uiBits>>1) : (Int)(uiBits>>1); 246 #if RExt__DECODER_DEBUG_BIT_STATISTICS 247 totalLen+=uiLength+uiLength; 248 #endif 189 249 } 190 250 else … … 192 252 riVal = 0; 193 253 } 194 } 195 254 #if RExt__DECODER_DEBUG_BIT_STATISTICS 255 TComCodingStatistics::IncrementStatisticEP(pSymbolName, Int(totalLen), riVal); 256 #endif 257 } 258 259 #if RExt__DECODER_DEBUG_BIT_STATISTICS 260 Void SyntaxElementParser::xReadFlag (UInt& ruiCode, const Char *pSymbolName) 261 #else 196 262 Void SyntaxElementParser::xReadFlag (UInt& ruiCode) 263 #endif 197 264 { 198 265 m_pcBitstream->read( 1, ruiCode ); 266 #if RExt__DECODER_DEBUG_BIT_STATISTICS 267 TComCodingStatistics::IncrementStatisticEP(pSymbolName, 1, Int(ruiCode)); 268 #endif 269 } 270 271 Void SyntaxElementParser::xReadRbspTrailingBits() 272 { 273 UInt bit; 274 READ_FLAG( bit, "rbsp_stop_one_bit"); 275 assert (bit==1); 276 Int cnt = 0; 277 while (m_pcBitstream->getNumBitsUntilByteAligned()) 278 { 279 READ_FLAG( bit, "rbsp_alignment_zero_bit"); 280 assert (bit==0); 281 cnt++; 282 } 283 assert(cnt<8); 284 } 285 286 Void AUDReader::parseAccessUnitDelimiter(TComInputBitstream* bs, UInt &picType) 287 { 288 setBitstream(bs); 289 290 #if ENC_DEC_TRACE 291 xTraceAccessUnitDelimiter(); 292 #endif 293 294 READ_CODE (3, picType, "pic_type"); 295 xReadRbspTrailingBits(); 296 } 297 298 Void FDReader::parseFillerData(TComInputBitstream* bs, UInt &fdSize) 299 { 300 setBitstream(bs); 301 #if ENC_DEC_TRACE 302 xTraceFillerData(); 303 #endif 304 UInt ffByte; 305 fdSize = 0; 306 while( m_pcBitstream->getNumBitsLeft() >8 ) 307 { 308 READ_CODE (8, ffByte, "ff_byte"); 309 assert (ffByte==0xff); 310 fdSize++; 311 } 312 xReadRbspTrailingBits(); 199 313 } 200 314 -
trunk/source/Lib/TLibDecoder/SyntaxElementParser.h
r1179 r1313 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 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 42 42 #pragma once 43 43 #endif // _MSC_VER > 1000 44 45 #include "../TLibCommon/TComRom.h" 46 44 #include "TLibCommon/TComRom.h" 47 45 #if ENC_DEC_TRACE 48 46 … … 54 52 #else 55 53 54 #if RExt__DECODER_DEBUG_BIT_STATISTICS 55 56 #define READ_CODE(length, code, name) xReadCode ( length, code, name ) 57 #define READ_UVLC( code, name) xReadUvlc ( code, name ) 58 #define READ_SVLC( code, name) xReadSvlc ( code, name ) 59 #define READ_FLAG( code, name) xReadFlag ( code, name ) 60 61 #else 62 56 63 #define READ_CODE(length, code, name) xReadCode ( length, code ) 57 64 #define READ_UVLC( code, name) xReadUvlc ( code ) 58 65 #define READ_SVLC( code, name) xReadSvlc ( code ) 59 66 #define READ_FLAG( code, name) xReadFlag ( code ) 67 68 #endif 60 69 61 70 #endif … … 78 87 virtual ~SyntaxElementParser() {}; 79 88 89 #if RExt__DECODER_DEBUG_BIT_STATISTICS 90 Void xReadCode ( UInt length, UInt& val, const Char *pSymbolName ); 91 Void xReadUvlc ( UInt& val, const Char *pSymbolName ); 92 Void xReadSvlc ( Int& val, const Char *pSymbolName ); 93 Void xReadFlag ( UInt& val, const Char *pSymbolName ); 94 #else 80 95 Void xReadCode ( UInt length, UInt& val ); 81 96 Void xReadUvlc ( UInt& val ); 82 97 Void xReadSvlc ( Int& val ); 83 98 Void xReadFlag ( UInt& val ); 99 #endif 84 100 #if ENC_DEC_TRACE 85 101 Void xReadCodeTr (UInt length, UInt& rValue, const Char *pSymbolName); … … 91 107 Void setBitstream ( TComInputBitstream* p ) { m_pcBitstream = p; } 92 108 TComInputBitstream* getBitstream() { return m_pcBitstream; } 109 110 protected: 111 Void xReadRbspTrailingBits(); 93 112 }; 113 114 class AUDReader: public SyntaxElementParser 115 { 116 public: 117 AUDReader() {}; 118 virtual ~AUDReader() {}; 119 Void parseAccessUnitDelimiter(TComInputBitstream* bs, UInt &picType); 120 }; 121 122 class FDReader: public SyntaxElementParser 123 { 124 public: 125 FDReader() {}; 126 virtual ~FDReader() {}; 127 Void parseFillerData(TComInputBitstream* bs, UInt &fdSize); 128 }; 129 94 130 95 131 //! \} -
trunk/source/Lib/TLibDecoder/TDecBinCoder.h
r1179 r1313 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 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 36 36 */ 37 37 38 #ifndef __TDEC _BIN_CODER__39 #define __TDEC _BIN_CODER__38 #ifndef __TDECBINCODER__ 39 #define __TDECBINCODER__ 40 40 41 41 #include "TLibCommon/ContextModel.h" 42 42 #include "TLibCommon/TComBitStream.h" 43 44 #if RExt__DECODER_DEBUG_BIT_STATISTICS 45 class TComCodingStatisticsClassType; 46 #endif 43 47 44 48 //! \ingroup TLibDecoder … … 55 59 virtual Void finish () = 0; 56 60 61 #if RExt__DECODER_DEBUG_BIT_STATISTICS 62 virtual Void decodeBin ( UInt& ruiBin, ContextModel& rcCtxModel, const class TComCodingStatisticsClassType &whichStat ) = 0; 63 virtual Void decodeBinEP ( UInt& ruiBin , const class TComCodingStatisticsClassType &whichStat ) = 0; 64 virtual Void decodeBinsEP ( UInt& ruiBins, Int numBins , const class TComCodingStatisticsClassType &whichStat ) = 0; 65 #else 57 66 virtual Void decodeBin ( UInt& ruiBin, ContextModel& rcCtxModel ) = 0; 58 67 virtual Void decodeBinEP ( UInt& ruiBin ) = 0; 59 68 virtual Void decodeBinsEP ( UInt& ruiBins, Int numBins ) = 0; 69 #endif 70 71 virtual Void align () = 0; 72 60 73 virtual Void decodeBinTrm ( UInt& ruiBin ) = 0; 61 62 virtual Void xReadPCMCode ( UInt uiLength, UInt& ruiCode) 74 75 virtual Void xReadPCMCode ( UInt uiLength, UInt& ruiCode) = 0; 63 76 64 77 virtual ~TDecBinIf() {} 65 78 66 virtual Void copyState ( TDecBinIf* pcTDecBinIf ) = 0; 67 virtual TDecBinCABAC* getTDecBinCABAC () { return 0; } 79 virtual Void copyState ( const TDecBinIf* pcTDecBinIf ) = 0; 80 virtual TDecBinCABAC* getTDecBinCABAC () { return 0; } 81 virtual const TDecBinCABAC* getTDecBinCABAC () const { return 0; } 68 82 }; 69 83 -
trunk/source/Lib/TLibDecoder/TDecBinCoderCABAC.cpp
r1179 r1313 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 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 37 37 38 38 #include "TDecBinCoderCABAC.h" 39 #include "../TLibCommon/TComRom.h" 39 #include "TLibCommon/Debug.h" 40 #if RExt__DECODER_DEBUG_BIT_STATISTICS 41 #include "TLibCommon/TComCodingStatistics.h" 42 #endif 40 43 41 44 //! \ingroup TLibDecoder … … 67 70 { 68 71 assert( m_pcTComBitstream->getNumBitsUntilByteAligned() == 0 ); 72 #if RExt__DECODER_DEBUG_BIT_STATISTICS 73 TComCodingStatistics::UpdateCABACStat(STATS__CABAC_INITIALISATION, 512, 510, 0); 74 #endif 69 75 m_uiRange = 510; 70 76 m_bitsNeeded = -8; … … 89 95 */ 90 96 Void 91 TDecBinCABAC::copyState( TDecBinIf* pcTDecBinIf )92 { 93 TDecBinCABAC* pcTDecBinCABAC = pcTDecBinIf->getTDecBinCABAC();97 TDecBinCABAC::copyState( const TDecBinIf* pcTDecBinIf ) 98 { 99 const TDecBinCABAC* pcTDecBinCABAC = pcTDecBinIf->getTDecBinCABAC(); 94 100 m_uiRange = pcTDecBinCABAC->m_uiRange; 95 101 m_uiValue = pcTDecBinCABAC->m_uiValue; … … 98 104 99 105 100 Void 101 TDecBinCABAC::decodeBin( UInt& ruiBin, ContextModel &rcCtxModel ) 102 { 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 #if DEBUG_CABAC_BINS 114 const UInt startingRange = m_uiRange; 115 #endif 116 103 117 UInt uiLPS = TComCABACTables::sm_aucLPSTable[ rcCtxModel.getState() ][ ( m_uiRange >> 6 ) - 4 ]; 104 118 m_uiRange -= uiLPS; 105 119 UInt scaledRange = m_uiRange << 7; 106 120 107 121 if( m_uiValue < scaledRange ) 108 122 { 109 123 // MPS path 110 124 ruiBin = rcCtxModel.getMps(); 125 #if RExt__DECODER_DEBUG_BIT_STATISTICS 126 TComCodingStatistics::UpdateCABACStat(whichStat, m_uiRange+uiLPS, m_uiRange, Int(ruiBin)); 127 #endif 111 128 rcCtxModel.updateMPS(); 112 113 if ( scaledRange >= ( 256 << 7 ) ) 114 { 115 return; 116 } 117 118 m_uiRange = scaledRange >> 6; 119 m_uiValue += m_uiValue; 120 121 if ( ++m_bitsNeeded == 0 ) 122 { 123 m_bitsNeeded = -8; 124 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 } 125 140 } 126 141 } … … 128 143 { 129 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 130 149 Int numBits = TComCABACTables::sm_aucRenormTable[ uiLPS >> 3 ]; 131 150 m_uiValue = ( m_uiValue - scaledRange ) << numBits; 132 151 m_uiRange = uiLPS << numBits; 133 ruiBin = 1 - rcCtxModel.getMps();134 152 rcCtxModel.updateLPS(); 135 153 136 154 m_bitsNeeded += numBits; 137 155 138 156 if ( m_bitsNeeded >= 0 ) 139 157 { … … 142 160 } 143 161 } 144 } 145 146 Void 147 TDecBinCABAC::decodeBinEP( UInt& ruiBin ) 148 { 162 163 #if DEBUG_CABAC_BINS 164 if ((g_debugCounter + debugCabacBinWindow) >= debugCabacBinTargetLine) 165 { 166 std::cout << g_debugCounter << ": coding bin value " << ruiBin << ", range = [" << startingRange << "->" << m_uiRange << "]\n"; 167 } 168 169 if (g_debugCounter >= debugCabacBinTargetLine) 170 { 171 Char breakPointThis; 172 breakPointThis = 7; 173 } 174 if (g_debugCounter >= (debugCabacBinTargetLine + debugCabacBinWindow)) 175 { 176 exit(0); 177 } 178 g_debugCounter++; 179 #endif 180 } 181 182 183 #if RExt__DECODER_DEBUG_BIT_STATISTICS 184 Void TDecBinCABAC::decodeBinEP( UInt& ruiBin, const TComCodingStatisticsClassType &whichStat ) 185 #else 186 Void TDecBinCABAC::decodeBinEP( UInt& ruiBin ) 187 #endif 188 { 189 if (m_uiRange == 256) 190 { 191 #if RExt__DECODER_DEBUG_BIT_STATISTICS 192 decodeAlignedBinsEP(ruiBin, 1, whichStat); 193 #else 194 decodeAlignedBinsEP(ruiBin, 1); 195 #endif 196 return; 197 } 198 149 199 m_uiValue += m_uiValue; 150 200 151 201 if ( ++m_bitsNeeded >= 0 ) 152 202 { … … 154 204 m_uiValue += m_pcTComBitstream->readByte(); 155 205 } 156 206 157 207 ruiBin = 0; 158 208 UInt scaledRange = m_uiRange << 7; … … 162 212 m_uiValue -= scaledRange; 163 213 } 164 } 165 214 #if RExt__DECODER_DEBUG_BIT_STATISTICS 215 TComCodingStatistics::IncrementStatisticEP(whichStat, 1, Int(ruiBin)); 216 #endif 217 } 218 219 #if RExt__DECODER_DEBUG_BIT_STATISTICS 220 Void TDecBinCABAC::decodeBinsEP( UInt& ruiBin, Int numBins, const TComCodingStatisticsClassType &whichStat ) 221 #else 166 222 Void TDecBinCABAC::decodeBinsEP( UInt& ruiBin, Int numBins ) 167 { 223 #endif 224 { 225 if (m_uiRange == 256) 226 { 227 #if RExt__DECODER_DEBUG_BIT_STATISTICS 228 decodeAlignedBinsEP(ruiBin, numBins, whichStat); 229 #else 230 decodeAlignedBinsEP(ruiBin, numBins); 231 #endif 232 return; 233 } 234 168 235 UInt bins = 0; 169 236 #if RExt__DECODER_DEBUG_BIT_STATISTICS 237 Int origNumBins=numBins; 238 #endif 170 239 while ( numBins > 8 ) 171 240 { 172 241 m_uiValue = ( m_uiValue << 8 ) + ( m_pcTComBitstream->readByte() << ( 8 + m_bitsNeeded ) ); 173 242 174 243 UInt scaledRange = m_uiRange << 15; 175 244 for ( Int i = 0; i < 8; i++ ) … … 185 254 numBins -= 8; 186 255 } 187 256 188 257 m_bitsNeeded += numBins; 189 258 m_uiValue <<= numBins; 190 259 191 260 if ( m_bitsNeeded >= 0 ) 192 261 { … … 194 263 m_bitsNeeded -= 8; 195 264 } 196 265 197 266 UInt scaledRange = m_uiRange << ( numBins + 7 ); 198 267 for ( Int i = 0; i < numBins; i++ ) … … 206 275 } 207 276 } 208 277 209 278 ruiBin = bins; 279 #if RExt__DECODER_DEBUG_BIT_STATISTICS 280 TComCodingStatistics::IncrementStatisticEP(whichStat, origNumBins, Int(ruiBin)); 281 #endif 282 } 283 284 Void TDecBinCABAC::align() 285 { 286 #if RExt__DECODER_DEBUG_BIT_STATISTICS 287 TComCodingStatistics::UpdateCABACStat(STATS__CABAC_EP_BIT_ALIGNMENT, m_uiRange, 256, 0); 288 #endif 289 m_uiRange = 256; 290 } 291 292 #if RExt__DECODER_DEBUG_BIT_STATISTICS 293 Void TDecBinCABAC::decodeAlignedBinsEP( UInt& ruiBins, Int numBins, const class TComCodingStatisticsClassType &whichStat ) 294 #else 295 Void TDecBinCABAC::decodeAlignedBinsEP( UInt& ruiBins, Int numBins ) 296 #endif 297 { 298 Int binsRemaining = numBins; 299 ruiBins = 0; 300 301 assert(m_uiRange == 256); //aligned decode only works when range = 256 302 303 while (binsRemaining > 0) 304 { 305 const UInt binsToRead = std::min<UInt>(binsRemaining, 8); //read bytes if able to take advantage of the system's byte-read function 306 const UInt binMask = (1 << binsToRead) - 1; 307 308 //The MSB of m_uiValue is known to be 0 because range is 256. Therefore: 309 // > The comparison against the symbol range of 128 is simply a test on the next-most-significant bit 310 // > "Subtracting" the symbol range if the decoded bin is 1 simply involves clearing that bit. 311 // 312 //As a result, the required bins are simply the <binsToRead> next-most-significant bits of m_uiValue 313 //(m_uiValue is stored MSB-aligned in a 16-bit buffer - hence the shift of 15) 314 // 315 // 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)) 316 // 317 const UInt newBins = (m_uiValue >> (15 - binsToRead)) & binMask; 318 319 ruiBins = (ruiBins << binsToRead) | newBins; 320 m_uiValue = (m_uiValue << binsToRead) & 0x7FFF; 321 322 binsRemaining -= binsToRead; 323 m_bitsNeeded += binsToRead; 324 325 if (m_bitsNeeded >= 0) 326 { 327 m_uiValue |= m_pcTComBitstream->readByte() << m_bitsNeeded; 328 m_bitsNeeded -= 8; 329 } 330 } 331 332 #if RExt__DECODER_DEBUG_BIT_STATISTICS 333 TComCodingStatistics::IncrementStatisticEP(whichStat, numBins, Int(ruiBins)); 334 #endif 210 335 } 211 336 … … 218 343 { 219 344 ruiBin = 1; 345 #if RExt__DECODER_DEBUG_BIT_STATISTICS 346 TComCodingStatistics::UpdateCABACStat(STATS__CABAC_TRM_BITS, m_uiRange+2, 2, ruiBin); 347 TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS, -m_bitsNeeded, 0); 348 #endif 220 349 } 221 350 else 222 351 { 223 352 ruiBin = 0; 353 #if RExt__DECODER_DEBUG_BIT_STATISTICS 354 TComCodingStatistics::UpdateCABACStat(STATS__CABAC_TRM_BITS, m_uiRange+2, m_uiRange, ruiBin); 355 #endif 224 356 if ( scaledRange < ( 256 << 7 ) ) 225 357 { 226 358 m_uiRange = scaledRange >> 6; 227 359 m_uiValue += m_uiValue; 228 360 229 361 if ( ++m_bitsNeeded == 0 ) 230 362 { 231 363 m_bitsNeeded = -8; 232 m_uiValue += m_pcTComBitstream->readByte(); 364 m_uiValue += m_pcTComBitstream->readByte(); 233 365 } 234 366 } … … 245 377 assert ( uiLength > 0 ); 246 378 m_pcTComBitstream->read (uiLength, ruiCode); 379 #if RExt__DECODER_DEBUG_BIT_STATISTICS 380 TComCodingStatistics::IncrementStatisticEP(STATS__CABAC_PCM_CODE_BITS, uiLength, ruiCode); 381 #endif 247 382 } 248 383 //! \} -
trunk/source/Lib/TLibDecoder/TDecBinCoderCABAC.h
r1179 r1313 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 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 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: -
trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
r1196 r1313 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-2015, ITU/ISO/IEC … … 39 39 #include "SEIread.h" 40 40 #include "TDecSlice.h" 41 #if H_3D 41 #include "TLibCommon/TComChromaFormat.h" 42 #if RExt__DECODER_DEBUG_BIT_STATISTICS 43 #include "TLibCommon/TComCodingStatistics.h" 44 #endif 45 #if NH_MV 42 46 #include "TDecTop.h" 43 47 #endif 48 44 49 //! \ingroup TLibDecoder 45 50 //! \{ 46 51 47 52 #if ENC_DEC_TRACE 48 49 Void xTraceSPSHeader (TComSPS *pSPS) 50 { 51 #if H_MV_ENC_DEC_TRAC 52 if ( g_disableHLSTrace ) 53 { 54 return; 55 } 56 // To avoid mismatches 57 fprintf( g_hTrace, "=========== Sequence Parameter Set LayerId: %d ===========\n", pSPS->getLayerId() ); 58 #else 59 fprintf( g_hTrace, "=========== Sequence Parameter Set ID: %d ===========\n", pSPS->getSPSId() ); 60 #endif 61 } 62 63 Void xTracePPSHeader (TComPPS *pPPS) 64 { 65 #if H_MV_ENC_DEC_TRAC 66 if ( g_disableHLSTrace ) 67 { 68 return; 69 } 70 fprintf( g_hTrace, "=========== Picture Parameter Set LayerId: %d ===========\n", pPPS->getLayerId() ); 71 #else 72 fprintf( g_hTrace, "=========== Picture Parameter Set ID: %d ===========\n", pPPS->getPPSId() ); 73 #endif 74 } 75 76 Void xTraceSliceHeader (TComSlice *pSlice) 77 { 78 #if H_MV_ENC_DEC_TRAC 79 if ( g_disableHLSTrace ) 80 { 81 return; 82 } 83 #endif 84 fprintf( g_hTrace, "=========== Slice ===========\n"); 85 } 86 87 #endif 88 53 #if !H_MV_ENC_DEC_TRAC 54 Void xTraceVPSHeader () 55 { 56 fprintf( g_hTrace, "=========== Video Parameter Set ===========\n" ); 57 } 58 59 Void xTraceSPSHeader () 60 { 61 fprintf( g_hTrace, "=========== Sequence Parameter Set ===========\n" ); 62 } 63 64 Void xTracePPSHeader () 65 { 66 fprintf( g_hTrace, "=========== Picture Parameter Set ===========\n"); 67 } 68 #endif 69 #endif 89 70 // ==================================================================================================================== 90 71 // Constructor / destructor / create / destroy … … 97 78 TDecCavlc::~TDecCavlc() 98 79 { 80 99 81 } 100 82 … … 103 85 // ==================================================================================================================== 104 86 105 void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx )87 Void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx ) 106 88 { 107 89 UInt code; … … 117 99 } 118 100 119 if (interRPSPred) 101 if (interRPSPred) 120 102 { 121 103 UInt bit; … … 138 120 for(Int j=0 ; j <= rpsRef->getNumberOfPictures(); j++) 139 121 { 140 READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 122 READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 141 123 Int refIdc = bit; 142 if (refIdc == 0) 124 if (refIdc == 0) 143 125 { 144 126 READ_CODE(1, bit, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. … … 155 137 k0++; 156 138 } 157 else 139 else 158 140 { 159 141 k1++; 160 142 } 161 143 k++; 162 } 163 rps->setRefIdc(j,refIdc); 164 } 165 rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1); 144 } 145 rps->setRefIdc(j,refIdc); 146 } 147 rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1); 166 148 rps->setNumberOfPictures(k); 167 149 rps->setNumberOfNegativePictures(k0); … … 199 181 } 200 182 201 #if H_3D 202 Void TDecCavlc::parsePPS(TComPPS* pcPPS, TComVPS* pcVPS ) 183 Void TDecCavlc::parsePPS(TComPPS* pcPPS) 184 { 185 #if ENC_DEC_TRACE 186 #if H_MV_ENC_DEC_TRAC 187 tracePSHeader( "PPS", pcPPS->getLayerId() ); 203 188 #else 204 Void TDecCavlc::parsePPS(TComPPS* pcPPS) 205 #endif 206 { 207 #if ENC_DEC_TRACE 208 xTracePPSHeader (pcPPS); 189 xTracePPSHeader (); 190 #endif 209 191 #endif 210 192 UInt uiCode; … … 215 197 assert(uiCode <= 63); 216 198 pcPPS->setPPSId (uiCode); 217 199 218 200 READ_UVLC( uiCode, "pps_seq_parameter_set_id"); 219 201 assert(uiCode <= 15); 220 202 pcPPS->setSPSId (uiCode); 221 203 222 204 READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag" ); pcPPS->setDependentSliceSegmentsEnabledFlag ( uiCode == 1 ); 205 223 206 READ_FLAG( uiCode, "output_flag_present_flag" ); pcPPS->setOutputFlagPresentFlag( uiCode==1 ); 224 207 225 208 READ_CODE(3, uiCode, "num_extra_slice_header_bits"); pcPPS->setNumExtraSliceHeaderBits(uiCode); 209 226 210 READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode ); 227 211 … … 231 215 assert(uiCode <= 14); 232 216 pcPPS->setNumRefIdxL0DefaultActive(uiCode+1); 233 217 234 218 READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1"); 235 219 assert(uiCode <= 14); 236 220 pcPPS->setNumRefIdxL1DefaultActive(uiCode+1); 237 221 238 222 READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode); 239 223 READ_FLAG( uiCode, "constrained_intra_pred_flag" ); pcPPS->setConstrainedIntraPred( uiCode ? true : false ); 240 READ_FLAG( uiCode, "transform_skip_enabled_flag" ); 241 pcPPS->setUseTransformSkip ( uiCode ? true : false ); 224 READ_FLAG( uiCode, "transform_skip_enabled_flag" ); 225 pcPPS->setUseTransformSkip ( uiCode ? true : false ); 242 226 243 227 READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" ); pcPPS->setUseDQP( uiCode ? true : false ); … … 252 236 } 253 237 READ_SVLC( iCode, "pps_cb_qp_offset"); 254 pcPPS->set ChromaCbQpOffset(iCode);255 assert( pcPPS->get ChromaCbQpOffset() >= -12 );256 assert( pcPPS->get ChromaCbQpOffset() <= 12 );238 pcPPS->setQpOffset(COMPONENT_Cb, iCode); 239 assert( pcPPS->getQpOffset(COMPONENT_Cb) >= -12 ); 240 assert( pcPPS->getQpOffset(COMPONENT_Cb) <= 12 ); 257 241 258 242 READ_SVLC( iCode, "pps_cr_qp_offset"); 259 pcPPS->setChromaCrQpOffset(iCode); 260 assert( pcPPS->getChromaCrQpOffset() >= -12 ); 261 assert( pcPPS->getChromaCrQpOffset() <= 12 ); 243 pcPPS->setQpOffset(COMPONENT_Cr, iCode); 244 assert( pcPPS->getQpOffset(COMPONENT_Cr) >= -12 ); 245 assert( pcPPS->getQpOffset(COMPONENT_Cr) <= 12 ); 246 247 assert(MAX_NUM_COMPONENT<=3); 262 248 263 249 READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" ); … … 273 259 READ_FLAG( uiCode, "tiles_enabled_flag" ); pcPPS->setTilesEnabledFlag ( uiCode == 1 ); 274 260 READ_FLAG( uiCode, "entropy_coding_sync_enabled_flag" ); pcPPS->setEntropyCodingSyncEnabledFlag( uiCode == 1 ); 275 261 276 262 if( pcPPS->getTilesEnabledFlag() ) 277 263 { … … 280 266 READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setTileUniformSpacingFlag( uiCode == 1 ); 281 267 282 if( !pcPPS->getTileUniformSpacingFlag()) 283 { 284 std::vector<Int> columnWidth(pcPPS->getNumTileColumnsMinus1()); 285 for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++) 286 { 287 READ_UVLC( uiCode, "column_width_minus1" ); 288 columnWidth[i] = uiCode+1; 289 } 290 pcPPS->setTileColumnWidth(columnWidth); 291 292 std::vector<Int> rowHeight (pcPPS->getTileNumRowsMinus1()); 293 for(UInt i=0; i<pcPPS->getTileNumRowsMinus1(); i++) 294 { 295 READ_UVLC( uiCode, "row_height_minus1" ); 296 rowHeight[i] = uiCode + 1; 297 } 298 pcPPS->setTileRowHeight(rowHeight); 299 } 300 301 if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getTileNumRowsMinus1() !=0) 268 const UInt tileColumnsMinus1 = pcPPS->getNumTileColumnsMinus1(); 269 const UInt tileRowsMinus1 = pcPPS->getNumTileRowsMinus1(); 270 271 if ( !pcPPS->getTileUniformSpacingFlag()) 272 { 273 if (tileColumnsMinus1 > 0) 274 { 275 std::vector<Int> columnWidth(tileColumnsMinus1); 276 for(UInt i = 0; i < tileColumnsMinus1; i++) 277 { 278 READ_UVLC( uiCode, "column_width_minus1" ); 279 columnWidth[i] = uiCode+1; 280 } 281 pcPPS->setTileColumnWidth(columnWidth); 282 } 283 284 if (tileRowsMinus1 > 0) 285 { 286 std::vector<Int> rowHeight (tileRowsMinus1); 287 for(UInt i = 0; i < tileRowsMinus1; i++) 288 { 289 READ_UVLC( uiCode, "row_height_minus1" ); 290 rowHeight[i] = uiCode + 1; 291 } 292 pcPPS->setTileRowHeight(rowHeight); 293 } 294 } 295 296 if ((tileColumnsMinus1 + tileRowsMinus1) != 0) 302 297 { 303 298 READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false ); 304 299 } 305 300 } 306 READ_FLAG( uiCode, " loop_filter_across_slices_enabled_flag" );pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode ? true : false );301 READ_FLAG( uiCode, "pps_loop_filter_across_slices_enabled_flag" ); pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode ? true : false ); 307 302 READ_FLAG( uiCode, "deblocking_filter_control_present_flag" ); pcPPS->setDeblockingFilterControlPresentFlag( uiCode ? true : false ); 308 303 if(pcPPS->getDeblockingFilterControlPresentFlag()) … … 319 314 if(pcPPS->getScalingListPresentFlag ()) 320 315 { 321 parseScalingList( pcPPS->getScalingList() ); 322 } 316 parseScalingList( &(pcPPS->getScalingList()) ); 317 } 318 323 319 READ_FLAG( uiCode, "lists_modification_present_flag"); 324 320 pcPPS->setListsModificationPresentFlag(uiCode); … … 329 325 READ_FLAG( uiCode, "slice_segment_header_extension_present_flag"); 330 326 pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); 331 332 #if H_MV 327 333 328 READ_FLAG( uiCode, "pps_extension_present_flag"); 334 #else335 READ_FLAG( uiCode, "pps_extension_flag");336 #endif337 329 if (uiCode) 338 330 { 339 340 #if H_MV 331 #if NH_MV 341 332 READ_FLAG( uiCode, "pps_range_extensions_flag" ); pcPPS->setPpsRangeExtensionsFlag( uiCode == 1 ); 342 333 READ_FLAG( uiCode, "pps_multilayer_extension_flag" ); pcPPS->setPpsMultilayerExtensionFlag( uiCode == 1 ); 343 #if !H_3D344 READ_CODE( 6, uiCode, "pps_extension_6bits" ); pcPPS->setPpsExtension6bits( uiCode );345 #else346 334 READ_FLAG( uiCode, "pps_3d_extension_flag" ); pcPPS->setPps3dExtensionFlag( uiCode == 1 ); 347 335 READ_CODE( 5, uiCode, "pps_extension_5bits" ); pcPPS->setPpsExtension5bits( uiCode ); 348 #endif349 336 if ( pcPPS->getPpsRangeExtensionsFlag() ) 350 337 { 351 assert(0); 352 } 338 TComPPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension(); 339 340 if (pcPPS->getUseTransformSkip()) 341 { 342 READ_UVLC( uiCode, "log2_max_transform_skip_block_size_minus2"); 343 ppsRangeExtension.setLog2MaxTransformSkipBlockSize(uiCode+2); 344 } 345 346 READ_FLAG( uiCode, "cross_component_prediction_enabled_flag"); 347 ppsRangeExtension.setCrossComponentPredictionEnabledFlag(uiCode != 0); 348 349 READ_FLAG( uiCode, "chroma_qp_offset_list_enabled_flag"); 350 if (uiCode == 0) 351 { 352 ppsRangeExtension.clearChromaQpOffsetList(); 353 ppsRangeExtension.setDiffCuChromaQpOffsetDepth(0); 354 } 355 else 356 { 357 READ_UVLC(uiCode, "diff_cu_chroma_qp_offset_depth"); ppsRangeExtension.setDiffCuChromaQpOffsetDepth(uiCode); 358 UInt tableSizeMinus1 = 0; 359 READ_UVLC(tableSizeMinus1, "chroma_qp_offset_list_len_minus1"); 360 assert(tableSizeMinus1 < MAX_QP_OFFSET_LIST_SIZE); 361 362 for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx <= (tableSizeMinus1); cuChromaQpOffsetIdx++) 363 { 364 Int cbOffset; 365 Int crOffset; 366 READ_SVLC(cbOffset, "cb_qp_offset_list[i]"); 367 assert(cbOffset >= -12 && cbOffset <= 12); 368 READ_SVLC(crOffset, "cr_qp_offset_list[i]"); 369 assert(crOffset >= -12 && crOffset <= 12); 370 // table uses +1 for index (see comment inside the function) 371 ppsRangeExtension.setChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1, cbOffset, crOffset); 372 } 373 assert(ppsRangeExtension.getChromaQpOffsetListLen() == tableSizeMinus1 + 1); 374 } 375 376 READ_UVLC( uiCode, "log2_sao_offset_scale_luma"); 377 ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, uiCode); 378 READ_UVLC( uiCode, "log2_sao_offset_scale_chroma"); 379 ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, uiCode); } 353 380 354 381 if ( pcPPS->getPpsMultilayerExtensionFlag() ) 355 382 { 356 parsePPSMultilayerExtension( pcPPS ); 357 } 358 #if !H_3D 359 if ( pcPPS->getPpsExtension6bits() ) 360 { 361 #else 383 parsePpsMultilayerExtension( pcPPS ); 384 } 385 362 386 if ( pcPPS->getPps3dExtensionFlag() ) 363 387 { 364 parsePPSExtension( pcPPS, pcVPS ); 365 } 388 #if NH_3D 389 parsePps3dExtension( pcPPS ); 390 #endif 391 } 392 #if NH_3D 366 393 if ( pcPPS->getPpsExtension5bits() ) 367 { 368 #endif 369 370 #endif 371 394 #else 395 if ( pcPPS->getPpsExtension5bits() || pcPPS->getPps3dExtensionFlag() ) 396 #endif 397 { 372 398 while ( xMoreRbspData() ) 373 399 { 374 400 READ_FLAG( uiCode, "pps_extension_data_flag"); 375 401 } 376 #if H_MV 377 } 378 #endif 379 } 380 } 381 382 383 #if H_3D 384 Void TDecCavlc::parsePPSExtension( TComPPS* pcPPS, TComVPS* pcVPS ) 385 { 386 //Ed.(GT): pcVPS should not be used here. Needs to be fixed. 387 UInt uiCode = 0; 388 TComDLT* pcDLT = new TComDLT; 389 390 READ_FLAG(uiCode, "dlt_present_flag"); 391 pcDLT->setDltPresentFlag( (uiCode == 1) ? true : false ); 392 393 if ( pcDLT->getDltPresentFlag() ) 394 { 395 READ_CODE(6, uiCode, "pps_depth_layers_minus1"); 396 pcDLT->setNumDepthViews( uiCode ); 397 398 READ_CODE(4, uiCode, "pps_bit_depth_for_depth_views_minus8"); 399 pcDLT->setDepthViewBitDepth( (uiCode+8) ); 400 401 for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) 402 { 403 if ( i != 0 ) 404 { 405 if( pcVPS->getDepthId( i ) == 1 ) 406 { 407 READ_FLAG(uiCode, "dlt_flag[i]"); 408 pcDLT->setUseDLTFlag(i, (uiCode == 1) ? true : false); 409 410 if ( pcDLT->getUseDLTFlag( i ) ) 411 { 412 Bool bDltBitMapRepFlag = false; 413 UInt uiMaxDiff = 0xffffffff; 414 UInt uiMinDiff = 0; 415 UInt uiCodeLength = 0; 416 417 READ_FLAG(uiCode, "inter_view_dlt_pred_enable_flag[ i ]"); 418 419 if( uiCode ) 402 } 403 404 #else 405 #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS 406 static const char *syntaxStrings[]={ "pps_range_extension_flag", 407 "pps_multilayer_extension_flag", 408 "pps_extension_6bits[0]", 409 "pps_extension_6bits[1]", 410 "pps_extension_6bits[2]", 411 "pps_extension_6bits[3]", 412 "pps_extension_6bits[4]", 413 "pps_extension_6bits[5]" }; 414 #endif 415 416 Bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]; 417 for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) 418 { 419 READ_FLAG( uiCode, syntaxStrings[i] ); 420 pps_extension_flags[i] = uiCode!=0; 421 } 422 423 Bool bSkipTrailingExtensionBits=false; 424 for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. 425 { 426 if (pps_extension_flags[i]) 427 { 428 switch (PPSExtensionFlagIndex(i)) 429 { 430 case PPS_EXT__REXT: 420 431 { 421 assert( pcDLT->getUseDLTFlag( 1 )); 432 TComPPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension(); 433 assert(!bSkipTrailingExtensionBits); 434 435 if (pcPPS->getUseTransformSkip()) 436 { 437 READ_UVLC( uiCode, "log2_max_transform_skip_block_size_minus2"); 438 ppsRangeExtension.setLog2MaxTransformSkipBlockSize(uiCode+2); 422 439 } 423 pcDLT->setInterViewDltPredEnableFlag( i, (uiCode == 1) ? true : false ); 424 425 if ( pcDLT->getInterViewDltPredEnableFlag( i ) == false ) 440 441 READ_FLAG( uiCode, "cross_component_prediction_enabled_flag"); 442 ppsRangeExtension.setCrossComponentPredictionEnabledFlag(uiCode != 0); 443 444 READ_FLAG( uiCode, "chroma_qp_offset_list_enabled_flag"); 445 if (uiCode == 0) 426 446 { 427 READ_FLAG(uiCode, "dlt_bit_map_rep_flag[ layerId ]");428 bDltBitMapRepFlag = (uiCode == 1) ? true : false;447 ppsRangeExtension.clearChromaQpOffsetList(); 448 ppsRangeExtension.setDiffCuChromaQpOffsetDepth(0); 429 449 } 430 450 else 431 451 { 432 bDltBitMapRepFlag = false; 452 READ_UVLC(uiCode, "diff_cu_chroma_qp_offset_depth"); ppsRangeExtension.setDiffCuChromaQpOffsetDepth(uiCode); 453 UInt tableSizeMinus1 = 0; 454 READ_UVLC(tableSizeMinus1, "chroma_qp_offset_list_len_minus1"); 455 assert(tableSizeMinus1 < MAX_QP_OFFSET_LIST_SIZE); 456 457 for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx <= (tableSizeMinus1); cuChromaQpOffsetIdx++) 458 { 459 Int cbOffset; 460 Int crOffset; 461 READ_SVLC(cbOffset, "cb_qp_offset_list[i]"); 462 assert(cbOffset >= -12 && cbOffset <= 12); 463 READ_SVLC(crOffset, "cr_qp_offset_list[i]"); 464 assert(crOffset >= -12 && crOffset <= 12); 465 // table uses +1 for index (see comment inside the function) 466 ppsRangeExtension.setChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1, cbOffset, crOffset); 467 } 468 assert(ppsRangeExtension.getChromaQpOffsetListLen() == tableSizeMinus1 + 1); 469 } 470 471 READ_UVLC( uiCode, "log2_sao_offset_scale_luma"); 472 ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, uiCode); 473 READ_UVLC( uiCode, "log2_sao_offset_scale_chroma"); 474 ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, uiCode); 475 } 476 break; 477 default: 478 bSkipTrailingExtensionBits=true; 479 break; 480 } 481 } 482 } 483 if (bSkipTrailingExtensionBits) 484 { 485 while ( xMoreRbspData() ) 486 { 487 READ_FLAG( uiCode, "pps_extension_data_flag"); 488 } 489 } 490 #endif 491 } 492 xReadRbspTrailingBits(); 493 } 494 495 #if NH_3D 496 Void TDecCavlc::parsePps3dExtension( TComPPS* pcPPS ) 497 { 498 #if NH_3D_DLT 499 UInt uiCode = 0; 500 // 501 TComDLT* pcDLT = pcPPS->getDLT(); 502 503 READ_FLAG(uiCode, "dlts_present_flag"); 504 pcDLT->setDltPresentFlag( (uiCode == 1) ? true : false ); 505 506 if ( pcDLT->getDltPresentFlag() ) 507 { 508 READ_CODE(6, uiCode, "pps_depth_layers_minus1"); 509 #if NH_3D_VER141_DEC_COMP_FLAG 510 pcDLT->setNumDepthViews( uiCode ); 511 #else 512 pcDLT->setNumDepthViews( uiCode+1 ); 513 #endif 514 515 READ_CODE(4, uiCode, "pps_bit_depth_for_depth_layers_minus8"); 516 pcDLT->setDepthViewBitDepth( (uiCode+8) ); 517 518 #if NH_3D_DLT_FIX 519 for( Int i = 0; i <= pcDLT->getNumDepthViews()-1; i++ ) 520 #else 521 for( Int i = 0; i <= pcDLT->getNumDepthViews(); i++ ) 522 #endif 523 { 524 Int layerId = pcDLT->getDepthIdxToLayerId(i); 525 526 READ_FLAG(uiCode, "dlt_flag[i]"); 527 pcDLT->setUseDLTFlag(layerId, (uiCode == 1) ? true : false); 528 529 if ( pcDLT->getUseDLTFlag( layerId ) ) 530 { 531 Bool bDltBitMapRepFlag = false; 532 UInt uiMaxDiff = MAX_INT; 533 UInt uiMinDiff = 0; 534 UInt uiCodeLength = 0; 535 536 READ_FLAG(uiCode, "dlt_pred_flag[i]"); 537 538 if( uiCode ) 539 { 540 assert( pcDLT->getUseDLTFlag( 1 )); 541 } 542 pcDLT->setInterViewDltPredEnableFlag( layerId, (uiCode == 1) ? true : false ); 543 544 if ( pcDLT->getInterViewDltPredEnableFlag( layerId ) == false ) 545 { 546 READ_FLAG(uiCode, "dlt_val_flags_present_flag[i]"); 547 bDltBitMapRepFlag = (uiCode == 1) ? true : false; 548 } 549 else 550 { 551 bDltBitMapRepFlag = false; 552 } 553 554 UInt uiNumDepthValues = 0; 555 std::vector<Int> aiIdx2DepthValue(256, 0); 556 557 // Bit map 558 if ( bDltBitMapRepFlag ) 559 { 560 for (UInt d=0; d<256; d++) 561 { 562 READ_FLAG(uiCode, "dlt_value_flag[i][j]"); 563 if (uiCode == 1) 564 { 565 aiIdx2DepthValue[uiNumDepthValues] = d; 566 uiNumDepthValues++; 567 } 568 } 569 } 570 // Diff Coding 571 else 572 { 573 READ_CODE(8, uiNumDepthValues, "num_val_delta_dlt"); // num_entry 574 575 { 576 // The condition if( pcVPS->getNumDepthValues(i) > 0 ) is always true since for Single-view Diff Coding, there is at least one depth value in depth component. 577 578 if (uiNumDepthValues > 1) 579 { 580 READ_CODE(8, uiCode, "max_diff"); 581 uiMaxDiff = uiCode; 582 } 583 else 584 { 585 uiMaxDiff = 0; // when there is only one value in DLT 433 586 } 434 587 435 UInt uiNumDepthValues = 0; 436 Int aiIdx2DepthValue[256]; 437 438 // Bit map 439 if ( bDltBitMapRepFlag ) 588 if (uiNumDepthValues > 2) 440 589 { 441 for (UInt d=0; d<256; d++) 590 uiCodeLength = (UInt) gCeilLog2(uiMaxDiff + 1); 591 READ_CODE(uiCodeLength, uiCode, "min_diff_minus1"); 592 uiMinDiff = uiCode + 1; 593 } 594 else 595 { 596 uiMinDiff = uiMaxDiff; // when there are only one or two values in DLT 597 } 598 599 READ_CODE(8, uiCode, "delta_dlt_val0"); // entry0 600 aiIdx2DepthValue[0] = uiCode; 601 602 if (uiMaxDiff == uiMinDiff) 603 { 604 for (UInt d=1; d<uiNumDepthValues; d++) 442 605 { 443 READ_FLAG(uiCode, "dlt_bit_map_flag[ layerId ][ j ]"); 444 if (uiCode == 1) 445 { 446 aiIdx2DepthValue[uiNumDepthValues] = d; 447 uiNumDepthValues++; 448 } 606 aiIdx2DepthValue[d] = aiIdx2DepthValue[d-1] + uiMinDiff + 0; 449 607 } 450 608 } 451 // Diff Coding452 609 else 453 610 { 454 READ_CODE(8, uiNumDepthValues, "num_depth_values_in_dlt[i]"); // num_entry455 611 uiCodeLength = (UInt) gCeilLog2(uiMaxDiff - uiMinDiff + 1); 612 for (UInt d=1; d<uiNumDepthValues; d++) 456 613 { 457 // The condition if( pcVPS->getNumDepthValues(i) > 0 ) is always true since for Single-view Diff Coding, there is at least one depth value in depth component. 458 459 if (uiNumDepthValues > 1) 460 { 461 READ_CODE(8, uiCode, "max_diff[ layerId ]"); 462 uiMaxDiff = uiCode; 463 } 464 else 465 { 466 uiMaxDiff = 0; // when there is only one value in DLT 467 } 468 469 if (uiNumDepthValues > 2) 470 { 471 uiCodeLength = (UInt) ceil(Log2(uiMaxDiff + 1)); 472 READ_CODE(uiCodeLength, uiCode, "min_diff_minus1[ layerId ]"); 473 uiMinDiff = uiCode + 1; 474 } 475 else 476 { 477 uiMinDiff = uiMaxDiff; // when there are only one or two values in DLT 478 } 479 480 READ_CODE(8, uiCode, "dlt_depth_value0[layerId]"); // entry0 481 aiIdx2DepthValue[0] = uiCode; 482 483 if (uiMaxDiff == uiMinDiff) 484 { 485 for (UInt d=1; d<uiNumDepthValues; d++) 486 { 487 aiIdx2DepthValue[d] = aiIdx2DepthValue[d-1] + uiMinDiff + 0; 488 } 489 } 490 else 491 { 492 uiCodeLength = (UInt) ceil(Log2(uiMaxDiff - uiMinDiff + 1)); 493 for (UInt d=1; d<uiNumDepthValues; d++) 494 { 495 READ_CODE(uiCodeLength, uiCode, "dlt_depth_value_diff_minus_min[ layerId ][ j ]"); 496 aiIdx2DepthValue[d] = aiIdx2DepthValue[d-1] + uiMinDiff + uiCode; 497 } 498 } 499 614 READ_CODE(uiCodeLength, uiCode, "delta_val_diff_minus_min[k]"); 615 aiIdx2DepthValue[d] = aiIdx2DepthValue[d-1] + uiMinDiff + uiCode; 500 616 } 501 617 } 502 618 503 if( pcDLT->getInterViewDltPredEnableFlag( i ) )504 {505 // interpret decoded values as delta DLT506 AOF( pcVPS->getDepthId( 1 ) == 1 );507 AOF( i > 1 );508 // assumes ref layer id to be 1509 Int* piRefDLT = pcDLT->idx2DepthValue( 1 );510 UInt uiRefNum = pcDLT->getNumDepthValues( 1 );511 pcDLT->setDeltaDLT(i, piRefDLT, uiRefNum, aiIdx2DepthValue, uiNumDepthValues);512 }513 else514 {515 // store final DLT516 pcDLT->setDepthLUTs(i, aiIdx2DepthValue, uiNumDepthValues);517 }518 519 619 } 520 620 } 521 } 522 } 523 } 524 525 pcPPS->setDLT( pcDLT ); 526 } 527 #endif 621 622 if( pcDLT->getInterViewDltPredEnableFlag( layerId ) ) 623 { 624 // interpret decoded values as delta DLT 625 AOF( layerId > 1 ); 626 // assumes ref layer id to be 1 627 std::vector<Int> viRefDLT = pcDLT->idx2DepthValue( 1 ); 628 UInt uiRefNum = pcDLT->getNumDepthValues( 1 ); 629 pcDLT->setDeltaDLT(layerId, viRefDLT, uiRefNum, aiIdx2DepthValue, uiNumDepthValues); 630 } 631 else 632 { 633 // store final DLT 634 pcDLT->setDepthLUTs(layerId, aiIdx2DepthValue, uiNumDepthValues); 635 } 636 } 637 } 638 } 639 #endif 640 } 641 #endif 642 528 643 529 644 Void TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS) … … 541 656 { 542 657 READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode); 543 READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode);658 READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode); 544 659 } 545 660 } … … 552 667 553 668 READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode); 554 #if H_MV669 #if NH_MV 555 670 assert( pcSPS->getLayerId() == 0 || !pcVUI->getVideoSignalTypePresentFlag() ); 556 671 #endif … … 564 679 READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode); 565 680 READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode); 566 READ_CODE(8, uiCode, "matrix_coeff icients");pcVUI->setMatrixCoefficients(uiCode);681 READ_CODE(8, uiCode, "matrix_coeffs"); pcVUI->setMatrixCoefficients(uiCode); 567 682 } 568 683 } … … 585 700 { 586 701 Window &defDisp = pcVUI->getDefaultDisplayWindow(); 587 #if H_MV702 #if NH_MV 588 703 defDisp.setScaledFlag( false ); 589 704 READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode ); … … 598 713 #endif 599 714 } 715 600 716 TimingInfo *timingInfo = pcVUI->getTimingInfo(); 601 717 READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); … … 609 725 READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); 610 726 } 611 READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); 612 if( pcVUI->getHrdParametersPresentFlag() ) 613 { 614 parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); 615 } 616 } 727 728 READ_FLAG( uiCode, "vui_hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); 729 if( pcVUI->getHrdParametersPresentFlag() ) 730 { 731 parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); 732 } 733 } 734 617 735 READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); 618 736 if (pcVUI->getBitstreamRestrictionFlag()) … … 621 739 READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); 622 740 READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); 623 READ_UVLC( uiCode, "min_spatial_segmentation_idc");pcVUI->setMinSpatialSegmentationIdc(uiCode);741 READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); 624 742 assert(uiCode < 4096); 625 743 READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); 626 READ_UVLC( uiCode, "max_bits_per_min cu_denom" );pcVUI->setMaxBitsPerMinCuDenom(uiCode);744 READ_UVLC( uiCode, "max_bits_per_min_cu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); 627 745 READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); 628 746 READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); … … 639 757 if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) 640 758 { 641 READ_FLAG( uiCode, "sub_pic_ cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false );759 READ_FLAG( uiCode, "sub_pic_hrd_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); 642 760 if( hrd->getSubPicCpbParamsPresentFlag() ) 643 761 { 644 762 READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); 645 READ_CODE( 5, uiCode, "du_cpb_removal_delay_ length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode );763 READ_CODE( 5, uiCode, "du_cpb_removal_delay_increment_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); 646 764 READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); 647 765 READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); … … 670 788 hrd->setFixedPicRateWithinCvsFlag( i, true ); 671 789 } 790 672 791 hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present 673 792 hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present 793 674 794 if( hrd->getFixedPicRateWithinCvsFlag( i ) ) 675 795 { … … 677 797 } 678 798 else 679 { 799 { 680 800 READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); 681 801 } 682 802 if (!hrd->getLowDelayHrdFlag( i )) 683 803 { 684 READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); 685 } 804 READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); 805 } 806 686 807 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) 687 808 { … … 707 828 Void TDecCavlc::parseSPS(TComSPS* pcSPS) 708 829 { 709 #if ENC_DEC_TRACE 710 xTraceSPSHeader (pcSPS); 830 #if ENC_DEC_TRACE 831 #if H_MV_ENC_DEC_TRAC 832 tracePSHeader( "SPS", pcSPS->getLayerId() ); 833 #else 834 xTraceSPSHeader (); 835 #endif 711 836 #endif 712 837 … … 714 839 READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); 715 840 716 #if H_MV841 #if NH_MV 717 842 if ( pcSPS->getLayerId() == 0 ) 718 843 { 719 844 #endif 720 721 722 #if H_MV845 READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); 846 assert(uiCode <= 6); 847 #if NH_MV 723 848 } 724 849 else … … 731 856 #endif 732 857 733 READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" );pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false );734 735 736 737 738 739 740 741 #if H_MV858 READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); 859 if ( pcSPS->getMaxTLayers() == 1 ) 860 { 861 // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 862 assert( uiCode == 1 ); 863 } 864 865 parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 866 #if NH_MV 742 867 pcSPS->getPTL()->inferGeneralValues ( true, 0, NULL ); 743 868 pcSPS->getPTL()->inferSubLayerValues( pcSPS->getMaxTLayers() - 1, 0, NULL ); … … 746 871 READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); 747 872 assert(uiCode <= 15); 748 #if H_MV873 #if NH_MV 749 874 if ( pcSPS->getMultiLayerExtSpsFlag() ) 750 875 { … … 758 883 { 759 884 #endif 760 READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); 761 assert(uiCode <= 3); 762 // 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 763 #if !H_3D_DISABLE_CHROMA 764 assert (uiCode == 1); 765 #endif 766 if( uiCode == 3 ) 767 { 768 READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); 769 } 770 771 READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); 772 READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); 885 886 READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); 887 assert(uiCode <= 3); 888 if( pcSPS->getChromaFormatIdc() == CHROMA_444 ) 889 { 890 READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); 891 } 892 893 READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); 894 READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); 773 895 READ_FLAG( uiCode, "conformance_window_flag"); 774 896 if (uiCode != 0) 775 897 { 776 898 Window &conf = pcSPS->getConformanceWindow(); 777 #if H_MV899 #if NH_MV 778 900 // Needs to be scaled later, when ChromaFormatIdc is known. 779 901 conf.setScaledFlag( false ); … … 791 913 } 792 914 793 #if H_MV915 #if NH_MV 794 916 if ( !pcSPS->getMultiLayerExtSpsFlag() ) 795 917 { 796 918 #endif 797 READ_UVLC( uiCode, "bit_depth_luma_minus8" ); 798 assert(uiCode <= 6); 799 pcSPS->setBitDepthY( uiCode + 8 ); 800 pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); 801 802 READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); 803 assert(uiCode <= 6); 804 pcSPS->setBitDepthC( uiCode + 8 ); 805 pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); 806 #if H_MV 919 920 READ_UVLC( uiCode, "bit_depth_luma_minus8" ); 921 #if O0043_BEST_EFFORT_DECODING 922 pcSPS->setStreamBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode); 923 const UInt forceDecodeBitDepth = pcSPS->getForceDecodeBitDepth(); 924 if (forceDecodeBitDepth != 0) 925 { 926 uiCode = forceDecodeBitDepth - 8; 927 } 928 #endif 929 assert(uiCode <= 8); 930 pcSPS->setBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode); 931 932 #if O0043_BEST_EFFORT_DECODING 933 pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*(pcSPS->getStreamBitDepth(CHANNEL_TYPE_LUMA)-8)) ); 934 #else 935 pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*uiCode) ); 936 #endif 937 938 READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); 939 #if O0043_BEST_EFFORT_DECODING 940 pcSPS->setStreamBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode); 941 if (forceDecodeBitDepth != 0) 942 { 943 uiCode = forceDecodeBitDepth - 8; 944 } 945 #endif 946 assert(uiCode <= 8); 947 pcSPS->setBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode); 948 #if O0043_BEST_EFFORT_DECODING 949 pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*(pcSPS->getStreamBitDepth(CHANNEL_TYPE_CHROMA)-8)) ); 950 #else 951 pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*uiCode) ); 952 #endif 953 #if NH_MV 807 954 } 808 955 #endif … … 811 958 assert(uiCode <= 12); 812 959 813 #if H_MV960 #if NH_MV 814 961 if ( !pcSPS->getMultiLayerExtSpsFlag()) 815 962 { 816 963 #endif 817 818 819 820 821 822 823 824 READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" );825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 #if H_MV841 } 842 #endif 843 844 READ_UVLC( uiCode, "log2_min_ coding_block_size_minus3" );964 UInt subLayerOrderingInfoPresentFlag; 965 READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); 966 967 for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) 968 { 969 READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); 970 pcSPS->setMaxDecPicBuffering( uiCode + 1, i); 971 READ_UVLC ( uiCode, "sps_max_num_reorder_pics[i]" ); 972 pcSPS->setNumReorderPics(uiCode, i); 973 READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); 974 pcSPS->setMaxLatencyIncrease( uiCode, i ); 975 976 if (!subLayerOrderingInfoPresentFlag) 977 { 978 for (i++; i <= pcSPS->getMaxTLayers()-1; i++) 979 { 980 pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); 981 pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); 982 pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); 983 } 984 break; 985 } 986 } 987 #if NH_MV 988 } 989 #endif 990 991 READ_UVLC( uiCode, "log2_min_luma_coding_block_size_minus3" ); 845 992 Int log2MinCUSize = uiCode + 3; 846 993 pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); 847 READ_UVLC( uiCode, "log2_diff_max_min_ coding_block_size" );994 READ_UVLC( uiCode, "log2_diff_max_min_luma_coding_block_size" ); 848 995 pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); 849 996 850 997 if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) 851 998 { 852 999 assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); 853 1000 } 854 1001 855 1002 Int maxCUDepthDelta = uiCode; 856 pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); 1003 pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); 857 1004 pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); 858 READ_UVLC( uiCode, "log2_min_ transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 );859 860 READ_UVLC( uiCode, "log2_diff_max_min_ transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() );1005 READ_UVLC( uiCode, "log2_min_luma_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); 1006 1007 READ_UVLC( uiCode, "log2_diff_max_min_luma_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); 861 1008 pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); 862 1009 … … 865 1012 866 1013 Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); 867 pcSPS->setMax CUDepth( maxCUDepthDelta + addCuDepth );1014 pcSPS->setMaxTotalCUDepth( maxCUDepthDelta + addCuDepth + getMaxCUDepthOffset(pcSPS->getChromaFormatIdc(), pcSPS->getQuadtreeTULog2MinSize()) ); 868 1015 869 1016 READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); 870 1017 if(pcSPS->getScalingListFlag()) 871 1018 { 872 #if H_MV1019 #if NH_MV 873 1020 if ( pcSPS->getMultiLayerExtSpsFlag() ) 874 1021 { … … 883 1030 { 884 1031 #endif 885 886 887 888 parseScalingList( pcSPS->getScalingList() );889 890 #if H_MV1032 READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); 1033 if(pcSPS->getScalingListPresentFlag ()) 1034 { 1035 parseScalingList( &(pcSPS->getScalingList()) ); 1036 } 1037 #if NH_MV 891 1038 } 892 1039 #endif … … 898 1045 if( pcSPS->getUsePCM() ) 899 1046 { 900 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepth Luma (1 + uiCode );901 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepth Chroma (1 + uiCode );1047 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_LUMA, 1 + uiCode ); 1048 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_CHROMA, 1 + uiCode ); 902 1049 READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); 903 1050 READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); … … 918 1065 } 919 1066 READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); 920 if (pcSPS->getLongTermRefsPresent()) 921 { 922 READ_UVLC( uiCode, "num_long_term_ref_pic _sps" );1067 if (pcSPS->getLongTermRefsPresent()) 1068 { 1069 READ_UVLC( uiCode, "num_long_term_ref_pics_sps" ); 923 1070 pcSPS->setNumLongTermRefPicSPS(uiCode); 924 1071 for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) … … 941 1088 } 942 1089 943 944 #if H_MV945 1090 READ_FLAG( uiCode, "sps_extension_present_flag"); 1091 #if NH_MV 946 1092 pcSPS->setSpsExtensionPresentFlag( uiCode ); 947 1093 if (pcSPS->getSpsExtensionPresentFlag( ) ) 1094 { 1095 READ_FLAG( uiCode, "sps_range_extensions_flag" ); pcSPS->setSpsRangeExtensionsFlag( uiCode == 1 ); 1096 READ_FLAG( uiCode, "sps_multilayer_extension_flag" ); pcSPS->setSpsMultilayerExtensionFlag( uiCode == 1 ); 1097 READ_FLAG( uiCode , "sps_3d_extension_flag" ); pcSPS->setSps3dExtensionFlag( uiCode == 1 ); 1098 READ_CODE( 5, uiCode, "sps_extension_5bits" ) ; pcSPS->setSpsExtension5bits( uiCode ); 1099 1100 if ( pcSPS->getSpsRangeExtensionsFlag() ) 1101 { 1102 TComSPSRExt &spsRangeExtension = pcSPS->getSpsRangeExtension(); 1103 READ_FLAG( uiCode, "transform_skip_rotation_enabled_flag"); spsRangeExtension.setTransformSkipRotationEnabledFlag(uiCode != 0); 1104 READ_FLAG( uiCode, "transform_skip_context_enabled_flag"); spsRangeExtension.setTransformSkipContextEnabledFlag (uiCode != 0); 1105 READ_FLAG( uiCode, "implicit_rdpcm_enabled_flag"); spsRangeExtension.setRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT, (uiCode != 0)); 1106 READ_FLAG( uiCode, "explicit_rdpcm_enabled_flag"); spsRangeExtension.setRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT, (uiCode != 0)); 1107 READ_FLAG( uiCode, "extended_precision_processing_flag"); spsRangeExtension.setExtendedPrecisionProcessingFlag (uiCode != 0); 1108 READ_FLAG( uiCode, "intra_smoothing_disabled_flag"); spsRangeExtension.setIntraSmoothingDisabledFlag (uiCode != 0); 1109 READ_FLAG( uiCode, "high_precision_offsets_enabled_flag"); spsRangeExtension.setHighPrecisionOffsetsEnabledFlag (uiCode != 0); 1110 READ_FLAG( uiCode, "persistent_rice_adaptation_enabled_flag"); spsRangeExtension.setPersistentRiceAdaptationEnabledFlag (uiCode != 0); 1111 READ_FLAG( uiCode, "cabac_bypass_alignment_enabled_flag"); spsRangeExtension.setCabacBypassAlignmentEnabledFlag (uiCode != 0); 1112 } 1113 1114 if ( pcSPS->getSpsMultilayerExtensionFlag() ) 1115 { 1116 parseSpsMultilayerExtension( pcSPS ); 1117 } 1118 1119 if ( pcSPS->getSps3dExtensionFlag() ) 1120 { 1121 #if NH_3D 1122 parseSps3dExtension( pcSPS ); 1123 #endif 1124 } 1125 1126 #if NH_3D 1127 if ( pcSPS->getSpsExtension5bits() ) 948 1128 #else 949 READ_FLAG( uiCode, "sps_extension_flag"); 1129 if ( pcSPS->getSpsExtension5bits() || pcSPS->getSps3dExtensionFlag() ) 1130 #endif 1131 { 1132 while ( xMoreRbspData() ) 1133 { 1134 READ_FLAG( uiCode, "sps_extension_data_flag"); 1135 } 1136 } 1137 } 1138 #else 950 1139 if (uiCode) 951 #endif 952 { 953 #if H_MV 954 READ_FLAG( uiCode, "sps_range_extensions_flag" ); pcSPS->setSpsRangeExtensionsFlag( uiCode == 1 ); 955 READ_FLAG( uiCode, "sps_multilayer_extension_flag" ); pcSPS->setSpsMultilayerExtensionFlag( uiCode == 1 ); 956 #if !H_3D 957 READ_CODE( 6, uiCode, "sps_extension_6bits" ); pcSPS->setSpsExtension6bits( uiCode ); 958 #else 959 READ_FLAG( uiCode, "sps_3d_extension_flag" ); pcSPS->setSps3dExtensionFlag( uiCode == 1 ); 960 READ_CODE( 5, uiCode, "sps_extension_5bits" ); pcSPS->setSpsExtension5bits( uiCode ); 961 #endif 962 } 963 964 if ( pcSPS->getSpsRangeExtensionsFlag() ) 965 { 966 assert( 0 ); 967 } 968 969 if ( pcSPS->getSpsMultilayerExtensionFlag() ) 970 { 971 parseSPSExtension( pcSPS ); 972 } 973 974 #if H_3D 975 if ( pcSPS->getSps3dExtensionFlag() ) 976 { 977 parseSPS3dExtension( pcSPS ); 978 } 979 980 if ( pcSPS->getSpsExtension5bits() ) 981 { 982 #else 983 if ( pcSPS->getSpsExtension6bits() ) 984 { 985 #endif 986 987 #endif 988 while ( xMoreRbspData() ) 989 { 990 READ_FLAG( uiCode, "sps_extension_data_flag"); 991 } 992 } 993 } 994 995 #if H_MV 996 Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) 1140 { 1141 1142 #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS 1143 static const char *syntaxStrings[]={ "sps_range_extension_flag", 1144 "sps_multilayer_extension_flag", 1145 "sps_extension_6bits[0]", 1146 "sps_extension_6bits[1]", 1147 "sps_extension_6bits[2]", 1148 "sps_extension_6bits[3]", 1149 "sps_extension_6bits[4]", 1150 "sps_extension_6bits[5]" }; 1151 #endif 1152 Bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS]; 1153 1154 for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) 1155 { 1156 READ_FLAG( uiCode, syntaxStrings[i] ); 1157 sps_extension_flags[i] = uiCode!=0; 1158 } 1159 1160 Bool bSkipTrailingExtensionBits=false; 1161 for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. 1162 { 1163 if (sps_extension_flags[i]) 1164 { 1165 switch (SPSExtensionFlagIndex(i)) 1166 { 1167 case SPS_EXT__REXT: 1168 assert(!bSkipTrailingExtensionBits); 1169 { 1170 TComSPSRExt &spsRangeExtension = pcSPS->getSpsRangeExtension(); 1171 READ_FLAG( uiCode, "transform_skip_rotation_enabled_flag"); spsRangeExtension.setTransformSkipRotationEnabledFlag(uiCode != 0); 1172 READ_FLAG( uiCode, "transform_skip_context_enabled_flag"); spsRangeExtension.setTransformSkipContextEnabledFlag (uiCode != 0); 1173 READ_FLAG( uiCode, "implicit_rdpcm_enabled_flag"); spsRangeExtension.setRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT, (uiCode != 0)); 1174 READ_FLAG( uiCode, "explicit_rdpcm_enabled_flag"); spsRangeExtension.setRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT, (uiCode != 0)); 1175 READ_FLAG( uiCode, "extended_precision_processing_flag"); spsRangeExtension.setExtendedPrecisionProcessingFlag (uiCode != 0); 1176 READ_FLAG( uiCode, "intra_smoothing_disabled_flag"); spsRangeExtension.setIntraSmoothingDisabledFlag (uiCode != 0); 1177 READ_FLAG( uiCode, "high_precision_offsets_enabled_flag"); spsRangeExtension.setHighPrecisionOffsetsEnabledFlag (uiCode != 0); 1178 READ_FLAG( uiCode, "persistent_rice_adaptation_enabled_flag"); spsRangeExtension.setPersistentRiceAdaptationEnabledFlag (uiCode != 0); 1179 READ_FLAG( uiCode, "cabac_bypass_alignment_enabled_flag"); spsRangeExtension.setCabacBypassAlignmentEnabledFlag (uiCode != 0); 1180 } 1181 break; 1182 default: 1183 bSkipTrailingExtensionBits=true; 1184 break; 1185 } 1186 } 1187 } 1188 if (bSkipTrailingExtensionBits) 1189 { 1190 while ( xMoreRbspData() ) 1191 { 1192 READ_FLAG( uiCode, "sps_extension_data_flag"); 1193 } 1194 } 1195 } 1196 #endif 1197 xReadRbspTrailingBits(); 1198 } 1199 1200 #if NH_MV 1201 Void TDecCavlc::parseSpsMultilayerExtension( TComSPS* pcSPS ) 997 1202 { 998 1203 UInt uiCode; 999 READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false); 1000 1001 } 1002 1003 #if H_3D 1004 Void TDecCavlc::parseSPS3dExtension( TComSPS* pcSPS ) 1204 READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false); 1205 } 1206 1207 #if NH_3D 1208 Void TDecCavlc::parseSps3dExtension( TComSPS* pcSPS ) 1005 1209 { 1006 TComSps3dExtension * sps3dExt = pcSPS->getSps3dExtension();1210 TComSps3dExtension sps3dExt; 1007 1211 UInt uiCode; 1008 1212 for( Int d = 0; d <= 1; d++ ) 1009 1213 { 1010 READ_FLAG( uiCode, "iv_mv_pred_flag" ); sps3dExt ->setIvMvPredFlag( d, uiCode == 1 );1011 READ_FLAG( uiCode, "iv_mv_scaling_flag" ); sps3dExt ->setIvMvScalingFlag( d, uiCode == 1 );1214 READ_FLAG( uiCode, "iv_mv_pred_flag" ); sps3dExt.setIvMvPredFlag( d, uiCode == 1 ); 1215 READ_FLAG( uiCode, "iv_mv_scaling_flag" ); sps3dExt.setIvMvScalingFlag( d, uiCode == 1 ); 1012 1216 if( d == 0 ) 1013 1217 { 1014 READ_UVLC( uiCode, "log2_sub_pb_size_minus3" ); sps3dExt ->setLog2SubPbSizeMinus3( d, uiCode );1015 READ_FLAG( uiCode, "iv_res_pred_flag" ); sps3dExt ->setIvResPredFlag( d, uiCode == 1 );1016 READ_FLAG( uiCode, "depth_refinement_flag" ); sps3dExt ->setDepthRefinementFlag( d, uiCode == 1 );1017 READ_FLAG( uiCode, "view_synthesis_pred_flag" ); sps3dExt ->setViewSynthesisPredFlag( d, uiCode == 1 );1018 READ_FLAG( uiCode, "depth_based_blk_part_flag" ); sps3dExt ->setDepthBasedBlkPartFlag( d, uiCode == 1 );1218 READ_UVLC( uiCode, "log2_sub_pb_size_minus3" ); sps3dExt.setLog2SubPbSizeMinus3( d, uiCode ); 1219 READ_FLAG( uiCode, "iv_res_pred_flag" ); sps3dExt.setIvResPredFlag( d, uiCode == 1 ); 1220 READ_FLAG( uiCode, "depth_refinement_flag" ); sps3dExt.setDepthRefinementFlag( d, uiCode == 1 ); 1221 READ_FLAG( uiCode, "view_synthesis_pred_flag" ); sps3dExt.setViewSynthesisPredFlag( d, uiCode == 1 ); 1222 READ_FLAG( uiCode, "depth_based_blk_part_flag" ); sps3dExt.setDepthBasedBlkPartFlag( d, uiCode == 1 ); 1019 1223 } 1020 1224 else 1021 1225 { 1022 READ_FLAG( uiCode, "mpi_flag" ); sps3dExt->setMpiFlag( d, uiCode == 1 ); 1023 READ_UVLC( uiCode, "log2_mpi_sub_pb_size_minus3" ); sps3dExt->setLog2MpiSubPbSizeMinus3( d, uiCode ); 1024 READ_FLAG( uiCode, "intra_contour_flag" ); sps3dExt->setIntraContourFlag( d, uiCode == 1 ); 1025 READ_FLAG( uiCode, "intra_sdc_wedge_flag" ); sps3dExt->setIntraSdcWedgeFlag( d, uiCode == 1 ); 1026 READ_FLAG( uiCode, "qt_pred_flag" ); sps3dExt->setQtPredFlag( d, uiCode == 1 ); 1027 READ_FLAG( uiCode, "inter_sdc_flag" ); sps3dExt->setInterSdcFlag( d, uiCode == 1 ); 1028 READ_FLAG( uiCode, "intra_skip_flag" ); sps3dExt->setDepthIntraSkipFlag( d, uiCode == 1 ); 1029 } 1030 } 1031 } 1032 #endif 1033 1034 Void TDecCavlc::parsePPSMultilayerExtension(TComPPS* pcPPS) 1226 READ_FLAG( uiCode, "mpi_flag" ); sps3dExt.setMpiFlag( d, uiCode == 1 ); 1227 READ_UVLC( uiCode, "log2_mpi_sub_pb_size_minus3" ); sps3dExt.setLog2MpiSubPbSizeMinus3( d, uiCode ); 1228 READ_FLAG( uiCode, "intra_contour_flag" ); sps3dExt.setIntraContourFlag( d, uiCode == 1 ); 1229 READ_FLAG( uiCode, "intra_sdc_wedge_flag" ); sps3dExt.setIntraSdcWedgeFlag( d, uiCode == 1 ); 1230 READ_FLAG( uiCode, "qt_pred_flag" ); sps3dExt.setQtPredFlag( d, uiCode == 1 ); 1231 READ_FLAG( uiCode, "inter_sdc_flag" ); sps3dExt.setInterSdcFlag( d, uiCode == 1 ); 1232 READ_FLAG( uiCode, "intra_skip_flag" ); sps3dExt.setDepthIntraSkipFlag( d, uiCode == 1 ); 1233 } 1234 } 1235 pcSPS->setSps3dExtension( sps3dExt ); 1236 } 1237 #endif 1238 1239 Void TDecCavlc::parsePpsMultilayerExtension(TComPPS* pcPPS) 1035 1240 { 1036 1241 UInt uiCode = 0; … … 1087 1292 Void TDecCavlc::parseVPS(TComVPS* pcVPS) 1088 1293 { 1294 #if ENC_DEC_TRACE 1295 #if H_MV_ENC_DEC_TRAC 1296 tracePSHeader( "VPS", getDecTop()->getLayerId() ); 1297 #else 1298 xTraceVPSHeader (); 1299 #endif 1300 #endif 1301 1089 1302 UInt uiCode; 1090 1303 1091 1304 READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); 1092 #if H_MV1305 #if NH_MV 1093 1306 READ_FLAG( uiCode, "vps_base_layer_internal_flag" ); pcVPS->setVpsBaseLayerInternalFlag( uiCode == 1 ); 1094 1307 READ_FLAG( uiCode, "vps_base_layer_available_flag" ); pcVPS->setVpsBaseLayerAvailableFlag( uiCode == 1 ); 1095 1308 #else 1096 READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); 1097 #endif 1098 #if H_MV 1309 READ_FLAG( uiCode, "vps_base_layer_internal_flag" ); assert(uiCode == 1); 1310 READ_FLAG( uiCode, "vps_base_layer_available_flag" ); assert(uiCode == 1); 1311 #endif 1312 #if NH_MV 1099 1313 READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayersMinus1( std::min( uiCode, (UInt) ( MAX_NUM_LAYER_IDS-1) ) ); 1100 1314 #else 1101 READ_CODE( 6, uiCode, "vps_ reserved_zero_6bits" ); assert(uiCode == 0);1315 READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); 1102 1316 #endif 1103 1317 READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER); 1104 1318 READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); 1105 1319 assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); 1106 1107 READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); 1320 READ_CODE( 16, uiCode, "vps_reserved_0xffff_16bits" ); assert(uiCode == 0xffff); 1108 1321 parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); 1109 #if H_MV1322 #if NH_MV 1110 1323 pcVPS->getPTL()->inferGeneralValues ( true, 0, NULL ); 1111 1324 pcVPS->getPTL()->inferSubLayerValues( pcVPS->getMaxTLayers() - 1, 0, NULL ); … … 1115 1328 for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) 1116 1329 { 1117 READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); 1118 READ_UVLC( uiCode, "vps_ num_reorder_pics[i]" );pcVPS->setNumReorderPics( uiCode, i );1330 READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); 1331 READ_UVLC( uiCode, "vps_max_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); 1119 1332 READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); 1120 1333 … … 1132 1345 1133 1346 assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); 1134 #if H_MV1347 #if NH_MV 1135 1348 assert( pcVPS->getVpsMaxLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 ); 1136 1349 READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setVpsMaxLayerId( uiCode ); … … 1142 1355 #else 1143 1356 assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); 1144 READ_CODE( 6, uiCode, "vps_max_ nuh_reserved_zero_layer_id" );pcVPS->setMaxNuhReservedZeroLayerId( uiCode );1145 READ_UVLC( uiCode, "vps_ max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 );1357 READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); 1358 READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); 1146 1359 for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) 1147 1360 { … … 1150 1363 #endif 1151 1364 { 1152 READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); 1153 } 1154 } 1155 #if H_MV1365 READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); 1366 } 1367 } 1368 #if NH_MV 1156 1369 pcVPS->deriveLayerSetLayerIdList(); 1157 1370 #endif 1371 1158 1372 TimingInfo *timingInfo = pcVPS->getTimingInfo(); 1159 1373 READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); … … 1167 1381 READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); 1168 1382 } 1383 1169 1384 READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); 1170 1385 … … 1175 1390 for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) 1176 1391 { 1177 READ_UVLC( uiCode, "hrd_ op_set_idx" );pcVPS->setHrdOpSetIdx( uiCode, i );1392 READ_UVLC( uiCode, "hrd_layer_set_idx[i]" ); pcVPS->setHrdOpSetIdx( uiCode, i ); 1178 1393 if( i > 0 ) 1179 1394 { 1180 READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i );1395 READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); 1181 1396 } 1182 1397 else … … 1188 1403 } 1189 1404 } 1190 #if H_MV1405 #if NH_MV 1191 1406 READ_FLAG( uiCode, "vps_extension_flag" ); pcVPS->setVpsExtensionFlag( uiCode == 1 ? true : false ); 1192 1407 if ( pcVPS->getVpsExtensionFlag() ) … … 1196 1411 #endif 1197 1412 { 1198 #if H_MV1413 #if NH_MV 1199 1414 m_pcBitstream->readOutTrailingBits(); 1200 1415 parseVPSExtension( pcVPS ); … … 1202 1417 if (uiCode) 1203 1418 { 1204 #if H_3D1419 #if NH_3D 1205 1420 READ_FLAG( uiCode, "vps_3d_extension_flag" ); 1206 1421 if ( uiCode ) … … 1208 1423 m_pcBitstream->readOutTrailingBits(); 1209 1424 pcVPS->createCamPars(pcVPS->getNumViews()); 1210 parseV PS3dExtension( pcVPS );1425 parseVps3dExtension( pcVPS ); 1211 1426 } 1212 1427 READ_FLAG( uiCode, "vps_extension3_flag" ); … … 1219 1434 READ_FLAG( uiCode, "vps_extension_data_flag"); 1220 1435 } 1221 #if H_MV 1222 #if H_3D 1223 } 1224 #endif 1225 } 1226 #endif 1227 } 1228 return; 1229 } 1230 1231 #if H_MV 1436 #if NH_MV 1437 #if NH_3D 1438 } 1439 #endif 1440 } 1441 #endif 1442 } 1443 1444 xReadRbspTrailingBits(); 1445 } 1446 1447 #if NH_MV 1232 1448 Void TDecCavlc::parseVPSExtension( TComVPS* pcVPS ) 1233 1449 { … … 1306 1522 } 1307 1523 1308 #if H_3D1524 #if NH_3D 1309 1525 pcVPS->initViewCompLayer( ); 1310 1526 #endif … … 1441 1657 READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); pcVPS->setVpsNumRepFormatsMinus1( uiCode ); 1442 1658 1659 std::vector<TComRepFormat> repFormats; 1660 repFormats.resize( pcVPS->getVpsNumRepFormatsMinus1() + 1 ); 1443 1661 for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ ) 1444 { 1445 assert( pcVPS->getRepFormat(i) == NULL ); 1446 TComRepFormat* curRepFormat = new TComRepFormat(); 1447 TComRepFormat* prevRepFormat = i > 0 ? pcVPS->getRepFormat( i - 1) : NULL; 1448 parseRepFormat( i, curRepFormat , prevRepFormat); 1449 pcVPS->setRepFormat(i, curRepFormat ); 1450 } 1662 { 1663 TComRepFormat* curRepFormat = &repFormats[i]; 1664 TComRepFormat* prevRepFormat = i > 0 ? &repFormats[ i - 1] : NULL; 1665 parseRepFormat( i, curRepFormat , prevRepFormat); 1666 } 1667 pcVPS->setRepFormat( repFormats ); 1451 1668 1452 1669 if ( pcVPS->getVpsNumRepFormatsMinus1() > 0 ) … … 1514 1731 } 1515 1732 READ_FLAG( uiCode, "vps_vui_present_flag" ); pcVPS->setVpsVuiPresentFlag( uiCode == 1 ); 1733 1734 TComVPSVUI vpsVui; 1516 1735 if( pcVPS->getVpsVuiPresentFlag() ) 1517 1736 { 1518 1737 m_pcBitstream->readOutTrailingBits(); // vps_vui_alignment_bit_equal_to_one 1519 parseVPSVUI( pcVPS );1738 parseVPSVUI( pcVPS, &vpsVui ); 1520 1739 } 1521 1740 else 1522 { 1523 TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( );1524 assert( pcVPSVUI);1525 pcVPSVUI->inferVpsVui( false );1526 }1741 { 1742 // inference of syntax elements that differ from default inference (as done in constructor), when VPS VUI is not present 1743 vpsVui.setCrossLayerIrapAlignedFlag( false ); 1744 } 1745 pcVPS->setVPSVUI( vpsVui ); 1527 1746 pcVPS->checkVPSExtensionSyntax(); 1528 1747 } 1529 1748 1530 Void TDecCavlc::parseRepFormat( Int i, TComRepFormat* pcRepFormat, TComRepFormat* pcPrevRepFormat )1749 Void TDecCavlc::parseRepFormat( Int i, TComRepFormat* pcRepFormat, const TComRepFormat* pcPrevRepFormat ) 1531 1750 { 1532 1751 assert( pcRepFormat ); … … 1552 1771 else 1553 1772 { 1554 pcRepFormat->inferChromaAndBitDepth(pcPrevRepFormat , false);1773 pcRepFormat->inferChromaAndBitDepth(pcPrevRepFormat ); 1555 1774 } 1556 1775 READ_FLAG( uiCode, "conformance_window_vps_flag" ); pcRepFormat->setConformanceWindowVpsFlag( uiCode == 1 ); … … 1565 1784 1566 1785 1567 Void TDecCavlc::parseVPSVUI( TComVPS* pcVPS)1786 Void TDecCavlc::parseVPSVUI( const TComVPS* pcVPS, TComVPSVUI* vpsVui ) 1568 1787 { 1569 1788 assert( pcVPS ); 1570 1571 TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); 1572 1573 assert( pcVPSVUI ); 1789 assert( vpsVui ); 1790 1791 vpsVui->init(pcVPS->getNumAddLayerSets(),pcVPS->getMaxSubLayersMinus1() + 1, pcVPS->getMaxLayersMinus1() + 1 ); 1574 1792 1575 1793 UInt uiCode; 1576 READ_FLAG( uiCode, "cross_layer_pic_type_aligned_flag" ); pcVPSVUI->setCrossLayerPicTypeAlignedFlag( uiCode == 1 );1577 if ( ! pcVPSVUI->getCrossLayerPicTypeAlignedFlag() )1794 READ_FLAG( uiCode, "cross_layer_pic_type_aligned_flag" ); vpsVui->setCrossLayerPicTypeAlignedFlag( uiCode == 1 ); 1795 if ( !vpsVui->getCrossLayerPicTypeAlignedFlag() ) 1578 1796 { 1579 READ_FLAG( uiCode, "cross_layer_irap_aligned_flag" ); pcVPSVUI->setCrossLayerIrapAlignedFlag( uiCode == 1 );1580 } 1581 if( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) )1582 { 1583 READ_FLAG( uiCode, "all_layers_idr_aligned_flag" ); pcVPSVUI->setAllLayersIdrAlignedFlag( uiCode == 1 );1584 } 1585 READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); pcVPSVUI->setBitRatePresentVpsFlag( uiCode == 1 );1586 READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); pcVPSVUI->setPicRatePresentVpsFlag( uiCode == 1 );1587 if( pcVPSVUI->getBitRatePresentVpsFlag( ) || pcVPSVUI->getPicRatePresentVpsFlag( ) )1797 READ_FLAG( uiCode, "cross_layer_irap_aligned_flag" ); vpsVui->setCrossLayerIrapAlignedFlag( uiCode == 1 ); 1798 } 1799 if( vpsVui->getCrossLayerIrapAlignedFlag( ) ) 1800 { 1801 READ_FLAG( uiCode, "all_layers_idr_aligned_flag" ); vpsVui->setAllLayersIdrAlignedFlag( uiCode == 1 ); 1802 } 1803 READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); vpsVui->setBitRatePresentVpsFlag( uiCode == 1 ); 1804 READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); vpsVui->setPicRatePresentVpsFlag( uiCode == 1 ); 1805 if( vpsVui->getBitRatePresentVpsFlag( ) || vpsVui->getPicRatePresentVpsFlag( ) ) 1588 1806 { 1589 1807 for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i < pcVPS->getNumLayerSets(); i++ ) … … 1591 1809 for( Int j = 0; j <= pcVPS->getMaxSubLayersInLayerSetMinus1( i ); j++ ) 1592 1810 { 1593 if( pcVPSVUI->getBitRatePresentVpsFlag( ) )1594 { 1595 READ_FLAG( uiCode, "bit_rate_present_flag" ); pcVPSVUI->setBitRatePresentFlag( i, j, uiCode == 1 );1596 } 1597 if( pcVPSVUI->getPicRatePresentVpsFlag( ) )1598 { 1599 READ_FLAG( uiCode, "pic_rate_present_flag" ); pcVPSVUI->setPicRatePresentFlag( i, j, uiCode == 1 );1600 } 1601 if( pcVPSVUI->getBitRatePresentFlag( i, j ) )1602 { 1603 READ_CODE( 16, uiCode, "avg_bit_rate" ); pcVPSVUI->setAvgBitRate( i, j, uiCode );1604 READ_CODE( 16, uiCode, "max_bit_rate" ); pcVPSVUI->setMaxBitRate( i, j, uiCode );1605 } 1606 if( pcVPSVUI->getPicRatePresentFlag( i, j ) )1607 { 1608 READ_CODE( 2, uiCode, "constant_pic_rate_idc" ); pcVPSVUI->setConstantPicRateIdc( i, j, uiCode );1609 READ_CODE( 16, uiCode, "avg_pic_rate" ); pcVPSVUI->setAvgPicRate( i, j, uiCode );1610 } 1611 } 1612 } 1613 } 1614 1615 READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); pcVPSVUI->setVideoSignalInfoIdxPresentFlag( uiCode == 1 );1616 if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() )1617 { 1618 READ_CODE( 4, uiCode, "vps_num_video_signal_info_minus1" ); pcVPSVUI->setVpsNumVideoSignalInfoMinus1( uiCode );1811 if( vpsVui->getBitRatePresentVpsFlag( ) ) 1812 { 1813 READ_FLAG( uiCode, "bit_rate_present_flag" ); vpsVui->setBitRatePresentFlag( i, j, uiCode == 1 ); 1814 } 1815 if( vpsVui->getPicRatePresentVpsFlag( ) ) 1816 { 1817 READ_FLAG( uiCode, "pic_rate_present_flag" ); vpsVui->setPicRatePresentFlag( i, j, uiCode == 1 ); 1818 } 1819 if( vpsVui->getBitRatePresentFlag( i, j ) ) 1820 { 1821 READ_CODE( 16, uiCode, "avg_bit_rate" ); vpsVui->setAvgBitRate( i, j, uiCode ); 1822 READ_CODE( 16, uiCode, "max_bit_rate" ); vpsVui->setMaxBitRate( i, j, uiCode ); 1823 } 1824 if( vpsVui->getPicRatePresentFlag( i, j ) ) 1825 { 1826 READ_CODE( 2, uiCode, "constant_pic_rate_idc" ); vpsVui->setConstantPicRateIdc( i, j, uiCode ); 1827 READ_CODE( 16, uiCode, "avg_pic_rate" ); vpsVui->setAvgPicRate( i, j, uiCode ); 1828 } 1829 } 1830 } 1831 } 1832 1833 READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vpsVui->setVideoSignalInfoIdxPresentFlag( uiCode == 1 ); 1834 if( vpsVui->getVideoSignalInfoIdxPresentFlag() ) 1835 { 1836 READ_CODE( 4, uiCode, "vps_num_video_signal_info_minus1" ); vpsVui->setVpsNumVideoSignalInfoMinus1( uiCode ); 1619 1837 } 1620 1838 else 1621 1839 { 1622 pcVPSVUI->setVpsNumVideoSignalInfoMinus1( pcVPS->getMaxLayersMinus1() - pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1 ); 1623 } 1624 1625 for( Int i = 0; i <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1(); i++ ) 1626 { 1627 assert( pcVPSVUI->getVideoSignalInfo( i ) == NULL ); 1628 TComVideoSignalInfo* curVideoSignalInfo = new TComVideoSignalInfo(); 1629 parseVideoSignalInfo( curVideoSignalInfo ); 1630 pcVPSVUI->setVideoSignalInfo(i, curVideoSignalInfo ); 1631 } 1632 1633 if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 ) 1840 vpsVui->setVpsNumVideoSignalInfoMinus1( (pcVPS->getMaxLayersMinus1() - pcVPS->getVpsBaseLayerInternalFlag()) ? 0 : 1 ); 1841 } 1842 1843 std::vector<TComVideoSignalInfo> videoSignalInfos; 1844 videoSignalInfos.resize(vpsVui->getVpsNumVideoSignalInfoMinus1() + 1 ); 1845 1846 for( Int i = 0; i <= vpsVui->getVpsNumVideoSignalInfoMinus1(); i++ ) 1847 { 1848 parseVideoSignalInfo( &videoSignalInfos[i] ); 1849 } 1850 vpsVui->setVideoSignalInfo( videoSignalInfos ); 1851 1852 if( vpsVui->getVideoSignalInfoIdxPresentFlag() && vpsVui->getVpsNumVideoSignalInfoMinus1() > 0 ) 1634 1853 { 1635 1854 for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) 1636 1855 { 1637 READ_CODE( 4, uiCode, "vps_video_signal_info_idx" ); pcVPSVUI->setVpsVideoSignalInfoIdx( i, uiCode );1638 } 1639 } 1640 else if ( ! pcVPSVUI->getVideoSignalInfoIdxPresentFlag() )1856 READ_CODE( 4, uiCode, "vps_video_signal_info_idx" ); vpsVui->setVpsVideoSignalInfoIdx( i, uiCode ); 1857 } 1858 } 1859 else if ( !vpsVui->getVideoSignalInfoIdxPresentFlag() ) 1641 1860 { 1642 1861 for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) 1643 1862 { 1644 pcVPSVUI->setVpsVideoSignalInfoIdx( i, i );1863 vpsVui->setVpsVideoSignalInfoIdx( i, i ); 1645 1864 } 1646 1865 } … … 1649 1868 for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) 1650 1869 { 1651 pcVPSVUI->setVpsVideoSignalInfoIdx( i, 0 );1652 } 1653 } 1654 1655 READ_FLAG( uiCode, "tiles_not_in_use_flag" ); pcVPSVUI->setTilesNotInUseFlag( uiCode == 1 );1656 if( ! pcVPSVUI->getTilesNotInUseFlag() )1870 vpsVui->setVpsVideoSignalInfoIdx( i, 0 ); 1871 } 1872 } 1873 1874 READ_FLAG( uiCode, "tiles_not_in_use_flag" ); vpsVui->setTilesNotInUseFlag( uiCode == 1 ); 1875 if( !vpsVui->getTilesNotInUseFlag() ) 1657 1876 { 1658 1877 for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) 1659 1878 { 1660 READ_FLAG( uiCode, "tiles_in_use_flag[i]" ); pcVPSVUI->setTilesInUseFlag( i, uiCode == 1 );1661 if( pcVPSVUI->getTilesInUseFlag( i ) )1662 { 1663 READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[i]" ); pcVPSVUI->setLoopFilterNotAcrossTilesFlag( i, uiCode == 1 );1879 READ_FLAG( uiCode, "tiles_in_use_flag[i]" ); vpsVui->setTilesInUseFlag( i, uiCode == 1 ); 1880 if( vpsVui->getTilesInUseFlag( i ) ) 1881 { 1882 READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[i]" ); vpsVui->setLoopFilterNotAcrossTilesFlag( i, uiCode == 1 ); 1664 1883 } 1665 1884 } … … 1669 1888 { 1670 1889 Int layerIdx = pcVPS->getLayerIdInVps(pcVPS->getIdDirectRefLayer(pcVPS->getLayerIdInNuh( i ) , j )); 1671 if( pcVPSVUI->getTilesInUseFlag( i ) && pcVPSVUI->getTilesInUseFlag( layerIdx ) )1672 { 1673 READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); pcVPSVUI->setTileBoundariesAlignedFlag( i, j, uiCode == 1 );1890 if( vpsVui->getTilesInUseFlag( i ) && vpsVui->getTilesInUseFlag( layerIdx ) ) 1891 { 1892 READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vpsVui->setTileBoundariesAlignedFlag( i, j, uiCode == 1 ); 1674 1893 } 1675 1894 } … … 1677 1896 } 1678 1897 1679 READ_FLAG( uiCode, "wpp_not_in_use_flag" ); pcVPSVUI->setWppNotInUseFlag( uiCode == 1 );1898 READ_FLAG( uiCode, "wpp_not_in_use_flag" ); vpsVui->setWppNotInUseFlag( uiCode == 1 ); 1680 1899 1681 if( ! pcVPSVUI->getWppNotInUseFlag( ))1900 if( !vpsVui->getWppNotInUseFlag( )) 1682 1901 { 1683 1902 for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) 1684 1903 { 1685 READ_FLAG( uiCode, "wpp_in_use_flag[i]" ); pcVPSVUI->setWppInUseFlag( i, uiCode == 1 );1686 } 1687 } 1688 READ_FLAG( uiCode, "single_layer_for_non_irap_flag" ); pcVPSVUI->setSingleLayerForNonIrapFlag( uiCode == 1 );1689 READ_FLAG( uiCode, "higher_layer_irap_skip_flag" ); pcVPSVUI->setHigherLayerIrapSkipFlag( uiCode == 1 );1690 READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); pcVPSVUI->setIlpRestrictedRefLayersFlag( uiCode == 1 );1691 1692 if( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) )1904 READ_FLAG( uiCode, "wpp_in_use_flag[i]" ); vpsVui->setWppInUseFlag( i, uiCode == 1 ); 1905 } 1906 } 1907 READ_FLAG( uiCode, "single_layer_for_non_irap_flag" ); vpsVui->setSingleLayerForNonIrapFlag( uiCode == 1 ); 1908 READ_FLAG( uiCode, "higher_layer_irap_skip_flag" ); vpsVui->setHigherLayerIrapSkipFlag( uiCode == 1 ); 1909 READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); vpsVui->setIlpRestrictedRefLayersFlag( uiCode == 1 ); 1910 1911 if( vpsVui->getIlpRestrictedRefLayersFlag( ) ) 1693 1912 { 1694 1913 for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) … … 1698 1917 if( pcVPS->getVpsBaseLayerInternalFlag() || pcVPS->getIdDirectRefLayer( pcVPS->getLayerIdInNuh( i ), j ) > 0 ) 1699 1918 { 1700 READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcVPSVUI->setMinSpatialSegmentOffsetPlus1( i, j, uiCode );1701 if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 )1919 READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); vpsVui->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); 1920 if( vpsVui->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 ) 1702 1921 { 1703 READ_FLAG( uiCode, "ctu_based_offset_enabled_flag" ); pcVPSVUI->setCtuBasedOffsetEnabledFlag( i, j, uiCode == 1 );1704 if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) )1922 READ_FLAG( uiCode, "ctu_based_offset_enabled_flag" ); vpsVui->setCtuBasedOffsetEnabledFlag( i, j, uiCode == 1 ); 1923 if( vpsVui->getCtuBasedOffsetEnabledFlag( i, j ) ) 1705 1924 { 1706 READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1" ); pcVPSVUI->setMinHorizontalCtuOffsetPlus1( i, j, uiCode );1925 READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1" ); vpsVui->setMinHorizontalCtuOffsetPlus1( i, j, uiCode ); 1707 1926 } 1708 1927 } … … 1712 1931 } 1713 1932 1714 READ_FLAG( uiCode, "vps_vui_bsp_hrd_present_flag" ); pcVPSVUI->setVpsVuiBspHrdPresentFlag( uiCode == 1 );1715 if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) )1716 { 1717 assert(pcVPS->getTimingInfo()->getTimingInfoPresentFlag() == 1); 1718 parseVpsVuiBspHrdParameters( pcVPS );1933 READ_FLAG( uiCode, "vps_vui_bsp_hrd_present_flag" ); vpsVui->setVpsVuiBspHrdPresentFlag( uiCode == 1 ); 1934 if ( vpsVui->getVpsVuiBspHrdPresentFlag( ) ) 1935 { 1936 assert(pcVPS->getTimingInfo()->getTimingInfoPresentFlag() == 1); 1937 parseVpsVuiBspHrdParameters( pcVPS, vpsVui ); 1719 1938 } 1720 1939 for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) … … 1722 1941 if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i )) == 0 ) 1723 1942 { 1724 READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); pcVPSVUI->setBaseLayerParameterSetCompatibilityFlag( i, uiCode == 1 ); 1725 } 1726 } 1727 } 1728 1729 Void TDecCavlc::parseVpsVuiBspHrdParameters( TComVPS* pcVPS ) 1730 { 1731 assert( pcVPS ); 1732 1733 TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); 1734 1735 assert( pcVPSVUI ); 1736 1737 TComVpsVuiBspHrdParameters* vpsVuiBspHrdP = pcVPSVUI->getVpsVuiBspHrdParameters(); 1738 assert( vpsVuiBspHrdP == NULL ); 1739 vpsVuiBspHrdP = new TComVpsVuiBspHrdParameters; 1740 pcVPSVUI->setVpsVuiBspHrdParameters( vpsVuiBspHrdP ); 1943 READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); vpsVui->setBaseLayerParameterSetCompatibilityFlag( i, uiCode == 1 ); 1944 } 1945 } 1946 } 1947 1948 Void TDecCavlc::parseVpsVuiBspHrdParameters( const TComVPS* pcVPS, TComVPSVUI* vpsVui ) 1949 { 1950 assert( pcVPS ); 1951 assert( vpsVui ); 1952 1953 TComVpsVuiBspHrdParameters vpsVuiBspHrdP; 1954 1741 1955 UInt uiCode; 1742 READ_UVLC( uiCode, "vps_num_add_hrd_params" ); vpsVuiBspHrdP ->setVpsNumAddHrdParams( uiCode );1743 vpsVuiBspHrdP ->createAfterVpsNumAddHrdParams( pcVPS );1744 for( Int i = pcVPS->getNumHrdParameters(); i < pcVPS->getNumHrdParameters() + vpsVuiBspHrdP ->getVpsNumAddHrdParams(); i++ )1956 READ_UVLC( uiCode, "vps_num_add_hrd_params" ); vpsVuiBspHrdP.setVpsNumAddHrdParams( uiCode ); 1957 vpsVuiBspHrdP.createAfterVpsNumAddHrdParams( pcVPS ); 1958 for( Int i = pcVPS->getNumHrdParameters(); i < pcVPS->getNumHrdParameters() + vpsVuiBspHrdP.getVpsNumAddHrdParams(); i++ ) 1745 1959 { 1746 1960 if( i > 0 ) 1747 1961 { 1748 READ_FLAG( uiCode, "cprms_add_present_flag" ); vpsVuiBspHrdP ->setCprmsAddPresentFlag( i, uiCode == 1 );1962 READ_FLAG( uiCode, "cprms_add_present_flag" ); vpsVuiBspHrdP.setCprmsAddPresentFlag( i, uiCode == 1 ); 1749 1963 } 1750 1964 else 1751 1965 { 1752 vpsVuiBspHrdP->setCprmsAddPresentFlag( i, true ); 1753 } 1754 1755 READ_UVLC( uiCode, "num_sub_layer_hrd_minus1" ); vpsVuiBspHrdP->setNumSubLayerHrdMinus1( i, uiCode ); 1756 TComHRD* hrdParameters = vpsVuiBspHrdP->getHrdParametermeters( i ); 1757 parseHrdParameters( hrdParameters, vpsVuiBspHrdP->getCprmsAddPresentFlag( i ), vpsVuiBspHrdP->getNumSubLayerHrdMinus1( i ) ); 1758 } 1759 1760 vpsVuiBspHrdP->setNumPartitionsInSchemeMinus1( 0, 0, 0); 1761 vpsVuiBspHrdP->createAfterNumPartitionsInSchemeMinus1( 0, 0 ); 1966 vpsVuiBspHrdP.setCprmsAddPresentFlag( i, true ); 1967 } 1968 1969 READ_UVLC( uiCode, "num_sub_layer_hrd_minus1" ); vpsVuiBspHrdP.setNumSubLayerHrdMinus1( i, uiCode ); 1970 1971 TComHRD hrdParameters; 1972 parseHrdParameters( &hrdParameters, vpsVuiBspHrdP.getCprmsAddPresentFlag( i ), vpsVuiBspHrdP.getNumSubLayerHrdMinus1( i ) ); 1973 vpsVuiBspHrdP.setHrdParametermeters( i, hrdParameters ); 1974 } 1975 1976 vpsVuiBspHrdP.setNumPartitionsInSchemeMinus1( 0, 0, 0); 1977 vpsVuiBspHrdP.createAfterNumPartitionsInSchemeMinus1( pcVPS, 0, 0 ); 1762 1978 1763 1979 for( Int h = 0; h < pcVPS->getNumOutputLayerSets(); h++ ) … … 1765 1981 if ( h == 0) 1766 1982 { 1767 vpsVuiBspHrdP ->setNumSignalledPartitioningSchemes( h, 0 );1983 vpsVuiBspHrdP.setNumSignalledPartitioningSchemes( h, 0 ); 1768 1984 } 1769 1985 else 1770 1986 { 1771 READ_UVLC( uiCode, "num_signalled_partitioning_schemes" ); vpsVuiBspHrdP ->setNumSignalledPartitioningSchemes( h, uiCode );1987 READ_UVLC( uiCode, "num_signalled_partitioning_schemes" ); vpsVuiBspHrdP.setNumSignalledPartitioningSchemes( h, uiCode ); 1772 1988 } 1773 vpsVuiBspHrdP ->createAfterNumSignalledPartitioningSchemes(h );1774 1775 for( Int j = 0; j < vpsVuiBspHrdP ->getNumSignalledPartitioningSchemes( h ) + 1; j++ )1989 vpsVuiBspHrdP.createAfterNumSignalledPartitioningSchemes( pcVPS, h ); 1990 1991 for( Int j = 0; j < vpsVuiBspHrdP.getNumSignalledPartitioningSchemes( h ) + 1; j++ ) 1776 1992 { 1777 1993 if ( j == 0 && h == 0 ) 1778 1994 { 1779 vpsVuiBspHrdP ->setNumPartitionsInSchemeMinus1( h, j, uiCode );1995 vpsVuiBspHrdP.setNumPartitionsInSchemeMinus1( h, j, uiCode ); 1780 1996 } 1781 1997 else if( j == 0 ) 1782 1998 { 1783 vpsVuiBspHrdP ->setNumPartitionsInSchemeMinus1( h, j, pcVPS->getNumLayersInIdList( h ) - 1 );1999 vpsVuiBspHrdP.setNumPartitionsInSchemeMinus1( h, j, pcVPS->getNumLayersInIdList( h ) - 1 ); 1784 2000 } 1785 2001 else 1786 2002 { 1787 READ_UVLC( uiCode, "num_partitions_in_scheme_minus1" ); vpsVuiBspHrdP ->setNumPartitionsInSchemeMinus1( h, j, uiCode );1788 } 1789 vpsVuiBspHrdP ->createAfterNumPartitionsInSchemeMinus1(h, j );1790 1791 for( Int k = 0; k <= vpsVuiBspHrdP ->getNumPartitionsInSchemeMinus1( h, j ); k++ )2003 READ_UVLC( uiCode, "num_partitions_in_scheme_minus1" ); vpsVuiBspHrdP.setNumPartitionsInSchemeMinus1( h, j, uiCode ); 2004 } 2005 vpsVuiBspHrdP.createAfterNumPartitionsInSchemeMinus1(pcVPS, h, j ); 2006 2007 for( Int k = 0; k <= vpsVuiBspHrdP.getNumPartitionsInSchemeMinus1( h, j ); k++ ) 1792 2008 { 1793 2009 for( Int r = 0; r < pcVPS->getNumLayersInIdList(pcVPS->olsIdxToLsIdx( h ) ) ; r++ ) … … 1795 2011 if( h == 0 && j == 0 && k == 0 && r == 0 ) 1796 2012 { 1797 vpsVuiBspHrdP ->setLayerIncludedInPartitionFlag( h, j, k, r, true );2013 vpsVuiBspHrdP.setLayerIncludedInPartitionFlag( h, j, k, r, true ); 1798 2014 } 1799 2015 else if ( h > 0 && j == 0 ) 1800 2016 { 1801 vpsVuiBspHrdP ->setLayerIncludedInPartitionFlag( h, j, k, r, (k == r) );2017 vpsVuiBspHrdP.setLayerIncludedInPartitionFlag( h, j, k, r, (k == r) ); 1802 2018 } 1803 2019 else 1804 2020 { 1805 READ_FLAG( uiCode, "layer_included_in_partition_flag" ); vpsVuiBspHrdP ->setLayerIncludedInPartitionFlag( h, j, k, r, uiCode == 1 );2021 READ_FLAG( uiCode, "layer_included_in_partition_flag" ); vpsVuiBspHrdP.setLayerIncludedInPartitionFlag( h, j, k, r, uiCode == 1 ); 1806 2022 } 1807 2023 } … … 1810 2026 if ( h > 0 ) 1811 2027 { 1812 for( Int i = 0; i < vpsVuiBspHrdP ->getNumSignalledPartitioningSchemes( h ) + 1; i++ )2028 for( Int i = 0; i < vpsVuiBspHrdP.getNumSignalledPartitioningSchemes( h ) + 1; i++ ) 1813 2029 { 1814 2030 for( Int t = 0; t <= pcVPS->getMaxSubLayersInLayerSetMinus1( pcVPS->olsIdxToLsIdx( i ) ); t++ ) 1815 2031 { 1816 READ_UVLC( uiCode, "num_bsp_schedules_minus1" ); vpsVuiBspHrdP ->setNumBspSchedulesMinus1( h, i, t, uiCode );1817 vpsVuiBspHrdP ->createAfterNumBspSchedulesMinus1(h, i, t );1818 for( Int j = 0; j <= vpsVuiBspHrdP ->getNumBspSchedulesMinus1( h, i, t ); j++ )2032 READ_UVLC( uiCode, "num_bsp_schedules_minus1" ); vpsVuiBspHrdP.setNumBspSchedulesMinus1( h, i, t, uiCode ); 2033 vpsVuiBspHrdP.createAfterNumBspSchedulesMinus1(pcVPS, h, i, t ); 2034 for( Int j = 0; j <= vpsVuiBspHrdP.getNumBspSchedulesMinus1( h, i, t ); j++ ) 1819 2035 { 1820 for( Int k = 0; k <= vpsVuiBspHrdP ->getNumPartitionsInSchemeMinus1( h, j ); k++ )2036 for( Int k = 0; k <= vpsVuiBspHrdP.getNumPartitionsInSchemeMinus1( h, j ); k++ ) 1821 2037 { 1822 READ_CODE( vpsVuiBspHrdP ->getBspHrdIdxLen( pcVPS ), uiCode, "bsp_hrd_idx" ); vpsVuiBspHrdP->setBspHrdIdx( h, i, t, j, k, uiCode );1823 READ_UVLC( uiCode, "bsp_sched_idx" ); vpsVuiBspHrdP ->setBspSchedIdx( h, i, t, j, k, uiCode );2038 READ_CODE( vpsVuiBspHrdP.getBspHrdIdxLen( pcVPS ), uiCode, "bsp_hrd_idx" ); vpsVuiBspHrdP.setBspHrdIdx( h, i, t, j, k, uiCode ); 2039 READ_UVLC( uiCode, "bsp_sched_idx" ); vpsVuiBspHrdP.setBspSchedIdx( h, i, t, j, k, uiCode ); 1824 2040 } 1825 2041 } … … 1828 2044 } 1829 2045 } 2046 vpsVui->setVpsVuiBspHrdParameters( vpsVuiBspHrdP ); 1830 2047 } 1831 2048 … … 1843 2060 { 1844 2061 UInt uiCode; 1845 TComDpbSize* dpbSize = vps->getDpbSize(); 1846 assert ( dpbSize != 0 ); 2062 TComDpbSize dpbSize; 2063 2064 dpbSize.init( vps->getNumOutputLayerSets(), vps->getVpsMaxLayerId() + 1, vps->getMaxSubLayersMinus1() + 1 ) ; 1847 2065 1848 2066 for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ ) 1849 2067 { 1850 2068 Int currLsIdx = vps->olsIdxToLsIdx( i ); 1851 READ_FLAG( uiCode, "sub_layer_flag_info_present_flag" ); dpbSize ->setSubLayerFlagInfoPresentFlag( i, uiCode == 1 );2069 READ_FLAG( uiCode, "sub_layer_flag_info_present_flag" ); dpbSize.setSubLayerFlagInfoPresentFlag( i, uiCode == 1 ); 1852 2070 for( Int j = 0; j <= vps->getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ ) 1853 2071 { 1854 if( j > 0 && dpbSize ->getSubLayerDpbInfoPresentFlag( i, j ) )1855 { 1856 READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag" ); dpbSize ->setSubLayerDpbInfoPresentFlag( i, j, uiCode == 1 );1857 } 1858 if( dpbSize ->getSubLayerDpbInfoPresentFlag( i, j ) )2072 if( j > 0 && dpbSize.getSubLayerDpbInfoPresentFlag( i, j ) ) 2073 { 2074 READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag" ); dpbSize.setSubLayerDpbInfoPresentFlag( i, j, uiCode == 1 ); 2075 } 2076 if( dpbSize.getSubLayerDpbInfoPresentFlag( i, j ) ) 1859 2077 { 1860 2078 for( Int k = 0; k < vps->getNumLayersInIdList( currLsIdx ); k++ ) … … 1862 2080 if ( vps->getNecessaryLayerFlag( i, k ) && ( vps->getVpsBaseLayerInternalFlag() || ( vps->getLayerSetLayerIdList(vps->olsIdxToLsIdx(i),k) != 0 ) )) 1863 2081 { 1864 READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1" ); dpbSize ->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode );2082 READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1" ); dpbSize.setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode ); 1865 2083 } 1866 2084 else … … 1868 2086 if ( vps->getNecessaryLayerFlag( i, k ) && ( j == 0 ) && ( k == 0 )) 1869 2087 { 1870 dpbSize ->setMaxVpsDecPicBufferingMinus1(i ,k, j, 0 );2088 dpbSize.setMaxVpsDecPicBufferingMinus1(i ,k, j, 0 ); 1871 2089 } 1872 2090 } 1873 2091 } 1874 READ_UVLC( uiCode, "max_vps_num_reorder_pics" ); dpbSize ->setMaxVpsNumReorderPics( i, j, uiCode );1875 READ_UVLC( uiCode, "max_vps_latency_increase_plus1" ); dpbSize ->setMaxVpsLatencyIncreasePlus1( i, j, uiCode );2092 READ_UVLC( uiCode, "max_vps_num_reorder_pics" ); dpbSize.setMaxVpsNumReorderPics( i, j, uiCode ); 2093 READ_UVLC( uiCode, "max_vps_latency_increase_plus1" ); dpbSize.setMaxVpsLatencyIncreasePlus1( i, j, uiCode ); 1876 2094 } 1877 2095 else … … 1883 2101 if ( vps->getNecessaryLayerFlag(i, k ) ) 1884 2102 { 1885 dpbSize ->setMaxVpsDecPicBufferingMinus1( i, k, j, dpbSize->getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) );2103 dpbSize.setMaxVpsDecPicBufferingMinus1( i, k, j, dpbSize.getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) ); 1886 2104 } 1887 2105 } 1888 dpbSize ->setMaxVpsNumReorderPics ( i, j, dpbSize->getMaxVpsNumReorderPics ( i, j - 1 ) );1889 dpbSize ->setMaxVpsLatencyIncreasePlus1( i, j, dpbSize->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) );2106 dpbSize.setMaxVpsNumReorderPics ( i, j, dpbSize.getMaxVpsNumReorderPics ( i, j - 1 ) ); 2107 dpbSize.setMaxVpsLatencyIncreasePlus1( i, j, dpbSize.getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); 1890 2108 } 1891 2109 } 1892 2110 } 1893 2111 } 1894 } 1895 1896 #if H_3D 1897 Void TDecCavlc::parseVPS3dExtension( TComVPS* pcVPS ) 2112 vps->setDpbSize( dpbSize ); 2113 } 2114 2115 #if NH_3D 2116 Void TDecCavlc::parseVps3dExtension( TComVPS* pcVPS ) 1898 2117 { 1899 2118 UInt uiCode; … … 1929 2148 #endif 1930 2149 #endif 1931 #if H_MV 1932 Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, Int targetOlsIdx) 1933 #else 1934 Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) 1935 #endif 2150 2151 Void TDecCavlc::parseSliceHeader (TComSlice* pcSlice, ParameterSetManager *parameterSetManager, const Int prevTid0POC) 1936 2152 { 1937 2153 UInt uiCode; … … 1939 2155 1940 2156 #if ENC_DEC_TRACE 1941 xTraceSliceHeader(rpcSlice); 2157 #if NH_MV 2158 tracePSHeader( "Slice", pcSlice->getLayerId() ); 2159 #else 2160 xTraceSliceHeader(); 2161 #endif 1942 2162 #endif 1943 2163 TComPPS* pps = NULL; 1944 2164 TComSPS* sps = NULL; 1945 #if H_MV2165 #if NH_MV 1946 2166 TComVPS* vps = NULL; 1947 2167 #endif … … 1949 2169 UInt firstSliceSegmentInPic; 1950 2170 READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); 1951 if( rpcSlice->getRapPicFlag())1952 { 2171 if( pcSlice->getRapPicFlag()) 2172 { 1953 2173 READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already 1954 #if SETTING_NO_OUT_PIC_PRIOR 1955 rpcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); 1956 #else 1957 rpcSlice->setNoOutputPicPrior( false ); 1958 #endif 1959 } 1960 1961 READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); 1962 pps = parameterSetManager->getPrefetchedPPS(uiCode); 2174 pcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); 2175 } 2176 READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); pcSlice->setPPSId(uiCode); 2177 pps = parameterSetManager->getPPS(uiCode); 1963 2178 //!KS: need to add error handling code here, if PPS is not available 1964 2179 assert(pps!=0); 1965 sps = parameterSetManager->get PrefetchedSPS(pps->getSPSId());2180 sps = parameterSetManager->getSPS(pps->getSPSId()); 1966 2181 //!KS: need to add error handling code here, if SPS is not available 1967 2182 assert(sps!=0); 1968 #if H_MV 1969 vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId()); 1970 assert( vps != NULL ); 1971 1972 sps->inferRepFormat ( vps , rpcSlice->getLayerId() ); 2183 #if NH_MV 2184 vps = parameterSetManager->getVPS(sps->getVPSId()); 2185 assert( vps != NULL ); 2186 m_decTop->initFromActiveVps( vps ); 2187 Int targetOlsIdx = m_decTop->getTargetOlsIdx(); 2188 2189 // Do inference 2190 sps->inferRepFormat ( vps , pcSlice->getLayerId(), false ); 1973 2191 sps->inferScalingList( parameterSetManager->getActiveSPS( sps->getSpsScalingListRefLayerId() ) ); 1974 sps->inferSpsMaxDecPicBufferingMinus1( vps, targetOlsIdx, rpcSlice->getLayerId(), false ); 2192 sps->inferSpsMaxDecPicBufferingMinus1( vps, targetOlsIdx, pcSlice->getLayerId(), false ); 2193 2194 if( sps->getMultiLayerExtSpsFlag() ) 2195 { 2196 sps->setTemporalIdNestingFlag( (sps->getMaxTLayers() > 1) ? vps->getTemporalNestingFlag() : true ); 2197 } 1975 2198 1976 2199 if ( sps->getVuiParametersPresentFlag() ) 1977 2200 { 1978 sps->getVuiParameters()->inferVideoSignalInfo( vps, rpcSlice->getLayerId() ); 1979 } 1980 rpcSlice->setVPS(vps); 1981 rpcSlice->setViewId ( vps->getViewId ( rpcSlice->getLayerId() ) ); 1982 rpcSlice->setViewIndex( vps->getViewIndex( rpcSlice->getLayerId() ) ); 1983 #if H_3D 1984 rpcSlice->setIsDepth ( vps->getDepthId ( rpcSlice->getLayerId() ) == 1 ); 1985 #endif 1986 #endif 1987 rpcSlice->setSPS(sps); 1988 rpcSlice->setPPS(pps); 2201 sps->getVuiParameters()->inferVideoSignalInfo( vps, pcSlice->getLayerId() ); 2202 } 2203 2204 2205 pcSlice->setVPS(vps); 2206 pcSlice->setSPS(sps); 2207 pcSlice->setPPS(pps); 2208 2209 pcSlice->setViewId ( vps->getViewId ( pcSlice->getLayerId() ) ); 2210 pcSlice->setViewIndex( vps->getViewIndex( pcSlice->getLayerId() ) ); 2211 #if NH_3D 2212 pcSlice->setIsDepth ( vps->getDepthId ( pcSlice->getLayerId() ) == 1 ); 2213 #endif 2214 #endif 2215 2216 const ChromaFormat chFmt = sps->getChromaFormatIdc(); 2217 const UInt numValidComp=getNumberValidComponents(chFmt); 2218 const Bool bChroma=(chFmt!=CHROMA_400); 2219 1989 2220 if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) 1990 2221 { 1991 READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false);2222 READ_FLAG( uiCode, "dependent_slice_segment_flag" ); pcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); 1992 2223 } 1993 2224 else 1994 2225 { 1995 rpcSlice->setDependentSliceSegmentFlag(false);2226 pcSlice->setDependentSliceSegmentFlag(false); 1996 2227 } 1997 2228 Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); 1998 Int maxParts = (1<<(sps->getMaxCUDepth()<<1));1999 2229 UInt sliceSegmentAddress = 0; 2000 2230 Int bitsSliceSegmentAddress = 0; … … 2009 2239 } 2010 2240 //set uiCode to equal slice start address (or dependent slice start address) 2011 Int startCuAddress = maxParts*sliceSegmentAddress; 2012 rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); 2013 rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); 2014 2015 if (rpcSlice->getDependentSliceSegmentFlag()) 2016 { 2017 rpcSlice->setNextSlice ( false ); 2018 rpcSlice->setNextSliceSegment ( true ); 2019 } 2020 else 2021 { 2022 rpcSlice->setNextSlice ( true ); 2023 rpcSlice->setNextSliceSegment ( false ); 2024 2025 rpcSlice->setSliceCurStartCUAddr(startCuAddress); 2026 rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); 2027 } 2028 2029 #if H_MV 2241 pcSlice->setSliceSegmentCurStartCtuTsAddr( sliceSegmentAddress );// this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet. 2242 pcSlice->setSliceSegmentCurEndCtuTsAddr(numCTUs); // Set end as the last CTU of the picture. 2243 2244 #if NH_MV 2030 2245 UInt slicePicOrderCntLsb = 0; 2031 2246 #endif 2032 2247 2033 if(!rpcSlice->getDependentSliceSegmentFlag()) 2034 { 2035 #if H_MV 2248 2249 if (!pcSlice->getDependentSliceSegmentFlag()) 2250 { 2251 pcSlice->setSliceCurStartCtuTsAddr(sliceSegmentAddress); // this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet. 2252 pcSlice->setSliceCurEndCtuTsAddr(numCTUs); 2253 } 2254 2255 if(!pcSlice->getDependentSliceSegmentFlag()) 2256 { 2257 #if NH_MV 2036 2258 Int esb = 0; //Don't use i, otherwise will shadow something below 2037 2259 2038 if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )2260 if ( pps->getNumExtraSliceHeaderBits() > esb ) 2039 2261 { 2040 2262 esb++; 2041 READ_FLAG( uiCode, "discardable_flag" ); rpcSlice->setDiscardableFlag( uiCode == 1 );2263 READ_FLAG( uiCode, "discardable_flag" ); pcSlice->setDiscardableFlag( uiCode == 1 ); 2042 2264 if ( uiCode == 1 ) 2043 2265 { 2044 assert( rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R &&2045 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R &&2046 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R &&2047 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R &&2048 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R);2049 } 2050 } 2051 2052 if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )2266 assert(pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && 2267 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && 2268 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && 2269 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && 2270 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); 2271 } 2272 } 2273 2274 if ( pps->getNumExtraSliceHeaderBits() > esb ) 2053 2275 { 2054 2276 esb++; 2055 READ_FLAG( uiCode, "cross_layer_bla_flag" ); rpcSlice->setCrossLayerBlaFlag( uiCode == 1 );2056 } 2057 rpcSlice->checkCrossLayerBlaFlag( );2058 2059 2060 for (; esb < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++)2277 READ_FLAG( uiCode, "cross_layer_bla_flag" ); pcSlice->setCrossLayerBlaFlag( uiCode == 1 ); 2278 } 2279 pcSlice->checkCrossLayerBlaFlag( ); 2280 2281 2282 for (; esb < pps->getNumExtraSliceHeaderBits(); esb++) 2061 2283 #else 2062 for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)2063 #endif 2064 { 2065 READ_FLAG(uiCode, "slice_reserved_ undetermined_flag[]"); // ignored2066 } 2067 2068 READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode);2284 for (Int i = 0; i < pps->getNumExtraSliceHeaderBits(); i++) 2285 #endif 2286 { 2287 READ_FLAG(uiCode, "slice_reserved_flag[]"); // ignored 2288 } 2289 2290 READ_UVLC ( uiCode, "slice_type" ); pcSlice->setSliceType((SliceType)uiCode); 2069 2291 if( pps->getOutputFlagPresentFlag() ) 2070 2292 { 2071 READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false );2293 READ_FLAG( uiCode, "pic_output_flag" ); pcSlice->setPicOutputFlag( uiCode ? true : false ); 2072 2294 } 2073 2295 else 2074 2296 { 2075 rpcSlice->setPicOutputFlag( true ); 2076 } 2077 // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present 2078 2079 #if H_3D_DISABLE_CHROMA 2080 assert (sps->getChromaFormatIdc() == 1 || rpcSlice->getIsDepth() ); 2081 assert (sps->getChromaFormatIdc() == 0 || !rpcSlice->getIsDepth() ); 2082 #else 2083 assert (sps->getChromaFormatIdc() == 1 ); 2084 #endif 2085 // if( separate_colour_plane_flag == 1 ) 2086 // colour_plane_id u(2) 2087 2088 2089 #if H_MV 2297 pcSlice->setPicOutputFlag( true ); 2298 } 2299 2300 // if (separate_colour_plane_flag == 1) 2301 // read colour_plane_id 2302 // (separate_colour_plane_flag == 1) is not supported in this version of the standard. 2303 2304 #if NH_MV 2090 2305 Int iPOClsb = slicePicOrderCntLsb; // Needed later 2091 if ( ( rpcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( rpcSlice->getLayerIdInVps())) || !rpcSlice->getIdrPicFlag() )2306 if ( (pcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( pcSlice->getLayerIdInVps())) || !pcSlice->getIdrPicFlag() ) 2092 2307 { 2093 2308 READ_CODE(sps->getBitsForPOC(), slicePicOrderCntLsb, "slice_pic_order_cnt_lsb"); 2094 2309 } 2095 rpcSlice->setSlicePicOrderCntLsb( slicePicOrderCntLsb );2310 pcSlice->setSlicePicOrderCntLsb( slicePicOrderCntLsb ); 2096 2311 2097 2312 Bool picOrderCntMSBZeroFlag = false; 2098 2313 2099 2314 // as in HM code. However are all cases for IRAP picture with NoRaslOutputFlag equal to 1 covered?? 2100 picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP );2101 picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL );2102 picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP );2103 picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || rpcSlice->getIdrPicFlag();2315 picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP ); 2316 picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ); 2317 picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ); 2318 picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || pcSlice->getIdrPicFlag(); 2104 2319 2105 2320 // TBD picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getLayerId() > 0 && !rpcSlice->getFirstPicInLayerDecodedFlag() ); … … 2109 2324 if ( !picOrderCntMSBZeroFlag ) 2110 2325 { 2111 Int prevPicOrderCnt = rpcSlice->getPrevTid0POC();2326 Int prevPicOrderCnt = prevTid0POC; 2112 2327 Int maxPicOrderCntLsb = 1 << sps->getBitsForPOC(); 2113 2328 Int prevPicOrderCntLsb = prevPicOrderCnt & (maxPicOrderCntLsb - 1); … … 2128 2343 } 2129 2344 2130 rpcSlice->setPOC( picOrderCntMSB + slicePicOrderCntLsb );2131 if ( rpcSlice->getPocResetFlag() )2132 { 2133 rpcSlice->setPocBeforeReset ( rpcSlice->getPOC() );2134 rpcSlice->setPOC ( 0 );2345 pcSlice->setPOC( picOrderCntMSB + slicePicOrderCntLsb ); 2346 if ( pcSlice->getPocResetFlag() ) 2347 { 2348 pcSlice->setPocBeforeReset ( pcSlice->getPOC() ); 2349 pcSlice->setPOC ( 0 ); 2135 2350 } 2136 2351 #endif 2137 2352 2138 if( rpcSlice->getIdrPicFlag() ) 2139 { 2140 #if !H_MV 2141 rpcSlice->setPOC(0); 2142 #endif 2143 TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); 2144 rps->setNumberOfNegativePictures(0); 2145 rps->setNumberOfPositivePictures(0); 2146 rps->setNumberOfLongtermPictures(0); 2147 rps->setNumberOfPictures(0); 2148 rpcSlice->setRPS(rps); 2149 #if H_MV 2150 rpcSlice->setEnableTMVPFlag(false); 2353 if( pcSlice->getIdrPicFlag() ) 2354 { 2355 #if !NH_MV 2356 pcSlice->setPOC(0); 2357 #endif 2358 TComReferencePictureSet* rps = pcSlice->getLocalRPS(); 2359 (*rps)=TComReferencePictureSet(); 2360 pcSlice->setRPS(rps); 2361 #if NH_MV 2362 pcSlice->setEnableTMVPFlag(false); 2151 2363 #endif 2152 2364 } 2153 2365 else 2154 2366 { 2155 #if ! H_MV2156 READ_CODE(sps->getBitsForPOC(), uiCode, " pic_order_cnt_lsb");2367 #if !NH_MV 2368 READ_CODE(sps->getBitsForPOC(), uiCode, "slice_pic_order_cnt_lsb"); 2157 2369 Int iPOClsb = uiCode; 2158 Int iPrevPOC = rpcSlice->getPrevTid0POC();2370 Int iPrevPOC = prevTid0POC; 2159 2371 Int iMaxPOClsb = 1<< sps->getBitsForPOC(); 2160 2372 Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); … … 2165 2377 iPOCmsb = iPrevPOCmsb + iMaxPOClsb; 2166 2378 } 2167 else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) 2379 else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) 2168 2380 { 2169 2381 iPOCmsb = iPrevPOCmsb - iMaxPOClsb; … … 2173 2385 iPOCmsb = iPrevPOCmsb; 2174 2386 } 2175 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP2176 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL2177 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )2387 if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 2388 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 2389 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 2178 2390 { 2179 2391 // For BLA picture types, POCmsb is set to 0. 2180 2392 iPOCmsb = 0; 2181 2393 } 2182 rpcSlice->setPOC (iPOCmsb+iPOClsb);2394 pcSlice->setPOC (iPOCmsb+iPOClsb); 2183 2395 #endif 2184 2396 TComReferencePictureSet* rps; 2185 rps = rpcSlice->getLocalRPS(); 2186 rpcSlice->setRPS(rps); 2397 rps = pcSlice->getLocalRPS(); 2398 (*rps)=TComReferencePictureSet(); 2399 2400 pcSlice->setRPS(rps); 2187 2401 READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); 2188 2402 if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header 2189 { 2403 { 2190 2404 parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); 2191 #if H_MV2405 #if NH_MV 2192 2406 if ( !rps->getInterRPSPrediction( ) ) 2193 2407 { // check sum of num_positive_pics and num_negative_pics … … 2195 2409 vps->getVpsExtensionFlag(), 2196 2410 MAX_INT, // To be replaced by MaxDbpSize 2197 rpcSlice->getLayerId(),2411 pcSlice->getLayerId(), 2198 2412 sps->getMaxDecPicBuffering( sps->getSpsMaxSubLayersMinus1() ) - 1 ); 2199 2413 } 2200 2414 #endif 2415 2201 2416 } 2202 2417 else // use reference to short-term reference picture set in PPS 2203 2418 { 2204 2419 Int numBits = 0; 2205 while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets())2420 while ((1 << numBits) < sps->getRPSList()->getNumberOfReferencePictureSets()) 2206 2421 { 2207 2422 numBits++; … … 2214 2429 { 2215 2430 uiCode = 0; 2431 2216 2432 } 2217 2433 *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); … … 2222 2438 UInt numOfLtrp = 0; 2223 2439 UInt numLtrpInSPS = 0; 2224 if ( rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0)2440 if (sps->getNumLongTermRefPicSPS() > 0) 2225 2441 { 2226 2442 READ_UVLC( uiCode, "num_long_term_sps"); … … 2230 2446 } 2231 2447 Int bitsForLtrpInSPS = 0; 2232 while ( rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS))2448 while (sps->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) 2233 2449 { 2234 2450 bitsForLtrpInSPS++; … … 2237 2453 numOfLtrp += uiCode; 2238 2454 rps->setNumberOfLongtermPictures(numOfLtrp); 2239 Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC();2240 Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0; ;2455 Int maxPicOrderCntLSB = 1 << sps->getBitsForPOC(); 2456 Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0; 2241 2457 for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) 2242 2458 { … … 2249 2465 READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); 2250 2466 } 2251 Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode);2252 2253 pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode);2467 Bool usedByCurrFromSPS=sps->getUsedByCurrPicLtSPSFlag(uiCode); 2468 2469 pocLsbLt = sps->getLtRefPicPocLsbSps(uiCode); 2254 2470 rps->setUsed(j,usedByCurrFromSPS); 2255 2471 } 2256 2472 else 2257 2473 { 2258 READ_CODE( rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode;2474 READ_CODE(sps->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; 2259 2475 READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); 2260 2476 } 2261 2477 READ_FLAG(uiCode,"delta_poc_msb_present_flag"); 2262 2478 Bool mSBPresentFlag = uiCode ? true : false; 2263 if(mSBPresentFlag) 2479 if(mSBPresentFlag) 2264 2480 { 2265 2481 READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); … … 2276 2492 else 2277 2493 { 2278 deltaPocMSBCycleLT = uiCode + prevDeltaMSB; 2494 deltaPocMSBCycleLT = uiCode + prevDeltaMSB; 2279 2495 } 2280 2496 2281 Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB2497 Int pocLTCurr = pcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB 2282 2498 - iPOClsb + pocLsbLt; 2283 rps->setPOC (j, pocLTCurr); 2284 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr);2285 rps->setCheckLTMSBPresent(j,true); 2499 rps->setPOC (j, pocLTCurr); 2500 rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLTCurr); 2501 rps->setCheckLTMSBPresent(j,true); 2286 2502 } 2287 2503 else 2288 2504 { 2289 2505 rps->setPOC (j, pocLsbLt); 2290 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt);2291 rps->setCheckLTMSBPresent(j,false); 2292 2506 rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLsbLt); 2507 rps->setCheckLTMSBPresent(j,false); 2508 2293 2509 // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present 2294 2510 if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) … … 2300 2516 } 2301 2517 offset += rps->getNumberOfLongtermPictures(); 2302 rps->setNumberOfPictures(offset); 2303 } 2304 #if H_MV2518 rps->setNumberOfPictures(offset); 2519 } 2520 #if NH_MV 2305 2521 if ( !rps->getInterRPSPrediction( ) ) 2306 2522 { // check sum of NumPositivePics, NumNegativePics, num_long_term_sps and num_long_term_pics … … 2308 2524 vps->getVpsExtensionFlag(), 2309 2525 MAX_INT, // To be replaced by MaxDbpsize 2310 rpcSlice->getLayerId(),2526 pcSlice->getLayerId(), 2311 2527 sps->getMaxDecPicBuffering( sps->getSpsMaxSubLayersMinus1() ) - 1 ); 2312 2528 } 2313 2529 #endif 2314 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 2315 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 2316 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 2530 2531 if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 2532 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 2533 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 2317 2534 { 2318 2535 // In the case of BLA picture types, rps data is read from slice header but ignored 2319 rps = rpcSlice->getLocalRPS(); 2320 rps->setNumberOfNegativePictures(0); 2321 rps->setNumberOfPositivePictures(0); 2322 rps->setNumberOfLongtermPictures(0); 2323 rps->setNumberOfPictures(0); 2324 rpcSlice->setRPS(rps); 2325 } 2326 if (rpcSlice->getSPS()->getTMVPFlagsPresent()) 2327 { 2328 #if H_MV 2536 rps = pcSlice->getLocalRPS(); 2537 (*rps)=TComReferencePictureSet(); 2538 pcSlice->setRPS(rps); 2539 } 2540 if (sps->getTMVPFlagsPresent()) 2541 { 2542 #if NH_MV 2329 2543 READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" ); 2330 2544 #else 2331 READ_FLAG( uiCode, "slice_temporal_mvp_enable _flag" );2332 #endif 2333 rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false );2545 READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" ); 2546 #endif 2547 pcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); 2334 2548 } 2335 2549 else 2336 2550 { 2337 rpcSlice->setEnableTMVPFlag(false);2338 } 2339 } 2340 #if H_MV2551 pcSlice->setEnableTMVPFlag(false); 2552 } 2553 } 2554 #if NH_MV 2341 2555 Bool interLayerPredLayerIdcPresentFlag = false; 2342 Int layerId = rpcSlice->getLayerId();2343 #if H_3D2344 if( rpcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumRefListLayers( layerId ) > 0 )2556 Int layerId = pcSlice->getLayerId(); 2557 #if NH_3D 2558 if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumRefListLayers( layerId ) > 0 ) 2345 2559 #else 2346 if( rpcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 )2560 if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 ) 2347 2561 #endif 2348 2562 { 2349 READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); rpcSlice->setInterLayerPredEnabledFlag( uiCode == 1 );2350 #if H_3D2351 if( rpcSlice->getInterLayerPredEnabledFlag() && vps->getNumRefListLayers( layerId ) > 1 )2563 READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); pcSlice->setInterLayerPredEnabledFlag( uiCode == 1 ); 2564 #if NH_3D 2565 if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumRefListLayers( layerId ) > 1 ) 2352 2566 #else 2353 if( rpcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 )2567 if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 ) 2354 2568 #endif 2355 2569 { 2356 2570 if( !vps->getMaxOneActiveRefLayerFlag()) 2357 2571 { 2358 READ_CODE( rpcSlice->getNumInterLayerRefPicsMinus1Len( ), uiCode, "num_inter_layer_ref_pics_minus1" ); rpcSlice->setNumInterLayerRefPicsMinus1( uiCode );