Changeset 125 in SHVCSoftware for trunk/source/Lib/TLibDecoder/NALread.cpp
- Timestamp:
- 16 Apr 2013, 06:39:31 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibDecoder/NALread.cpp
r2 r125 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 2, ITU/ISO/IEC6 * Copyright (c) 2010-2013, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 32 32 */ 33 33 34 /** 35 \file NALread.cpp 36 \brief reading funtionality for NAL units 37 */ 38 39 34 40 #include <vector> 35 41 #include <algorithm> … … 44 50 //! \ingroup TLibDecoder 45 51 //! \{ 46 static void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, TComInputBitstream *pcBitstream)52 static void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, Bool isVclNalUnit) 47 53 { 48 unsignedzeroCount = 0;54 UInt zeroCount = 0; 49 55 vector<uint8_t>::iterator it_read, it_write; 50 56 51 57 for (it_read = it_write = nalUnitBuf.begin(); it_read != nalUnitBuf.end(); it_read++, it_write++) 52 58 { 59 assert(zeroCount < 2 || *it_read >= 0x03); 53 60 if (zeroCount == 2 && *it_read == 0x03) 54 61 { 55 62 it_read++; 56 63 zeroCount = 0; 64 if (it_read == nalUnitBuf.end()) 65 { 66 break; 67 } 57 68 } 58 69 zeroCount = (*it_read == 0x00) ? zeroCount+1 : 0; 59 70 *it_write = *it_read; 71 } 72 assert(zeroCount == 0); 73 74 if (isVclNalUnit) 75 { 76 // Remove cabac_zero_word from payload if present 77 Int n = 0; 78 79 while (it_write[-1] == 0x00) 80 { 81 it_write--; 82 n++; 83 } 84 85 if (n > 0) 86 { 87 printf("\nDetected %d instances of cabac_zero_word", n/2); 88 } 60 89 } 61 90 … … 63 92 } 64 93 65 #if NAL_UNIT_HEADER66 94 Void readNalUnitHeader(InputNALUnit& nalu) 67 95 { 68 96 TComInputBitstream& bs = *nalu.m_Bitstream; 69 97 70 bool forbidden_zero_bit = bs.read(1); // forbidden_zero_bit98 Bool forbidden_zero_bit = bs.read(1); // forbidden_zero_bit 71 99 assert(forbidden_zero_bit == 0); 72 100 nalu.m_nalUnitType = (NalUnitType) bs.read(6); // nal_unit_type 101 nalu.m_reservedZero6Bits = bs.read(6); // nuh_reserved_zero_6bits 73 102 #if SVC_EXTENSION 74 nalu.m_reservedZero6Bits = bs.read(6); // nuh_reserved_zero_6bits75 103 nalu.m_layerId = nalu.m_reservedZero6Bits; 76 104 #else 77 #if TARGET_DECLAYERID_SET78 nalu.m_reservedZero6Bits = bs.read(6); // nuh_reserved_zero_6bits79 105 assert(nalu.m_reservedZero6Bits == 0); 80 #else81 unsigned reserved_one_6bits = bs.read(6); // nuh_reserved_zero_6bits82 assert(reserved_one_6bits == 0);83 #endif84 106 #endif 85 107 nalu.m_temporalId = bs.read(3) - 1; // nuh_temporal_id_plus1 … … 87 109 if ( nalu.m_temporalId ) 88 110 { 89 #if NAL_UNIT_TYPES_J1003_D790 111 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA 91 112 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLANT … … 98 119 && nalu.m_nalUnitType != NAL_UNIT_EOS 99 120 && nalu.m_nalUnitType != NAL_UNIT_EOB ); 100 #else101 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA102 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRANT103 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA104 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLANT105 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR106 && nalu.m_nalUnitType != NAL_UNIT_VPS107 && nalu.m_nalUnitType != NAL_UNIT_SPS );108 #endif109 121 } 110 122 else 111 123 { 112 #if NAL_UNIT_TYPES_J1003_D7113 124 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TLA 114 125 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N 115 126 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R 116 127 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N ); 117 #else118 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TLA );119 #endif120 128 } 121 129 } 122 #endif123 130 /** 124 131 * create a NALunit structure with given header values and storage for … … 129 136 /* perform anti-emulation prevention */ 130 137 TComInputBitstream *pcBitstream = new TComInputBitstream(NULL); 131 convertPayloadToRBSP(nalUnitBuf, pcBitstream);132 138 convertPayloadToRBSP(nalUnitBuf, (nalUnitBuf[0] & 64) == 0); 139 133 140 nalu.m_Bitstream = new TComInputBitstream(&nalUnitBuf); 134 141 delete pcBitstream; 135 #if NAL_UNIT_HEADER136 142 readNalUnitHeader(nalu); 137 #else138 TComInputBitstream& bs = *nalu.m_Bitstream;139 140 bool forbidden_zero_bit = bs.read(1);141 assert(forbidden_zero_bit == 0);142 #if !REMOVE_NAL_REF_FLAG143 nalu.m_nalRefFlag = (bs.read(1) != 0 );144 #endif145 nalu.m_nalUnitType = (NalUnitType) bs.read(6);146 #if REMOVE_NAL_REF_FLAG147 unsigned reserved_one_6bits = bs.read(6);148 assert(reserved_one_6bits == 0);149 #endif150 #if TEMPORAL_ID_PLUS1151 nalu.m_temporalId = bs.read(3) - 1;152 #if !REMOVE_NAL_REF_FLAG153 unsigned reserved_one_5bits = bs.read(5);154 assert(reserved_one_5bits == 0);155 #endif156 #else157 nalu.m_temporalId = bs.read(3);158 unsigned reserved_one_5bits = bs.read(5);159 #if SVC_EXTENSION160 assert(reserved_one_5bits >= 1);161 nalu.m_layerId = reserved_one_5bits - 1;162 #else163 assert(reserved_one_5bits == 1);164 #endif165 #endif166 167 if ( nalu.m_temporalId )168 {169 #if NAL_UNIT_TYPES_J1003_D7170 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA171 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLANT172 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_N_LP173 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR174 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_N_LP175 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA );176 #else177 assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA178 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRANT179 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA180 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLANT181 && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR );182 #endif183 }184 #endif185 143 } 186 144 //! \}
Note: See TracChangeset for help on using the changeset viewer.