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-2014, 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 | #include "TLibCommon/TComBitCounter.h" |
---|
35 | #include "TLibCommon/TComBitStream.h" |
---|
36 | #include "TLibCommon/SEI.h" |
---|
37 | #include "TLibCommon/TComSlice.h" |
---|
38 | #include "SEIwrite.h" |
---|
39 | |
---|
40 | //! \ingroup TLibEncoder |
---|
41 | //! \{ |
---|
42 | |
---|
43 | #if ENC_DEC_TRACE |
---|
44 | Void xTraceSEIHeader() |
---|
45 | { |
---|
46 | fprintf( g_hTrace, "=========== SEI message ===========\n"); |
---|
47 | } |
---|
48 | |
---|
49 | Void xTraceSEIMessageType(SEI::PayloadType payloadType) |
---|
50 | { |
---|
51 | switch (payloadType) |
---|
52 | { |
---|
53 | case SEI::DECODED_PICTURE_HASH: |
---|
54 | fprintf( g_hTrace, "=========== Decoded picture hash SEI message ===========\n"); |
---|
55 | break; |
---|
56 | case SEI::USER_DATA_UNREGISTERED: |
---|
57 | fprintf( g_hTrace, "=========== User Data Unregistered SEI message ===========\n"); |
---|
58 | break; |
---|
59 | case SEI::ACTIVE_PARAMETER_SETS: |
---|
60 | fprintf( g_hTrace, "=========== Active Parameter sets SEI message ===========\n"); |
---|
61 | break; |
---|
62 | case SEI::BUFFERING_PERIOD: |
---|
63 | fprintf( g_hTrace, "=========== Buffering period SEI message ===========\n"); |
---|
64 | break; |
---|
65 | case SEI::PICTURE_TIMING: |
---|
66 | fprintf( g_hTrace, "=========== Picture timing SEI message ===========\n"); |
---|
67 | break; |
---|
68 | case SEI::RECOVERY_POINT: |
---|
69 | fprintf( g_hTrace, "=========== Recovery point SEI message ===========\n"); |
---|
70 | break; |
---|
71 | case SEI::FRAME_PACKING: |
---|
72 | fprintf( g_hTrace, "=========== Frame Packing Arrangement SEI message ===========\n"); |
---|
73 | break; |
---|
74 | case SEI::DISPLAY_ORIENTATION: |
---|
75 | fprintf( g_hTrace, "=========== Display Orientation SEI message ===========\n"); |
---|
76 | break; |
---|
77 | case SEI::TEMPORAL_LEVEL0_INDEX: |
---|
78 | fprintf( g_hTrace, "=========== Temporal Level Zero Index SEI message ===========\n"); |
---|
79 | break; |
---|
80 | case SEI::REGION_REFRESH_INFO: |
---|
81 | fprintf( g_hTrace, "=========== Gradual Decoding Refresh Information SEI message ===========\n"); |
---|
82 | break; |
---|
83 | case SEI::DECODING_UNIT_INFO: |
---|
84 | fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n"); |
---|
85 | break; |
---|
86 | case SEI::TONE_MAPPING_INFO: |
---|
87 | fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n"); |
---|
88 | break; |
---|
89 | #if Q0074_SEI_COLOR_MAPPING |
---|
90 | case SEI::COLOR_MAPPING_INFO: |
---|
91 | fprintf( g_hTrace, "=========== Color Mapping Info SEI message ===========\n"); |
---|
92 | break; |
---|
93 | #endif |
---|
94 | case SEI::SOP_DESCRIPTION: |
---|
95 | fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n"); |
---|
96 | break; |
---|
97 | case SEI::SCALABLE_NESTING: |
---|
98 | fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n"); |
---|
99 | break; |
---|
100 | #if SVC_EXTENSION |
---|
101 | #if LAYERS_NOT_PRESENT_SEI |
---|
102 | case SEI::LAYERS_NOT_PRESENT: |
---|
103 | fprintf( g_hTrace, "=========== Layers Present SEI message ===========\n"); |
---|
104 | break; |
---|
105 | #endif |
---|
106 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
107 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
---|
108 | fprintf( g_hTrace, "=========== Inter Layer Constrained Tile Sets SEI message ===========\n"); |
---|
109 | break; |
---|
110 | #endif |
---|
111 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
112 | case SEI::SUB_BITSTREAM_PROPERTY: |
---|
113 | fprintf( g_hTrace, "=========== Sub-bitstream property SEI message ===========\n"); |
---|
114 | break; |
---|
115 | #endif |
---|
116 | #if O0164_MULTI_LAYER_HRD |
---|
117 | case SEI::BSP_NESTING: |
---|
118 | fprintf( g_hTrace, "=========== Bitstream partition nesting SEI message ===========\n"); |
---|
119 | break; |
---|
120 | case SEI::BSP_INITIAL_ARRIVAL_TIME: |
---|
121 | fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n"); |
---|
122 | break; |
---|
123 | case SEI::BSP_HRD: |
---|
124 | fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n"); |
---|
125 | break; |
---|
126 | #endif |
---|
127 | #endif //SVC_EXTENSION |
---|
128 | default: |
---|
129 | fprintf( g_hTrace, "=========== Unknown SEI message ===========\n"); |
---|
130 | break; |
---|
131 | } |
---|
132 | } |
---|
133 | #endif |
---|
134 | |
---|
135 | #if O0164_MULTI_LAYER_HRD |
---|
136 | void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting& nestingSei, const SEIBspNesting& bspNestingSei) |
---|
137 | #else |
---|
138 | void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps) |
---|
139 | #endif |
---|
140 | { |
---|
141 | switch (sei.payloadType()) |
---|
142 | { |
---|
143 | case SEI::USER_DATA_UNREGISTERED: |
---|
144 | xWriteSEIuserDataUnregistered(*static_cast<const SEIuserDataUnregistered*>(&sei)); |
---|
145 | break; |
---|
146 | case SEI::ACTIVE_PARAMETER_SETS: |
---|
147 | xWriteSEIActiveParameterSets(*static_cast<const SEIActiveParameterSets*>(& sei)); |
---|
148 | break; |
---|
149 | case SEI::DECODING_UNIT_INFO: |
---|
150 | xWriteSEIDecodingUnitInfo(*static_cast<const SEIDecodingUnitInfo*>(& sei), sps); |
---|
151 | break; |
---|
152 | case SEI::DECODED_PICTURE_HASH: |
---|
153 | xWriteSEIDecodedPictureHash(*static_cast<const SEIDecodedPictureHash*>(&sei)); |
---|
154 | break; |
---|
155 | case SEI::BUFFERING_PERIOD: |
---|
156 | xWriteSEIBufferingPeriod(*static_cast<const SEIBufferingPeriod*>(&sei), sps); |
---|
157 | break; |
---|
158 | case SEI::PICTURE_TIMING: |
---|
159 | xWriteSEIPictureTiming(*static_cast<const SEIPictureTiming*>(&sei), sps); |
---|
160 | break; |
---|
161 | case SEI::RECOVERY_POINT: |
---|
162 | xWriteSEIRecoveryPoint(*static_cast<const SEIRecoveryPoint*>(&sei)); |
---|
163 | break; |
---|
164 | case SEI::FRAME_PACKING: |
---|
165 | xWriteSEIFramePacking(*static_cast<const SEIFramePacking*>(&sei)); |
---|
166 | break; |
---|
167 | case SEI::DISPLAY_ORIENTATION: |
---|
168 | xWriteSEIDisplayOrientation(*static_cast<const SEIDisplayOrientation*>(&sei)); |
---|
169 | break; |
---|
170 | case SEI::TEMPORAL_LEVEL0_INDEX: |
---|
171 | xWriteSEITemporalLevel0Index(*static_cast<const SEITemporalLevel0Index*>(&sei)); |
---|
172 | break; |
---|
173 | case SEI::REGION_REFRESH_INFO: |
---|
174 | xWriteSEIGradualDecodingRefreshInfo(*static_cast<const SEIGradualDecodingRefreshInfo*>(&sei)); |
---|
175 | break; |
---|
176 | case SEI::TONE_MAPPING_INFO: |
---|
177 | xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei)); |
---|
178 | break; |
---|
179 | #if Q0074_SEI_COLOR_MAPPING |
---|
180 | case SEI::COLOR_MAPPING_INFO: |
---|
181 | xWriteSEIColorMappingInfo(*static_cast<const SEIColorMappingInfo*>(&sei)); |
---|
182 | break; |
---|
183 | #endif |
---|
184 | case SEI::SOP_DESCRIPTION: |
---|
185 | xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei)); |
---|
186 | break; |
---|
187 | case SEI::SCALABLE_NESTING: |
---|
188 | #if O0164_MULTI_LAYER_HRD |
---|
189 | xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), vps, sps); |
---|
190 | #else |
---|
191 | xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps); |
---|
192 | #endif |
---|
193 | break; |
---|
194 | #if SVC_EXTENSION |
---|
195 | #if LAYERS_NOT_PRESENT_SEI |
---|
196 | case SEI::LAYERS_NOT_PRESENT: |
---|
197 | xWriteSEILayersNotPresent(*static_cast<const SEILayersNotPresent*>(&sei)); |
---|
198 | break; |
---|
199 | #endif |
---|
200 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
201 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
---|
202 | xWriteSEIInterLayerConstrainedTileSets(*static_cast<const SEIInterLayerConstrainedTileSets*>(&sei)); |
---|
203 | break; |
---|
204 | #endif |
---|
205 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
206 | case SEI::SUB_BITSTREAM_PROPERTY: |
---|
207 | xWriteSEISubBitstreamProperty(*static_cast<const SEISubBitstreamProperty*>(&sei)); |
---|
208 | break; |
---|
209 | #endif |
---|
210 | #if O0164_MULTI_LAYER_HRD |
---|
211 | case SEI::BSP_NESTING: |
---|
212 | xWriteSEIBspNesting(bs, *static_cast<const SEIBspNesting*>(&sei), vps, sps, nestingSei); |
---|
213 | break; |
---|
214 | case SEI::BSP_INITIAL_ARRIVAL_TIME: |
---|
215 | xWriteSEIBspInitialArrivalTime(*static_cast<const SEIBspInitialArrivalTime*>(&sei), vps, sps, nestingSei, bspNestingSei); |
---|
216 | break; |
---|
217 | case SEI::BSP_HRD: |
---|
218 | xWriteSEIBspHrd(*static_cast<const SEIBspHrd*>(&sei), sps, nestingSei); |
---|
219 | break; |
---|
220 | #endif |
---|
221 | #endif //SVC_EXTENSION |
---|
222 | default: |
---|
223 | assert(!"Unhandled SEI message"); |
---|
224 | } |
---|
225 | } |
---|
226 | |
---|
227 | /** |
---|
228 | * marshal a single SEI message sei, storing the marshalled representation |
---|
229 | * in bitstream bs. |
---|
230 | */ |
---|
231 | #if O0164_MULTI_LAYER_HRD |
---|
232 | Void SEIWriter::writeSEImessage(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei) |
---|
233 | #else |
---|
234 | Void SEIWriter::writeSEImessage(TComBitIf& bs, const SEI& sei, TComSPS *sps) |
---|
235 | #endif |
---|
236 | { |
---|
237 | /* calculate how large the payload data is */ |
---|
238 | /* TODO: this would be far nicer if it used vectored buffers */ |
---|
239 | TComBitCounter bs_count; |
---|
240 | bs_count.resetBits(); |
---|
241 | setBitstream(&bs_count); |
---|
242 | |
---|
243 | |
---|
244 | #if ENC_DEC_TRACE |
---|
245 | Bool traceEnable = g_HLSTraceEnable; |
---|
246 | g_HLSTraceEnable = false; |
---|
247 | #endif |
---|
248 | #if O0164_MULTI_LAYER_HRD |
---|
249 | xWriteSEIpayloadData(bs_count, sei, vps, sps, *nestingSei, *bspNestingSei); |
---|
250 | #else |
---|
251 | xWriteSEIpayloadData(bs_count, sei, sps); |
---|
252 | #endif |
---|
253 | #if ENC_DEC_TRACE |
---|
254 | g_HLSTraceEnable = traceEnable; |
---|
255 | #endif |
---|
256 | |
---|
257 | UInt payload_data_num_bits = bs_count.getNumberOfWrittenBits(); |
---|
258 | assert(0 == payload_data_num_bits % 8); |
---|
259 | |
---|
260 | setBitstream(&bs); |
---|
261 | |
---|
262 | #if ENC_DEC_TRACE |
---|
263 | if (g_HLSTraceEnable) |
---|
264 | xTraceSEIHeader(); |
---|
265 | #endif |
---|
266 | |
---|
267 | UInt payloadType = sei.payloadType(); |
---|
268 | for (; payloadType >= 0xff; payloadType -= 0xff) |
---|
269 | { |
---|
270 | WRITE_CODE(0xff, 8, "payload_type"); |
---|
271 | } |
---|
272 | WRITE_CODE(payloadType, 8, "payload_type"); |
---|
273 | |
---|
274 | UInt payloadSize = payload_data_num_bits/8; |
---|
275 | for (; payloadSize >= 0xff; payloadSize -= 0xff) |
---|
276 | { |
---|
277 | WRITE_CODE(0xff, 8, "payload_size"); |
---|
278 | } |
---|
279 | WRITE_CODE(payloadSize, 8, "payload_size"); |
---|
280 | |
---|
281 | /* payloadData */ |
---|
282 | #if ENC_DEC_TRACE |
---|
283 | if (g_HLSTraceEnable) |
---|
284 | xTraceSEIMessageType(sei.payloadType()); |
---|
285 | #endif |
---|
286 | |
---|
287 | #if O0164_MULTI_LAYER_HRD |
---|
288 | xWriteSEIpayloadData(bs, sei, vps, sps, *nestingSei, *bspNestingSei); |
---|
289 | #else |
---|
290 | xWriteSEIpayloadData(bs, sei, sps); |
---|
291 | #endif |
---|
292 | } |
---|
293 | |
---|
294 | /** |
---|
295 | * marshal a user_data_unregistered SEI message sei, storing the marshalled |
---|
296 | * representation in bitstream bs. |
---|
297 | */ |
---|
298 | Void SEIWriter::xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei) |
---|
299 | { |
---|
300 | for (UInt i = 0; i < 16; i++) |
---|
301 | { |
---|
302 | WRITE_CODE(sei.uuid_iso_iec_11578[i], 8 , "sei.uuid_iso_iec_11578[i]"); |
---|
303 | } |
---|
304 | |
---|
305 | for (UInt i = 0; i < sei.userDataLength; i++) |
---|
306 | { |
---|
307 | WRITE_CODE(sei.userData[i], 8 , "user_data"); |
---|
308 | } |
---|
309 | } |
---|
310 | |
---|
311 | /** |
---|
312 | * marshal a decoded picture hash SEI message, storing the marshalled |
---|
313 | * representation in bitstream bs. |
---|
314 | */ |
---|
315 | Void SEIWriter::xWriteSEIDecodedPictureHash(const SEIDecodedPictureHash& sei) |
---|
316 | { |
---|
317 | UInt val; |
---|
318 | |
---|
319 | WRITE_CODE(sei.method, 8, "hash_type"); |
---|
320 | |
---|
321 | for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++) |
---|
322 | { |
---|
323 | if(sei.method == SEIDecodedPictureHash::MD5) |
---|
324 | { |
---|
325 | for (UInt i = 0; i < 16; i++) |
---|
326 | { |
---|
327 | WRITE_CODE(sei.digest[yuvIdx][i], 8, "picture_md5"); |
---|
328 | } |
---|
329 | } |
---|
330 | else if(sei.method == SEIDecodedPictureHash::CRC) |
---|
331 | { |
---|
332 | val = (sei.digest[yuvIdx][0] << 8) + sei.digest[yuvIdx][1]; |
---|
333 | WRITE_CODE(val, 16, "picture_crc"); |
---|
334 | } |
---|
335 | else if(sei.method == SEIDecodedPictureHash::CHECKSUM) |
---|
336 | { |
---|
337 | val = (sei.digest[yuvIdx][0] << 24) + (sei.digest[yuvIdx][1] << 16) + (sei.digest[yuvIdx][2] << 8) + sei.digest[yuvIdx][3]; |
---|
338 | WRITE_CODE(val, 32, "picture_checksum"); |
---|
339 | } |
---|
340 | } |
---|
341 | } |
---|
342 | |
---|
343 | Void SEIWriter::xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei) |
---|
344 | { |
---|
345 | WRITE_CODE(sei.activeVPSId, 4, "active_video_parameter_set_id"); |
---|
346 | WRITE_FLAG(sei.m_selfContainedCvsFlag, "self_contained_cvs_flag"); |
---|
347 | WRITE_FLAG(sei.m_noParameterSetUpdateFlag, "no_parameter_set_update_flag"); |
---|
348 | WRITE_UVLC(sei.numSpsIdsMinus1, "num_sps_ids_minus1"); |
---|
349 | |
---|
350 | assert (sei.activeSeqParameterSetId.size() == (sei.numSpsIdsMinus1 + 1)); |
---|
351 | |
---|
352 | for (Int i = 0; i < sei.activeSeqParameterSetId.size(); i++) |
---|
353 | { |
---|
354 | WRITE_UVLC(sei.activeSeqParameterSetId[i], "active_seq_parameter_set_id"); |
---|
355 | } |
---|
356 | xWriteByteAlign(); |
---|
357 | } |
---|
358 | |
---|
359 | Void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, TComSPS *sps) |
---|
360 | { |
---|
361 | TComVUI *vui = sps->getVuiParameters(); |
---|
362 | WRITE_UVLC(sei.m_decodingUnitIdx, "decoding_unit_idx"); |
---|
363 | if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag()) |
---|
364 | { |
---|
365 | WRITE_CODE( sei.m_duSptCpbRemovalDelay, (vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay"); |
---|
366 | } |
---|
367 | WRITE_FLAG( sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag"); |
---|
368 | if(sei.m_dpbOutputDuDelayPresentFlag) |
---|
369 | { |
---|
370 | WRITE_CODE(sei.m_picSptDpbOutputDuDelay, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, "pic_spt_dpb_output_du_delay"); |
---|
371 | } |
---|
372 | xWriteByteAlign(); |
---|
373 | } |
---|
374 | |
---|
375 | Void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, TComSPS *sps) |
---|
376 | { |
---|
377 | Int i, nalOrVcl; |
---|
378 | TComVUI *vui = sps->getVuiParameters(); |
---|
379 | TComHRD *hrd = vui->getHrdParameters(); |
---|
380 | |
---|
381 | WRITE_UVLC( sei.m_bpSeqParameterSetId, "bp_seq_parameter_set_id" ); |
---|
382 | if( !hrd->getSubPicCpbParamsPresentFlag() ) |
---|
383 | { |
---|
384 | WRITE_FLAG( sei.m_rapCpbParamsPresentFlag, "irap_cpb_params_present_flag" ); |
---|
385 | } |
---|
386 | if( sei.m_rapCpbParamsPresentFlag ) |
---|
387 | { |
---|
388 | WRITE_CODE( sei.m_cpbDelayOffset, hrd->getCpbRemovalDelayLengthMinus1() + 1, "cpb_delay_offset" ); |
---|
389 | WRITE_CODE( sei.m_dpbDelayOffset, hrd->getDpbOutputDelayLengthMinus1() + 1, "dpb_delay_offset" ); |
---|
390 | } |
---|
391 | WRITE_FLAG( sei.m_concatenationFlag, "concatenation_flag"); |
---|
392 | WRITE_CODE( sei.m_auCpbRemovalDelayDelta - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), "au_cpb_removal_delay_delta_minus1" ); |
---|
393 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
394 | { |
---|
395 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
396 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
397 | { |
---|
398 | for( i = 0; i < ( hrd->getCpbCntMinus1( 0 ) + 1 ); i ++ ) |
---|
399 | { |
---|
400 | WRITE_CODE( sei.m_initialCpbRemovalDelay[i][nalOrVcl],( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , "initial_cpb_removal_delay" ); |
---|
401 | WRITE_CODE( sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl],( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ), "initial_cpb_removal_delay_offset" ); |
---|
402 | if( hrd->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag ) |
---|
403 | { |
---|
404 | WRITE_CODE( sei.m_initialAltCpbRemovalDelay[i][nalOrVcl], ( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , "initial_alt_cpb_removal_delay" ); |
---|
405 | WRITE_CODE( sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl], ( hrd->getInitialCpbRemovalDelayLengthMinus1() + 1 ),"initial_alt_cpb_removal_delay_offset" ); |
---|
406 | } |
---|
407 | } |
---|
408 | } |
---|
409 | } |
---|
410 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
---|
411 | if (sei.m_useAltCpbParamsFlagPresent) |
---|
412 | { |
---|
413 | WRITE_FLAG( sei.m_useAltCpbParamsFlag, "use_alt_cpb_params_flag"); |
---|
414 | } |
---|
415 | #endif |
---|
416 | xWriteByteAlign(); |
---|
417 | } |
---|
418 | Void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, TComSPS *sps) |
---|
419 | { |
---|
420 | Int i; |
---|
421 | TComVUI *vui = sps->getVuiParameters(); |
---|
422 | TComHRD *hrd = vui->getHrdParameters(); |
---|
423 | |
---|
424 | if( vui->getFrameFieldInfoPresentFlag() ) |
---|
425 | { |
---|
426 | WRITE_CODE( sei.m_picStruct, 4, "pic_struct" ); |
---|
427 | WRITE_CODE( sei.m_sourceScanType, 2, "source_scan_type" ); |
---|
428 | WRITE_FLAG( sei.m_duplicateFlag ? 1 : 0, "duplicate_flag" ); |
---|
429 | } |
---|
430 | |
---|
431 | if( hrd->getCpbDpbDelaysPresentFlag() ) |
---|
432 | { |
---|
433 | WRITE_CODE( sei.m_auCpbRemovalDelay - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), "au_cpb_removal_delay_minus1" ); |
---|
434 | WRITE_CODE( sei.m_picDpbOutputDelay, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), "pic_dpb_output_delay" ); |
---|
435 | if(hrd->getSubPicCpbParamsPresentFlag()) |
---|
436 | { |
---|
437 | WRITE_CODE(sei.m_picDpbOutputDuDelay, hrd->getDpbOutputDelayDuLengthMinus1()+1, "pic_dpb_output_du_delay" ); |
---|
438 | } |
---|
439 | if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) |
---|
440 | { |
---|
441 | WRITE_UVLC( sei.m_numDecodingUnitsMinus1, "num_decoding_units_minus1" ); |
---|
442 | WRITE_FLAG( sei.m_duCommonCpbRemovalDelayFlag, "du_common_cpb_removal_delay_flag" ); |
---|
443 | if( sei.m_duCommonCpbRemovalDelayFlag ) |
---|
444 | { |
---|
445 | WRITE_CODE( sei.m_duCommonCpbRemovalDelayMinus1, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), "du_common_cpb_removal_delay_minus1" ); |
---|
446 | } |
---|
447 | for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ ) |
---|
448 | { |
---|
449 | WRITE_UVLC( sei.m_numNalusInDuMinus1[ i ], "num_nalus_in_du_minus1"); |
---|
450 | if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) ) |
---|
451 | { |
---|
452 | WRITE_CODE( sei.m_duCpbRemovalDelayMinus1[ i ], ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), "du_cpb_removal_delay_minus1" ); |
---|
453 | } |
---|
454 | } |
---|
455 | } |
---|
456 | } |
---|
457 | xWriteByteAlign(); |
---|
458 | } |
---|
459 | Void SEIWriter::xWriteSEIRecoveryPoint(const SEIRecoveryPoint& sei) |
---|
460 | { |
---|
461 | WRITE_SVLC( sei.m_recoveryPocCnt, "recovery_poc_cnt" ); |
---|
462 | WRITE_FLAG( sei.m_exactMatchingFlag, "exact_matching_flag" ); |
---|
463 | WRITE_FLAG( sei.m_brokenLinkFlag, "broken_link_flag" ); |
---|
464 | xWriteByteAlign(); |
---|
465 | } |
---|
466 | Void SEIWriter::xWriteSEIFramePacking(const SEIFramePacking& sei) |
---|
467 | { |
---|
468 | WRITE_UVLC( sei.m_arrangementId, "frame_packing_arrangement_id" ); |
---|
469 | WRITE_FLAG( sei.m_arrangementCancelFlag, "frame_packing_arrangement_cancel_flag" ); |
---|
470 | |
---|
471 | if( sei.m_arrangementCancelFlag == 0 ) { |
---|
472 | WRITE_CODE( sei.m_arrangementType, 7, "frame_packing_arrangement_type" ); |
---|
473 | |
---|
474 | WRITE_FLAG( sei.m_quincunxSamplingFlag, "quincunx_sampling_flag" ); |
---|
475 | WRITE_CODE( sei.m_contentInterpretationType, 6, "content_interpretation_type" ); |
---|
476 | WRITE_FLAG( sei.m_spatialFlippingFlag, "spatial_flipping_flag" ); |
---|
477 | WRITE_FLAG( sei.m_frame0FlippedFlag, "frame0_flipped_flag" ); |
---|
478 | WRITE_FLAG( sei.m_fieldViewsFlag, "field_views_flag" ); |
---|
479 | WRITE_FLAG( sei.m_currentFrameIsFrame0Flag, "current_frame_is_frame0_flag" ); |
---|
480 | |
---|
481 | WRITE_FLAG( sei.m_frame0SelfContainedFlag, "frame0_self_contained_flag" ); |
---|
482 | WRITE_FLAG( sei.m_frame1SelfContainedFlag, "frame1_self_contained_flag" ); |
---|
483 | |
---|
484 | if(sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) |
---|
485 | { |
---|
486 | WRITE_CODE( sei.m_frame0GridPositionX, 4, "frame0_grid_position_x" ); |
---|
487 | WRITE_CODE( sei.m_frame0GridPositionY, 4, "frame0_grid_position_y" ); |
---|
488 | WRITE_CODE( sei.m_frame1GridPositionX, 4, "frame1_grid_position_x" ); |
---|
489 | WRITE_CODE( sei.m_frame1GridPositionY, 4, "frame1_grid_position_y" ); |
---|
490 | } |
---|
491 | |
---|
492 | WRITE_CODE( sei.m_arrangementReservedByte, 8, "frame_packing_arrangement_reserved_byte" ); |
---|
493 | WRITE_FLAG( sei.m_arrangementPersistenceFlag, "frame_packing_arrangement_persistence_flag" ); |
---|
494 | } |
---|
495 | |
---|
496 | WRITE_FLAG( sei.m_upsampledAspectRatio, "upsampled_aspect_ratio" ); |
---|
497 | |
---|
498 | xWriteByteAlign(); |
---|
499 | } |
---|
500 | |
---|
501 | Void SEIWriter::xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei) |
---|
502 | { |
---|
503 | Int i; |
---|
504 | WRITE_UVLC( sei.m_toneMapId, "tone_map_id" ); |
---|
505 | WRITE_FLAG( sei.m_toneMapCancelFlag, "tone_map_cancel_flag" ); |
---|
506 | if( !sei.m_toneMapCancelFlag ) |
---|
507 | { |
---|
508 | WRITE_FLAG( sei.m_toneMapPersistenceFlag, "tone_map_persistence_flag" ); |
---|
509 | WRITE_CODE( sei.m_codedDataBitDepth, 8, "coded_data_bit_depth" ); |
---|
510 | WRITE_CODE( sei.m_targetBitDepth, 8, "target_bit_depth" ); |
---|
511 | WRITE_UVLC( sei.m_modelId, "model_id" ); |
---|
512 | switch(sei.m_modelId) |
---|
513 | { |
---|
514 | case 0: |
---|
515 | { |
---|
516 | WRITE_CODE( sei.m_minValue, 32, "min_value" ); |
---|
517 | WRITE_CODE( sei.m_maxValue, 32, "max_value" ); |
---|
518 | break; |
---|
519 | } |
---|
520 | case 1: |
---|
521 | { |
---|
522 | WRITE_CODE( sei.m_sigmoidMidpoint, 32, "sigmoid_midpoint" ); |
---|
523 | WRITE_CODE( sei.m_sigmoidWidth, 32, "sigmoid_width" ); |
---|
524 | break; |
---|
525 | } |
---|
526 | case 2: |
---|
527 | { |
---|
528 | UInt num = 1u << sei.m_targetBitDepth; |
---|
529 | for(i = 0; i < num; i++) |
---|
530 | { |
---|
531 | WRITE_CODE( sei.m_startOfCodedInterval[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3, "start_of_coded_interval" ); |
---|
532 | } |
---|
533 | break; |
---|
534 | } |
---|
535 | case 3: |
---|
536 | { |
---|
537 | WRITE_CODE( sei.m_numPivots, 16, "num_pivots" ); |
---|
538 | for(i = 0; i < sei.m_numPivots; i++ ) |
---|
539 | { |
---|
540 | WRITE_CODE( sei.m_codedPivotValue[i], (( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3, "coded_pivot_value" ); |
---|
541 | WRITE_CODE( sei.m_targetPivotValue[i], (( sei.m_targetBitDepth + 7 ) >> 3 ) << 3, "target_pivot_value"); |
---|
542 | } |
---|
543 | break; |
---|
544 | } |
---|
545 | case 4: |
---|
546 | { |
---|
547 | WRITE_CODE( sei.m_cameraIsoSpeedIdc, 8, "camera_iso_speed_idc" ); |
---|
548 | if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO |
---|
549 | { |
---|
550 | WRITE_CODE( sei.m_cameraIsoSpeedValue, 32, "camera_iso_speed_value" ); |
---|
551 | } |
---|
552 | WRITE_CODE( sei.m_exposureIndexIdc, 8, "exposure_index_idc" ); |
---|
553 | if( sei.m_exposureIndexIdc == 255) //Extended_ISO |
---|
554 | { |
---|
555 | WRITE_CODE( sei.m_exposureIndexValue, 32, "exposure_index_value" ); |
---|
556 | } |
---|
557 | WRITE_FLAG( sei.m_exposureCompensationValueSignFlag, "exposure_compensation_value_sign_flag" ); |
---|
558 | WRITE_CODE( sei.m_exposureCompensationValueNumerator, 16, "exposure_compensation_value_numerator" ); |
---|
559 | WRITE_CODE( sei.m_exposureCompensationValueDenomIdc, 16, "exposure_compensation_value_denom_idc" ); |
---|
560 | WRITE_CODE( sei.m_refScreenLuminanceWhite, 32, "ref_screen_luminance_white" ); |
---|
561 | WRITE_CODE( sei.m_extendedRangeWhiteLevel, 32, "extended_range_white_level" ); |
---|
562 | WRITE_CODE( sei.m_nominalBlackLevelLumaCodeValue, 16, "nominal_black_level_luma_code_value" ); |
---|
563 | WRITE_CODE( sei.m_nominalWhiteLevelLumaCodeValue, 16, "nominal_white_level_luma_code_value" ); |
---|
564 | WRITE_CODE( sei.m_extendedWhiteLevelLumaCodeValue, 16, "extended_white_level_luma_code_value" ); |
---|
565 | break; |
---|
566 | } |
---|
567 | default: |
---|
568 | { |
---|
569 | assert(!"Undefined SEIToneMapModelId"); |
---|
570 | break; |
---|
571 | } |
---|
572 | }//switch m_modelId |
---|
573 | }//if(!sei.m_toneMapCancelFlag) |
---|
574 | |
---|
575 | xWriteByteAlign(); |
---|
576 | } |
---|
577 | |
---|
578 | #if Q0074_SEI_COLOR_MAPPING |
---|
579 | Void SEIWriter::xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei) |
---|
580 | { |
---|
581 | WRITE_UVLC( sei.m_colorMapId, "colour_map_id" ); |
---|
582 | WRITE_FLAG( sei.m_colorMapCancelFlag, "colour_map_cancel_flag" ); |
---|
583 | if( !sei.m_colorMapCancelFlag ) |
---|
584 | { |
---|
585 | WRITE_FLAG( sei.m_colorMapPersistenceFlag, "colour_map_persistence_flag" ); |
---|
586 | WRITE_FLAG( sei.m_colorMap_video_signal_type_present_flag, "colour_map_video_signal_type_present_flag" ); |
---|
587 | if ( sei.m_colorMap_video_signal_type_present_flag ) |
---|
588 | { |
---|
589 | WRITE_FLAG( sei.m_colorMap_video_full_range_flag, "colour_map_video_full_range_flag" ); |
---|
590 | WRITE_CODE( sei.m_colorMap_primaries, 8, "colour_map_primaries" ); |
---|
591 | WRITE_CODE( sei.m_colorMap_transfer_characteristics, 8, "colour_map_transfer_characteristics" ); |
---|
592 | WRITE_CODE( sei.m_colorMap_matrix_coeffs, 8, "colour_map_matrix_coeffs" ); |
---|
593 | } |
---|
594 | } |
---|
595 | |
---|
596 | WRITE_CODE( sei.m_colour_map_coded_data_bit_depth, 5, "colour_map_coded_data_bit_depth" ); |
---|
597 | WRITE_CODE( sei.m_colour_map_target_bit_depth, 5, "colour_map_target_bit_depth" ); |
---|
598 | WRITE_UVLC( sei.m_colorMapModelId, "colour_map_model_id" ); |
---|
599 | |
---|
600 | assert( sei.m_colorMapModelId == 0 ); |
---|
601 | |
---|
602 | for( Int i=0 ; i<3 ; i++ ) |
---|
603 | { |
---|
604 | WRITE_CODE( sei.m_num_input_pivots[i] - 1, 8, "num_input_pivots_minus1[i]" ); |
---|
605 | for( Int j=0 ; j<sei.m_num_input_pivots[i] ; j++ ) |
---|
606 | { |
---|
607 | WRITE_CODE( sei.m_coded_input_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "coded_input_pivot_value[i][j]" ); |
---|
608 | WRITE_CODE( sei.m_target_input_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "target_input_pivot_value[i][j]" ); |
---|
609 | } |
---|
610 | } |
---|
611 | |
---|
612 | WRITE_FLAG( sei.m_matrix_flag, "matrix_flag" ); |
---|
613 | if( sei.m_matrix_flag ) |
---|
614 | { |
---|
615 | WRITE_CODE( sei.m_log2_matrix_denom, 4, "log2_matrix_denom" ); |
---|
616 | for( Int i=0 ; i<3 ; i++ ) |
---|
617 | { |
---|
618 | for( Int j=0 ; j<3 ; j++ ) |
---|
619 | { |
---|
620 | WRITE_SVLC( sei.m_matrix_coef[i][j], "matrix_coef[i][j]" ); |
---|
621 | } |
---|
622 | } |
---|
623 | } |
---|
624 | |
---|
625 | for( Int i=0 ; i<3 ; i++ ) |
---|
626 | { |
---|
627 | WRITE_CODE( sei.m_num_output_pivots[i] - 1, 8, "num_output_pivots_minus1[i]" ); |
---|
628 | for( Int j=0 ; j<sei.m_num_output_pivots[i] ; j++ ) |
---|
629 | { |
---|
630 | WRITE_CODE( sei.m_coded_output_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "coded_output_pivot_value[i][j]" ); |
---|
631 | WRITE_CODE( sei.m_target_output_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "target_output_pivot_value[i][j]" ); |
---|
632 | } |
---|
633 | } |
---|
634 | |
---|
635 | xWriteByteAlign(); |
---|
636 | } |
---|
637 | #endif |
---|
638 | |
---|
639 | Void SEIWriter::xWriteSEIDisplayOrientation(const SEIDisplayOrientation &sei) |
---|
640 | { |
---|
641 | WRITE_FLAG( sei.cancelFlag, "display_orientation_cancel_flag" ); |
---|
642 | if( !sei.cancelFlag ) |
---|
643 | { |
---|
644 | WRITE_FLAG( sei.horFlip, "hor_flip" ); |
---|
645 | WRITE_FLAG( sei.verFlip, "ver_flip" ); |
---|
646 | WRITE_CODE( sei.anticlockwiseRotation, 16, "anticlockwise_rotation" ); |
---|
647 | WRITE_FLAG( sei.persistenceFlag, "display_orientation_persistence_flag" ); |
---|
648 | } |
---|
649 | xWriteByteAlign(); |
---|
650 | } |
---|
651 | |
---|
652 | Void SEIWriter::xWriteSEITemporalLevel0Index(const SEITemporalLevel0Index &sei) |
---|
653 | { |
---|
654 | WRITE_CODE( sei.tl0Idx, 8 , "tl0_idx" ); |
---|
655 | WRITE_CODE( sei.rapIdx, 8 , "rap_idx" ); |
---|
656 | xWriteByteAlign(); |
---|
657 | } |
---|
658 | |
---|
659 | Void SEIWriter::xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei) |
---|
660 | { |
---|
661 | WRITE_FLAG( sei.m_gdrForegroundFlag, "gdr_foreground_flag"); |
---|
662 | xWriteByteAlign(); |
---|
663 | } |
---|
664 | |
---|
665 | Void SEIWriter::xWriteSEISOPDescription(const SEISOPDescription& sei) |
---|
666 | { |
---|
667 | WRITE_UVLC( sei.m_sopSeqParameterSetId, "sop_seq_parameter_set_id" ); |
---|
668 | WRITE_UVLC( sei.m_numPicsInSopMinus1, "num_pics_in_sop_minus1" ); |
---|
669 | for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) |
---|
670 | { |
---|
671 | WRITE_CODE( sei.m_sopDescVclNaluType[i], 6, "sop_desc_vcl_nalu_type" ); |
---|
672 | WRITE_CODE( sei.m_sopDescTemporalId[i], 3, "sop_desc_temporal_id" ); |
---|
673 | if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) |
---|
674 | { |
---|
675 | WRITE_UVLC( sei.m_sopDescStRpsIdx[i], "sop_desc_st_rps_idx" ); |
---|
676 | } |
---|
677 | if (i > 0) |
---|
678 | { |
---|
679 | WRITE_SVLC( sei.m_sopDescPocDelta[i], "sop_desc_poc_delta" ); |
---|
680 | } |
---|
681 | } |
---|
682 | |
---|
683 | xWriteByteAlign(); |
---|
684 | } |
---|
685 | |
---|
686 | #if O0164_MULTI_LAYER_HRD |
---|
687 | Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComVPS *vps, TComSPS *sps) |
---|
688 | #else |
---|
689 | Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps) |
---|
690 | #endif |
---|
691 | { |
---|
692 | WRITE_FLAG( sei.m_bitStreamSubsetFlag, "bitstream_subset_flag" ); |
---|
693 | WRITE_FLAG( sei.m_nestingOpFlag, "nesting_op_flag " ); |
---|
694 | if (sei.m_nestingOpFlag) |
---|
695 | { |
---|
696 | WRITE_FLAG( sei.m_defaultOpFlag, "default_op_flag" ); |
---|
697 | WRITE_UVLC( sei.m_nestingNumOpsMinus1, "nesting_num_ops" ); |
---|
698 | for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++) |
---|
699 | { |
---|
700 | WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" ); |
---|
701 | WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3, "nesting_max_temporal_id" ); |
---|
702 | WRITE_UVLC( sei.m_nestingOpIdx[i], "nesting_op_idx" ); |
---|
703 | } |
---|
704 | } |
---|
705 | else |
---|
706 | { |
---|
707 | WRITE_FLAG( sei.m_allLayersFlag, "all_layers_flag" ); |
---|
708 | if (!sei.m_allLayersFlag) |
---|
709 | { |
---|
710 | WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" ); |
---|
711 | WRITE_UVLC( sei.m_nestingNumLayersMinus1, "nesting_num_layers" ); |
---|
712 | for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) |
---|
713 | { |
---|
714 | WRITE_CODE( sei.m_nestingLayerId[i], 6, "nesting_layer_id" ); |
---|
715 | } |
---|
716 | } |
---|
717 | } |
---|
718 | |
---|
719 | // byte alignment |
---|
720 | while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) |
---|
721 | { |
---|
722 | WRITE_FLAG( 0, "nesting_zero_bit" ); |
---|
723 | } |
---|
724 | |
---|
725 | // write nested SEI messages |
---|
726 | for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++) |
---|
727 | { |
---|
728 | #if O0164_MULTI_LAYER_HRD |
---|
729 | writeSEImessage(bs, *(*it), vps, sps, &sei); |
---|
730 | #else |
---|
731 | writeSEImessage(bs, *(*it), sps); |
---|
732 | #endif |
---|
733 | } |
---|
734 | } |
---|
735 | |
---|
736 | Void SEIWriter::xWriteByteAlign() |
---|
737 | { |
---|
738 | if( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0) |
---|
739 | { |
---|
740 | WRITE_FLAG( 1, "bit_equal_to_one" ); |
---|
741 | while( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) |
---|
742 | { |
---|
743 | WRITE_FLAG( 0, "bit_equal_to_zero" ); |
---|
744 | } |
---|
745 | } |
---|
746 | }; |
---|
747 | |
---|
748 | #if SVC_EXTENSION |
---|
749 | #if LAYERS_NOT_PRESENT_SEI |
---|
750 | Void SEIWriter::xWriteSEILayersNotPresent(const SEILayersNotPresent& sei) |
---|
751 | { |
---|
752 | WRITE_UVLC( sei.m_activeVpsId, "lp_sei_active_vps_id" ); |
---|
753 | for (UInt i = 0; i < sei.m_vpsMaxLayers; i++) |
---|
754 | { |
---|
755 | WRITE_FLAG( sei.m_layerNotPresentFlag[i], "layer_not_present_flag" ); |
---|
756 | } |
---|
757 | xWriteByteAlign(); |
---|
758 | } |
---|
759 | #endif |
---|
760 | |
---|
761 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
762 | Void SEIWriter::xWriteSEIInterLayerConstrainedTileSets(const SEIInterLayerConstrainedTileSets& sei) |
---|
763 | { |
---|
764 | WRITE_FLAG( sei.m_ilAllTilesExactSampleValueMatchFlag, "il_all_tiles_exact_sample_value_match_flag" ); |
---|
765 | WRITE_FLAG( sei.m_ilOneTilePerTileSetFlag, "il_one_tile_per_tile_set_flag" ); |
---|
766 | if( !sei.m_ilOneTilePerTileSetFlag ) |
---|
767 | { |
---|
768 | WRITE_UVLC( sei.m_ilNumSetsInMessageMinus1, "il_num_sets_in_message_minus1" ); |
---|
769 | if( sei.m_ilNumSetsInMessageMinus1 ) |
---|
770 | { |
---|
771 | WRITE_FLAG( sei.m_skippedTileSetPresentFlag, "skipped_tile_set_present_flag" ); |
---|
772 | } |
---|
773 | UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1; |
---|
774 | for( UInt i = 0; i < numSignificantSets; i++ ) |
---|
775 | { |
---|
776 | WRITE_UVLC( sei.m_ilctsId[i], "ilcts_id" ); |
---|
777 | WRITE_UVLC( sei.m_ilNumTileRectsInSetMinus1[i], "il_num_tile_rects_in_set_minus1" ); |
---|
778 | for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ ) |
---|
779 | { |
---|
780 | WRITE_UVLC( sei.m_ilTopLeftTileIndex[i][j], "il_top_left_tile_index" ); |
---|
781 | WRITE_UVLC( sei.m_ilBottomRightTileIndex[i][j], "il_bottom_right_tile_index" ); |
---|
782 | } |
---|
783 | WRITE_CODE( sei.m_ilcIdc[i], 2, "ilc_idc" ); |
---|
784 | if( sei.m_ilAllTilesExactSampleValueMatchFlag ) |
---|
785 | { |
---|
786 | WRITE_FLAG( sei.m_ilExactSampleValueMatchFlag[i], "il_exact_sample_value_match_flag" ); |
---|
787 | } |
---|
788 | } |
---|
789 | } |
---|
790 | else |
---|
791 | { |
---|
792 | WRITE_CODE( sei.m_allTilesIlcIdc, 2, "all_tiles_ilc_idc" ); |
---|
793 | } |
---|
794 | |
---|
795 | xWriteByteAlign(); |
---|
796 | } |
---|
797 | #endif |
---|
798 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
799 | Void SEIWriter::xWriteSEISubBitstreamProperty(const SEISubBitstreamProperty &sei) |
---|
800 | { |
---|
801 | WRITE_CODE( sei.m_activeVpsId, 4, "active_vps_id" ); |
---|
802 | assert( sei.m_numAdditionalSubStreams >= 1 ); |
---|
803 | WRITE_UVLC( sei.m_numAdditionalSubStreams - 1, "num_additional_sub_streams_minus1" ); |
---|
804 | |
---|
805 | for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ ) |
---|
806 | { |
---|
807 | WRITE_CODE( sei.m_subBitstreamMode[i], 2, "sub_bitstream_mode[i]" ); |
---|
808 | WRITE_UVLC( sei.m_outputLayerSetIdxToVps[i], "output_layer_set_idx_to_vps[i]" ); |
---|
809 | WRITE_CODE( sei.m_highestSublayerId[i], 3, "highest_sub_layer_id[i]" ); |
---|
810 | WRITE_CODE( sei.m_avgBitRate[i], 16, "avg_bit_rate[i]" ); |
---|
811 | WRITE_CODE( sei.m_maxBitRate[i], 16, "max_bit_rate[i]" ); |
---|
812 | } |
---|
813 | xWriteByteAlign(); |
---|
814 | } |
---|
815 | #endif |
---|
816 | |
---|
817 | #if O0164_MULTI_LAYER_HRD |
---|
818 | Void SEIWriter::xWriteSEIBspNesting(TComBitIf& bs, const SEIBspNesting &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
819 | { |
---|
820 | WRITE_UVLC( sei.m_bspIdx, "bsp_idx" ); |
---|
821 | |
---|
822 | while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) |
---|
823 | { |
---|
824 | WRITE_FLAG( 0, "bsp_nesting_zero_bit" ); |
---|
825 | } |
---|
826 | |
---|
827 | // write nested SEI messages |
---|
828 | for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++) |
---|
829 | { |
---|
830 | writeSEImessage(bs, *(*it), vps, sps, &nestingSei, &sei); |
---|
831 | } |
---|
832 | } |
---|
833 | |
---|
834 | Void SEIWriter::xWriteSEIBspInitialArrivalTime(const SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei) |
---|
835 | { |
---|
836 | assert(vps->getVpsVuiPresentFlag()); |
---|
837 | |
---|
838 | UInt schedCombCnt = vps->getNumBspSchedCombinations(nestingSei.m_nestingOpIdx[0]); |
---|
839 | UInt len; |
---|
840 | UInt hrdIdx; |
---|
841 | |
---|
842 | if (schedCombCnt > 0) |
---|
843 | { |
---|
844 | hrdIdx = vps->getBspCombHrdIdx(nestingSei.m_nestingOpIdx[0], 0, bspNestingSei.m_bspIdx); |
---|
845 | } |
---|
846 | else |
---|
847 | { |
---|
848 | hrdIdx = 0; |
---|
849 | } |
---|
850 | |
---|
851 | TComHRD *hrd = vps->getBspHrd(hrdIdx); |
---|
852 | |
---|
853 | if (hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag()) |
---|
854 | { |
---|
855 | len = hrd->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
856 | } |
---|
857 | else |
---|
858 | { |
---|
859 | len = 23 + 1; |
---|
860 | } |
---|
861 | |
---|
862 | if (hrd->getNalHrdParametersPresentFlag()) |
---|
863 | { |
---|
864 | for(UInt i = 0; i < schedCombCnt; i++) |
---|
865 | { |
---|
866 | WRITE_CODE( sei.m_nalInitialArrivalDelay[i], len, "nal_initial_arrival_delay" ); |
---|
867 | } |
---|
868 | } |
---|
869 | else |
---|
870 | { |
---|
871 | for(UInt i = 0; i < schedCombCnt; i++) |
---|
872 | { |
---|
873 | WRITE_CODE( sei.m_vclInitialArrivalDelay[i], len, "vcl_initial_arrival_delay" ); |
---|
874 | } |
---|
875 | } |
---|
876 | } |
---|
877 | |
---|
878 | Void SEIWriter::xWriteSEIBspHrd(const SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
879 | { |
---|
880 | WRITE_UVLC( sei.m_seiNumBspHrdParametersMinus1, "sei_num_bsp_hrd_parameters_minus1" ); |
---|
881 | for (UInt i = 0; i <= sei.m_seiNumBspHrdParametersMinus1; i++) |
---|
882 | { |
---|
883 | if (i > 0) |
---|
884 | { |
---|
885 | WRITE_FLAG( sei.m_seiBspCprmsPresentFlag[i], "sei_bsp_cprms_present_flag" ); |
---|
886 | } |
---|
887 | xCodeHrdParameters(sei.hrd, i==0 ? 1 : sei.m_seiBspCprmsPresentFlag[i], nestingSei.m_nestingMaxTemporalIdPlus1[0]-1); |
---|
888 | } |
---|
889 | for (UInt h = 0; h <= nestingSei.m_nestingNumOpsMinus1; h++) |
---|
890 | { |
---|
891 | UInt lsIdx = nestingSei.m_nestingOpIdx[h]; |
---|
892 | WRITE_UVLC( sei.m_seiNumBitstreamPartitionsMinus1[lsIdx], "num_sei_bitstream_partitions_minus1[i]"); |
---|
893 | for (UInt i = 0; i <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; i++) |
---|
894 | { |
---|
895 | for (UInt j = 0; j < sei.m_vpsMaxLayers; j++) |
---|
896 | { |
---|
897 | if (sei.m_layerIdIncludedFlag[lsIdx][j]) |
---|
898 | { |
---|
899 | WRITE_FLAG( sei.m_seiLayerInBspFlag[lsIdx][i][j], "sei_layer_in_bsp_flag[lsIdx][i][j]" ); |
---|
900 | } |
---|
901 | } |
---|
902 | } |
---|
903 | WRITE_UVLC( sei.m_seiNumBspSchedCombinationsMinus1[lsIdx], "sei_num_bsp_sched_combinations_minus1[i]"); |
---|
904 | for (UInt i = 0; i <= sei.m_seiNumBspSchedCombinationsMinus1[lsIdx]; i++) |
---|
905 | { |
---|
906 | for (UInt j = 0; j <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; j++) |
---|
907 | { |
---|
908 | WRITE_UVLC( sei.m_seiBspCombHrdIdx[lsIdx][i][j], "sei_bsp_comb_hrd_idx[lsIdx][i][j]"); |
---|
909 | WRITE_UVLC( sei.m_seiBspCombScheddx[lsIdx][i][j], "sei_bsp_comb_sched_idx[lsIdx][i][j]"); |
---|
910 | } |
---|
911 | } |
---|
912 | } |
---|
913 | } |
---|
914 | |
---|
915 | Void SEIWriter::xCodeHrdParameters( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 ) |
---|
916 | { |
---|
917 | if( commonInfPresentFlag ) |
---|
918 | { |
---|
919 | WRITE_FLAG( hrd->getNalHrdParametersPresentFlag() ? 1 : 0 , "nal_hrd_parameters_present_flag" ); |
---|
920 | WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 , "vcl_hrd_parameters_present_flag" ); |
---|
921 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
922 | { |
---|
923 | WRITE_FLAG( hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0, "sub_pic_cpb_params_present_flag" ); |
---|
924 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
925 | { |
---|
926 | WRITE_CODE( hrd->getTickDivisorMinus2(), 8, "tick_divisor_minus2" ); |
---|
927 | WRITE_CODE( hrd->getDuCpbRemovalDelayLengthMinus1(), 5, "du_cpb_removal_delay_length_minus1" ); |
---|
928 | WRITE_FLAG( hrd->getSubPicCpbParamsInPicTimingSEIFlag() ? 1 : 0, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); |
---|
929 | WRITE_CODE( hrd->getDpbOutputDelayDuLengthMinus1(), 5, "dpb_output_delay_du_length_minus1" ); |
---|
930 | } |
---|
931 | WRITE_CODE( hrd->getBitRateScale(), 4, "bit_rate_scale" ); |
---|
932 | WRITE_CODE( hrd->getCpbSizeScale(), 4, "cpb_size_scale" ); |
---|
933 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
934 | { |
---|
935 | WRITE_CODE( hrd->getDuCpbSizeScale(), 4, "du_cpb_size_scale" ); |
---|
936 | } |
---|
937 | WRITE_CODE( hrd->getInitialCpbRemovalDelayLengthMinus1(), 5, "initial_cpb_removal_delay_length_minus1" ); |
---|
938 | WRITE_CODE( hrd->getCpbRemovalDelayLengthMinus1(), 5, "au_cpb_removal_delay_length_minus1" ); |
---|
939 | WRITE_CODE( hrd->getDpbOutputDelayLengthMinus1(), 5, "dpb_output_delay_length_minus1" ); |
---|
940 | } |
---|
941 | } |
---|
942 | Int i, j, nalOrVcl; |
---|
943 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
944 | { |
---|
945 | WRITE_FLAG( hrd->getFixedPicRateFlag( i ) ? 1 : 0, "fixed_pic_rate_general_flag"); |
---|
946 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
947 | { |
---|
948 | WRITE_FLAG( hrd->getFixedPicRateWithinCvsFlag( i ) ? 1 : 0, "fixed_pic_rate_within_cvs_flag"); |
---|
949 | } |
---|
950 | else |
---|
951 | { |
---|
952 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
953 | } |
---|
954 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
955 | { |
---|
956 | WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ), "elemental_duration_in_tc_minus1"); |
---|
957 | } |
---|
958 | else |
---|
959 | { |
---|
960 | WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0, "low_delay_hrd_flag"); |
---|
961 | } |
---|
962 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
963 | { |
---|
964 | WRITE_UVLC( hrd->getCpbCntMinus1( i ), "cpb_cnt_minus1"); |
---|
965 | } |
---|
966 | |
---|
967 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
968 | { |
---|
969 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
970 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
971 | { |
---|
972 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
973 | { |
---|
974 | WRITE_UVLC( hrd->getBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_value_minus1"); |
---|
975 | WRITE_UVLC( hrd->getCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_value_minus1"); |
---|
976 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
977 | { |
---|
978 | WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1"); |
---|
979 | WRITE_UVLC( hrd->getDuBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_du_value_minus1"); |
---|
980 | } |
---|
981 | WRITE_FLAG( hrd->getCbrFlag( i, j, nalOrVcl ) ? 1 : 0, "cbr_flag"); |
---|
982 | } |
---|
983 | } |
---|
984 | } |
---|
985 | } |
---|
986 | } |
---|
987 | |
---|
988 | #endif |
---|
989 | |
---|
990 | #endif //SVC_EXTENSION |
---|
991 | |
---|
992 | //! \} |
---|