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 | |
---|
687 | Int schedSelIdx = 0; |
---|
688 | |
---|
689 | for(i = 0; i < maxValues; i++) |
---|
690 | { |
---|
691 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); |
---|
692 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
---|
693 | |
---|
694 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
695 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
696 | { |
---|
697 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
---|
698 | } |
---|
699 | if( i > 0 ) |
---|
700 | { |
---|
701 | assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() ); |
---|
702 | assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); |
---|
703 | assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); |
---|
704 | } |
---|
705 | } |
---|
706 | pHRD = hrdVec[schedSelIdx]; |
---|
707 | } |
---|
708 | else |
---|
709 | { |
---|
710 | const TComVUI *vui = sps->getVuiParameters(); |
---|
711 | pHRD = vui->getHrdParameters(); |
---|
712 | } |
---|
713 | // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently. |
---|
714 | #else |
---|
715 | const TComVUI *pVUI = sps->getVuiParameters(); |
---|
716 | const TComHRD *pHRD = pVUI->getHrdParameters(); |
---|
717 | #endif |
---|
718 | |
---|
719 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
720 | |
---|
721 | sei_read_uvlc( pDecodedMessageOutputStream, code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; |
---|
722 | if( !pHRD->getSubPicCpbParamsPresentFlag() ) |
---|
723 | { |
---|
724 | sei_read_flag( pDecodedMessageOutputStream, code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code; |
---|
725 | } |
---|
726 | if( sei.m_rapCpbParamsPresentFlag ) |
---|
727 | { |
---|
728 | sei_read_code( pDecodedMessageOutputStream, pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; |
---|
729 | sei_read_code( pDecodedMessageOutputStream, pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; |
---|
730 | } |
---|
731 | |
---|
732 | //read splicing flag and cpb_removal_delay_delta |
---|
733 | sei_read_flag( pDecodedMessageOutputStream, code, "concatenation_flag"); |
---|
734 | sei.m_concatenationFlag = code; |
---|
735 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" ); |
---|
736 | sei.m_auCpbRemovalDelayDelta = code + 1; |
---|
737 | |
---|
738 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
739 | { |
---|
740 | if( ( ( nalOrVcl == 0 ) && ( pHRD->getNalHrdParametersPresentFlag() ) ) || |
---|
741 | ( ( nalOrVcl == 1 ) && ( pHRD->getVclHrdParametersPresentFlag() ) ) ) |
---|
742 | { |
---|
743 | for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ ) |
---|
744 | { |
---|
745 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_delay":"nal_initial_cpb_removal_delay" ); |
---|
746 | sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code; |
---|
747 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_offset":"vcl_initial_cpb_removal_offset" ); |
---|
748 | sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code; |
---|
749 | if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag ) |
---|
750 | { |
---|
751 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_delay":"vcl_initial_alt_cpb_removal_delay" ); |
---|
752 | sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code; |
---|
753 | sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_offset":"vcl_initial_alt_cpb_removal_offset" ); |
---|
754 | sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code; |
---|
755 | } |
---|
756 | } |
---|
757 | } |
---|
758 | } |
---|
759 | |
---|
760 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
---|
761 | sei.m_useAltCpbParamsFlag = false; |
---|
762 | sei.m_useAltCpbParamsFlagPresent = false; |
---|
763 | if (xPayloadExtensionPresent()) |
---|
764 | { |
---|
765 | sei_read_flag( pDecodedMessageOutputStream, code, "use_alt_cpb_params_flag"); |
---|
766 | sei.m_useAltCpbParamsFlag = code; |
---|
767 | sei.m_useAltCpbParamsFlagPresent = true; |
---|
768 | } |
---|
769 | #endif |
---|
770 | } |
---|
771 | |
---|
772 | #if SVC_EXTENSION |
---|
773 | Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize, const TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, const TComVPS *vps, std::ostream *pDecodedMessageOutputStream) |
---|
774 | #else |
---|
775 | Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
---|
776 | #endif |
---|
777 | { |
---|
778 | Int i; |
---|
779 | UInt code; |
---|
780 | |
---|
781 | #if SVC_EXTENSION |
---|
782 | const TComHRD *hrd; |
---|
783 | const TComVUI *vui = sps->getVuiParameters(); |
---|
784 | if( bspNestingSei ) // If BP SEI contained inside a BSP nesting SEI message |
---|
785 | { |
---|
786 | assert( nestingSei ); |
---|
787 | Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; |
---|
788 | Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; |
---|
789 | Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; |
---|
790 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
---|
791 | std::vector<Int> hrdIdx(maxValues, 0); |
---|
792 | std::vector<const TComHRD*> hrdVec; |
---|
793 | std::vector<Int> syntaxElemLen(maxValues, 0); |
---|
794 | for(i = 0; i < maxValues; i++) |
---|
795 | { |
---|
796 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); |
---|
797 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
---|
798 | |
---|
799 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
800 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
801 | { |
---|
802 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
---|
803 | } |
---|
804 | if( i > 0 ) |
---|
805 | { |
---|
806 | assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); |
---|
807 | assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag() == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() ); |
---|
808 | assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() ); |
---|
809 | assert( hrdVec[i]->getDpbOutputDelayLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayLengthMinus1() ); |
---|
810 | assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); |
---|
811 | assert( hrdVec[i]->getDuCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getDuCpbRemovalDelayLengthMinus1() ); |
---|
812 | // To be done: Check CpbDpbDelaysPresentFlag |
---|
813 | } |
---|
814 | } |
---|
815 | hrd = hrdVec[0]; |
---|
816 | } |
---|
817 | else |
---|
818 | { |
---|
819 | hrd = vui->getHrdParameters(); |
---|
820 | } |
---|
821 | // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently. |
---|
822 | #else |
---|
823 | const TComVUI *vui = sps->getVuiParameters(); |
---|
824 | const TComHRD *hrd = vui->getHrdParameters(); |
---|
825 | #endif |
---|
826 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
827 | |
---|
828 | if( vui->getFrameFieldInfoPresentFlag() ) |
---|
829 | { |
---|
830 | sei_read_code( pDecodedMessageOutputStream, 4, code, "pic_struct" ); sei.m_picStruct = code; |
---|
831 | sei_read_code( pDecodedMessageOutputStream, 2, code, "source_scan_type" ); sei.m_sourceScanType = code; |
---|
832 | sei_read_flag( pDecodedMessageOutputStream, code, "duplicate_flag" ); sei.m_duplicateFlag = (code == 1); |
---|
833 | } |
---|
834 | |
---|
835 | if( hrd->getCpbDpbDelaysPresentFlag()) |
---|
836 | { |
---|
837 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" ); |
---|
838 | sei.m_auCpbRemovalDelay = code + 1; |
---|
839 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" ); |
---|
840 | sei.m_picDpbOutputDelay = code; |
---|
841 | |
---|
842 | if(hrd->getSubPicCpbParamsPresentFlag()) |
---|
843 | { |
---|
844 | sei_read_code( pDecodedMessageOutputStream, hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" ); |
---|
845 | sei.m_picDpbOutputDuDelay = code; |
---|
846 | } |
---|
847 | |
---|
848 | if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) |
---|
849 | { |
---|
850 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_decoding_units_minus1"); |
---|
851 | sei.m_numDecodingUnitsMinus1 = code; |
---|
852 | sei_read_flag( pDecodedMessageOutputStream, code, "du_common_cpb_removal_delay_flag" ); |
---|
853 | sei.m_duCommonCpbRemovalDelayFlag = code; |
---|
854 | if( sei.m_duCommonCpbRemovalDelayFlag ) |
---|
855 | { |
---|
856 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_increment_minus1" ); |
---|
857 | sei.m_duCommonCpbRemovalDelayMinus1 = code; |
---|
858 | } |
---|
859 | sei.m_numNalusInDuMinus1.resize(sei.m_numDecodingUnitsMinus1 + 1 ); |
---|
860 | sei.m_duCpbRemovalDelayMinus1.resize( sei.m_numDecodingUnitsMinus1 + 1 ); |
---|
861 | |
---|
862 | for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ ) |
---|
863 | { |
---|
864 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_nalus_in_du_minus1[i]"); |
---|
865 | sei.m_numNalusInDuMinus1[ i ] = code; |
---|
866 | if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) ) |
---|
867 | { |
---|
868 | sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1[i]" ); |
---|
869 | sei.m_duCpbRemovalDelayMinus1[ i ] = code; |
---|
870 | } |
---|
871 | } |
---|
872 | } |
---|
873 | } |
---|
874 | } |
---|
875 | |
---|
876 | Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
877 | { |
---|
878 | Int iCode; |
---|
879 | UInt uiCode; |
---|
880 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
881 | |
---|
882 | sei_read_svlc( pDecodedMessageOutputStream, iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; |
---|
883 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; |
---|
884 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; |
---|
885 | } |
---|
886 | |
---|
887 | Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
888 | { |
---|
889 | UInt val; |
---|
890 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
891 | |
---|
892 | sei_read_uvlc( pDecodedMessageOutputStream, val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; |
---|
893 | sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; |
---|
894 | |
---|
895 | if ( !sei.m_arrangementCancelFlag ) |
---|
896 | { |
---|
897 | sei_read_code( pDecodedMessageOutputStream, 7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val; |
---|
898 | assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) ); |
---|
899 | |
---|
900 | sei_read_flag( pDecodedMessageOutputStream, val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; |
---|
901 | |
---|
902 | sei_read_code( pDecodedMessageOutputStream, 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; |
---|
903 | sei_read_flag( pDecodedMessageOutputStream, val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; |
---|
904 | sei_read_flag( pDecodedMessageOutputStream, val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; |
---|
905 | sei_read_flag( pDecodedMessageOutputStream, val, "field_views_flag" ); sei.m_fieldViewsFlag = val; |
---|
906 | sei_read_flag( pDecodedMessageOutputStream, val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; |
---|
907 | sei_read_flag( pDecodedMessageOutputStream, val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; |
---|
908 | sei_read_flag( pDecodedMessageOutputStream, val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; |
---|
909 | |
---|
910 | if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) |
---|
911 | { |
---|
912 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; |
---|
913 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; |
---|
914 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; |
---|
915 | sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; |
---|
916 | } |
---|
917 | |
---|
918 | sei_read_code( pDecodedMessageOutputStream, 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; |
---|
919 | sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = (val != 0); |
---|
920 | } |
---|
921 | sei_read_flag( pDecodedMessageOutputStream, val, "upsampled_aspect_ratio_flag" ); sei.m_upsampledAspectRatio = val; |
---|
922 | } |
---|
923 | |
---|
924 | Void SEIReader::xParseSEISegmentedRectFramePacking(SEISegmentedRectFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
925 | { |
---|
926 | UInt val; |
---|
927 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
928 | sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; |
---|
929 | if( !sei.m_arrangementCancelFlag ) |
---|
930 | { |
---|
931 | sei_read_code( pDecodedMessageOutputStream, 2, val, "segmented_rect_content_interpretation_type" ); sei.m_contentInterpretationType = val; |
---|
932 | sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_persistence" ); sei.m_arrangementPersistenceFlag = val; |
---|
933 | } |
---|
934 | } |
---|
935 | |
---|
936 | Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
937 | { |
---|
938 | UInt val; |
---|
939 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
940 | sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; |
---|
941 | if( !sei.cancelFlag ) |
---|
942 | { |
---|
943 | sei_read_flag( pDecodedMessageOutputStream, val, "hor_flip" ); sei.horFlip = val; |
---|
944 | sei_read_flag( pDecodedMessageOutputStream, val, "ver_flip" ); sei.verFlip = val; |
---|
945 | sei_read_code( pDecodedMessageOutputStream, 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; |
---|
946 | sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; |
---|
947 | } |
---|
948 | } |
---|
949 | |
---|
950 | Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
951 | { |
---|
952 | UInt val; |
---|
953 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
954 | sei_read_code( pDecodedMessageOutputStream, 8, val, "temporal_sub_layer_zero_idx" ); sei.tl0Idx = val; |
---|
955 | sei_read_code( pDecodedMessageOutputStream, 8, val, "irap_pic_id" ); sei.rapIdx = val; |
---|
956 | } |
---|
957 | |
---|
958 | Void SEIReader::xParseSEIRegionRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
959 | { |
---|
960 | UInt val; |
---|
961 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
962 | sei_read_flag( pDecodedMessageOutputStream, val, "refreshed_region_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; |
---|
963 | } |
---|
964 | |
---|
965 | Void SEIReader::xParseSEINoDisplay(SEINoDisplay& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
966 | { |
---|
967 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
968 | sei.m_noDisplay = true; |
---|
969 | } |
---|
970 | |
---|
971 | Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
972 | { |
---|
973 | Int i; |
---|
974 | UInt val; |
---|
975 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
976 | sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_id" ); sei.m_toneMapId = val; |
---|
977 | sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; |
---|
978 | |
---|
979 | if ( !sei.m_toneMapCancelFlag ) |
---|
980 | { |
---|
981 | sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val; |
---|
982 | sei_read_code( pDecodedMessageOutputStream, 8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val; |
---|
983 | sei_read_code( pDecodedMessageOutputStream, 8, val, "target_bit_depth" ); sei.m_targetBitDepth = val; |
---|
984 | sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_model_id" ); sei.m_modelId = val; |
---|
985 | switch(sei.m_modelId) |
---|
986 | { |
---|
987 | case 0: |
---|
988 | { |
---|
989 | sei_read_code( pDecodedMessageOutputStream, 32, val, "min_value" ); sei.m_minValue = val; |
---|
990 | sei_read_code( pDecodedMessageOutputStream, 32, val, "max_value" ); sei.m_maxValue = val; |
---|
991 | break; |
---|
992 | } |
---|
993 | case 1: |
---|
994 | { |
---|
995 | sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val; |
---|
996 | sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val; |
---|
997 | break; |
---|
998 | } |
---|
999 | case 2: |
---|
1000 | { |
---|
1001 | UInt num = 1u << sei.m_targetBitDepth; |
---|
1002 | sei.m_startOfCodedInterval.resize(num+1); |
---|
1003 | for(i = 0; i < num; i++) |
---|
1004 | { |
---|
1005 | sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval[i]" ); |
---|
1006 | sei.m_startOfCodedInterval[i] = val; |
---|
1007 | } |
---|
1008 | sei.m_startOfCodedInterval[num] = 1u << sei.m_codedDataBitDepth; |
---|
1009 | break; |
---|
1010 | } |
---|
1011 | case 3: |
---|
1012 | { |
---|
1013 | sei_read_code( pDecodedMessageOutputStream, 16, val, "num_pivots" ); sei.m_numPivots = val; |
---|
1014 | sei.m_codedPivotValue.resize(sei.m_numPivots); |
---|
1015 | sei.m_targetPivotValue.resize(sei.m_numPivots); |
---|
1016 | for(i = 0; i < sei.m_numPivots; i++ ) |
---|
1017 | { |
---|
1018 | sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value[i]" ); |
---|
1019 | sei.m_codedPivotValue[i] = val; |
---|
1020 | sei_read_code( pDecodedMessageOutputStream, ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value[i]" ); |
---|
1021 | sei.m_targetPivotValue[i] = val; |
---|
1022 | } |
---|
1023 | break; |
---|
1024 | } |
---|
1025 | case 4: |
---|
1026 | { |
---|
1027 | sei_read_code( pDecodedMessageOutputStream, 8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedIdc = val; |
---|
1028 | if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO |
---|
1029 | { |
---|
1030 | sei_read_code( pDecodedMessageOutputStream, 32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val; |
---|
1031 | } |
---|
1032 | sei_read_code( pDecodedMessageOutputStream, 8, val, "exposure_index_idc" ); sei.m_exposureIndexIdc = val; |
---|
1033 | if( sei.m_exposureIndexIdc == 255) //Extended_ISO |
---|
1034 | { |
---|
1035 | sei_read_code( pDecodedMessageOutputStream, 32, val, "exposure_index_value" ); sei.m_exposureIndexValue = val; |
---|
1036 | } |
---|
1037 | sei_read_flag( pDecodedMessageOutputStream, val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val; |
---|
1038 | sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val; |
---|
1039 | sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val; |
---|
1040 | sei_read_code( pDecodedMessageOutputStream, 32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val; |
---|
1041 | sei_read_code( pDecodedMessageOutputStream, 32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val; |
---|
1042 | sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_black_level_code_value" ); sei.m_nominalBlackLevelLumaCodeValue = val; |
---|
1043 | sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_white_level_code_value" ); sei.m_nominalWhiteLevelLumaCodeValue= val; |
---|
1044 | sei_read_code( pDecodedMessageOutputStream, 16, val, "extended_white_level_code_value" ); sei.m_extendedWhiteLevelLumaCodeValue = val; |
---|
1045 | break; |
---|
1046 | } |
---|
1047 | default: |
---|
1048 | { |
---|
1049 | assert(!"Undefined SEIToneMapModelId"); |
---|
1050 | break; |
---|
1051 | } |
---|
1052 | }//switch model id |
---|
1053 | }// if(!sei.m_toneMapCancelFlag) |
---|
1054 | } |
---|
1055 | |
---|
1056 | Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1057 | { |
---|
1058 | Int iCode; |
---|
1059 | UInt uiCode; |
---|
1060 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
1061 | |
---|
1062 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; |
---|
1063 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; |
---|
1064 | for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) |
---|
1065 | { |
---|
1066 | sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "sop_vcl_nut[i]" ); sei.m_sopDescVclNaluType[i] = uiCode; |
---|
1067 | sei_read_code( pDecodedMessageOutputStream, 3, sei.m_sopDescTemporalId[i], "sop_temporal_id[i]" ); sei.m_sopDescTemporalId[i] = uiCode; |
---|
1068 | if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) |
---|
1069 | { |
---|
1070 | sei_read_uvlc( pDecodedMessageOutputStream, sei.m_sopDescStRpsIdx[i], "sop_short_term_rps_idx[i]" ); sei.m_sopDescStRpsIdx[i] = uiCode; |
---|
1071 | } |
---|
1072 | if (i > 0) |
---|
1073 | { |
---|
1074 | sei_read_svlc( pDecodedMessageOutputStream, iCode, "sop_poc_delta[i]" ); sei.m_sopDescPocDelta[i] = iCode; |
---|
1075 | } |
---|
1076 | } |
---|
1077 | } |
---|
1078 | |
---|
1079 | #if LAYERS_NOT_PRESENT_SEI |
---|
1080 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, const TComVPS *vps, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
---|
1081 | #else |
---|
1082 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) |
---|
1083 | #endif |
---|
1084 | { |
---|
1085 | UInt uiCode; |
---|
1086 | SEIMessages seis; |
---|
1087 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
1088 | |
---|
1089 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; |
---|
1090 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; |
---|
1091 | if (sei.m_nestingOpFlag) |
---|
1092 | { |
---|
1093 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode; |
---|
1094 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode; |
---|
1095 | for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++) |
---|
1096 | { |
---|
1097 | sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_max_temporal_id_plus1[i]" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode; |
---|
1098 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_op_idx[i]" ); sei.m_nestingOpIdx[i] = uiCode; |
---|
1099 | } |
---|
1100 | } |
---|
1101 | else |
---|
1102 | { |
---|
1103 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode; |
---|
1104 | if (!sei.m_allLayersFlag) |
---|
1105 | { |
---|
1106 | sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode; |
---|
1107 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode; |
---|
1108 | for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) |
---|
1109 | { |
---|
1110 | sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "nesting_layer_id[i]" ); sei.m_nestingLayerId[i] = uiCode; |
---|
1111 | } |
---|
1112 | } |
---|
1113 | } |
---|
1114 | |
---|
1115 | // byte alignment |
---|
1116 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1117 | { |
---|
1118 | UInt code; |
---|
1119 | sei_read_flag( pDecodedMessageOutputStream, code, "nesting_zero_bit" ); |
---|
1120 | } |
---|
1121 | |
---|
1122 | // read nested SEI messages |
---|
1123 | do |
---|
1124 | { |
---|
1125 | #if O0164_MULTI_LAYER_HRD |
---|
1126 | #if LAYERS_NOT_PRESENT_SEI |
---|
1127 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream, &sei); |
---|
1128 | #else |
---|
1129 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream, &sei); |
---|
1130 | #endif |
---|
1131 | #else |
---|
1132 | #if LAYERS_NOT_PRESENT_SEI |
---|
1133 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream); |
---|
1134 | #else |
---|
1135 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream); |
---|
1136 | #endif |
---|
1137 | #endif |
---|
1138 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
1139 | |
---|
1140 | if (pDecodedMessageOutputStream) |
---|
1141 | { |
---|
1142 | (*pDecodedMessageOutputStream) << "End of scalable nesting SEI message\n"; |
---|
1143 | } |
---|
1144 | } |
---|
1145 | |
---|
1146 | Void SEIReader::xParseSEITempMotionConstraintsTileSets(SEITempMotionConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1147 | { |
---|
1148 | UInt code; |
---|
1149 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
1150 | sei_read_flag( pDecodedMessageOutputStream, code, "mc_all_tiles_exact_sample_value_match_flag"); sei.m_mc_all_tiles_exact_sample_value_match_flag = (code != 0); |
---|
1151 | sei_read_flag( pDecodedMessageOutputStream, code, "each_tile_one_tile_set_flag"); sei.m_each_tile_one_tile_set_flag = (code != 0); |
---|
1152 | |
---|
1153 | if(!sei.m_each_tile_one_tile_set_flag) |
---|
1154 | { |
---|
1155 | sei_read_flag( pDecodedMessageOutputStream, code, "limited_tile_set_display_flag"); sei.m_limited_tile_set_display_flag = (code != 0); |
---|
1156 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_sets_in_message_minus1"); sei.setNumberOfTileSets(code + 1); |
---|
1157 | |
---|
1158 | if(sei.getNumberOfTileSets() != 0) |
---|
1159 | { |
---|
1160 | for(Int i = 0; i < sei.getNumberOfTileSets(); i++) |
---|
1161 | { |
---|
1162 | sei_read_uvlc( pDecodedMessageOutputStream, code, "mcts_id"); sei.tileSetData(i).m_mcts_id = code; |
---|
1163 | |
---|
1164 | if(sei.m_limited_tile_set_display_flag) |
---|
1165 | { |
---|
1166 | sei_read_flag( pDecodedMessageOutputStream, code, "display_tile_set_flag"); sei.tileSetData(i).m_display_tile_set_flag = (code != 1); |
---|
1167 | } |
---|
1168 | |
---|
1169 | sei_read_uvlc( pDecodedMessageOutputStream, code, "num_tile_rects_in_set_minus1"); sei.tileSetData(i).setNumberOfTileRects(code + 1); |
---|
1170 | |
---|
1171 | for(Int j=0; j<sei.tileSetData(i).getNumberOfTileRects(); j++) |
---|
1172 | { |
---|
1173 | sei_read_uvlc( pDecodedMessageOutputStream, code, "top_left_tile_index"); sei.tileSetData(i).topLeftTileIndex(j) = code; |
---|
1174 | sei_read_uvlc( pDecodedMessageOutputStream, code, "bottom_right_tile_index"); sei.tileSetData(i).bottomRightTileIndex(j) = code; |
---|
1175 | } |
---|
1176 | |
---|
1177 | if(!sei.m_mc_all_tiles_exact_sample_value_match_flag) |
---|
1178 | { |
---|
1179 | sei_read_flag( pDecodedMessageOutputStream, code, "exact_sample_value_match_flag"); sei.tileSetData(i).m_exact_sample_value_match_flag = (code != 0); |
---|
1180 | } |
---|
1181 | sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_level_idc_present_flag"); sei.tileSetData(i).m_mcts_tier_level_idc_present_flag = (code != 0); |
---|
1182 | |
---|
1183 | if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag) |
---|
1184 | { |
---|
1185 | sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_flag"); sei.tileSetData(i).m_mcts_tier_flag = (code != 0); |
---|
1186 | sei_read_code( pDecodedMessageOutputStream, 8, code, "mcts_level_idc"); sei.tileSetData(i).m_mcts_level_idc = code; |
---|
1187 | } |
---|
1188 | } |
---|
1189 | } |
---|
1190 | } |
---|
1191 | else |
---|
1192 | { |
---|
1193 | sei_read_flag( pDecodedMessageOutputStream, code, "max_mcs_tier_level_idc_present_flag"); sei.m_max_mcs_tier_level_idc_present_flag = code; |
---|
1194 | if(sei.m_max_mcs_tier_level_idc_present_flag) |
---|
1195 | { |
---|
1196 | sei_read_flag( pDecodedMessageOutputStream, code, "max_mcts_tier_flag"); sei.m_max_mcts_tier_flag = code; |
---|
1197 | sei_read_code( pDecodedMessageOutputStream, 8, code, "max_mcts_level_idc"); sei.m_max_mcts_level_idc = code; |
---|
1198 | } |
---|
1199 | } |
---|
1200 | } |
---|
1201 | |
---|
1202 | Void SEIReader::xParseSEITimeCode(SEITimeCode& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1203 | { |
---|
1204 | UInt code; |
---|
1205 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
1206 | sei_read_code( pDecodedMessageOutputStream, 2, code, "num_clock_ts"); sei.numClockTs = code; |
---|
1207 | for(Int i = 0; i < sei.numClockTs; i++) |
---|
1208 | { |
---|
1209 | TComSEITimeSet currentTimeSet; |
---|
1210 | sei_read_flag( pDecodedMessageOutputStream, code, "clock_time_stamp_flag[i]"); currentTimeSet.clockTimeStampFlag = code; |
---|
1211 | if(currentTimeSet.clockTimeStampFlag) |
---|
1212 | { |
---|
1213 | sei_read_flag( pDecodedMessageOutputStream, code, "nuit_field_based_flag"); currentTimeSet.numUnitFieldBasedFlag = code; |
---|
1214 | sei_read_code( pDecodedMessageOutputStream, 5, code, "counting_type"); currentTimeSet.countingType = code; |
---|
1215 | sei_read_flag( pDecodedMessageOutputStream, code, "full_timestamp_flag"); currentTimeSet.fullTimeStampFlag = code; |
---|
1216 | sei_read_flag( pDecodedMessageOutputStream, code, "discontinuity_flag"); currentTimeSet.discontinuityFlag = code; |
---|
1217 | sei_read_flag( pDecodedMessageOutputStream, code, "cnt_dropped_flag"); currentTimeSet.cntDroppedFlag = code; |
---|
1218 | sei_read_code( pDecodedMessageOutputStream, 9, code, "n_frames"); currentTimeSet.numberOfFrames = code; |
---|
1219 | if(currentTimeSet.fullTimeStampFlag) |
---|
1220 | { |
---|
1221 | sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code; |
---|
1222 | sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code; |
---|
1223 | sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code; |
---|
1224 | } |
---|
1225 | else |
---|
1226 | { |
---|
1227 | sei_read_flag( pDecodedMessageOutputStream, code, "seconds_flag"); currentTimeSet.secondsFlag = code; |
---|
1228 | if(currentTimeSet.secondsFlag) |
---|
1229 | { |
---|
1230 | sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code; |
---|
1231 | sei_read_flag( pDecodedMessageOutputStream, code, "minutes_flag"); currentTimeSet.minutesFlag = code; |
---|
1232 | if(currentTimeSet.minutesFlag) |
---|
1233 | { |
---|
1234 | sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code; |
---|
1235 | sei_read_flag( pDecodedMessageOutputStream, code, "hours_flag"); currentTimeSet.hoursFlag = code; |
---|
1236 | if(currentTimeSet.hoursFlag) |
---|
1237 | { |
---|
1238 | sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code; |
---|
1239 | } |
---|
1240 | } |
---|
1241 | } |
---|
1242 | } |
---|
1243 | sei_read_code( pDecodedMessageOutputStream, 5, code, "time_offset_length"); currentTimeSet.timeOffsetLength = code; |
---|
1244 | if(currentTimeSet.timeOffsetLength > 0) |
---|
1245 | { |
---|
1246 | sei_read_code( pDecodedMessageOutputStream, currentTimeSet.timeOffsetLength, code, "time_offset_value"); |
---|
1247 | if((code & (1 << (currentTimeSet.timeOffsetLength-1))) == 0) |
---|
1248 | { |
---|
1249 | currentTimeSet.timeOffsetValue = code; |
---|
1250 | } |
---|
1251 | else |
---|
1252 | { |
---|
1253 | code &= (1<< (currentTimeSet.timeOffsetLength-1)) - 1; |
---|
1254 | currentTimeSet.timeOffsetValue = ~code + 1; |
---|
1255 | } |
---|
1256 | } |
---|
1257 | } |
---|
1258 | sei.timeSetArray[i] = currentTimeSet; |
---|
1259 | } |
---|
1260 | } |
---|
1261 | |
---|
1262 | Void SEIReader::xParseSEIChromaSamplingFilterHint(SEIChromaSamplingFilterHint& sei, UInt payloadSize/*, TComSPS* sps*/, std::ostream *pDecodedMessageOutputStream) |
---|
1263 | { |
---|
1264 | UInt uiCode; |
---|
1265 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
1266 | |
---|
1267 | sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "ver_chroma_filter_idc"); sei.m_verChromaFilterIdc = uiCode; |
---|
1268 | sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "hor_chroma_filter_idc"); sei.m_horChromaFilterIdc = uiCode; |
---|
1269 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "ver_filtering_process_flag"); sei.m_verFilteringProcessFlag = uiCode; |
---|
1270 | if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1) |
---|
1271 | { |
---|
1272 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "target_format_idc"); sei.m_targetFormatIdc = uiCode; |
---|
1273 | if(sei.m_verChromaFilterIdc == 1) |
---|
1274 | { |
---|
1275 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_vertical_filters"); sei.m_numVerticalFilters = uiCode; |
---|
1276 | if(sei.m_numVerticalFilters > 0) |
---|
1277 | { |
---|
1278 | sei.m_verTapLengthMinus1 = (Int*)malloc(sei.m_numVerticalFilters * sizeof(Int)); |
---|
1279 | sei.m_verFilterCoeff = (Int**)malloc(sei.m_numVerticalFilters * sizeof(Int*)); |
---|
1280 | for(Int i = 0; i < sei.m_numVerticalFilters; i ++) |
---|
1281 | { |
---|
1282 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ver_tap_length_minus_1"); sei.m_verTapLengthMinus1[i] = uiCode; |
---|
1283 | sei.m_verFilterCoeff[i] = (Int*)malloc(sei.m_verTapLengthMinus1[i] * sizeof(Int)); |
---|
1284 | for(Int j = 0; j < sei.m_verTapLengthMinus1[i]; j ++) |
---|
1285 | { |
---|
1286 | sei_read_svlc( pDecodedMessageOutputStream, sei.m_verFilterCoeff[i][j], "ver_filter_coeff"); |
---|
1287 | } |
---|
1288 | } |
---|
1289 | } |
---|
1290 | } |
---|
1291 | if(sei.m_horChromaFilterIdc == 1) |
---|
1292 | { |
---|
1293 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_horizontal_filters"); sei.m_numHorizontalFilters = uiCode; |
---|
1294 | if(sei.m_numHorizontalFilters > 0) |
---|
1295 | { |
---|
1296 | sei.m_horTapLengthMinus1 = (Int*)malloc(sei.m_numHorizontalFilters * sizeof(Int)); |
---|
1297 | sei.m_horFilterCoeff = (Int**)malloc(sei.m_numHorizontalFilters * sizeof(Int*)); |
---|
1298 | for(Int i = 0; i < sei.m_numHorizontalFilters; i ++) |
---|
1299 | { |
---|
1300 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "hor_tap_length_minus_1"); sei.m_horTapLengthMinus1[i] = uiCode; |
---|
1301 | sei.m_horFilterCoeff[i] = (Int*)malloc(sei.m_horTapLengthMinus1[i] * sizeof(Int)); |
---|
1302 | for(Int j = 0; j < sei.m_horTapLengthMinus1[i]; j ++) |
---|
1303 | { |
---|
1304 | sei_read_svlc( pDecodedMessageOutputStream, sei.m_horFilterCoeff[i][j], "hor_filter_coeff"); |
---|
1305 | } |
---|
1306 | } |
---|
1307 | } |
---|
1308 | } |
---|
1309 | } |
---|
1310 | } |
---|
1311 | |
---|
1312 | Void SEIReader::xParseSEIKneeFunctionInfo(SEIKneeFunctionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1313 | { |
---|
1314 | Int i; |
---|
1315 | UInt val; |
---|
1316 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
1317 | |
---|
1318 | sei_read_uvlc( pDecodedMessageOutputStream, val, "knee_function_id" ); sei.m_kneeId = val; |
---|
1319 | sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_cancel_flag" ); sei.m_kneeCancelFlag = val; |
---|
1320 | if ( !sei.m_kneeCancelFlag ) |
---|
1321 | { |
---|
1322 | sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_persistence_flag" ); sei.m_kneePersistenceFlag = val; |
---|
1323 | sei_read_code( pDecodedMessageOutputStream, 32, val, "input_d_range" ); sei.m_kneeInputDrange = val; |
---|
1324 | sei_read_code( pDecodedMessageOutputStream, 32, val, "input_disp_luminance" ); sei.m_kneeInputDispLuminance = val; |
---|
1325 | sei_read_code( pDecodedMessageOutputStream, 32, val, "output_d_range" ); sei.m_kneeOutputDrange = val; |
---|
1326 | sei_read_code( pDecodedMessageOutputStream, 32, val, "output_disp_luminance" ); sei.m_kneeOutputDispLuminance = val; |
---|
1327 | sei_read_uvlc( pDecodedMessageOutputStream, val, "num_knee_points_minus1" ); sei.m_kneeNumKneePointsMinus1 = val; |
---|
1328 | assert( sei.m_kneeNumKneePointsMinus1 > 0 ); |
---|
1329 | sei.m_kneeInputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); |
---|
1330 | sei.m_kneeOutputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); |
---|
1331 | for(i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ ) |
---|
1332 | { |
---|
1333 | sei_read_code( pDecodedMessageOutputStream, 10, val, "input_knee_point" ); sei.m_kneeInputKneePoint[i] = val; |
---|
1334 | sei_read_code( pDecodedMessageOutputStream, 10, val, "output_knee_point" ); sei.m_kneeOutputKneePoint[i] = val; |
---|
1335 | } |
---|
1336 | } |
---|
1337 | } |
---|
1338 | |
---|
1339 | Void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1340 | { |
---|
1341 | UInt code; |
---|
1342 | output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); |
---|
1343 | |
---|
1344 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[0]" ); sei.values.primaries[0][0] = code; |
---|
1345 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[0]" ); sei.values.primaries[0][1] = code; |
---|
1346 | |
---|
1347 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[1]" ); sei.values.primaries[1][0] = code; |
---|
1348 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[1]" ); sei.values.primaries[1][1] = code; |
---|
1349 | |
---|
1350 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[2]" ); sei.values.primaries[2][0] = code; |
---|
1351 | sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[2]" ); sei.values.primaries[2][1] = code; |
---|
1352 | |
---|
1353 | |
---|
1354 | sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_x" ); sei.values.whitePoint[0] = code; |
---|
1355 | sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_y" ); sei.values.whitePoint[1] = code; |
---|
1356 | |
---|
1357 | sei_read_code( pDecodedMessageOutputStream, 32, code, "max_display_mastering_luminance" ); sei.values.maxLuminance = code; |
---|
1358 | sei_read_code( pDecodedMessageOutputStream, 32, code, "min_display_mastering_luminance" ); sei.values.minLuminance = code; |
---|
1359 | } |
---|
1360 | |
---|
1361 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
1362 | Void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& sei, UInt /*payloadSize*/, std::ostream *pDecodedMessageOutputStream) |
---|
1363 | { |
---|
1364 | UInt uiVal; |
---|
1365 | Int iVal; |
---|
1366 | |
---|
1367 | sei_read_uvlc( pDecodedMessageOutputStream, uiVal, "colour_remap_id" ); sei.m_colourRemapId = uiVal; |
---|
1368 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_cancel_flag" ); sei.m_colourRemapCancelFlag = uiVal; |
---|
1369 | if( !sei.m_colourRemapCancelFlag ) |
---|
1370 | { |
---|
1371 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_persistence_flag" ); sei.m_colourRemapPersistenceFlag = uiVal; |
---|
1372 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_video_signal_info_present_flag" ); sei.m_colourRemapVideoSignalInfoPresentFlag = uiVal; |
---|
1373 | if ( sei.m_colourRemapVideoSignalInfoPresentFlag ) |
---|
1374 | { |
---|
1375 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_full_range_flag" ); sei.m_colourRemapFullRangeFlag = uiVal; |
---|
1376 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_primaries" ); sei.m_colourRemapPrimaries = uiVal; |
---|
1377 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_transfer_function" ); sei.m_colourRemapTransferFunction = uiVal; |
---|
1378 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_matrix_coefficients" ); sei.m_colourRemapMatrixCoefficients = uiVal; |
---|
1379 | } |
---|
1380 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_input_bit_depth" ); sei.m_colourRemapInputBitDepth = uiVal; |
---|
1381 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "colour_remap_bit_depth" ); sei.m_colourRemapBitDepth = uiVal; |
---|
1382 | |
---|
1383 | for( Int c=0 ; c<3 ; c++ ) |
---|
1384 | { |
---|
1385 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "pre_lut_num_val_minus1[c]" ); sei.m_preLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; |
---|
1386 | sei.m_preLutCodedValue[c].resize(sei.m_preLutNumValMinus1[c]+1); |
---|
1387 | sei.m_preLutTargetValue[c].resize(sei.m_preLutNumValMinus1[c]+1); |
---|
1388 | if( uiVal> 0 ) |
---|
1389 | for ( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) |
---|
1390 | { |
---|
1391 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" ); sei.m_preLutCodedValue[c][i] = uiVal; |
---|
1392 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLutTargetValue[c][i] = uiVal; |
---|
1393 | } |
---|
1394 | else // pre_lut_num_val_minus1[c] == 0 |
---|
1395 | { |
---|
1396 | sei.m_preLutCodedValue[c][0] = 0; |
---|
1397 | sei.m_preLutTargetValue[c][0] = 0; |
---|
1398 | sei.m_preLutCodedValue[c][1] = (1 << sei.m_colourRemapInputBitDepth) - 1 ; |
---|
1399 | sei.m_preLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1 ; |
---|
1400 | } |
---|
1401 | } |
---|
1402 | |
---|
1403 | sei_read_flag( pDecodedMessageOutputStream, uiVal, "colour_remap_matrix_present_flag" ); sei.m_colourRemapMatrixPresentFlag = uiVal; |
---|
1404 | if( sei.m_colourRemapMatrixPresentFlag ) |
---|
1405 | { |
---|
1406 | sei_read_code( pDecodedMessageOutputStream, 4, uiVal, "log2_matrix_denom" ); sei.m_log2MatrixDenom = uiVal; |
---|
1407 | for ( Int c=0 ; c<3 ; c++ ) |
---|
1408 | for ( Int i=0 ; i<3 ; i++ ) |
---|
1409 | { |
---|
1410 | sei_read_svlc( pDecodedMessageOutputStream, iVal, "colour_remap_coeffs[c][i]" ); sei.m_colourRemapCoeffs[c][i] = iVal; |
---|
1411 | } |
---|
1412 | } |
---|
1413 | else // setting default matrix (I3) |
---|
1414 | { |
---|
1415 | sei.m_log2MatrixDenom = 0; |
---|
1416 | for ( Int c=0 ; c<3 ; c++ ) |
---|
1417 | for ( Int i=0 ; i<3 ; i++ ) |
---|
1418 | sei.m_colourRemapCoeffs[c][i] = (c==i) ? 1 : 0; |
---|
1419 | } |
---|
1420 | for( Int c=0 ; c<3 ; c++ ) |
---|
1421 | { |
---|
1422 | sei_read_code( pDecodedMessageOutputStream, 8, uiVal, "post_lut_num_val_minus1[c]" ); sei.m_postLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; |
---|
1423 | sei.m_postLutCodedValue[c].resize(sei.m_postLutNumValMinus1[c]+1); |
---|
1424 | sei.m_postLutTargetValue[c].resize(sei.m_postLutNumValMinus1[c]+1); |
---|
1425 | if( uiVal > 0 ) |
---|
1426 | for ( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) |
---|
1427 | { |
---|
1428 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" ); sei.m_postLutCodedValue[c][i] = uiVal; |
---|
1429 | sei_read_code( pDecodedMessageOutputStream, (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLutTargetValue[c][i] = uiVal; |
---|
1430 | } |
---|
1431 | else |
---|
1432 | { |
---|
1433 | sei.m_postLutCodedValue[c][0] = 0; |
---|
1434 | sei.m_postLutTargetValue[c][0] = 0; |
---|
1435 | sei.m_postLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1; |
---|
1436 | sei.m_postLutCodedValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1; |
---|
1437 | } |
---|
1438 | } |
---|
1439 | } |
---|
1440 | } |
---|
1441 | #endif |
---|
1442 | |
---|
1443 | |
---|
1444 | #if SVC_EXTENSION |
---|
1445 | #if LAYERS_NOT_PRESENT_SEI |
---|
1446 | Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, const TComVPS *vps, std::ostream *pDecodedMessageOutputStream) |
---|
1447 | { |
---|
1448 | UInt uiCode; |
---|
1449 | UInt i = 0; |
---|
1450 | |
---|
1451 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "lp_sei_active_vps_id" ); sei.m_activeVpsId = uiCode; |
---|
1452 | assert(vps->getVPSId() == sei.m_activeVpsId); |
---|
1453 | sei.m_vpsMaxLayers = vps->getMaxLayers(); |
---|
1454 | for (; i < sei.m_vpsMaxLayers; i++) |
---|
1455 | { |
---|
1456 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "layer_not_present_flag" ); sei.m_layerNotPresentFlag[i] = uiCode ? true : false; |
---|
1457 | } |
---|
1458 | for (; i < MAX_LAYERS; i++) |
---|
1459 | { |
---|
1460 | sei.m_layerNotPresentFlag[i] = false; |
---|
1461 | } |
---|
1462 | } |
---|
1463 | #endif |
---|
1464 | |
---|
1465 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
1466 | Void SEIReader::xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1467 | { |
---|
1468 | UInt uiCode; |
---|
1469 | |
---|
1470 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_all_tiles_exact_sample_value_match_flag" ); sei.m_ilAllTilesExactSampleValueMatchFlag = uiCode; |
---|
1471 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_one_tile_per_tile_set_flag" ); sei.m_ilOneTilePerTileSetFlag = uiCode; |
---|
1472 | if( !sei.m_ilOneTilePerTileSetFlag ) |
---|
1473 | { |
---|
1474 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_num_sets_in_message_minus1" ); sei.m_ilNumSetsInMessageMinus1 = uiCode; |
---|
1475 | if( sei.m_ilNumSetsInMessageMinus1 ) |
---|
1476 | { |
---|
1477 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "skipped_tile_set_present_flag" ); sei.m_skippedTileSetPresentFlag = uiCode; |
---|
1478 | } |
---|
1479 | else |
---|
1480 | { |
---|
1481 | sei.m_skippedTileSetPresentFlag = false; |
---|
1482 | } |
---|
1483 | UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1; |
---|
1484 | for( UInt i = 0; i < numSignificantSets; i++ ) |
---|
1485 | { |
---|
1486 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ilcts_id" ); sei.m_ilctsId[i] = uiCode; |
---|
1487 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_num_tile_rects_in_set_minus1" ) ;sei.m_ilNumTileRectsInSetMinus1[i] = uiCode; |
---|
1488 | for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ ) |
---|
1489 | { |
---|
1490 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_top_left_tile_index" ); sei.m_ilTopLeftTileIndex[i][j] = uiCode; |
---|
1491 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "il_bottom_right_tile_index" ); sei.m_ilBottomRightTileIndex[i][j] = uiCode; |
---|
1492 | } |
---|
1493 | sei_read_code( pDecodedMessageOutputStream, 2, uiCode, "ilc_idc" ); sei.m_ilcIdc[i] = uiCode; |
---|
1494 | if( sei.m_ilAllTilesExactSampleValueMatchFlag ) |
---|
1495 | { |
---|
1496 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "il_exact_sample_value_match_flag" ); sei.m_ilExactSampleValueMatchFlag[i] = uiCode; |
---|
1497 | } |
---|
1498 | } |
---|
1499 | } |
---|
1500 | else |
---|
1501 | { |
---|
1502 | sei_read_code( pDecodedMessageOutputStream, 2, uiCode, "all_tiles_ilc_idc" ); sei.m_allTilesIlcIdc = uiCode; |
---|
1503 | } |
---|
1504 | } |
---|
1505 | #endif |
---|
1506 | |
---|
1507 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
1508 | Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, const TComVPS *vps, std::ostream *pDecodedMessageOutputStream) |
---|
1509 | { |
---|
1510 | UInt uiCode; |
---|
1511 | sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "active_vps_id" ); sei.m_activeVpsId = uiCode; |
---|
1512 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreams = uiCode + 1; |
---|
1513 | |
---|
1514 | for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ ) |
---|
1515 | { |
---|
1516 | sei_read_code( pDecodedMessageOutputStream, 2, uiCode, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = uiCode; |
---|
1517 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "output_layer_set_idx_to_vps[i]" ); |
---|
1518 | |
---|
1519 | // The value of output_layer_set_idx_to_vps[ i ] shall be in the range of 0 to NumOutputLayerSets − 1, inclusive. |
---|
1520 | assert(uiCode > 0 && uiCode <= vps->getNumOutputLayerSets()-1); |
---|
1521 | |
---|
1522 | sei.m_outputLayerSetIdxToVps[i] = uiCode; |
---|
1523 | |
---|
1524 | sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = uiCode; |
---|
1525 | sei_read_code( pDecodedMessageOutputStream, 16, uiCode, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = uiCode; |
---|
1526 | sei_read_code( pDecodedMessageOutputStream, 16, uiCode, "max_bit_rate[i]" ); sei.m_maxBitRate[i] = uiCode; |
---|
1527 | } |
---|
1528 | } |
---|
1529 | #endif |
---|
1530 | |
---|
1531 | #if O0164_MULTI_LAYER_HRD |
---|
1532 | #if LAYERS_NOT_PRESENT_SEI |
---|
1533 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting &nestingSei, std::ostream *pDecodedMessageOutputStream) |
---|
1534 | #else |
---|
1535 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, const TComSPS *sps, const SEIScalableNesting &nestingSei, std::ostream *pDecodedMessageOutputStream) |
---|
1536 | #endif |
---|
1537 | { |
---|
1538 | UInt uiCode; |
---|
1539 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bsp_idx" ); sei.m_bspIdx = uiCode; |
---|
1540 | |
---|
1541 | // byte alignment |
---|
1542 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1543 | { |
---|
1544 | UInt code; |
---|
1545 | sei_read_flag( pDecodedMessageOutputStream, code, "bsp_nesting_zero_bit" ); |
---|
1546 | } |
---|
1547 | |
---|
1548 | sei.m_callerOwnsSEIs = false; |
---|
1549 | |
---|
1550 | // read nested SEI messages |
---|
1551 | Int numSeiMessages = 0; |
---|
1552 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_seis_in_bsp_minus1" ); assert( uiCode <= MAX_SEIS_IN_BSP_NESTING ); |
---|
1553 | numSeiMessages = uiCode; |
---|
1554 | for(Int i = 0; i < numSeiMessages; i++) |
---|
1555 | { |
---|
1556 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, pDecodedMessageOutputStream, &nestingSei, &sei); |
---|
1557 | } |
---|
1558 | } |
---|
1559 | |
---|
1560 | Void SEIReader::xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime &sei, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei, std::ostream *pDecodedMessageOutputStream) |
---|
1561 | { |
---|
1562 | assert(vps->getVpsVuiPresentFlag()); |
---|
1563 | |
---|
1564 | UInt uiCode; |
---|
1565 | Int psIdx = bspNestingSei.m_seiPartitioningSchemeIdx; |
---|
1566 | Int seiOlsIdx = bspNestingSei.m_seiOlsIdx; |
---|
1567 | Int maxTemporalId = nestingSei.m_nestingMaxTemporalIdPlus1[0]; |
---|
1568 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
---|
1569 | std::vector<Int> hrdIdx(0, maxValues); |
---|
1570 | std::vector<const TComHRD*> hrdVec; |
---|
1571 | std::vector<Int> syntaxElemLen; |
---|
1572 | for(Int i = 0; i < maxValues; i++) |
---|
1573 | { |
---|
1574 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei.m_bspIdx); |
---|
1575 | hrdVec[i] = vps->getBspHrd(hrdIdx[i]); |
---|
1576 | |
---|
1577 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
1578 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
1579 | { |
---|
1580 | assert( syntaxElemLen[i] == 24 ); // Default value of init_cpb_removal_delay_length_minus1 is 23 |
---|
1581 | } |
---|
1582 | if( i > 0 ) |
---|
1583 | { |
---|
1584 | assert( hrdVec[i]->getNalHrdParametersPresentFlag() == hrdVec[i-1]->getNalHrdParametersPresentFlag() ); |
---|
1585 | assert( hrdVec[i]->getVclHrdParametersPresentFlag() == hrdVec[i-1]->getVclHrdParametersPresentFlag() ); |
---|
1586 | } |
---|
1587 | } |
---|
1588 | if (hrdVec[0]->getNalHrdParametersPresentFlag()) |
---|
1589 | { |
---|
1590 | for(UInt i = 0; i < maxValues; i++) |
---|
1591 | { |
---|
1592 | sei_read_code( pDecodedMessageOutputStream, syntaxElemLen[i], uiCode, "nal_initial_arrival_delay[i]" ); sei.m_nalInitialArrivalDelay[i] = uiCode; |
---|
1593 | } |
---|
1594 | } |
---|
1595 | if( hrdVec[0]->getVclHrdParametersPresentFlag() ) |
---|
1596 | { |
---|
1597 | for(UInt i = 0; i < maxValues; i++) |
---|
1598 | { |
---|
1599 | sei_read_code( pDecodedMessageOutputStream, syntaxElemLen[i], uiCode, "vcl_initial_arrival_delay[i]" ); sei.m_vclInitialArrivalDelay[i] = uiCode; |
---|
1600 | } |
---|
1601 | } |
---|
1602 | } |
---|
1603 | |
---|
1604 | Void SEIReader::xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1, std::ostream *pDecodedMessageOutputStream) |
---|
1605 | { |
---|
1606 | UInt uiCode; |
---|
1607 | if( commonInfPresentFlag ) |
---|
1608 | { |
---|
1609 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
1610 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
1611 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
1612 | { |
---|
1613 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
1614 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
1615 | { |
---|
1616 | sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
1617 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
1618 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
1619 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
1620 | } |
---|
1621 | sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
1622 | sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
1623 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
1624 | { |
---|
1625 | sei_read_code( pDecodedMessageOutputStream, 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
1626 | } |
---|
1627 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
1628 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
1629 | sei_read_code( pDecodedMessageOutputStream, 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
1630 | } |
---|
1631 | } |
---|
1632 | Int i, j, nalOrVcl; |
---|
1633 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
1634 | { |
---|
1635 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
1636 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
1637 | { |
---|
1638 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
1639 | } |
---|
1640 | else |
---|
1641 | { |
---|
1642 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
1643 | } |
---|
1644 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
1645 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
1646 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
1647 | { |
---|
1648 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
1649 | } |
---|
1650 | else |
---|
1651 | { |
---|
1652 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
1653 | } |
---|
1654 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
1655 | { |
---|
1656 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
1657 | } |
---|
1658 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
1659 | { |
---|
1660 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
1661 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
1662 | { |
---|
1663 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
1664 | { |
---|
1665 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1666 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1667 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
1668 | { |
---|
1669 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1670 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1671 | } |
---|
1672 | sei_read_flag( pDecodedMessageOutputStream, uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
1673 | } |
---|
1674 | } |
---|
1675 | } |
---|
1676 | } |
---|
1677 | } |
---|
1678 | #endif |
---|
1679 | |
---|
1680 | #if P0123_ALPHA_CHANNEL_SEI |
---|
1681 | void SEIReader::xParseSEIAlphaChannelInfo(SEIAlphaChannelInfo &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1682 | { |
---|
1683 | UInt value; |
---|
1684 | sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_cancel_flag"); sei.m_alphaChannelCancelFlag = value; |
---|
1685 | if(!sei.m_alphaChannelCancelFlag) |
---|
1686 | { |
---|
1687 | sei_read_code(pDecodedMessageOutputStream, 3, value, "alpha_channel_use_idc"); sei.m_alphaChannelUseIdc = value; |
---|
1688 | sei_read_code(pDecodedMessageOutputStream, 3, value, "alpha_channel_bit_depth_minus8"); sei.m_alphaChannelBitDepthMinus8 = value; |
---|
1689 | sei_read_code(pDecodedMessageOutputStream, sei.m_alphaChannelBitDepthMinus8 + 9, value, "alpha_transparent_value"); sei.m_alphaTransparentValue = value; |
---|
1690 | sei_read_code(pDecodedMessageOutputStream, sei.m_alphaChannelBitDepthMinus8 + 9, value, "alpha_opaque_value"); sei.m_alphaOpaqueValue = value; |
---|
1691 | sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_incr_flag"); sei.m_alphaChannelIncrFlag = value; |
---|
1692 | sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_clip_flag"); sei.m_alphaChannelClipFlag = value; |
---|
1693 | if(sei.m_alphaChannelClipFlag) |
---|
1694 | { |
---|
1695 | sei_read_flag(pDecodedMessageOutputStream, value, "alpha_channel_clip_type_flag"); sei.m_alphaChannelClipTypeFlag = value; |
---|
1696 | } |
---|
1697 | } |
---|
1698 | } |
---|
1699 | #endif |
---|
1700 | |
---|
1701 | #if Q0096_OVERLAY_SEI |
---|
1702 | Void SEIReader::xParseSEIOverlayInfo(SEIOverlayInfo& sei, UInt /*payloadSize*/, std::ostream *pDecodedMessageOutputStream) |
---|
1703 | { |
---|
1704 | Int i, j; |
---|
1705 | UInt val; |
---|
1706 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_info_cancel_flag" ); sei.m_overlayInfoCancelFlag = val; |
---|
1707 | if ( !sei.m_overlayInfoCancelFlag ) |
---|
1708 | { |
---|
1709 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_content_aux_id_minus128" ); sei.m_overlayContentAuxIdMinus128 = val; |
---|
1710 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_label_aux_id_minus128" ); sei.m_overlayLabelAuxIdMinus128 = val; |
---|
1711 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_alpha_aux_id_minus128" ); sei.m_overlayAlphaAuxIdMinus128 = val; |
---|
1712 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_element_label_value_length_minus8" ); sei.m_overlayElementLabelValueLengthMinus8 = val; |
---|
1713 | sei_read_uvlc( pDecodedMessageOutputStream, val, "num_overlays_minus1" ); sei.m_numOverlaysMinus1 = val; |
---|
1714 | |
---|
1715 | assert( sei.m_numOverlaysMinus1 < MAX_OVERLAYS ); |
---|
1716 | sei.m_overlayIdx.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1717 | sei.m_languageOverlayPresentFlag.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1718 | sei.m_overlayContentLayerId.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1719 | sei.m_overlayLabelPresentFlag.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1720 | sei.m_overlayLabelLayerId.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1721 | sei.m_overlayAlphaPresentFlag.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1722 | sei.m_overlayAlphaLayerId.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1723 | sei.m_numOverlayElementsMinus1.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1724 | sei.m_overlayElementLabelMin.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1725 | sei.m_overlayElementLabelMax.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1726 | for ( i=0 ; i<=sei.m_numOverlaysMinus1 ; i++ ) |
---|
1727 | { |
---|
1728 | sei_read_uvlc( pDecodedMessageOutputStream, val, "overlay_idx" ); sei.m_overlayIdx[i] = val; |
---|
1729 | sei_read_flag( pDecodedMessageOutputStream, val, "language_overlay_present_flag" ); sei.m_languageOverlayPresentFlag[i] = val; |
---|
1730 | sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_content_layer_id"); sei.m_overlayContentLayerId[i] = val; |
---|
1731 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_label_present_flag" ); sei.m_overlayLabelPresentFlag[i] = val; |
---|
1732 | if ( sei.m_overlayLabelPresentFlag[i] ) |
---|
1733 | { |
---|
1734 | sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_label_layer_id"); sei.m_overlayLabelLayerId[i] = val; |
---|
1735 | } |
---|
1736 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_alpha_present_flag" ); sei.m_overlayAlphaPresentFlag[i] = val; |
---|
1737 | if ( sei.m_overlayAlphaPresentFlag[i] ) |
---|
1738 | { |
---|
1739 | sei_read_code( pDecodedMessageOutputStream, 6, val, "overlay_alpha_layer_id"); sei.m_overlayAlphaLayerId[i] = val; |
---|
1740 | } |
---|
1741 | if ( sei.m_overlayLabelPresentFlag[i] ) |
---|
1742 | { |
---|
1743 | sei_read_uvlc( pDecodedMessageOutputStream, val, "num_overlay_elements_minus1"); sei.m_numOverlayElementsMinus1[i] = val; |
---|
1744 | assert( sei.m_numOverlayElementsMinus1[i] < MAX_OVERLAY_ELEMENTS ); |
---|
1745 | sei.m_overlayElementLabelMin[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
---|
1746 | sei.m_overlayElementLabelMax[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
---|
1747 | for ( j=0 ; j<=sei.m_numOverlayElementsMinus1[i] ; j++ ) |
---|
1748 | { |
---|
1749 | sei_read_code( pDecodedMessageOutputStream, sei.m_overlayElementLabelValueLengthMinus8 + 8, val, "overlay_element_label_min"); sei.m_overlayElementLabelMin[i][j] = val; |
---|
1750 | sei_read_code( pDecodedMessageOutputStream, sei.m_overlayElementLabelValueLengthMinus8 + 8, val, "overlay_element_label_max"); sei.m_overlayElementLabelMax[i][j] = val; |
---|
1751 | } |
---|
1752 | } |
---|
1753 | else |
---|
1754 | { |
---|
1755 | sei.m_numOverlayElementsMinus1[i] = 0; |
---|
1756 | } |
---|
1757 | } |
---|
1758 | |
---|
1759 | // byte alignment |
---|
1760 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1761 | { |
---|
1762 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_zero_bit" ); |
---|
1763 | assert( val==0 ); |
---|
1764 | } |
---|
1765 | |
---|
1766 | UChar* sval = new UChar[MAX_OVERLAY_STRING_BYTES]; |
---|
1767 | UInt slen; |
---|
1768 | sei.m_overlayLanguage.resize( sei.m_numOverlaysMinus1+1, NULL ); |
---|
1769 | sei.m_overlayLanguageLength.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1770 | sei.m_overlayName.resize( sei.m_numOverlaysMinus1+1, NULL ); |
---|
1771 | sei.m_overlayNameLength.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1772 | sei.m_overlayElementName.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1773 | sei.m_overlayElementNameLength.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1774 | for ( i=0 ; i<=sei.m_numOverlaysMinus1 ; i++ ) |
---|
1775 | { |
---|
1776 | if ( sei.m_languageOverlayPresentFlag[i] ) |
---|
1777 | { |
---|
1778 | READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_language" ); |
---|
1779 | sei.m_overlayLanguage[i] = new UChar[slen]; |
---|
1780 | memcpy(sei.m_overlayLanguage[i], sval, slen); |
---|
1781 | sei.m_overlayLanguageLength[i] = slen; |
---|
1782 | } |
---|
1783 | READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_name" ); |
---|
1784 | sei.m_overlayName[i] = new UChar[slen]; |
---|
1785 | memcpy(sei.m_overlayName[i], sval, slen); |
---|
1786 | sei.m_overlayNameLength[i] = slen; |
---|
1787 | if ( sei.m_overlayLabelPresentFlag[i] ) |
---|
1788 | { |
---|
1789 | sei.m_overlayElementName[i].resize( sei.m_numOverlayElementsMinus1[i]+1, NULL ); |
---|
1790 | sei.m_overlayElementNameLength[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
---|
1791 | for ( j=0 ; j<=sei.m_numOverlayElementsMinus1[i] ; j++) |
---|
1792 | { |
---|
1793 | READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_element_name" ); |
---|
1794 | sei.m_overlayElementName[i][j] = new UChar[slen]; |
---|
1795 | memcpy(sei.m_overlayElementName[i][j], sval, slen); |
---|
1796 | sei.m_overlayElementNameLength[i][j] = slen; |
---|
1797 | } |
---|
1798 | } |
---|
1799 | } |
---|
1800 | sei_read_flag( pDecodedMessageOutputStream, val, "overlay_info_persistence_flag" ); sei.m_overlayInfoPersistenceFlag = val; |
---|
1801 | } |
---|
1802 | } |
---|
1803 | #endif |
---|
1804 | |
---|
1805 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
---|
1806 | /** |
---|
1807 | * Check if SEI message contains payload extension |
---|
1808 | */ |
---|
1809 | Bool SEIReader::xPayloadExtensionPresent() |
---|
1810 | { |
---|
1811 | Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); |
---|
1812 | Bool payloadExtensionPresent = false; |
---|
1813 | |
---|
1814 | if (payloadBitsRemaining > 8) |
---|
1815 | { |
---|
1816 | payloadExtensionPresent = true; |
---|
1817 | } |
---|
1818 | else |
---|
1819 | { |
---|
1820 | Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); |
---|
1821 | while (payloadBitsRemaining && (finalBits & 1) == 0) |
---|
1822 | { |
---|
1823 | payloadBitsRemaining--; |
---|
1824 | finalBits >>= 1; |
---|
1825 | } |
---|
1826 | payloadBitsRemaining--; |
---|
1827 | if (payloadBitsRemaining > 0) |
---|
1828 | { |
---|
1829 | payloadExtensionPresent = true; |
---|
1830 | } |
---|
1831 | } |
---|
1832 | |
---|
1833 | return payloadExtensionPresent; |
---|
1834 | } |
---|
1835 | #endif |
---|
1836 | |
---|
1837 | #if Q0189_TMVP_CONSTRAINTS |
---|
1838 | Void SEIReader::xParseSEITMVPConstraints (SEITMVPConstrains& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1839 | { |
---|
1840 | UInt uiCode; |
---|
1841 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "prev_pics_not_used_flag" ); sei.prev_pics_not_used_flag = uiCode; |
---|
1842 | sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "no_intra_layer_col_pic_flag" ); sei.no_intra_layer_col_pic_flag = uiCode; |
---|
1843 | } |
---|
1844 | #endif |
---|
1845 | |
---|
1846 | #if Q0247_FRAME_FIELD_INFO |
---|
1847 | Void SEIReader::xParseSEIFrameFieldInfo (SEIFrameFieldInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) |
---|
1848 | { |
---|
1849 | UInt code; |
---|
1850 | sei_read_code( pDecodedMessageOutputStream, 4, code, "ffinfo_pic_struct" ); sei.m_ffinfo_picStruct = code; |
---|
1851 | sei_read_code( pDecodedMessageOutputStream, 2, code, "ffinfo_source_scan_type" ); sei.m_ffinfo_sourceScanType = code; |
---|
1852 | sei_read_flag( pDecodedMessageOutputStream, code, "ffinfo_duplicate_flag" ); sei.m_ffinfo_duplicateFlag = ( code == 1 ? true : false ); |
---|
1853 | } |
---|
1854 | #endif |
---|
1855 | |
---|
1856 | |
---|
1857 | #endif //SVC_EXTENSION |
---|
1858 | |
---|
1859 | //! \} |
---|