1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** |
---|
35 | \file SEIread.cpp |
---|
36 | \brief reading funtionality for SEI messages |
---|
37 | */ |
---|
38 | |
---|
39 | #include "TLibCommon/CommonDef.h" |
---|
40 | #include "TLibCommon/TComBitStream.h" |
---|
41 | #include "TLibCommon/SEI.h" |
---|
42 | #include "TLibCommon/TComSlice.h" |
---|
43 | #include "SyntaxElementParser.h" |
---|
44 | #include "SEIread.h" |
---|
45 | #include "TLibCommon/TComPicYuv.h" |
---|
46 | #include <iomanip> |
---|
47 | |
---|
48 | |
---|
49 | //! \ingroup TLibDecoder |
---|
50 | //! \{ |
---|
51 | |
---|
52 | |
---|
53 | #if ENC_DEC_TRACE |
---|
54 | Void xTraceSEIHeader() |
---|
55 | { |
---|
56 | fprintf( g_hTrace, "=========== SEI message ===========\n"); |
---|
57 | } |
---|
58 | |
---|
59 | Void xTraceSEIMessageType(SEI::PayloadType payloadType) |
---|
60 | { |
---|
61 | fprintf( g_hTrace, "=========== %s SEI message ===========\n", SEI::getSEIMessageString(payloadType)); |
---|
62 | } |
---|
63 | #endif |
---|
64 | |
---|
65 | Void SEIReader::sei_read_code(std::ostream *pOS, UInt uiLength, UInt& ruiCode, const Char *pSymbolName) |
---|
66 | { |
---|
67 | READ_CODE(uiLength, ruiCode, pSymbolName); |
---|
68 | if (pOS) |
---|
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 | |
---|
115 | |
---|
116 | /** |
---|
117 | * unmarshal a single SEI message from bitstream bs |
---|
118 | */ |
---|
119 | #if LAYERS_NOT_PRESENT_SEI |
---|
120 | Void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const TComVPS *vps, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
---|
121 | #else |
---|
122 | Void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
---|
123 | #endif |
---|
124 | { |
---|
125 | setBitstream(bs); |
---|
126 | |
---|
127 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
---|
128 | do |
---|
129 | { |
---|
130 | #if LAYERS_NOT_PRESENT_SEI |
---|
131 | xReadSEImessage(seis, nalUnitType, vps, sps, pDecodedMessageOutputStream); |
---|
132 | #else |
---|
133 | xReadSEImessage(seis, nalUnitType, sps, pDecodedMessageOutputStream); |
---|
134 | #endif |
---|
135 | /* SEI messages are an integer number of bytes, something has failed |
---|
136 | * in the parsing if bitstream not byte-aligned */ |
---|
137 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
---|
138 | } |
---|
139 | while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
140 | |
---|
141 | xReadRbspTrailingBits(); |
---|
142 | } |
---|
143 | |
---|
144 | #if O0164_MULTI_LAYER_HRD |
---|
145 | #if LAYERS_NOT_PRESENT_SEI |
---|
146 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, const TComVPS *vps, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream, const SEIScalableNesting *nestingSei, const SEIBspNesting *bspNestingSei) |
---|
147 | #else |
---|
148 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream, const SEIScalableNesting *nestingSei) |
---|
149 | #endif |
---|
150 | #else |
---|
151 | #if LAYERS_NOT_PRESENT_SEI |
---|
152 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, const TComVPS *vps, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
---|
153 | #else |
---|
154 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
---|
155 | #endif |
---|
156 | #endif |
---|
157 | { |
---|
158 | #if ENC_DEC_TRACE |
---|
159 | xTraceSEIHeader(); |
---|
160 | #endif |
---|
161 | Int payloadType = 0; |
---|
162 | UInt val = 0; |
---|
163 | |
---|
164 | do |
---|
165 | { |
---|
166 | sei_read_code(NULL, 8, val, "payload_type"); |
---|
167 | payloadType += val; |
---|
168 | } while (val==0xFF); |
---|
169 | |
---|
170 | UInt payloadSize = 0; |
---|
171 | do |
---|
172 | { |
---|
173 | sei_read_code(NULL, 8, val, "payload_size"); |
---|
174 | payloadSize += val; |
---|
175 | } while (val==0xFF); |
---|
176 | |
---|
177 | #if ENC_DEC_TRACE |
---|
178 | xTraceSEIMessageType((SEI::PayloadType)payloadType); |
---|
179 | #endif |
---|
180 | |
---|
181 | /* extract the payload for this single SEI message. |
---|
182 | * This allows greater safety in erroneous parsing of an SEI message |
---|
183 | * from affecting subsequent messages. |
---|
184 | * After parsing the payload, bs needs to be restored as the primary |
---|
185 | * bitstream. |
---|
186 | */ |
---|
187 | TComInputBitstream *bs = getBitstream(); |
---|
188 | setBitstream(bs->extractSubstream(payloadSize * 8)); |
---|
189 | |
---|
190 | SEI *sei = NULL; |
---|
191 | |
---|
192 | if(nalUnitType == NAL_UNIT_PREFIX_SEI) |
---|
193 | { |
---|
194 | switch (payloadType) |
---|
195 | { |
---|
196 | case SEI::USER_DATA_UNREGISTERED: |
---|
197 | sei = new SEIuserDataUnregistered; |
---|
198 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
199 | break; |
---|
200 | case SEI::ACTIVE_PARAMETER_SETS: |
---|
201 | sei = new SEIActiveParameterSets; |
---|
202 | xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
203 | break; |
---|
204 | case SEI::DECODING_UNIT_INFO: |
---|
205 | if (!sps) |
---|
206 | { |
---|
207 | printf ("Warning: Found Decoding unit SEI message, but no active SPS is available. Ignoring."); |
---|
208 | } |
---|
209 | else |
---|
210 | { |
---|
211 | sei = new SEIDecodingUnitInfo; |
---|
212 | #if SVC_EXTENSION |
---|
213 | xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps, pDecodedMessageOutputStream); |
---|
214 | #else |
---|
215 | xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, pDecodedMessageOutputStream); |
---|
216 | #endif |
---|
217 | } |
---|
218 | break; |
---|
219 | case SEI::BUFFERING_PERIOD: |
---|
220 | if (!sps) |
---|
221 | { |
---|
222 | printf ("Warning: Found Buffering period SEI message, but no active SPS is available. Ignoring."); |
---|
223 | } |
---|
224 | else |
---|
225 | { |
---|
226 | sei = new SEIBufferingPeriod; |
---|
227 | #if SVC_EXTENSION |
---|
228 | xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps, pDecodedMessageOutputStream); |
---|
229 | #else |
---|
230 | xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, pDecodedMessageOutputStream); |
---|
231 | #endif |
---|
232 | } |
---|
233 | break; |
---|
234 | case SEI::PICTURE_TIMING: |
---|
235 | if (!sps) |
---|
236 | { |
---|
237 | printf ("Warning: Found Picture timing SEI message, but no active SPS is available. Ignoring."); |
---|
238 | } |
---|
239 | else |
---|
240 | { |
---|
241 | sei = new SEIPictureTiming; |
---|
242 | #if SVC_EXTENSION |
---|
243 | xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, nestingSei, bspNestingSei, vps, pDecodedMessageOutputStream); |
---|
244 | #else |
---|
245 | xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, pDecodedMessageOutputStream); |
---|
246 | #endif |
---|
247 | } |
---|
248 | break; |
---|
249 | case SEI::RECOVERY_POINT: |
---|
250 | sei = new SEIRecoveryPoint; |
---|
251 | xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
252 | break; |
---|
253 | case SEI::FRAME_PACKING: |
---|
254 | sei = new SEIFramePacking; |
---|
255 | xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
256 | break; |
---|
257 | case SEI::SEGM_RECT_FRAME_PACKING: |
---|
258 | sei = new SEISegmentedRectFramePacking; |
---|
259 | xParseSEISegmentedRectFramePacking((SEISegmentedRectFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
260 | break; |
---|
261 | case SEI::DISPLAY_ORIENTATION: |
---|
262 | sei = new SEIDisplayOrientation; |
---|
263 | xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
264 | break; |
---|
265 | case SEI::TEMPORAL_LEVEL0_INDEX: |
---|
266 | sei = new SEITemporalLevel0Index; |
---|
267 | xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
268 | break; |
---|
269 | case SEI::REGION_REFRESH_INFO: |
---|
270 | sei = new SEIGradualDecodingRefreshInfo; |
---|
271 | xParseSEIRegionRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
272 | break; |
---|
273 | case SEI::NO_DISPLAY: |
---|
274 | sei = new SEINoDisplay; |
---|
275 | xParseSEINoDisplay((SEINoDisplay&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
276 | break; |
---|
277 | case SEI::TONE_MAPPING_INFO: |
---|
278 | sei = new SEIToneMappingInfo; |
---|
279 | xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
280 | break; |
---|
281 | case SEI::SOP_DESCRIPTION: |
---|
282 | sei = new SEISOPDescription; |
---|
283 | xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
284 | break; |
---|
285 | case SEI::SCALABLE_NESTING: |
---|
286 | sei = new SEIScalableNesting; |
---|
287 | #if LAYERS_NOT_PRESENT_SEI |
---|
288 | xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, vps, sps, pDecodedMessageOutputStream); |
---|
289 | #else |
---|
290 | xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps, pDecodedMessageOutputStream); |
---|
291 | #endif |
---|
292 | break; |
---|
293 | case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS: |
---|
294 | sei = new SEITempMotionConstrainedTileSets; |
---|
295 | xParseSEITempMotionConstraintsTileSets((SEITempMotionConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
296 | break; |
---|
297 | case SEI::TIME_CODE: |
---|
298 | sei = new SEITimeCode; |
---|
299 | xParseSEITimeCode((SEITimeCode&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
300 | break; |
---|
301 | case SEI::CHROMA_SAMPLING_FILTER_HINT: |
---|
302 | sei = new SEIChromaSamplingFilterHint; |
---|
303 | xParseSEIChromaSamplingFilterHint((SEIChromaSamplingFilterHint&) *sei, payloadSize/*, sps*/, pDecodedMessageOutputStream); |
---|
304 | //} |
---|
305 | break; |
---|
306 | case SEI::KNEE_FUNCTION_INFO: |
---|
307 | sei = new SEIKneeFunctionInfo; |
---|
308 | xParseSEIKneeFunctionInfo((SEIKneeFunctionInfo&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
309 | break; |
---|
310 | case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: |
---|
311 | sei = new SEIMasteringDisplayColourVolume; |
---|
312 | xParseSEIMasteringDisplayColourVolume((SEIMasteringDisplayColourVolume&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
313 | break; |
---|
314 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
315 | case SEI::COLOUR_REMAPPING_INFO: |
---|
316 | sei = new SEIColourRemappingInfo; |
---|
317 | xParseSEIColourRemappingInfo((SEIColourRemappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
318 | break; |
---|
319 | #endif |
---|
320 | #if SVC_EXTENSION |
---|
321 | #if LAYERS_NOT_PRESENT_SEI |
---|
322 | case SEI::LAYERS_NOT_PRESENT: |
---|
323 | if (!vps) |
---|
324 | { |
---|
325 | printf ("Warning: Found Layers not present SEI message, but no active VPS is available. Ignoring."); |
---|
326 | } |
---|
327 | else |
---|
328 | { |
---|
329 | sei = new SEILayersNotPresent; |
---|
330 | xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps, pDecodedMessageOutputStream); |
---|
331 | } |
---|
332 | break; |
---|
333 | #endif |
---|
334 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
335 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
---|
336 | sei = new SEIInterLayerConstrainedTileSets; |
---|
337 | xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
338 | break; |
---|
339 | #endif |
---|
340 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
341 | case SEI::SUB_BITSTREAM_PROPERTY: |
---|
342 | sei = new SEISubBitstreamProperty; |
---|
343 | xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, vps, pDecodedMessageOutputStream); |
---|
344 | break; |
---|
345 | #endif |
---|
346 | #if O0164_MULTI_LAYER_HRD |
---|
347 | case SEI::BSP_NESTING: |
---|
348 | sei = new SEIBspNesting; |
---|
349 | #if LAYERS_NOT_PRESENT_SEI |
---|
350 | xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, vps, sps, *nestingSei, pDecodedMessageOutputStream); |
---|
351 | #else |
---|
352 | xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, sps, *nestingSei, pDecodedMessageOutputStream); |
---|
353 | #endif |
---|
354 | break; |
---|
355 | case SEI::BSP_INITIAL_ARRIVAL_TIME: |
---|
356 | sei = new SEIBspInitialArrivalTime; |
---|
357 | xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, vps, sps, *nestingSei, *bspNestingSei, pDecodedMessageOutputStream); |
---|
358 | break; |
---|
359 | #endif |
---|
360 | #if Q0189_TMVP_CONSTRAINTS |
---|
361 | case SEI::TMVP_CONSTRAINTS: |
---|
362 | sei = new SEITMVPConstrains; |
---|
363 | xParseSEITMVPConstraints((SEITMVPConstrains&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
364 | break; |
---|
365 | #endif |
---|
366 | #if Q0247_FRAME_FIELD_INFO |
---|
367 | case SEI::FRAME_FIELD_INFO: |
---|
368 | sei = new SEIFrameFieldInfo; |
---|
369 | xParseSEIFrameFieldInfo ((SEIFrameFieldInfo&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
370 | break; |
---|
371 | #endif |
---|
372 | #if P0123_ALPHA_CHANNEL_SEI |
---|
373 | case SEI::ALPHA_CHANNEL_INFO: |
---|
374 | sei = new SEIAlphaChannelInfo; |
---|
375 | xParseSEIAlphaChannelInfo((SEIAlphaChannelInfo &) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
376 | break; |
---|
377 | #endif |
---|
378 | #if Q0096_OVERLAY_SEI |
---|
379 | case SEI::OVERLAY_INFO: |
---|
380 | sei = new SEIOverlayInfo; |
---|
381 | xParseSEIOverlayInfo((SEIOverlayInfo&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
382 | break; |
---|
383 | #endif |
---|
384 | #endif //SVC_EXTENSION |
---|
385 | default: |
---|
386 | for (UInt i = 0; i < payloadSize; i++) |
---|
387 | { |
---|
388 | UInt seiByte; |
---|
389 | sei_read_code (NULL, 8, seiByte, "unknown prefix SEI payload byte"); |
---|
390 | } |
---|
391 | printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType); |
---|
392 | if (pDecodedMessageOutputStream) |
---|
393 | { |
---|
394 | (*pDecodedMessageOutputStream) << "Unknown prefix SEI message (payloadType = " << payloadType << ") was found!\n"; |
---|
395 | } |
---|
396 | break; |
---|
397 | } |
---|
398 | } |
---|
399 | else |
---|
400 | { |
---|
401 | switch (payloadType) |
---|
402 | { |
---|
403 | case SEI::USER_DATA_UNREGISTERED: |
---|
404 | sei = new SEIuserDataUnregistered; |
---|
405 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
406 | break; |
---|
407 | case SEI::DECODED_PICTURE_HASH: |
---|
408 | sei = new SEIDecodedPictureHash; |
---|
409 | xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize, pDecodedMessageOutputStream); |
---|
410 | break; |
---|
411 | default: |
---|
412 | for (UInt i = 0; i < payloadSize; i++) |
---|
413 | { |
---|
414 | UInt seiByte; |
---|
415 | sei_read_code( NULL, 8, seiByte, "unknown suffix SEI payload byte"); |
---|
416 | } |
---|
417 | printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType); |
---|
418 | if (pDecodedMessageOutputStream) |
---|
419 | { |
---|
420 | (*pDecodedMessageOutputStream) << "Unknown suffix SEI message (payloadType = " << payloadType << ") was found!\n"; |
---|
421 | } |
---|
422 | break; |
---|
423 | } |
---|
424 | } |
---|
425 | |
---|
426 | if (sei != NULL) |
---|
427 | { |
---|
428 | seis.push_back(sei); |
---|
429 | } |
---|
430 | |
---|
431 | /* By definition the underlying bitstream terminates in a byte-aligned manner. |
---|
432 | * 1. Extract all bar the last MIN(bitsremaining,nine) bits as reserved_payload_extension_data |
---|
433 | * 2. Examine the final 8 bits to determine the payload_bit_equal_to_one marker |
---|
434 | * 3. Extract the remainingreserved_payload_extension_data bits. |
---|
435 | * |
---|
436 | * If there are fewer than 9 bits available, extract them. |
---|
437 | */ |
---|
438 | Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); |
---|
439 | if (payloadBitsRemaining) /* more_data_in_payload() */ |
---|
440 | { |
---|
441 | for (; payloadBitsRemaining > 9; payloadBitsRemaining--) |
---|
442 | { |
---|
443 | UInt reservedPayloadExtensionData; |
---|
444 | sei_read_code ( pDecodedMessageOutputStream, 1, reservedPayloadExtensionData, "reserved_payload_extension_data"); |
---|
445 | } |
---|
446 | |
---|
447 | /* 2 */ |
---|
448 | Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); |
---|
449 | Int finalPayloadBits = 0; |
---|
450 | for (Int mask = 0xff; finalBits & (mask >> finalPayloadBits); finalPayloadBits++) |
---|
451 | { |
---|
452 | continue; |
---|
453 | } |
---|
454 | |
---|
455 | /* 3 */ |
---|
456 | for (; payloadBitsRemaining > 9 - finalPayloadBits; payloadBitsRemaining--) |
---|
457 | { |
---|
458 | UInt reservedPayloadExtensionData; |
---|
459 | sei_read_flag ( 0, reservedPayloadExtensionData, "reserved_payload_extension_data"); |
---|
460 | } |
---|
461 | |
---|
462 | UInt dummy; |
---|
463 | sei_read_flag( 0, dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--; |
---|
464 | while (payloadBitsRemaining) |
---|
465 | { |
---|
466 | sei_read_flag( 0, dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--; |
---|
467 | } |
---|
468 | } |
---|
469 | |
---|
470 | /* restore primary bitstream for sei_message */ |
---|
471 | delete getBitstream(); |
---|
472 | setBitstream(bs); |
---|
473 | } |
---|
474 | |
---|
475 | /** |
---|
476 | * parse bitstream bs and unpack a user_data_unregistered SEI message |
---|
477 | * of payloasSize bytes into sei. |
---|
478 | */ |
---|
479 | |
---|
480 | Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
481 | { |
---|
482 | assert(payloadSize >= ISO_IEC_11578_LEN); |
---|
483 | UInt val; |
---|
484 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
485 | |
---|
486 | for (UInt i = 0; i < ISO_IEC_11578_LEN; i++) |
---|
487 | { |
---|
488 | sei_read_code( pDecodedMessageOutputStream, 8, val, "uuid_iso_iec_11578"); |
---|
489 | sei.uuid_iso_iec_11578[i] = val; |
---|
490 | } |
---|
491 | |
---|
492 | sei.userDataLength = payloadSize - ISO_IEC_11578_LEN; |
---|
493 | if (!sei.userDataLength) |
---|
494 | { |
---|
495 | sei.userData = 0; |
---|
496 | return; |
---|
497 | } |
---|
498 | |
---|
499 | sei.userData = new UChar[sei.userDataLength]; |
---|
500 | for (UInt i = 0; i < sei.userDataLength; i++) |
---|
501 | { |
---|
502 | sei_read_code( NULL, 8, val, "user_data_payload_byte" ); |
---|
503 | sei.userData[i] = val; |
---|
504 | } |
---|
505 | if (pDecodedMessageOutputStream) |
---|
506 | { |
---|
507 | (*pDecodedMessageOutputStream) << " User data payload size: " << sei.userDataLength << "\n"; |
---|
508 | } |
---|
509 | } |
---|
510 | |
---|
511 | /** |
---|
512 | * parse bitstream bs and unpack a decoded picture hash SEI message |
---|
513 | * of payloadSize bytes into sei. |
---|
514 | */ |
---|
515 | Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
516 | { |
---|
517 | UInt bytesRead = 0; |
---|
518 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
519 | |
---|
520 | UInt val; |
---|
521 | sei_read_code( pDecodedMessageOutputStream, 8, val, "hash_type"); |
---|
522 | sei.method = static_cast<SEIDecodedPictureHash::Method>(val); bytesRead++; |
---|
523 | |
---|
524 | const Char *traceString="\0"; |
---|
525 | switch (sei.method) |
---|
526 | { |
---|
527 | case SEIDecodedPictureHash::MD5: traceString="picture_md5"; break; |
---|
528 | case SEIDecodedPictureHash::CRC: traceString="picture_crc"; break; |
---|
529 | case SEIDecodedPictureHash::CHECKSUM: traceString="picture_checksum"; break; |
---|
530 | default: assert(false); break; |
---|
531 | } |
---|
532 | |
---|
533 | if (pDecodedMessageOutputStream) |
---|
534 | { |
---|
535 | (*pDecodedMessageOutputStream) << " " << std::setw(55) << traceString << ": " << std::hex << std::setfill('0'); |
---|
536 | } |
---|
537 | |
---|
538 | sei.m_pictureHash.hash.clear(); |
---|
539 | for(;bytesRead < payloadSize; bytesRead++) |
---|
540 | { |
---|
541 | sei_read_code( NULL, 8, val, traceString); |
---|
542 | sei.m_pictureHash.hash.push_back((UChar)val); |
---|
543 | if (pDecodedMessageOutputStream) |
---|
544 | { |
---|
545 | (*pDecodedMessageOutputStream) << std::setw(2) << val; |
---|
546 | } |
---|
547 | } |
---|
548 | |
---|
549 | if (pDecodedMessageOutputStream) |
---|
550 | { |
---|
551 | (*pDecodedMessageOutputStream) << std::dec << std::setfill(' ') << "\n"; |
---|
552 | } |
---|
553 | } |
---|
554 | |
---|
555 | Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
556 | { |
---|
557 | UInt val; |
---|
558 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
559 | |
---|
560 | sei_read_code( pDecodedMessageOutputStream, 4, val, "active_video_parameter_set_id"); sei.activeVPSId = val; |
---|
561 | sei_read_flag( pDecodedMessageOutputStream, val, "self_contained_cvs_flag"); sei.m_selfContainedCvsFlag = (val != 0); |
---|
562 | sei_read_flag( pDecodedMessageOutputStream, val, "no_parameter_set_update_flag"); sei.m_noParameterSetUpdateFlag = (val != 0); |
---|
563 | sei_read_uvlc( pDecodedMessageOutputStream, val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; |
---|
564 | |
---|
565 | sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1); |
---|
566 | #if R0247_SEI_ACTIVE |
---|
567 | sei.layerSpsIdx.resize(sei.numSpsIdsMinus1 + 1); |
---|
568 | #endif |
---|
569 | for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++) |
---|
570 | { |
---|
571 | sei_read_uvlc( pDecodedMessageOutputStream, val, "active_seq_parameter_set_id[i]"); sei.activeSeqParameterSetId[i] = val; |
---|
572 | } |
---|
573 | #if R0247_SEI_ACTIVE |
---|
574 | for (Int i=1; i < (sei.numSpsIdsMinus1 + 1); i++) |
---|
575 | { |
---|
576 | sei_read_uvlc( pDecodedMessageOutputStream, val, "layer_sps_idx"); sei.layerSpsIdx[i] = val; |
---|
577 | } |
---|
578 | #endif |
---|
579 | } |
---|
580 | |
---|
581 | #if SVC_EXTENSION |
---|
582 | Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt payloadSize, const TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, const TComVPS *vps, std::ostream *pDecodedMessageOutputStream) |
---|
583 | #else |
---|
584 | Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
---|
585 | #endif |
---|
586 | { |
---|
587 | UInt val; |
---|
588 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
589 | sei_read_uvlc( pDecodedMessageOutputStream, val, "decoding_unit_idx"); |
---|
590 | sei.m_decodingUnitIdx = val; |
---|
591 | |
---|
592 | #if SVC_EXTENSION |
---|
593 | const TComHRD *hrd; |
---|
594 | if( bspNestingSei ) // If DU info SEI contained inside a BSP nesting SEI message |
---|
595 | { |
---|
596 | assert( nestingSei ); |
---|
597 | Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; |
---|
598 | Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; |
---|
599 | Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; |
---|
600 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
---|
601 | std::vector<Int> hrdIdx(maxValues, 0); |
---|
602 | std::vector<const TComHRD*> hrdVec; |
---|
603 | std::vector<Int> syntaxElemLen(maxValues, 0); |
---|
604 | for(Int i = 0; i < maxValues; i++) |
---|
605 | { |
---|
606 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); |
---|
607 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
---|
608 | |
---|
609 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
610 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
611 | { |
---|
612 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
---|
613 | } |
---|
614 | if( i > 0 ) |
---|
615 | { |
---|
616 | assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); |
---|
617 | assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag() == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() ); |
---|
618 | assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); |
---|
619 | // To be done: Check CpbDpbDelaysPresentFlag |
---|
620 | } |
---|
621 | } |
---|
622 | hrd = hrdVec[0]; |
---|
623 | } |
---|
624 | else |
---|
625 | { |
---|
626 | const TComVUI *vui = sps->getVuiParameters(); |
---|
627 | hrd = vui->getHrdParameters(); |
---|
628 | } |
---|
629 | |
---|
630 | if(hrd->getSubPicCpbParamsInPicTimingSEIFlag()) |
---|
631 | { |
---|
632 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay_increment"); |
---|
633 | sei.m_duSptCpbRemovalDelay = val; |
---|
634 | } |
---|
635 | else |
---|
636 | { |
---|
637 | sei.m_duSptCpbRemovalDelay = 0; |
---|
638 | } |
---|
639 | sei_read_flag( pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0); |
---|
640 | if(sei.m_dpbOutputDuDelayPresentFlag) |
---|
641 | { |
---|
642 | sei_read_code( pDecodedMessageOutputStream, hrd->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); |
---|
643 | sei.m_picSptDpbOutputDuDelay = val; |
---|
644 | } |
---|
645 | #else |
---|
646 | const TComVUI *vui = sps->getVuiParameters(); |
---|
647 | if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag()) |
---|
648 | { |
---|
649 | sei_read_code( pDecodedMessageOutputStream, ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay_increment"); |
---|
650 | sei.m_duSptCpbRemovalDelay = val; |
---|
651 | } |
---|
652 | else |
---|
653 | { |
---|
654 | sei.m_duSptCpbRemovalDelay = 0; |
---|
655 | } |
---|
656 | sei_read_flag( pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0); |
---|
657 | if(sei.m_dpbOutputDuDelayPresentFlag) |
---|
658 | { |
---|
659 | sei_read_code( pDecodedMessageOutputStream, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); |
---|
660 | sei.m_picSptDpbOutputDuDelay = val; |
---|
661 | } |
---|
662 | #endif |
---|
663 | } |
---|
664 | |
---|
665 | #if SVC_EXTENSION |
---|
666 | Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt payloadSize, const TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, const TComVPS *vps, std::ostream *pDecodedMessageOutputStream) |
---|
667 | #else |
---|
668 | Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
---|
669 | #endif |
---|
670 | { |
---|
671 | Int i, nalOrVcl; |
---|
672 | UInt code; |
---|
673 | |
---|
674 | #if SVC_EXTENSION |
---|
675 | const TComHRD *pHRD; |
---|
676 | if( bspNestingSei ) // If BP SEI contained inside a BSP nesting SEI message |
---|
677 | { |
---|
678 | assert( nestingSei ); |
---|
679 | Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; |
---|
680 | Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; |
---|
681 | Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; |
---|
682 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
---|
683 | std::vector<Int> hrdIdx(maxValues, 0); |
---|
684 | std::vector<const TComHRD*> hrdVec; |
---|
685 | std::vector<Int> syntaxElemLen(maxValues, 0); |
---|
686 | for(i = 0; i < maxValues; i++) |
---|
687 | { |
---|
688 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); |
---|
689 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
---|
690 | |
---|
691 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
692 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
693 | { |
---|
694 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
---|
695 | } |
---|
696 | if( i > 0 ) |
---|
697 | { |
---|
698 | assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() ); |
---|
699 | assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); |
---|
700 | assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); |
---|
701 | } |
---|
702 | } |
---|
703 | pHRD = hrdVec[i]; |
---|
704 | } |
---|
705 | else |
---|
706 | { |
---|
707 | const TComVUI *vui = sps->getVuiParameters(); |
---|
708 | pHRD = vui->getHrdParameters(); |
---|
709 | } |
---|
710 | // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently. |
---|
711 | #else |
---|
712 | const TComVUI *pVUI = sps->getVuiParameters(); |
---|
713 | const TComHRD *pHRD = pVUI->getHrdParameters(); |
---|
714 | #endif |
---|
715 | |
---|
716 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
717 | |
---|
718 | sei_read_uvlc( pDecodedMessageOutputStream, code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; |
---|
719 | if( !pHRD->getSubPicCpbParamsPresentFlag() ) |
---|
720 | { |
---|
721 | sei_read_flag( pDecodedMessageOutputStream, code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code; |
---|
722 | } |
---|
723 | if( sei.m_rapCpbParamsPresentFlag ) |
---|
724 | { |
---|
725 | sei_read_code( pDecodedMessageOutputStream, pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; |
---|
726 | sei_read_code( pDecodedMessageOutputStream, pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; |
---|
727 | } |
---|
728 | |
---|
729 | //read splicing flag and cpb_removal_delay_delta |
---|
730 | sei_read_flag( pDecodedMessageOutputStream, code, "concatenation_flag"); |
---|
731 | sei.m_concatenationFlag = code; |
---|
732 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" ); |
---|
733 | sei.m_auCpbRemovalDelayDelta = code + 1; |
---|
734 | |
---|
735 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
736 | { |
---|
737 | if( ( ( nalOrVcl == 0 ) && ( pHRD->getNalHrdParametersPresentFlag() ) ) || |
---|
738 | ( ( nalOrVcl == 1 ) && ( pHRD->getVclHrdParametersPresentFlag() ) ) ) |
---|
739 | { |
---|
740 | for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ ) |
---|
741 | { |
---|
742 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_delay":"nal_initial_cpb_removal_delay" ); |
---|
743 | sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code; |
---|
744 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_offset":"vcl_initial_cpb_removal_offset" ); |
---|
745 | sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code; |
---|
746 | if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag ) |
---|
747 | { |
---|
748 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_delay":"vcl_initial_alt_cpb_removal_delay" ); |
---|
749 | sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code; |
---|
750 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_offset":"vcl_initial_alt_cpb_removal_offset" ); |
---|
751 | sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code; |
---|
752 | } |
---|
753 | } |
---|
754 | } |
---|
755 | } |
---|
756 | |
---|
757 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
---|
758 | sei.m_useAltCpbParamsFlag = false; |
---|
759 | sei.m_useAltCpbParamsFlagPresent = false; |
---|
760 | if (xPayloadExtensionPresent()) |
---|
761 | { |
---|
762 | sei_read_flag( pDecodedMessageOutputStream, code, "use_alt_cpb_params_flag"); |
---|
763 | sei.m_useAltCpbParamsFlag = code; |
---|
764 | sei.m_useAltCpbParamsFlagPresent = true; |
---|
765 | } |
---|
766 | #endif |
---|
767 | } |
---|
768 | |
---|
769 | #if SVC_EXTENSION |
---|
770 | Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize, const TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, const TComVPS *vps, std::ostream *pDecodedMessageOutputStream) |
---|
771 | #else |
---|
772 | Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
---|
773 | #endif |
---|
774 | { |
---|
775 | Int i; |
---|
776 | UInt code; |
---|
777 | |
---|
778 | #if SVC_EXTENSION |
---|
779 | const TComHRD *hrd; |
---|
780 | const TComVUI *vui = sps->getVuiParameters(); |
---|
781 | if( bspNestingSei ) // If BP SEI contained inside a BSP nesting SEI message |
---|
782 | { |
---|
783 | assert( nestingSei ); |
---|
784 | Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; |
---|
785 | Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; |
---|
786 | Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; |
---|
787 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
---|
788 | std::vector<Int> hrdIdx(maxValues, 0); |
---|
789 | std::vector<const TComHRD*> hrdVec; |
---|
790 | std::vector<Int> syntaxElemLen(maxValues, 0); |
---|
791 | for(i = 0; i < maxValues; i++) |
---|
792 | { |
---|
793 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); |
---|
794 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
---|
795 | |
---|
796 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
797 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
798 | { |
---|
799 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
---|
800 | } |
---|
801 | if( i > 0 ) |
---|
802 | { |
---|
803 | assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); |
---|
804 | assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag() == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() ); |
---|
805 | assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() ); |
---|
806 | assert( hrdVec[i]->getDpbOutputDelayLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayLengthMinus1() ); |
---|
807 | assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); |
---|
808 | assert( hrdVec[i]->getDuCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getDuCpbRemovalDelayLengthMinus1() ); |
---|
809 | // To be done: Check CpbDpbDelaysPresentFlag |
---|
810 | } |
---|
811 | } |
---|
812 | hrd = hrdVec[0]; |
---|
813 | } |
---|
814 | else |
---|
815 | { |
---|
816 | hrd = vui->getHrdParameters(); |
---|
817 | } |
---|
818 | // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently. |
---|
819 | #else |
---|
820 | const TComVUI *vui = sps->getVuiParameters(); |
---|
821 | const TComHRD *hrd = vui->getHrdParameters(); |
---|
822 | #endif |
---|
823 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
824 | |
---|
825 | if( vui->getFrameFieldInfoPresentFlag() ) |
---|
826 | { |
---|
827 | sei_read_code( pDecodedMessageOutputStream, 4, code, "pic_struct" ); sei.m_picStruct = code; |
---|
828 | sei_read_code( pDecodedMessageOutputStream, 2, code, "source_scan_type" ); sei.m_sourceScanType = code; |
---|
829 | sei_read_flag( pDecodedMessageOutputStream, code, "duplicate_flag" ); sei.m_duplicateFlag = (code == 1); |
---|
830 | } |
---|
831 | |
---|
832 | if( hrd->getCpbDpbDelaysPresentFlag()) |
---|
833 | { |
---|
834 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" ); |
---|
835 | sei.m_auCpbRemovalDelay = code + 1; |
---|
836 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" ); |
---|
837 | sei.m_picDpbOutputDelay = code; |
---|
838 | |
---|
839 | if(hrd->getSubPicCpbParamsPresentFlag()) |
---|
840 | { |
---|
841 | sei_read_code( pDecodedMessageOutputStream, hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" ); |
---|
842 | sei.m_picDpbOutputDuDelay = code; |
---|
843 | } |
---|
844 | |
---|
845 | if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) |
---|
846 | { |
---|
847 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_decoding_units_minus1"); |
---|
848 | sei.m_numDecodingUnitsMinus1 = code; |
---|
849 | sei_read_flag( pDecodedMessageOutputStream, code, "du_common_cpb_removal_delay_flag" ); |
---|
850 | sei.m_duCommonCpbRemovalDelayFlag = code; |
---|
851 | if( sei.m_duCommonCpbRemovalDelayFlag ) |
---|
852 | { |
---|
853 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_increment_minus1" ); |
---|
854 | sei.m_duCommonCpbRemovalDelayMinus1 = code; |
---|
855 | } |
---|
856 | sei.m_numNalusInDuMinus1.resize(sei.m_numDecodingUnitsMinus1 + 1 ); |
---|
857 | sei.m_duCpbRemovalDelayMinus1.resize( sei.m_numDecodingUnitsMinus1 + 1 ); |
---|
858 | |
---|
859 | for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ ) |
---|
860 | { |
---|
861 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_nalus_in_du_minus1[i]"); |
---|
862 | sei.m_numNalusInDuMinus1[ i ] = code; |
---|
863 | if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) ) |
---|
864 | { |
---|
865 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1[i]" ); |
---|
866 | sei.m_duCpbRemovalDelayMinus1[ i ] = code; |
---|
867 | } |
---|
868 | } |
---|
869 | } |
---|
870 | } |
---|
871 | } |
---|
872 | |
---|
873 | Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
874 | { |
---|
875 | Int iCode; |
---|
876 | UInt uiCode; |
---|
877 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
878 | |
---|
879 | sei_read_svlc( pDecodedMessageOutputStream, iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; |
---|
880 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; |
---|
881 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; |
---|
882 | } |
---|
883 | |
---|
884 | Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
885 | { |
---|
886 | UInt val; |
---|
887 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
888 | |
---|
889 | sei_read_uvlc( pDecodedMessageOutputStream, val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; |
---|
890 | sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; |
---|
891 | |
---|
892 | if ( !sei.m_arrangementCancelFlag ) |
---|
893 | { |
---|
894 | sei_read_code( pDecodedMessageOutputStream, 7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val; |
---|
895 | assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) ); |
---|
896 | |
---|
897 | sei_read_flag( pDecodedMessageOutputStream, val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; |
---|
898 | |
---|
899 | sei_read_code( pDecodedMessageOutputStream, 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; |
---|
900 | sei_read_flag( pDecodedMessageOutputStream, val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; |
---|
901 | sei_read_flag( pDecodedMessageOutputStream, val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; |
---|
902 | sei_read_flag( pDecodedMessageOutputStream, val, "field_views_flag" ); sei.m_fieldViewsFlag = val; |
---|
903 | sei_read_flag( pDecodedMessageOutputStream, val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; |
---|
904 | sei_read_flag( pDecodedMessageOutputStream, val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; |
---|
905 | sei_read_flag( pDecodedMessageOutputStream, val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; |
---|
906 | |
---|
907 | if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) |
---|
908 | { |
---|
909 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; |
---|
910 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; |
---|
911 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; |
---|
912 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; |
---|
913 | } |
---|
914 | |
---|
915 | sei_read_code( pDecodedMessageOutputStream, 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; |
---|
916 | sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = (val != 0); |
---|
917 | } |
---|
918 | sei_read_flag( pDecodedMessageOutputStream, val, "upsampled_aspect_ratio_flag" ); sei.m_upsampledAspectRatio = val; |
---|
919 | } |
---|
920 | |
---|
921 | Void SEIReader::xParseSEISegmentedRectFramePacking(SEISegmentedRectFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
922 | { |
---|
923 | UInt val; |
---|
924 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
925 | sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; |
---|
926 | if( !sei.m_arrangementCancelFlag ) |
---|
927 | { |
---|
928 | sei_read_code( pDecodedMessageOutputStream, 2, val, "segmented_rect_content_interpretation_type" ); sei.m_contentInterpretationType = val; |
---|
929 | sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_persistence" ); sei.m_arrangementPersistenceFlag = val; |
---|
930 | } |
---|
931 | } |
---|
932 | |
---|
933 | Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
934 | { |
---|
935 | UInt val; |
---|
936 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
937 | sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; |
---|
938 | if( !sei.cancelFlag ) |
---|
939 | { |
---|
940 | sei_read_flag( pDecodedMessageOutputStream, val, "hor_flip" ); sei.horFlip = val; |
---|
941 | sei_read_flag( pDecodedMessageOutputStream, val, "ver_flip" ); sei.verFlip = val; |
---|
942 | sei_read_code( pDecodedMessageOutputStream, 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; |
---|
943 | sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; |
---|
944 | } |
---|
945 | } |
---|
946 | |
---|
947 | Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
948 | { |
---|
949 | UInt val; |
---|
950 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
951 | sei_read_code( pDecodedMessageOutputStream, 8, val, "temporal_sub_layer_zero_idx" ); sei.tl0Idx = val; |
---|
952 | sei_read_code( pDecodedMessageOutputStream, 8, val, "irap_pic_id" ); sei.rapIdx = val; |
---|
953 | } |
---|
954 | |
---|
955 | Void SEIReader::xParseSEIRegionRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
956 | { |
---|
957 | UInt val; |
---|
958 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
959 | sei_read_flag( pDecodedMessageOutputStream, val, "refreshed_region_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; |
---|
960 | } |
---|
961 | |
---|
962 | Void SEIReader::xParseSEINoDisplay(SEINoDisplay& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
963 | { |
---|
964 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
965 | sei.m_noDisplay = true; |
---|
966 | } |
---|
967 | |
---|
968 | Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
969 | { |
---|
970 | Int i; |
---|
971 | UInt val; |
---|
972 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
973 | sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_id" ); sei.m_toneMapId = val; |
---|
974 | sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; |
---|
975 | |
---|
976 | if ( !sei.m_toneMapCancelFlag ) |
---|
977 | { |
---|
978 | sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val; |
---|
979 | sei_read_code( pDecodedMessageOutputStream, 8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val; |
---|
980 | sei_read_code( pDecodedMessageOutputStream, 8, val, "target_bit_depth" ); sei.m_targetBitDepth = val; |
---|
981 | sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_model_id" ); sei.m_modelId = val; |
---|
982 | switch(sei.m_modelId) |
---|
983 | { |
---|
984 | case 0: |
---|
985 | { |
---|
986 | sei_read_code( pDecodedMessageOutputStream, 32, val, "min_value" ); sei.m_minValue = val; |
---|
987 | sei_read_code( pDecodedMessageOutputStream, 32, val, "max_value" ); sei.m_maxValue = val; |
---|
988 | break; |
---|
989 | } |
---|
990 | case 1: |
---|
991 | { |
---|
992 | sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val; |
---|
993 | sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val; |
---|
994 | break; |
---|
995 | } |
---|
996 | case 2: |
---|
997 | { |
---|
998 | UInt num = 1u << sei.m_targetBitDepth; |
---|
999 | sei.m_startOfCodedInterval.resize(num+1); |
---|
1000 | for(i = 0; i < num; i++) |
---|
1001 | { |
---|
1002 | sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval[i]" ); |
---|
1003 | sei.m_startOfCodedInterval[i] = val; |
---|
1004 | } |
---|
1005 | sei.m_startOfCodedInterval[num] = 1u << sei.m_codedDataBitDepth; |
---|
1006 | break; |
---|
1007 | } |
---|
1008 | case 3: |
---|
1009 | { |
---|
1010 | sei_read_code( pDecodedMessageOutputStream, 16, val, "num_pivots" ); sei.m_numPivots = val; |
---|
1011 | sei.m_codedPivotValue.resize(sei.m_numPivots); |
---|
1012 | sei.m_targetPivotValue.resize(sei.m_numPivots); |
---|
1013 | for(i = 0; i < sei.m_numPivots; i++ ) |
---|
1014 | { |
---|
1015 | sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value[i]" ); |
---|
1016 | sei.m_codedPivotValue[i] = val; |
---|
1017 | sei_read_code( pDecodedMessageOutputStream, ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value[i]" ); |
---|
1018 | sei.m_targetPivotValue[i] = val; |
---|
1019 | } |
---|
1020 | break; |
---|
1021 | } |
---|
1022 | case 4: |
---|
1023 | { |
---|
1024 | sei_read_code( pDecodedMessageOutputStream, 8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedIdc = val; |
---|
1025 | if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO |
---|
1026 | { |
---|
1027 | sei_read_code( pDecodedMessageOutputStream, 32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val; |
---|
1028 | } |
---|
1029 | sei_read_code( pDecodedMessageOutputStream, 8, val, "exposure_index_idc" ); sei.m_exposureIndexIdc = val; |
---|
1030 | if( sei.m_exposureIndexIdc == 255) //Extended_ISO |
---|
1031 | { |
---|
1032 | sei_read_code( pDecodedMessageOutputStream, 32, val, "exposure_index_value" ); sei.m_exposureIndexValue = val; |
---|
1033 | } |
---|
1034 | sei_read_flag( pDecodedMessageOutputStream, val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val; |
---|
1035 | sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val; |
---|
1036 | sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val; |
---|
1037 | sei_read_code( pDecodedMessageOutputStream, 32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val; |
---|
1038 | sei_read_code( pDecodedMessageOutputStream, 32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val; |
---|
1039 | sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_black_level_code_value" ); sei.m_nominalBlackLevelLumaCodeValue = val; |
---|
1040 | sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_white_level_code_value" ); sei.m_nominalWhiteLevelLumaCodeValue= val; |
---|
1041 | sei_read_code( pDecodedMessageOutputStream, 16, val, "extended_white_level_code_value" ); sei.m_extendedWhiteLevelLumaCodeValue = val; |
---|
1042 | break; |
---|
1043 | } |
---|
1044 | default: |
---|
1045 | { |
---|
1046 | assert(!"Undefined SEIToneMapModelId"); |
---|
1047 | break; |
---|
1048 | } |
---|
1049 | }//switch model id |
---|
1050 | }// if(!sei.m_toneMapCancelFlag) |
---|
1051 | } |
---|
1052 | |
---|
1053 | Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1054 | { |
---|
1055 | Int iCode; |
---|
1056 | UInt uiCode; |
---|
1057 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
1058 | |
---|
1059 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; |
---|
1060 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; |
---|
1061 | for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) |
---|
1062 | { |
---|
1063 | sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "sop_vcl_nut[i]" ); sei.m_sopDescVclNaluType[i] = uiCode; |
---|
1064 | sei_read_code( pDecodedMessageOutputStream, 3, sei.m_sopDescTemporalId[i], "sop_temporal_id[i]" ); sei.m_sopDescTemporalId[i] = uiCode; |
---|
1065 | if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) |
---|
1066 | { |
---|
1067 | sei_read_uvlc( pDecodedMessageOutputStream, sei.m_sopDescStRpsIdx[i], "sop_short_term_rps_idx[i]" ); sei.m_sopDescStRpsIdx[i] = uiCode; |
---|
1068 | } |
---|
1069 | if (i > 0) |
---|
1070 | { |
---|
1071 | sei_read_svlc( pDecodedMessageOutputStream, iCode, "sop_poc_delta[i]" ); sei.m_sopDescPocDelta[i] = iCode; |
---|
1072 | } |
---|
1073 | } |
---|
1074 | } |
---|
1075 | |
---|
1076 | #if LAYERS_NOT_PRESENT_SEI |
---|
1077 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, const TComVPS *vps, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
---|
1078 | #else |
---|
1079 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
---|
1080 | #endif |
---|
1081 | { |
---|
1082 | UInt uiCode; |
---|
1083 | SEIMessages seis; |
---|
1084 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
1085 | |
---|
1086 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; |
---|
1087 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; |
---|
1088 | if (sei.m_nestingOpFlag) |
---|
1089 | { |
---|
1090 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode; |
---|
1091 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode; |
---|
1092 | for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++) |
---|
1093 | { |
---|
1094 | sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_max_temporal_id_plus1[i]" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode; |
---|
1095 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_op_idx[i]" ); sei.m_nestingOpIdx[i] = uiCode; |
---|
1096 | } |
---|
1097 | } |
---|
1098 | else |
---|
1099 | { |
---|
1100 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode; |
---|
1101 | if (!sei.m_allLayersFlag) |
---|
1102 | { |
---|
1103 | sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode; |
---|
1104 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode; |
---|
1105 | for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) |
---|
1106 | { |
---|
1107 | sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "nesting_layer_id[i]" ); sei.m_nestingLayerId[i] = uiCode; |
---|
1108 | } |
---|
1109 | } |
---|
1110 | } |
---|
1111 | |
---|
1112 | // byte alignment |
---|
1113 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1114 | { |
---|
1115 | UInt code; |
---|
1116 | sei_read_flag( pDecodedMessageOutputStream, code, "nesting_zero_bit" ); |
---|
1117 | } |
---|
1118 | |
---|
1119 | // read nested SEI messages |
---|
1120 | do |
---|
1121 | { |
---|
1122 | #if O0164_MULTI_LAYER_HRD |
---|
1123 | #if LAYERS_NOT_PRESENT_SEI |
---|
1124 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream, &sei); |
---|
1125 | #else |
---|
1126 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream, &sei); |
---|
1127 | #endif |
---|
1128 | #else |
---|
1129 | #if LAYERS_NOT_PRESENT_SEI |
---|
1130 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream); |
---|
1131 | #else |
---|
1132 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream); |
---|
1133 | #endif |
---|
1134 | #endif |
---|
1135 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
1136 | |
---|
1137 | if (pDecodedMessageOutputStream) |
---|
1138 | { |
---|
1139 | (*pDecodedMessageOutputStream) << "End of scalable nesting SEI message\n"; |
---|
1140 | } |
---|
1141 | } |
---|
1142 | |
---|
1143 | Void SEIReader::xParseSEITempMotionConstraintsTileSets(SEITempMotionConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1144 | { |
---|
1145 | UInt code; |
---|
1146 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
1147 | 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); |
---|
1148 | sei_read_flag( pDecodedMessageOutputStream, code, "each_tile_one_tile_set_flag"); sei.m_each_tile_one_tile_set_flag = (code != 0); |
---|
1149 | |
---|
1150 | if(!sei.m_each_tile_one_tile_set_flag) |
---|
1151 | { |
---|
1152 | sei_read_flag( pDecodedMessageOutputStream, code, "limited_tile_set_display_flag"); sei.m_limited_tile_set_display_flag = (code != 0); |
---|
1153 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_sets_in_message_minus1"); sei.setNumberOfTileSets(code + 1); |
---|
1154 | |
---|
1155 | if(sei.getNumberOfTileSets() != 0) |
---|
1156 | { |
---|
1157 | for(Int i = 0; i < sei.getNumberOfTileSets(); i++) |
---|
1158 | { |
---|
1159 | sei_read_uvlc( pDecodedMessageOutputStream, code, "mcts_id"); sei.tileSetData(i).m_mcts_id = code; |
---|
1160 | |
---|
1161 | if(sei.m_limited_tile_set_display_flag) |
---|
1162 | { |
---|
1163 | sei_read_flag( pDecodedMessageOutputStream, code, "display_tile_set_flag"); sei.tileSetData(i).m_display_tile_set_flag = (code != 1); |
---|
1164 | } |
---|
1165 | |
---|
1166 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_tile_rects_in_set_minus1"); sei.tileSetData(i).setNumberOfTileRects(code + 1); |
---|
1167 | |
---|
1168 | for(Int j=0; j<sei.tileSetData(i).getNumberOfTileRects(); j++) |
---|
1169 | { |
---|
1170 | sei_read_uvlc( pDecodedMessageOutputStream, code, "top_left_tile_index"); sei.tileSetData(i).topLeftTileIndex(j) = code; |
---|
1171 | sei_read_uvlc( pDecodedMessageOutputStream, code, "bottom_right_tile_index"); sei.tileSetData(i).bottomRightTileIndex(j) = code; |
---|
1172 | } |
---|
1173 | |
---|
1174 | if(!sei.m_mc_all_tiles_exact_sample_value_match_flag) |
---|
1175 | { |
---|
1176 | sei_read_flag( pDecodedMessageOutputStream, code, "exact_sample_value_match_flag"); sei.tileSetData(i).m_exact_sample_value_match_flag = (code != 0); |
---|
1177 | } |
---|
1178 | sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_level_idc_present_flag"); sei.tileSetData(i).m_mcts_tier_level_idc_present_flag = (code != 0); |
---|
1179 | |
---|
1180 | if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag) |
---|
1181 | { |
---|
1182 | sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_flag"); sei.tileSetData(i).m_mcts_tier_flag = (code != 0); |
---|
1183 | sei_read_code( pDecodedMessageOutputStream, 8, code, "mcts_level_idc"); sei.tileSetData(i).m_mcts_level_idc = code; |
---|
1184 | } |
---|
1185 | } |
---|
1186 | } |
---|
1187 | } |
---|
1188 | else |
---|
1189 | { |
---|
1190 | sei_read_flag( pDecodedMessageOutputStream, code, "max_mcs_tier_level_idc_present_flag"); sei.m_max_mcs_tier_level_idc_present_flag = code; |
---|
1191 | if(sei.m_max_mcs_tier_level_idc_present_flag) |
---|
1192 | { |
---|
1193 | sei_read_flag( pDecodedMessageOutputStream, code, "max_mcts_tier_flag"); sei.m_max_mcts_tier_flag = code; |
---|
1194 | sei_read_code( pDecodedMessageOutputStream, 8, code, "max_mcts_level_idc"); sei.m_max_mcts_level_idc = code; |
---|
1195 | } |
---|
1196 | } |
---|
1197 | } |
---|
1198 | |
---|
1199 | Void SEIReader::xParseSEITimeCode(SEITimeCode& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1200 | { |
---|
1201 | UInt code; |
---|
1202 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
1203 | sei_read_code( pDecodedMessageOutputStream, 2, code, "num_clock_ts"); sei.numClockTs = code; |
---|
1204 | for(Int i = 0; i < sei.numClockTs; i++) |
---|
1205 | { |
---|
1206 | TComSEITimeSet currentTimeSet; |
---|
1207 | sei_read_flag( pDecodedMessageOutputStream, code, "clock_time_stamp_flag[i]"); currentTimeSet.clockTimeStampFlag = code; |
---|
1208 | if(currentTimeSet.clockTimeStampFlag) |
---|
1209 | { |
---|
1210 | sei_read_flag( pDecodedMessageOutputStream, code, "nuit_field_based_flag"); currentTimeSet.numUnitFieldBasedFlag = code; |
---|
1211 | sei_read_code( pDecodedMessageOutputStream, 5, code, "counting_type"); currentTimeSet.countingType = code; |
---|
1212 | sei_read_flag( pDecodedMessageOutputStream, code, "full_timestamp_flag"); currentTimeSet.fullTimeStampFlag = code; |
---|
1213 | sei_read_flag( pDecodedMessageOutputStream, code, "discontinuity_flag"); currentTimeSet.discontinuityFlag = code; |
---|
1214 | sei_read_flag( pDecodedMessageOutputStream, code, "cnt_dropped_flag"); currentTimeSet.cntDroppedFlag = code; |
---|
1215 | sei_read_code( pDecodedMessageOutputStream, 9, code, "n_frames"); currentTimeSet.numberOfFrames = code; |
---|
1216 | if(currentTimeSet.fullTimeStampFlag) |
---|
1217 | { |
---|
1218 | sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code; |
---|
1219 | sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code; |
---|
1220 | sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code; |
---|
1221 | } |
---|
1222 | else |
---|
1223 | { |
---|
1224 | sei_read_flag( pDecodedMessageOutputStream, code, "seconds_flag"); currentTimeSet.secondsFlag = code; |
---|
1225 | if(currentTimeSet.secondsFlag) |
---|
1226 | { |
---|
1227 | sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code; |
---|
1228 | sei_read_flag( pDecodedMessageOutputStream, code, "minutes_flag"); currentTimeSet.minutesFlag = code; |
---|
1229 | if(currentTimeSet.minutesFlag) |
---|
1230 | { |
---|
1231 | sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code; |
---|
1232 | sei_read_flag( pDecodedMessageOutputStream, code, "hours_flag"); currentTimeSet.hoursFlag = code; |
---|
1233 | if(currentTimeSet.hoursFlag) |
---|
1234 | { |
---|
1235 | sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code; |
---|
1236 | } |
---|
1237 | } |
---|
1238 | } |
---|
1239 | } |
---|
1240 | sei_read_code( pDecodedMessageOutputStream, 5, code, "time_offset_length"); currentTimeSet.timeOffsetLength = code; |
---|
1241 | if(currentTimeSet.timeOffsetLength > 0) |
---|
1242 | { |
---|
1243 | sei_read_code( pDecodedMessageOutputStream, currentTimeSet.timeOffsetLength, code, "time_offset_value"); |
---|
1244 | if((code & (1 << (currentTimeSet.timeOffsetLength-1))) == 0) |
---|
1245 | { |
---|
1246 | currentTimeSet.timeOffsetValue = code; |
---|
1247 | } |
---|
1248 | else |
---|
1249 | { |
---|
1250 | code &= (1<< (currentTimeSet.timeOffsetLength-1)) - 1; |
---|
1251 | currentTimeSet.timeOffsetValue = ~code + 1; |
---|
1252 | } |
---|
1253 | } |
---|
1254 | } |
---|
1255 | sei.timeSetArray[i] = currentTimeSet; |
---|
1256 | } |
---|
1257 | } |
---|
1258 | |
---|
1259 | Void SEIReader::xParseSEIChromaSamplingFilterHint(SEIChromaSamplingFilterHint& sei, UInt payloadSize/*, TComSPS* sps*/, std::ostream *pDecodedMessageOutputStream) |
---|
1260 | { |
---|
1261 | UInt uiCode; |
---|
1262 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
1263 | |
---|
1264 | sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "ver_chroma_filter_idc"); sei.m_verChromaFilterIdc = uiCode; |
---|
1265 | sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "hor_chroma_filter_idc"); sei.m_horChromaFilterIdc = uiCode; |
---|
1266 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "ver_filtering_process_flag"); sei.m_verFilteringProcessFlag = uiCode; |
---|
1267 | if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1) |
---|
1268 | { |
---|
1269 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "target_format_idc"); sei.m_targetFormatIdc = uiCode; |
---|
1270 | if(sei.m_verChromaFilterIdc == 1) |
---|
1271 | { |
---|
1272 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_vertical_filters"); sei.m_numVerticalFilters = uiCode; |
---|
1273 | if(sei.m_numVerticalFilters > 0) |
---|
1274 | { |
---|
1275 | sei.m_verTapLengthMinus1 = (Int*)malloc(sei.m_numVerticalFilters * sizeof(Int)); |
---|
1276 | sei.m_verFilterCoeff = (Int**)malloc(sei.m_numVerticalFilters * sizeof(Int*)); |
---|
1277 | for(Int i = 0; i < sei.m_numVerticalFilters; i ++) |
---|
1278 | { |
---|
1279 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ver_tap_length_minus_1"); sei.m_verTapLengthMinus1[i] = uiCode; |
---|
1280 | sei.m_verFilterCoeff[i] = (Int*)malloc(sei.m_verTapLengthMinus1[i] * sizeof(Int)); |
---|
1281 | for(Int j = 0; j < sei.m_verTapLengthMinus1[i]; j ++) |
---|
1282 | { |
---|
1283 | sei_read_svlc( pDecodedMessageOutputStream, sei.m_verFilterCoeff[i][j], "ver_filter_coeff"); |
---|
1284 | } |
---|
1285 | } |
---|
1286 | } |
---|
1287 | } |
---|
1288 | if(sei.m_horChromaFilterIdc == 1) |
---|
1289 | { |
---|
1290 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_horizontal_filters"); sei.m_numHorizontalFilters = uiCode; |
---|
1291 | if(sei.m_numHorizontalFilters > 0) |
---|
1292 | { |
---|
1293 | sei.m_horTapLengthMinus1 = (Int*)malloc(sei.m_numHorizontalFilters * sizeof(Int)); |
---|
1294 | sei.m_horFilterCoeff = (Int**)malloc(sei.m_numHorizontalFilters * sizeof(Int*)); |
---|
1295 | for(Int i = 0; i < sei.m_numHorizontalFilters; i ++) |
---|
1296 | { |
---|
1297 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "hor_tap_length_minus_1"); sei.m_horTapLengthMinus1[i] = uiCode; |
---|
1298 | sei.m_horFilterCoeff[i] = (Int*)malloc(sei.m_horTapLengthMinus1[i] * sizeof(Int)); |
---|
1299 | for(Int j = 0; j < sei.m_horTapLengthMinus1[i]; j ++) |
---|
1300 | { |
---|
1301 | sei_read_svlc( pDecodedMessageOutputStream, sei.m_horFilterCoeff[i][j], "hor_filter_coeff"); |
---|
1302 | } |
---|
1303 | } |
---|
1304 | } |
---|
1305 | } |
---|
1306 | } |
---|
1307 | } |
---|
1308 | |
---|
1309 | Void SEIReader::xParseSEIKneeFunctionInfo(SEIKneeFunctionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1310 | { |
---|
1311 | Int i; |
---|
1312 | UInt val; |
---|
1313 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
1314 | |
---|
1315 | sei_read_uvlc( pDecodedMessageOutputStream, val, "knee_function_id" ); sei.m_kneeId = val; |
---|
1316 | sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_cancel_flag" ); sei.m_kneeCancelFlag = val; |
---|
1317 | if ( !sei.m_kneeCancelFlag ) |
---|
1318 | { |
---|
1319 | sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_persistence_flag" ); sei.m_kneePersistenceFlag = val; |
---|
1320 | sei_read_code( pDecodedMessageOutputStream, 32, val, "input_d_range" ); sei.m_kneeInputDrange = val; |
---|
1321 | sei_read_code( pDecodedMessageOutputStream, 32, val, "input_disp_luminance" ); sei.m_kneeInputDispLuminance = val; |
---|
1322 | sei_read_code( pDecodedMessageOutputStream, 32, val, "output_d_range" ); sei.m_kneeOutputDrange = val; |
---|
1323 | sei_read_code( pDecodedMessageOutputStream, 32, val, "output_disp_luminance" ); sei.m_kneeOutputDispLuminance = val; |
---|
1324 | sei_read_uvlc( pDecodedMessageOutputStream, val, "num_knee_points_minus1" ); sei.m_kneeNumKneePointsMinus1 = val; |
---|
1325 | assert( sei.m_kneeNumKneePointsMinus1 > 0 ); |
---|
1326 | sei.m_kneeInputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); |
---|
1327 | sei.m_kneeOutputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); |
---|
1328 | for(i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ ) |
---|
1329 | { |
---|
1330 | sei_read_code( pDecodedMessageOutputStream, 10, val, "input_knee_point" ); sei.m_kneeInputKneePoint[i] = val; |
---|
1331 | sei_read_code( pDecodedMessageOutputStream, 10, val, "output_knee_point" ); sei.m_kneeOutputKneePoint[i] = val; |
---|
1332 | } |
---|
1333 | } |
---|
1334 | } |
---|
1335 | |
---|
1336 | Void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1337 | { |
---|
1338 | UInt code; |
---|
1339 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
1340 | |
---|
1341 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[0]" ); sei.values.primaries[0][0] = code; |
---|
1342 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[0]" ); sei.values.primaries[0][1] = code; |
---|
1343 | |
---|
1344 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[1]" ); sei.values.primaries[1][0] = code; |
---|
1345 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[1]" ); sei.values.primaries[1][1] = code; |
---|
1346 | |
---|
1347 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[2]" ); sei.values.primaries[2][0] = code; |
---|
1348 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[2]" ); sei.values.primaries[2][1] = code; |
---|
1349 | |
---|
1350 | |
---|
1351 | sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_x" ); sei.values.whitePoint[0] = code; |
---|
1352 | sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_y" ); sei.values.whitePoint[1] = code; |
---|
1353 | |
---|
1354 | sei_read_code( pDecodedMessageOutputStream, 32, code, "max_display_mastering_luminance" ); sei.values.maxLuminance = code; |
---|
1355 | sei_read_code( pDecodedMessageOutputStream, 32, code, "min_display_mastering_luminance" ); sei.values.minLuminance = code; |
---|
1356 | } |
---|
1357 | |
---|
1358 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
1359 | Void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& sei, UInt /*payloadSize*/, std::ostream *pDecodedMessageOutputStream) |
---|
1360 | { |
---|
1361 | UInt uiVal; |
---|
1362 | Int iVal; |
---|
1363 | |
---|
1364 | sei_read_uvlc( pDecodedMessageOutputStream, uiVal, "colour_remap_id" ); sei.m_colourRemapId = uiVal; |
---|
1365 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_cancel_flag" ); sei.m_colourRemapCancelFlag = uiVal; |
---|
1366 | if( !sei.m_colourRemapCancelFlag ) |
---|
1367 | { |
---|
1368 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_persistence_flag" ); sei.m_colourRemapPersistenceFlag = uiVal; |
---|
1369 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_video_signal_info_present_flag" ); sei.m_colourRemapVideoSignalInfoPresentFlag = uiVal; |
---|
1370 | if ( sei.m_colourRemapVideoSignalInfoPresentFlag ) |
---|
1371 | { |
---|
1372 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_full_range_flag" ); sei.m_colourRemapFullRangeFlag = uiVal; |
---|
1373 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_primaries" ); sei.m_colourRemapPrimaries = uiVal; |
---|
1374 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_transfer_function" ); sei.m_colourRemapTransferFunction = uiVal; |
---|
1375 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_matrix_coefficients" ); sei.m_colourRemapMatrixCoefficients = uiVal; |
---|
1376 | } |
---|
1377 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_input_bit_depth" ); sei.m_colourRemapInputBitDepth = uiVal; |
---|
1378 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_bit_depth" ); sei.m_colourRemapBitDepth = uiVal; |
---|
1379 | |
---|
1380 | for( Int c=0 ; c<3 ; c++ ) |
---|
1381 | { |
---|
1382 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "pre_lut_num_val_minus1[c]" ); sei.m_preLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; |
---|
1383 | sei.m_preLutCodedValue[c].resize(sei.m_preLutNumValMinus1[c]+1); |
---|
1384 | sei.m_preLutTargetValue[c].resize(sei.m_preLutNumValMinus1[c]+1); |
---|
1385 | if( uiVal> 0 ) |
---|
1386 | for ( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) |
---|
1387 | { |
---|
1388 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" ); sei.m_preLutCodedValue[c][i] = uiVal; |
---|
1389 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLutTargetValue[c][i] = uiVal; |
---|
1390 | } |
---|
1391 | else // pre_lut_num_val_minus1[c] == 0 |
---|
1392 | { |
---|
1393 | sei.m_preLutCodedValue[c][0] = 0; |
---|
1394 | sei.m_preLutTargetValue[c][0] = 0; |
---|
1395 | sei.m_preLutCodedValue[c][1] = (1 << sei.m_colourRemapInputBitDepth) - 1 ; |
---|
1396 | sei.m_preLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1 ; |
---|
1397 | } |
---|
1398 | } |
---|
1399 | |
---|
1400 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_matrix_present_flag" ); sei.m_colourRemapMatrixPresentFlag = uiVal; |
---|
1401 | if( sei.m_colourRemapMatrixPresentFlag ) |
---|
1402 | { |
---|
1403 | sei_read_code( pDecodedMessageOutputStream, 4, uiVal, "log2_matrix_denom" ); sei.m_log2MatrixDenom = uiVal; |
---|
1404 | for ( Int c=0 ; c<3 ; c++ ) |
---|
1405 | for ( Int i=0 ; i<3 ; i++ ) |
---|
1406 | { |
---|
1407 | sei_read_svlc( pDecodedMessageOutputStream, iVal, "colour_remap_coeffs[c][i]" ); sei.m_colourRemapCoeffs[c][i] = iVal; |
---|
1408 | } |
---|
1409 | } |
---|
1410 | else // setting default matrix (I3) |
---|
1411 | { |
---|
1412 | sei.m_log2MatrixDenom = 0; |
---|
1413 | for ( Int c=0 ; c<3 ; c++ ) |
---|
1414 | for ( Int i=0 ; i<3 ; i++ ) |
---|
1415 | sei.m_colourRemapCoeffs[c][i] = (c==i) ? 1 : 0; |
---|
1416 | } |
---|
1417 | for( Int c=0 ; c<3 ; c++ ) |
---|
1418 | { |
---|
1419 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "post_lut_num_val_minus1[c]" ); sei.m_postLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; |
---|
1420 | sei.m_postLutCodedValue[c].resize(sei.m_postLutNumValMinus1[c]+1); |
---|
1421 | sei.m_postLutTargetValue[c].resize(sei.m_postLutNumValMinus1[c]+1); |
---|
1422 | if( uiVal > 0 ) |
---|
1423 | for ( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) |
---|
1424 | { |
---|
1425 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" ); sei.m_postLutCodedValue[c][i] = uiVal; |
---|
1426 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLutTargetValue[c][i] = uiVal; |
---|
1427 | } |
---|
1428 | else |
---|
1429 | { |
---|
1430 | sei.m_postLutCodedValue[c][0] = 0; |
---|
1431 | sei.m_postLutTargetValue[c][0] = 0; |
---|
1432 | sei.m_postLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1; |
---|
1433 | sei.m_postLutCodedValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1; |
---|
1434 | } |
---|
1435 | } |
---|
1436 | } |
---|
1437 | } |
---|
1438 | #endif |
---|
1439 | |
---|
1440 | |
---|
1441 | #if SVC_EXTENSION |
---|
1442 | #if LAYERS_NOT_PRESENT_SEI |
---|
1443 | Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, const TComVPS *vps, std::ostream *pDecodedMessageOutputStream) |
---|
1444 | { |
---|
1445 | UInt uiCode; |
---|
1446 | UInt i = 0; |
---|
1447 | |
---|
1448 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "lp_sei_active_vps_id" ); sei.m_activeVpsId = uiCode; |
---|
1449 | assert(vps->getVPSId() == sei.m_activeVpsId); |
---|
1450 | sei.m_vpsMaxLayers = vps->getMaxLayers(); |
---|
1451 | for (; i < sei.m_vpsMaxLayers; i++) |
---|
1452 | { |
---|
1453 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "layer_not_present_flag" ); sei.m_layerNotPresentFlag[i] = uiCode ? true : false; |
---|
1454 | } |
---|
1455 | for (; i < MAX_LAYERS; i++) |
---|
1456 | { |
---|
1457 | sei.m_layerNotPresentFlag[i] = false; |
---|
1458 | } |
---|
1459 | } |
---|
1460 | #endif |
---|
1461 | |
---|
1462 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
1463 | Void SEIReader::xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1464 | { |
---|
1465 | UInt uiCode; |
---|
1466 | |
---|
1467 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_all_tiles_exact_sample_value_match_flag" ); sei.m_ilAllTilesExactSampleValueMatchFlag = uiCode; |
---|
1468 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_one_tile_per_tile_set_flag" ); sei.m_ilOneTilePerTileSetFlag = uiCode; |
---|
1469 | if( !sei.m_ilOneTilePerTileSetFlag ) |
---|
1470 | { |
---|
1471 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_num_sets_in_message_minus1" ); sei.m_ilNumSetsInMessageMinus1 = uiCode; |
---|
1472 | if( sei.m_ilNumSetsInMessageMinus1 ) |
---|
1473 | { |
---|
1474 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "skipped_tile_set_present_flag" ); sei.m_skippedTileSetPresentFlag = uiCode; |
---|
1475 | } |
---|
1476 | else |
---|
1477 | { |
---|
1478 | sei.m_skippedTileSetPresentFlag = false; |
---|
1479 | } |
---|
1480 | UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1; |
---|
1481 | for( UInt i = 0; i < numSignificantSets; i++ ) |
---|
1482 | { |
---|
1483 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ilcts_id" ); sei.m_ilctsId[i] = uiCode; |
---|
1484 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_num_tile_rects_in_set_minus1" ) ;sei.m_ilNumTileRectsInSetMinus1[i] = uiCode; |
---|
1485 | for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ ) |
---|
1486 | { |
---|
1487 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_top_left_tile_index" ); sei.m_ilTopLeftTileIndex[i][j] = uiCode; |
---|
1488 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_bottom_right_tile_index" ); sei.m_ilBottomRightTileIndex[i][j] = uiCode; |
---|
1489 | } |
---|
1490 | sei_read_code( pDecodedMessageOutputStream, 2, uiCode, "ilc_idc" ); sei.m_ilcIdc[i] = uiCode; |
---|
1491 | if( sei.m_ilAllTilesExactSampleValueMatchFlag ) |
---|
1492 | { |
---|
1493 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_exact_sample_value_match_flag" ); sei.m_ilExactSampleValueMatchFlag[i] = uiCode; |
---|
1494 | } |
---|
1495 | } |
---|
1496 | } |
---|
1497 | else |
---|
1498 | { |
---|
1499 | sei_read_code( pDecodedMessageOutputStream, 2, uiCode, "all_tiles_ilc_idc" ); sei.m_allTilesIlcIdc = uiCode; |
---|
1500 | } |
---|
1501 | } |
---|
1502 | #endif |
---|
1503 | |
---|
1504 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
1505 | Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, const TComVPS *vps, std::ostream *pDecodedMessageOutputStream) |
---|
1506 | { |
---|
1507 | UInt uiCode; |
---|
1508 | sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "active_vps_id" ); sei.m_activeVpsId = uiCode; |
---|
1509 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreams = uiCode + 1; |
---|
1510 | |
---|
1511 | for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ ) |
---|
1512 | { |
---|
1513 | sei_read_code( pDecodedMessageOutputStream, 2, uiCode, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = uiCode; |
---|
1514 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "output_layer_set_idx_to_vps[i]" ); |
---|
1515 | |
---|
1516 | // The value of output_layer_set_idx_to_vps[ i ] shall be in the range of 0 to NumOutputLayerSets − 1, inclusive. |
---|
1517 | assert(uiCode > 0 && uiCode <= vps->getNumOutputLayerSets()-1); |
---|
1518 | |
---|
1519 | sei.m_outputLayerSetIdxToVps[i] = uiCode; |
---|
1520 | |
---|
1521 | sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = uiCode; |
---|
1522 | sei_read_code( pDecodedMessageOutputStream, 16, uiCode, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = uiCode; |
---|
1523 | sei_read_code( pDecodedMessageOutputStream, 16, uiCode, "max_bit_rate[i]" ); sei.m_maxBitRate[i] = uiCode; |
---|
1524 | } |
---|
1525 | } |
---|
1526 | #endif |
---|
1527 | |
---|
1528 | #if O0164_MULTI_LAYER_HRD |
---|
1529 | #if LAYERS_NOT_PRESENT_SEI |
---|
1530 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting &nestingSei, std::ostream *pDecodedMessageOutputStream) |
---|
1531 | #else |
---|
1532 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, const TComSPS *sps, const SEIScalableNesting &nestingSei, std::ostream *pDecodedMessageOutputStream) |
---|
1533 | #endif |
---|
1534 | { |
---|
1535 | UInt uiCode; |
---|
1536 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bsp_idx" ); sei.m_bspIdx = uiCode; |
---|
1537 | |
---|
1538 | // byte alignment |
---|
1539 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1540 | { |
---|
1541 | UInt code; |
---|
1542 | sei_read_flag( pDecodedMessageOutputStream, code, "bsp_nesting_zero_bit" ); |
---|
1543 | } |
---|
1544 | |
---|
1545 | sei.m_callerOwnsSEIs = false; |
---|
1546 | |
---|
1547 | // read nested SEI messages |
---|
1548 | Int numSeiMessages = 0; |
---|
1549 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_seis_in_bsp_minus1" ); assert( uiCode <= MAX_SEIS_IN_BSP_NESTING ); |
---|
1550 | numSeiMessages = uiCode; |
---|
1551 | for(Int i = 0; i < numSeiMessages; i++) |
---|
1552 | { |
---|
1553 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream, &nestingSei, &sei); |
---|
1554 | } |
---|
1555 | } |
---|
1556 | |
---|
1557 | Void SEIReader::xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime &sei, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei, std::ostream *pDecodedMessageOutputStream) |
---|
1558 | { |
---|
1559 | assert(vps->getVpsVuiPresentFlag()); |
---|
1560 | |
---|
1561 | UInt uiCode; |
---|
1562 | Int psIdx = bspNestingSei.m_seiPartitioningSchemeIdx; |
---|
1563 | Int seiOlsIdx = bspNestingSei.m_seiOlsIdx; |
---|
1564 | Int maxTemporalId = nestingSei.m_nestingMaxTemporalIdPlus1[0]; |
---|
1565 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
---|
1566 | std::vector<Int> hrdIdx(0, maxValues); |
---|
1567 | std::vector<const TComHRD*> hrdVec; |
---|
1568 | std::vector<Int> syntaxElemLen; |
---|
1569 | for(Int i = 0; i < maxValues; i++) |
---|
1570 | { |
---|
1571 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei.m_bspIdx); |
---|
1572 | hrdVec[i] = vps->getBspHrd(hrdIdx[i]); |
---|
1573 | |
---|
1574 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
1575 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
1576 | { |
---|
1577 | assert( syntaxElemLen[i] == 24 ); // Default value of init_cpb_removal_delay_length_minus1 is 23 |
---|
1578 | } |
---|
1579 | if( i > 0 ) |
---|
1580 | { |
---|
1581 | assert( hrdVec[i]->getNalHrdParametersPresentFlag() == hrdVec[i-1]->getNalHrdParametersPresentFlag() ); |
---|
1582 | assert( hrdVec[i]->getVclHrdParametersPresentFlag() == hrdVec[i-1]->getVclHrdParametersPresentFlag() ); |
---|
1583 | } |
---|
1584 | } |
---|
1585 | if (hrdVec[0]->getNalHrdParametersPresentFlag()) |
---|
1586 | { |
---|
1587 | for(UInt i = 0; i < maxValues; i++) |
---|
1588 | { |
---|
1589 | sei_read_code( pDecodedMessageOutputStream, syntaxElemLen[i], uiCode, "nal_initial_arrival_delay[i]" ); sei.m_nalInitialArrivalDelay[i] = uiCode; |
---|
1590 | } |
---|
1591 | } |
---|
1592 | if( hrdVec[0]->getVclHrdParametersPresentFlag() ) |
---|
1593 | { |
---|
1594 | for(UInt i = 0; i < maxValues; i++) |
---|
1595 | { |
---|
1596 | sei_read_code( pDecodedMessageOutputStream, syntaxElemLen[i], uiCode, "vcl_initial_arrival_delay[i]" ); sei.m_vclInitialArrivalDelay[i] = uiCode; |
---|
1597 | } |
---|
1598 | } |
---|
1599 | } |
---|
1600 | |
---|
1601 | Void SEIReader::xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1, std::ostream *pDecodedMessageOutputStream) |
---|
1602 | { |
---|
1603 | UInt uiCode; |
---|
1604 | if( commonInfPresentFlag ) |
---|
1605 | { |
---|
1606 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
1607 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
1608 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
1609 | { |
---|
1610 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
1611 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
1612 | { |
---|
1613 | sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
1614 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
1615 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
1616 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
1617 | } |
---|
1618 | sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
1619 | sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
1620 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
1621 | { |
---|
1622 | sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
1623 | } |
---|
1624 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
1625 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
1626 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
1627 | } |
---|
1628 | } |
---|
1629 | Int i, j, nalOrVcl; |
---|
1630 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
1631 | { |
---|
1632 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
1633 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
1634 | { |
---|
1635 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
1636 | } |
---|
1637 | else |
---|
1638 | { |
---|
1639 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
1640 | } |
---|
1641 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
1642 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
1643 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
1644 | { |
---|
1645 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
1646 | } |
---|
1647 | else |
---|
1648 | { |
---|
1649 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
1650 | } |
---|
1651 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
1652 | { |
---|
1653 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
1654 | } |
---|
1655 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
1656 | { |
---|
1657 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
1658 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
1659 | { |
---|
1660 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
1661 | { |
---|
1662 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1663 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1664 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
1665 | { |
---|
1666 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1667 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1668 | } |
---|
1669 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
1670 | } |
---|
1671 | } |
---|
1672 | } |
---|
1673 | } |
---|
1674 | } |
---|
1675 | #endif |
---|
1676 | |
---|
1677 | #if P0123_ALPHA_CHANNEL_SEI |
---|
1678 | void SEIReader::xParseSEIAlphaChannelInfo(SEIAlphaChannelInfo &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1679 | { |
---|
1680 | UInt value; |
---|
1681 | sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_cancel_flag"); sei.m_alphaChannelCancelFlag = value; |
---|
1682 | if(!sei.m_alphaChannelCancelFlag) |
---|
1683 | { |
---|
1684 | sei_read_code(pDecodedMessageOutputStream, 3, value, "alpha_channel_use_idc"); sei.m_alphaChannelUseIdc = value; |
---|
1685 | sei_read_code(pDecodedMessageOutputStream, 3, value, "alpha_channel_bit_depth_minus8"); sei.m_alphaChannelBitDepthMinus8 = value; |
---|
1686 | sei_read_code(pDecodedMessageOutputStream, sei.m_alphaChannelBitDepthMinus8 + 9, value, "alpha_transparent_value"); sei.m_alphaTransparentValue = value; |
---|
1687 | sei_read_code(pDecodedMessageOutputStream, sei.m_alphaChannelBitDepthMinus8 + 9, value, "alpha_opaque_value"); sei.m_alphaOpaqueValue = value; |
---|
1688 | sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_incr_flag"); sei.m_alphaChannelIncrFlag = value; |
---|
1689 | sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_clip_flag"); sei.m_alphaChannelClipFlag = value; |
---|
1690 | if(sei.m_alphaChannelClipFlag) |
---|
1691 | { |
---|
1692 | sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_clip_type_flag"); sei.m_alphaChannelClipTypeFlag = value; |
---|
1693 | } |
---|
1694 | } |
---|
1695 | } |
---|
1696 | #endif |
---|
1697 | |
---|
1698 | #if Q0096_OVERLAY_SEI |
---|
1699 | Void SEIReader::xParseSEIOverlayInfo(SEIOverlayInfo& sei, UInt /*payloadSize*/, std::ostream *pDecodedMessageOutputStream) |
---|
1700 | { |
---|
1701 | Int i, j; |
---|
1702 | UInt val; |
---|
1703 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_info_cancel_flag" ); sei.m_overlayInfoCancelFlag = val; |
---|
1704 | if ( !sei.m_overlayInfoCancelFlag ) |
---|
1705 | { |
---|
1706 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_content_aux_id_minus128" ); sei.m_overlayContentAuxIdMinus128 = val; |
---|
1707 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_label_aux_id_minus128" ); sei.m_overlayLabelAuxIdMinus128 = val; |
---|
1708 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_alpha_aux_id_minus128" ); sei.m_overlayAlphaAuxIdMinus128 = val; |
---|
1709 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_element_label_value_length_minus8" ); sei.m_overlayElementLabelValueLengthMinus8 = val; |
---|
1710 | sei_read_uvlc( pDecodedMessageOutputStream, val, "num_overlays_minus1" ); sei.m_numOverlaysMinus1 = val; |
---|
1711 | |
---|
1712 | assert( sei.m_numOverlaysMinus1 < MAX_OVERLAYS ); |
---|
1713 | sei.m_overlayIdx.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1714 | sei.m_languageOverlayPresentFlag.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1715 | sei.m_overlayContentLayerId.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1716 | sei.m_overlayLabelPresentFlag.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1717 | sei.m_overlayLabelLayerId.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1718 | sei.m_overlayAlphaPresentFlag.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1719 | sei.m_overlayAlphaLayerId.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1720 | sei.m_numOverlayElementsMinus1.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1721 | sei.m_overlayElementLabelMin.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1722 | sei.m_overlayElementLabelMax.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1723 | for ( i=0 ; i<=sei.m_numOverlaysMinus1 ; i++ ) |
---|
1724 | { |
---|
1725 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_idx" ); sei.m_overlayIdx[i] = val; |
---|
1726 | sei_read_flag( pDecodedMessageOutputStream, val, "language_overlay_present_flag" ); sei.m_languageOverlayPresentFlag[i] = val; |
---|
1727 | sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_content_layer_id"); sei.m_overlayContentLayerId[i] = val; |
---|
1728 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_label_present_flag" ); sei.m_overlayLabelPresentFlag[i] = val; |
---|
1729 | if ( sei.m_overlayLabelPresentFlag[i] ) |
---|
1730 | { |
---|
1731 | sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_label_layer_id"); sei.m_overlayLabelLayerId[i] = val; |
---|
1732 | } |
---|
1733 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_alpha_present_flag" ); sei.m_overlayAlphaPresentFlag[i] = val; |
---|
1734 | if ( sei.m_overlayAlphaPresentFlag[i] ) |
---|
1735 | { |
---|
1736 | sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_alpha_layer_id"); sei.m_overlayAlphaLayerId[i] = val; |
---|
1737 | } |
---|
1738 | if ( sei.m_overlayLabelPresentFlag[i] ) |
---|
1739 | { |
---|
1740 | sei_read_uvlc( pDecodedMessageOutputStream, val, "num_overlay_elements_minus1"); sei.m_numOverlayElementsMinus1[i] = val; |
---|
1741 | assert( sei.m_numOverlayElementsMinus1[i] < MAX_OVERLAY_ELEMENTS ); |
---|
1742 | sei.m_overlayElementLabelMin[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
---|
1743 | sei.m_overlayElementLabelMax[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
---|
1744 | for ( j=0 ; j<=sei.m_numOverlayElementsMinus1[i] ; j++ ) |
---|
1745 | { |
---|
1746 | sei_read_code( pDecodedMessageOutputStream, sei.m_overlayElementLabelValueLengthMinus8 + 8, val, "overlay_element_label_min"); sei.m_overlayElementLabelMin[i][j] = val; |
---|
1747 | sei_read_code( pDecodedMessageOutputStream, sei.m_overlayElementLabelValueLengthMinus8 + 8, val, "overlay_element_label_max"); sei.m_overlayElementLabelMax[i][j] = val; |
---|
1748 | } |
---|
1749 | } |
---|
1750 | else |
---|
1751 | { |
---|
1752 | sei.m_numOverlayElementsMinus1[i] = 0; |
---|
1753 | } |
---|
1754 | } |
---|
1755 | |
---|
1756 | // byte alignment |
---|
1757 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1758 | { |
---|
1759 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_zero_bit" ); |
---|
1760 | assert( val==0 ); |
---|
1761 | } |
---|
1762 | |
---|
1763 | UChar* sval = new UChar[MAX_OVERLAY_STRING_BYTES]; |
---|
1764 | UInt slen; |
---|
1765 | sei.m_overlayLanguage.resize( sei.m_numOverlaysMinus1+1, NULL ); |
---|
1766 | sei.m_overlayLanguageLength.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1767 | sei.m_overlayName.resize( sei.m_numOverlaysMinus1+1, NULL ); |
---|
1768 | sei.m_overlayNameLength.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1769 | sei.m_overlayElementName.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1770 | sei.m_overlayElementNameLength.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1771 | for ( i=0 ; i<=sei.m_numOverlaysMinus1 ; i++ ) |
---|
1772 | { |
---|
1773 | if ( sei.m_languageOverlayPresentFlag[i] ) |
---|
1774 | { |
---|
1775 | READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_language" ); |
---|
1776 | sei.m_overlayLanguage[i] = new UChar[slen]; |
---|
1777 | memcpy(sei.m_overlayLanguage[i], sval, slen); |
---|
1778 | sei.m_overlayLanguageLength[i] = slen; |
---|
1779 | } |
---|
1780 | READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_name" ); |
---|
1781 | sei.m_overlayName[i] = new UChar[slen]; |
---|
1782 | memcpy(sei.m_overlayName[i], sval, slen); |
---|
1783 | sei.m_overlayNameLength[i] = slen; |
---|
1784 | if ( sei.m_overlayLabelPresentFlag[i] ) |
---|
1785 | { |
---|
1786 | sei.m_overlayElementName[i].resize( sei.m_numOverlayElementsMinus1[i]+1, NULL ); |
---|
1787 | sei.m_overlayElementNameLength[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
---|
1788 | for ( j=0 ; j<=sei.m_numOverlayElementsMinus1[i] ; j++) |
---|
1789 | { |
---|
1790 | READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_element_name" ); |
---|
1791 | sei.m_overlayElementName[i][j] = new UChar[slen]; |
---|
1792 | memcpy(sei.m_overlayElementName[i][j], sval, slen); |
---|
1793 | sei.m_overlayElementNameLength[i][j] = slen; |
---|
1794 | } |
---|
1795 | } |
---|
1796 | } |
---|
1797 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_info_persistence_flag" ); sei.m_overlayInfoPersistenceFlag = val; |
---|
1798 | } |
---|
1799 | } |
---|
1800 | #endif |
---|
1801 | |
---|
1802 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
---|
1803 | /** |
---|
1804 | * Check if SEI message contains payload extension |
---|
1805 | */ |
---|
1806 | Bool SEIReader::xPayloadExtensionPresent() |
---|
1807 | { |
---|
1808 | Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); |
---|
1809 | Bool payloadExtensionPresent = false; |
---|
1810 | |
---|
1811 | if (payloadBitsRemaining > 8) |
---|
1812 | { |
---|
1813 | payloadExtensionPresent = true; |
---|
1814 | } |
---|
1815 | else |
---|
1816 | { |
---|
1817 | Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); |
---|
1818 | while (payloadBitsRemaining && (finalBits & 1) == 0) |
---|
1819 | { |
---|
1820 | payloadBitsRemaining--; |
---|
1821 | finalBits >>= 1; |
---|
1822 | } |
---|
1823 | payloadBitsRemaining--; |
---|
1824 | if (payloadBitsRemaining > 0) |
---|
1825 | { |
---|
1826 | payloadExtensionPresent = true; |
---|
1827 | } |
---|
1828 | } |
---|
1829 | |
---|
1830 | return payloadExtensionPresent; |
---|
1831 | } |
---|
1832 | #endif |
---|
1833 | |
---|
1834 | #if Q0189_TMVP_CONSTRAINTS |
---|
1835 | Void SEIReader::xParseSEITMVPConstraints (SEITMVPConstrains& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1836 | { |
---|
1837 | UInt uiCode; |
---|
1838 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "prev_pics_not_used_flag" ); sei.prev_pics_not_used_flag = uiCode; |
---|
1839 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "no_intra_layer_col_pic_flag" ); sei.no_intra_layer_col_pic_flag = uiCode; |
---|
1840 | } |
---|
1841 | #endif |
---|
1842 | |
---|
1843 | #if Q0247_FRAME_FIELD_INFO |
---|
1844 | Void SEIReader::xParseSEIFrameFieldInfo (SEIFrameFieldInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1845 | { |
---|
1846 | UInt code; |
---|
1847 | sei_read_code( pDecodedMessageOutputStream, 4, code, "ffinfo_pic_struct" ); sei.m_ffinfo_picStruct = code; |
---|
1848 | sei_read_code( pDecodedMessageOutputStream, 2, code, "ffinfo_source_scan_type" ); sei.m_ffinfo_sourceScanType = code; |
---|
1849 | sei_read_flag( pDecodedMessageOutputStream, code, "ffinfo_duplicate_flag" ); sei.m_ffinfo_duplicateFlag = ( code == 1 ? true : false ); |
---|
1850 | } |
---|
1851 | #endif |
---|
1852 | |
---|
1853 | |
---|
1854 | #endif //SVC_EXTENSION |
---|
1855 | |
---|
1856 | //! \} |
---|