Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibDecoder/NALread.cpp
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset for help on using the changeset viewer.