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-2017, 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 | /** \file TEncCavlc.cpp |
---|
35 | \brief CAVLC encoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "../TLibCommon/CommonDef.h" |
---|
39 | #include "TEncCavlc.h" |
---|
40 | #include "SEIwrite.h" |
---|
41 | |
---|
42 | #if NH_MV |
---|
43 | #include "TEncTop.h" |
---|
44 | #endif |
---|
45 | |
---|
46 | //! \ingroup TLibEncoder |
---|
47 | //! \{ |
---|
48 | |
---|
49 | #if ENC_DEC_TRACE |
---|
50 | |
---|
51 | #if !NH_MV_ENC_DEC_TRAC |
---|
52 | Void xTraceVPSHeader () |
---|
53 | { |
---|
54 | fprintf( g_hTrace, "=========== Video Parameter Set ===========\n" ); |
---|
55 | } |
---|
56 | |
---|
57 | Void xTraceSPSHeader () |
---|
58 | { |
---|
59 | fprintf( g_hTrace, "=========== Sequence Parameter Set ===========\n" ); |
---|
60 | } |
---|
61 | |
---|
62 | Void xTracePPSHeader () |
---|
63 | { |
---|
64 | fprintf( g_hTrace, "=========== Picture Parameter Set ===========\n"); |
---|
65 | } |
---|
66 | |
---|
67 | Void xTraceSliceHeader ( ) |
---|
68 | { |
---|
69 | fprintf( g_hTrace, "=========== Slice ===========\n"); |
---|
70 | } |
---|
71 | #endif |
---|
72 | |
---|
73 | Void xTraceAccessUnitDelimiter () |
---|
74 | { |
---|
75 | fprintf( g_hTrace, "=========== Access Unit Delimiter ===========\n"); |
---|
76 | } |
---|
77 | |
---|
78 | #endif |
---|
79 | |
---|
80 | Void AUDWriter::codeAUD(TComBitIf& bs, const Int pictureType) |
---|
81 | { |
---|
82 | #if ENC_DEC_TRACE |
---|
83 | xTraceAccessUnitDelimiter(); |
---|
84 | #endif |
---|
85 | |
---|
86 | assert (pictureType < 3); |
---|
87 | setBitstream(&bs); |
---|
88 | WRITE_CODE(pictureType, 3, "pic_type"); |
---|
89 | xWriteRbspTrailingBits(); |
---|
90 | } |
---|
91 | |
---|
92 | // ==================================================================================================================== |
---|
93 | // Constructor / destructor / create / destroy |
---|
94 | // ==================================================================================================================== |
---|
95 | |
---|
96 | TEncCavlc::TEncCavlc() |
---|
97 | { |
---|
98 | m_pcBitIf = NULL; |
---|
99 | } |
---|
100 | |
---|
101 | TEncCavlc::~TEncCavlc() |
---|
102 | { |
---|
103 | } |
---|
104 | |
---|
105 | |
---|
106 | // ==================================================================================================================== |
---|
107 | // Public member functions |
---|
108 | // ==================================================================================================================== |
---|
109 | |
---|
110 | Void TEncCavlc::resetEntropy(const TComSlice* /*pSlice*/) |
---|
111 | { |
---|
112 | } |
---|
113 | |
---|
114 | |
---|
115 | Void TEncCavlc::codeShortTermRefPicSet( const TComReferencePictureSet* rps, Bool calledFromSliceHeader, Int idx) |
---|
116 | { |
---|
117 | #if PRINT_RPS_INFO |
---|
118 | Int lastBits = getNumberOfWrittenBits(); |
---|
119 | #endif |
---|
120 | if (idx > 0) |
---|
121 | { |
---|
122 | WRITE_FLAG( rps->getInterRPSPrediction(), "inter_ref_pic_set_prediction_flag" ); // inter_RPS_prediction_flag |
---|
123 | } |
---|
124 | if (rps->getInterRPSPrediction()) |
---|
125 | { |
---|
126 | Int deltaRPS = rps->getDeltaRPS(); |
---|
127 | if(calledFromSliceHeader) |
---|
128 | { |
---|
129 | WRITE_UVLC( rps->getDeltaRIdxMinus1(), "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
130 | } |
---|
131 | |
---|
132 | WRITE_CODE( (deltaRPS >=0 ? 0: 1), 1, "delta_rps_sign" ); //delta_rps_sign |
---|
133 | WRITE_UVLC( abs(deltaRPS) - 1, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
134 | |
---|
135 | for(Int j=0; j < rps->getNumRefIdc(); j++) |
---|
136 | { |
---|
137 | Int refIdc = rps->getRefIdc(j); |
---|
138 | WRITE_CODE( (refIdc==1? 1: 0), 1, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
139 | if (refIdc != 1) |
---|
140 | { |
---|
141 | WRITE_CODE( refIdc>>1, 1, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
142 | } |
---|
143 | } |
---|
144 | } |
---|
145 | else |
---|
146 | { |
---|
147 | WRITE_UVLC( rps->getNumberOfNegativePictures(), "num_negative_pics" ); |
---|
148 | WRITE_UVLC( rps->getNumberOfPositivePictures(), "num_positive_pics" ); |
---|
149 | Int prev = 0; |
---|
150 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
151 | { |
---|
152 | WRITE_UVLC( prev-rps->getDeltaPOC(j)-1, "delta_poc_s0_minus1" ); |
---|
153 | prev = rps->getDeltaPOC(j); |
---|
154 | WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s0_flag"); |
---|
155 | } |
---|
156 | prev = 0; |
---|
157 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
158 | { |
---|
159 | WRITE_UVLC( rps->getDeltaPOC(j)-prev-1, "delta_poc_s1_minus1" ); |
---|
160 | prev = rps->getDeltaPOC(j); |
---|
161 | WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s1_flag" ); |
---|
162 | } |
---|
163 | } |
---|
164 | |
---|
165 | #if PRINT_RPS_INFO |
---|
166 | printf("irps=%d (%2d bits) ", rps->getInterRPSPrediction(), getNumberOfWrittenBits() - lastBits); |
---|
167 | rps->printDeltaPOC(); |
---|
168 | #endif |
---|
169 | } |
---|
170 | |
---|
171 | |
---|
172 | Void TEncCavlc::codePPS( const TComPPS* pcPPS ) |
---|
173 | { |
---|
174 | #if ENC_DEC_TRACE |
---|
175 | #if NH_MV_ENC_DEC_TRAC |
---|
176 | tracePSHeader( "PPS", pcPPS->getLayerId() ); |
---|
177 | #else |
---|
178 | xTracePPSHeader (); |
---|
179 | #endif |
---|
180 | #endif |
---|
181 | WRITE_UVLC( pcPPS->getPPSId(), "pps_pic_parameter_set_id" ); |
---|
182 | WRITE_UVLC( pcPPS->getSPSId(), "pps_seq_parameter_set_id" ); |
---|
183 | WRITE_FLAG( pcPPS->getDependentSliceSegmentsEnabledFlag() ? 1 : 0, "dependent_slice_segments_enabled_flag" ); |
---|
184 | WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0, "output_flag_present_flag" ); |
---|
185 | WRITE_CODE( pcPPS->getNumExtraSliceHeaderBits(), 3, "num_extra_slice_header_bits"); |
---|
186 | WRITE_FLAG( pcPPS->getSignDataHidingEnabledFlag(), "sign_data_hiding_enabled_flag" ); |
---|
187 | WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0, "cabac_init_present_flag" ); |
---|
188 | #if H_3D_PPS_FIX_DEPTH |
---|
189 | if( pcPPS->getSPS()->getVPS()->getDepthId(pcPPS->getSPS()->getLayerId()) ) |
---|
190 | { |
---|
191 | WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive(), "num_ref_idx_l0_default_active_minus1"); |
---|
192 | WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive(), "num_ref_idx_l1_default_active_minus1"); |
---|
193 | } |
---|
194 | else |
---|
195 | { |
---|
196 | #endif |
---|
197 | WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive()-1, "num_ref_idx_l0_default_active_minus1"); |
---|
198 | WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive()-1, "num_ref_idx_l1_default_active_minus1"); |
---|
199 | #if H_3D_PPS_FIX_DEPTH |
---|
200 | } |
---|
201 | #endif |
---|
202 | WRITE_SVLC( pcPPS->getPicInitQPMinus26(), "init_qp_minus26"); |
---|
203 | WRITE_FLAG( pcPPS->getConstrainedIntraPred() ? 1 : 0, "constrained_intra_pred_flag" ); |
---|
204 | WRITE_FLAG( pcPPS->getUseTransformSkip() ? 1 : 0, "transform_skip_enabled_flag" ); |
---|
205 | WRITE_FLAG( pcPPS->getUseDQP() ? 1 : 0, "cu_qp_delta_enabled_flag" ); |
---|
206 | if ( pcPPS->getUseDQP() ) |
---|
207 | { |
---|
208 | WRITE_UVLC( pcPPS->getMaxCuDQPDepth(), "diff_cu_qp_delta_depth" ); |
---|
209 | } |
---|
210 | |
---|
211 | WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cb), "pps_cb_qp_offset" ); |
---|
212 | WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cr), "pps_cr_qp_offset" ); |
---|
213 | |
---|
214 | WRITE_FLAG( pcPPS->getSliceChromaQpFlag() ? 1 : 0, "pps_slice_chroma_qp_offsets_present_flag" ); |
---|
215 | |
---|
216 | WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
217 | WRITE_FLAG( pcPPS->getWPBiPred() ? 1 : 0, "weighted_bipred_flag" ); // Use of Weighting Bi-Prediction (B_SLICE) |
---|
218 | WRITE_FLAG( pcPPS->getTransquantBypassEnabledFlag() ? 1 : 0, "transquant_bypass_enabled_flag" ); |
---|
219 | WRITE_FLAG( pcPPS->getTilesEnabledFlag() ? 1 : 0, "tiles_enabled_flag" ); |
---|
220 | WRITE_FLAG( pcPPS->getEntropyCodingSyncEnabledFlag() ? 1 : 0, "entropy_coding_sync_enabled_flag" ); |
---|
221 | if( pcPPS->getTilesEnabledFlag() ) |
---|
222 | { |
---|
223 | WRITE_UVLC( pcPPS->getNumTileColumnsMinus1(), "num_tile_columns_minus1" ); |
---|
224 | WRITE_UVLC( pcPPS->getNumTileRowsMinus1(), "num_tile_rows_minus1" ); |
---|
225 | WRITE_FLAG( pcPPS->getTileUniformSpacingFlag(), "uniform_spacing_flag" ); |
---|
226 | if( !pcPPS->getTileUniformSpacingFlag() ) |
---|
227 | { |
---|
228 | for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++) |
---|
229 | { |
---|
230 | WRITE_UVLC( pcPPS->getTileColumnWidth(i)-1, "column_width_minus1" ); |
---|
231 | } |
---|
232 | for(UInt i=0; i<pcPPS->getNumTileRowsMinus1(); i++) |
---|
233 | { |
---|
234 | WRITE_UVLC( pcPPS->getTileRowHeight(i)-1, "row_height_minus1" ); |
---|
235 | } |
---|
236 | } |
---|
237 | assert ((pcPPS->getNumTileColumnsMinus1() + pcPPS->getNumTileRowsMinus1()) != 0); |
---|
238 | WRITE_FLAG( pcPPS->getLoopFilterAcrossTilesEnabledFlag()?1 : 0, "loop_filter_across_tiles_enabled_flag"); |
---|
239 | } |
---|
240 | WRITE_FLAG( pcPPS->getLoopFilterAcrossSlicesEnabledFlag()?1 : 0, "pps_loop_filter_across_slices_enabled_flag"); |
---|
241 | WRITE_FLAG( pcPPS->getDeblockingFilterControlPresentFlag()?1 : 0, "deblocking_filter_control_present_flag"); |
---|
242 | if(pcPPS->getDeblockingFilterControlPresentFlag()) |
---|
243 | { |
---|
244 | WRITE_FLAG( pcPPS->getDeblockingFilterOverrideEnabledFlag() ? 1 : 0, "deblocking_filter_override_enabled_flag" ); |
---|
245 | WRITE_FLAG( pcPPS->getPPSDeblockingFilterDisabledFlag() ? 1 : 0, "pps_deblocking_filter_disabled_flag" ); |
---|
246 | if(!pcPPS->getPPSDeblockingFilterDisabledFlag()) |
---|
247 | { |
---|
248 | WRITE_SVLC( pcPPS->getDeblockingFilterBetaOffsetDiv2(), "pps_beta_offset_div2" ); |
---|
249 | WRITE_SVLC( pcPPS->getDeblockingFilterTcOffsetDiv2(), "pps_tc_offset_div2" ); |
---|
250 | } |
---|
251 | } |
---|
252 | WRITE_FLAG( pcPPS->getScalingListPresentFlag() ? 1 : 0, "pps_scaling_list_data_present_flag" ); |
---|
253 | if( pcPPS->getScalingListPresentFlag() ) |
---|
254 | { |
---|
255 | codeScalingList( pcPPS->getScalingList() ); |
---|
256 | } |
---|
257 | #if H_3D_PPS_FIX_DEPTH |
---|
258 | if( pcPPS->getSPS()->getVPS()->getDepthId(pcPPS->getSPS()->getLayerId()) ) |
---|
259 | { |
---|
260 | WRITE_FLAG( 1, "lists_modification_present_flag" ); |
---|
261 | } |
---|
262 | else |
---|
263 | #endif |
---|
264 | WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag"); |
---|
265 | WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2"); |
---|
266 | WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag"); |
---|
267 | #if !NH_MV |
---|
268 | Bool pps_extension_present_flag=false; |
---|
269 | Bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]={false}; |
---|
270 | |
---|
271 | pps_extension_flags[PPS_EXT__REXT] = pcPPS->getPpsRangeExtension().settingsDifferFromDefaults(pcPPS->getUseTransformSkip()); |
---|
272 | |
---|
273 | // Other PPS extension flags checked here. |
---|
274 | |
---|
275 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) |
---|
276 | { |
---|
277 | pps_extension_present_flag|=pps_extension_flags[i]; |
---|
278 | } |
---|
279 | |
---|
280 | WRITE_FLAG( (pps_extension_present_flag?1:0), "pps_extension_present_flag" ); |
---|
281 | |
---|
282 | if (pps_extension_present_flag) |
---|
283 | { |
---|
284 | #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
285 | static const TChar *syntaxStrings[]={ "pps_range_extension_flag", |
---|
286 | "pps_multilayer_extension_flag", |
---|
287 | "pps_extension_6bits[0]", |
---|
288 | "pps_extension_6bits[1]", |
---|
289 | "pps_extension_6bits[2]", |
---|
290 | "pps_extension_6bits[3]", |
---|
291 | "pps_extension_6bits[4]", |
---|
292 | "pps_extension_6bits[5]" }; |
---|
293 | #endif |
---|
294 | |
---|
295 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) |
---|
296 | { |
---|
297 | WRITE_FLAG( pps_extension_flags[i]?1:0, syntaxStrings[i] ); |
---|
298 | } |
---|
299 | |
---|
300 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. |
---|
301 | { |
---|
302 | if (pps_extension_flags[i]) |
---|
303 | { |
---|
304 | switch (PPSExtensionFlagIndex(i)) |
---|
305 | { |
---|
306 | case PPS_EXT__REXT: |
---|
307 | { |
---|
308 | const TComPPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension(); |
---|
309 | if (pcPPS->getUseTransformSkip()) |
---|
310 | { |
---|
311 | WRITE_UVLC( ppsRangeExtension.getLog2MaxTransformSkipBlockSize()-2, "log2_max_transform_skip_block_size_minus2"); |
---|
312 | } |
---|
313 | |
---|
314 | WRITE_FLAG((ppsRangeExtension.getCrossComponentPredictionEnabledFlag() ? 1 : 0), "cross_component_prediction_enabled_flag" ); |
---|
315 | |
---|
316 | WRITE_FLAG(UInt(ppsRangeExtension.getChromaQpOffsetListEnabledFlag()), "chroma_qp_offset_list_enabled_flag" ); |
---|
317 | if (ppsRangeExtension.getChromaQpOffsetListEnabledFlag()) |
---|
318 | { |
---|
319 | WRITE_UVLC(ppsRangeExtension.getDiffCuChromaQpOffsetDepth(), "diff_cu_chroma_qp_offset_depth"); |
---|
320 | WRITE_UVLC(ppsRangeExtension.getChromaQpOffsetListLen() - 1, "chroma_qp_offset_list_len_minus1"); |
---|
321 | /* skip zero index */ |
---|
322 | for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx < ppsRangeExtension.getChromaQpOffsetListLen(); cuChromaQpOffsetIdx++) |
---|
323 | { |
---|
324 | WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CbOffset, "cb_qp_offset_list[i]"); |
---|
325 | WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CrOffset, "cr_qp_offset_list[i]"); |
---|
326 | } |
---|
327 | } |
---|
328 | |
---|
329 | WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), "log2_sao_offset_scale_luma" ); |
---|
330 | WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA), "log2_sao_offset_scale_chroma" ); |
---|
331 | } |
---|
332 | break; |
---|
333 | default: |
---|
334 | assert(pps_extension_flags[i]==false); // Should never get here with an active PPS extension flag. |
---|
335 | break; |
---|
336 | } // switch |
---|
337 | } // if flag present |
---|
338 | } // loop over PPS flags |
---|
339 | } // pps_extension_present_flag is non-zero |
---|
340 | #else |
---|
341 | WRITE_FLAG( 1, "pps_extension_present_flag" ); |
---|
342 | |
---|
343 | WRITE_FLAG( pcPPS->getPpsRangeExtensionsFlag( ) ? 1 : 0 , "pps_range_extensions_flag" ); |
---|
344 | WRITE_FLAG( pcPPS->getPpsMultilayerExtensionFlag( ) ? 1 : 0 , "pps_multilayer_extension_flag" ); |
---|
345 | WRITE_FLAG( pcPPS->getPps3dExtensionFlag( ) ? 1 : 0 , "pps_3d_extension_flag" ); |
---|
346 | WRITE_CODE( pcPPS->getPpsExtension5bits( ), 5, "pps_extension_5bits" ); |
---|
347 | if ( pcPPS->getPpsRangeExtensionsFlag() ) |
---|
348 | { |
---|
349 | const TComPPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension(); |
---|
350 | if (pcPPS->getUseTransformSkip()) |
---|
351 | { |
---|
352 | WRITE_UVLC( ppsRangeExtension.getLog2MaxTransformSkipBlockSize()-2, "log2_max_transform_skip_block_size_minus2"); |
---|
353 | } |
---|
354 | |
---|
355 | WRITE_FLAG((ppsRangeExtension.getCrossComponentPredictionEnabledFlag() ? 1 : 0), "cross_component_prediction_enabled_flag" ); |
---|
356 | |
---|
357 | WRITE_FLAG(UInt(ppsRangeExtension.getChromaQpOffsetListEnabledFlag()), "chroma_qp_offset_list_enabled_flag" ); |
---|
358 | if (ppsRangeExtension.getChromaQpOffsetListEnabledFlag()) |
---|
359 | { |
---|
360 | WRITE_UVLC(ppsRangeExtension.getDiffCuChromaQpOffsetDepth(), "diff_cu_chroma_qp_offset_depth"); |
---|
361 | WRITE_UVLC(ppsRangeExtension.getChromaQpOffsetListLen() - 1, "chroma_qp_offset_list_len_minus1"); |
---|
362 | /* skip zero index */ |
---|
363 | for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx < ppsRangeExtension.getChromaQpOffsetListLen(); cuChromaQpOffsetIdx++) |
---|
364 | { |
---|
365 | WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CbOffset, "cb_qp_offset_list[i]"); |
---|
366 | WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CrOffset, "cr_qp_offset_list[i]"); |
---|
367 | } |
---|
368 | } |
---|
369 | |
---|
370 | WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), "log2_sao_offset_scale_luma" ); |
---|
371 | WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA), "log2_sao_offset_scale_chroma" ); |
---|
372 | } |
---|
373 | |
---|
374 | if ( pcPPS->getPpsMultilayerExtensionFlag() ) |
---|
375 | { |
---|
376 | codePpsMultilayerExtension( pcPPS ); |
---|
377 | } |
---|
378 | |
---|
379 | #if NH_3D |
---|
380 | if( pcPPS->getPps3dExtensionFlag( ) ) // This probably needs to be aligned with Rext and SHVC |
---|
381 | { |
---|
382 | codePps3dExtension( pcPPS ); |
---|
383 | } |
---|
384 | #endif |
---|
385 | #endif |
---|
386 | xWriteRbspTrailingBits(); |
---|
387 | } |
---|
388 | |
---|
389 | #if NH_3D |
---|
390 | Void TEncCavlc::codePps3dExtension ( const TComPPS* pcPPS ) |
---|
391 | { |
---|
392 | WRITE_FLAG( pcPPS->getDLT()->getDltPresentFlag() ? 1 : 0, "dlts_present_flag" ); |
---|
393 | |
---|
394 | if ( pcPPS->getDLT()->getDltPresentFlag() ) |
---|
395 | { |
---|
396 | WRITE_CODE(pcPPS->getDLT()->getNumDepthViews() - 1, 6, "pps_depth_layers_minus1"); |
---|
397 | WRITE_CODE((pcPPS->getDLT()->getDepthViewBitDepth() - 8), 4, "pps_bit_depth_for_depth_layers_minus8"); |
---|
398 | |
---|
399 | for( Int i = 0; i <= pcPPS->getDLT()->getNumDepthViews()-1; i++ ) |
---|
400 | { |
---|
401 | Int layerId = pcPPS->getDLT()->getDepthIdxToLayerId(i); |
---|
402 | |
---|
403 | WRITE_FLAG( pcPPS->getDLT()->getUseDLTFlag( layerId ) ? 1 : 0, "dlt_flag[i]" ); |
---|
404 | |
---|
405 | if ( pcPPS->getDLT()->getUseDLTFlag( layerId ) ) |
---|
406 | { |
---|
407 | std::vector<Int> aiIdx2DepthValue_coded(256, 0); |
---|
408 | UInt uiNumDepthValues_coded = pcPPS->getDLT()->getNumDepthValues(layerId); |
---|
409 | |
---|
410 | // ----------------------------- Actual coding ----------------------------- |
---|
411 | WRITE_FLAG( pcPPS->getDLT()->getInterViewDltPredEnableFlag( layerId ) ? 1 : 0, "dlt_pred_flag[i]"); |
---|
412 | if ( pcPPS->getDLT()->getInterViewDltPredEnableFlag( layerId ) == false ) |
---|
413 | { |
---|
414 | WRITE_FLAG( pcPPS->getDLT()->getUseBitmapRep( layerId ) ? 1 : 0, "dlt_val_flags_present_flag[i]" ); |
---|
415 | |
---|
416 | for( UInt ui = 0; ui<uiNumDepthValues_coded; ui++ ) |
---|
417 | { |
---|
418 | aiIdx2DepthValue_coded[ui] = pcPPS->getDLT()->idx2DepthValue(layerId, ui); |
---|
419 | } |
---|
420 | } |
---|
421 | else |
---|
422 | { |
---|
423 | AOF( layerId > 1 ); |
---|
424 | // assumes ref layer id to be 1 |
---|
425 | std::vector<Int> viRefDLT = pcPPS->getDLT()->idx2DepthValue( 1 ); |
---|
426 | UInt uiRefNum = pcPPS->getDLT()->getNumDepthValues( 1 ); |
---|
427 | pcPPS->getDLT()->getDeltaDLT(layerId, viRefDLT, uiRefNum, aiIdx2DepthValue_coded, uiNumDepthValues_coded); |
---|
428 | } |
---|
429 | |
---|
430 | // bit map coding |
---|
431 | if ( pcPPS->getDLT()->getUseBitmapRep( layerId ) ) |
---|
432 | { |
---|
433 | UInt uiDltArrayIndex = 0; |
---|
434 | for (UInt d=0; d < 256; d++) |
---|
435 | { |
---|
436 | if ( d == aiIdx2DepthValue_coded[uiDltArrayIndex] ) |
---|
437 | { |
---|
438 | WRITE_FLAG(1, "dlt_value_flag[i][j]"); |
---|
439 | uiDltArrayIndex++; |
---|
440 | } |
---|
441 | else |
---|
442 | { |
---|
443 | WRITE_FLAG(0, "dlt_value_flag[i][j]"); |
---|
444 | } |
---|
445 | } |
---|
446 | } |
---|
447 | // Diff Coding |
---|
448 | else |
---|
449 | { |
---|
450 | UInt uiMaxDiff = 0; |
---|
451 | UInt uiMinDiff = MAX_INT; |
---|
452 | UInt uiLengthMinDiff = 0; |
---|
453 | UInt uiLengthDltDiffMinusMin = 0; |
---|
454 | |
---|
455 | std::vector<UInt> puiDltDiffValues(uiNumDepthValues_coded, 0); |
---|
456 | |
---|
457 | for (UInt d = 1; d < uiNumDepthValues_coded; d++) |
---|
458 | { |
---|
459 | puiDltDiffValues[d] = aiIdx2DepthValue_coded[d] - aiIdx2DepthValue_coded[d-1]; |
---|
460 | |
---|
461 | if ( uiMaxDiff < puiDltDiffValues[d] ) |
---|
462 | { |
---|
463 | uiMaxDiff = puiDltDiffValues[d]; |
---|
464 | } |
---|
465 | |
---|
466 | if ( uiMinDiff > puiDltDiffValues[d] ) |
---|
467 | { |
---|
468 | uiMinDiff = puiDltDiffValues[d]; |
---|
469 | } |
---|
470 | } |
---|
471 | |
---|
472 | if ( uiNumDepthValues_coded > 2 ) |
---|
473 | { |
---|
474 | uiLengthMinDiff = (UInt) gCeilLog2(uiMaxDiff + 1); |
---|
475 | } |
---|
476 | if (uiMaxDiff > uiMinDiff) |
---|
477 | { |
---|
478 | uiLengthDltDiffMinusMin = (UInt) gCeilLog2(uiMaxDiff - uiMinDiff + 1); |
---|
479 | } |
---|
480 | |
---|
481 | WRITE_CODE(uiNumDepthValues_coded, 8, "num_val_delta_dlt"); // num_entry |
---|
482 | { |
---|
483 | // The condition if( uiNumDepthValues_coded > 0 ) is always true since for Single-view Diff Coding, there is at least one depth value in depth component. |
---|
484 | if ( uiNumDepthValues_coded > 1 ) |
---|
485 | { |
---|
486 | WRITE_CODE(uiMaxDiff, 8, "max_diff"); // max_diff |
---|
487 | } |
---|
488 | |
---|
489 | if ( uiNumDepthValues_coded > 2 ) |
---|
490 | { |
---|
491 | WRITE_CODE((uiMinDiff - 1), uiLengthMinDiff, "min_diff_minus1"); // min_diff_minus1 |
---|
492 | } |
---|
493 | |
---|
494 | WRITE_CODE(aiIdx2DepthValue_coded[0], 8, "delta_dlt_val0"); // entry0 |
---|
495 | |
---|
496 | if (uiMaxDiff > uiMinDiff) |
---|
497 | { |
---|
498 | for (UInt d=1; d < uiNumDepthValues_coded; d++) |
---|
499 | { |
---|
500 | WRITE_CODE( (puiDltDiffValues[d] - uiMinDiff), uiLengthDltDiffMinusMin, "delta_val_diff_minus_min[k]"); // entry_value_diff_minus_min[ k ] |
---|
501 | } |
---|
502 | } |
---|
503 | } |
---|
504 | |
---|
505 | } |
---|
506 | } |
---|
507 | } |
---|
508 | } |
---|
509 | } |
---|
510 | #endif |
---|
511 | |
---|
512 | Void TEncCavlc::codeVUI( const TComVUI *pcVUI, const TComSPS* pcSPS ) |
---|
513 | { |
---|
514 | #if ENC_DEC_TRACE |
---|
515 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
516 | #endif |
---|
517 | WRITE_FLAG(pcVUI->getAspectRatioInfoPresentFlag(), "aspect_ratio_info_present_flag"); |
---|
518 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
519 | { |
---|
520 | WRITE_CODE(pcVUI->getAspectRatioIdc(), 8, "aspect_ratio_idc" ); |
---|
521 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
522 | { |
---|
523 | WRITE_CODE(pcVUI->getSarWidth(), 16, "sar_width"); |
---|
524 | WRITE_CODE(pcVUI->getSarHeight(), 16, "sar_height"); |
---|
525 | } |
---|
526 | } |
---|
527 | WRITE_FLAG(pcVUI->getOverscanInfoPresentFlag(), "overscan_info_present_flag"); |
---|
528 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
529 | { |
---|
530 | WRITE_FLAG(pcVUI->getOverscanAppropriateFlag(), "overscan_appropriate_flag"); |
---|
531 | } |
---|
532 | WRITE_FLAG(pcVUI->getVideoSignalTypePresentFlag(), "video_signal_type_present_flag"); |
---|
533 | #if NH_MV |
---|
534 | assert( pcSPS->getLayerId() == 0 || !pcVUI->getVideoSignalTypePresentFlag() ); |
---|
535 | #endif |
---|
536 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
537 | { |
---|
538 | WRITE_CODE(pcVUI->getVideoFormat(), 3, "video_format"); |
---|
539 | WRITE_FLAG(pcVUI->getVideoFullRangeFlag(), "video_full_range_flag"); |
---|
540 | WRITE_FLAG(pcVUI->getColourDescriptionPresentFlag(), "colour_description_present_flag"); |
---|
541 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
542 | { |
---|
543 | WRITE_CODE(pcVUI->getColourPrimaries(), 8, "colour_primaries"); |
---|
544 | WRITE_CODE(pcVUI->getTransferCharacteristics(), 8, "transfer_characteristics"); |
---|
545 | WRITE_CODE(pcVUI->getMatrixCoefficients(), 8, "matrix_coeffs"); |
---|
546 | } |
---|
547 | } |
---|
548 | |
---|
549 | WRITE_FLAG(pcVUI->getChromaLocInfoPresentFlag(), "chroma_loc_info_present_flag"); |
---|
550 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
551 | { |
---|
552 | WRITE_UVLC(pcVUI->getChromaSampleLocTypeTopField(), "chroma_sample_loc_type_top_field"); |
---|
553 | WRITE_UVLC(pcVUI->getChromaSampleLocTypeBottomField(), "chroma_sample_loc_type_bottom_field"); |
---|
554 | } |
---|
555 | |
---|
556 | WRITE_FLAG(pcVUI->getNeutralChromaIndicationFlag(), "neutral_chroma_indication_flag"); |
---|
557 | WRITE_FLAG(pcVUI->getFieldSeqFlag(), "field_seq_flag"); |
---|
558 | WRITE_FLAG(pcVUI->getFrameFieldInfoPresentFlag(), "frame_field_info_present_flag"); |
---|
559 | |
---|
560 | Window defaultDisplayWindow = pcVUI->getDefaultDisplayWindow(); |
---|
561 | WRITE_FLAG(defaultDisplayWindow.getWindowEnabledFlag(), "default_display_window_flag"); |
---|
562 | if( defaultDisplayWindow.getWindowEnabledFlag() ) |
---|
563 | { |
---|
564 | WRITE_UVLC(defaultDisplayWindow.getWindowLeftOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_left_offset"); |
---|
565 | WRITE_UVLC(defaultDisplayWindow.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_right_offset"); |
---|
566 | WRITE_UVLC(defaultDisplayWindow.getWindowTopOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_top_offset"); |
---|
567 | WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset()/ TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_bottom_offset"); |
---|
568 | } |
---|
569 | const TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
570 | WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(), "vui_timing_info_present_flag"); |
---|
571 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
572 | { |
---|
573 | WRITE_CODE(timingInfo->getNumUnitsInTick(), 32, "vui_num_units_in_tick"); |
---|
574 | WRITE_CODE(timingInfo->getTimeScale(), 32, "vui_time_scale"); |
---|
575 | WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(), "vui_poc_proportional_to_timing_flag"); |
---|
576 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
577 | { |
---|
578 | WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(), "vui_num_ticks_poc_diff_one_minus1"); |
---|
579 | } |
---|
580 | WRITE_FLAG(pcVUI->getHrdParametersPresentFlag(), "vui_hrd_parameters_present_flag"); |
---|
581 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
582 | { |
---|
583 | codeHrdParameters(pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
584 | } |
---|
585 | } |
---|
586 | |
---|
587 | WRITE_FLAG(pcVUI->getBitstreamRestrictionFlag(), "bitstream_restriction_flag"); |
---|
588 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
589 | { |
---|
590 | WRITE_FLAG(pcVUI->getTilesFixedStructureFlag(), "tiles_fixed_structure_flag"); |
---|
591 | WRITE_FLAG(pcVUI->getMotionVectorsOverPicBoundariesFlag(), "motion_vectors_over_pic_boundaries_flag"); |
---|
592 | WRITE_FLAG(pcVUI->getRestrictedRefPicListsFlag(), "restricted_ref_pic_lists_flag"); |
---|
593 | WRITE_UVLC(pcVUI->getMinSpatialSegmentationIdc(), "min_spatial_segmentation_idc"); |
---|
594 | WRITE_UVLC(pcVUI->getMaxBytesPerPicDenom(), "max_bytes_per_pic_denom"); |
---|
595 | WRITE_UVLC(pcVUI->getMaxBitsPerMinCuDenom(), "max_bits_per_min_cu_denom"); |
---|
596 | WRITE_UVLC(pcVUI->getLog2MaxMvLengthHorizontal(), "log2_max_mv_length_horizontal"); |
---|
597 | WRITE_UVLC(pcVUI->getLog2MaxMvLengthVertical(), "log2_max_mv_length_vertical"); |
---|
598 | } |
---|
599 | } |
---|
600 | |
---|
601 | Void TEncCavlc::codeHrdParameters( const TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 ) |
---|
602 | { |
---|
603 | if( commonInfPresentFlag ) |
---|
604 | { |
---|
605 | WRITE_FLAG( hrd->getNalHrdParametersPresentFlag() ? 1 : 0 , "nal_hrd_parameters_present_flag" ); |
---|
606 | WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 , "vcl_hrd_parameters_present_flag" ); |
---|
607 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
608 | { |
---|
609 | WRITE_FLAG( hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0, "sub_pic_hrd_params_present_flag" ); |
---|
610 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
611 | { |
---|
612 | WRITE_CODE( hrd->getTickDivisorMinus2(), 8, "tick_divisor_minus2" ); |
---|
613 | WRITE_CODE( hrd->getDuCpbRemovalDelayLengthMinus1(), 5, "du_cpb_removal_delay_increment_length_minus1" ); |
---|
614 | WRITE_FLAG( hrd->getSubPicCpbParamsInPicTimingSEIFlag() ? 1 : 0, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); |
---|
615 | WRITE_CODE( hrd->getDpbOutputDelayDuLengthMinus1(), 5, "dpb_output_delay_du_length_minus1" ); |
---|
616 | } |
---|
617 | WRITE_CODE( hrd->getBitRateScale(), 4, "bit_rate_scale" ); |
---|
618 | WRITE_CODE( hrd->getCpbSizeScale(), 4, "cpb_size_scale" ); |
---|
619 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
620 | { |
---|
621 | WRITE_CODE( hrd->getDuCpbSizeScale(), 4, "du_cpb_size_scale" ); |
---|
622 | } |
---|
623 | WRITE_CODE( hrd->getInitialCpbRemovalDelayLengthMinus1(), 5, "initial_cpb_removal_delay_length_minus1" ); |
---|
624 | WRITE_CODE( hrd->getCpbRemovalDelayLengthMinus1(), 5, "au_cpb_removal_delay_length_minus1" ); |
---|
625 | WRITE_CODE( hrd->getDpbOutputDelayLengthMinus1(), 5, "dpb_output_delay_length_minus1" ); |
---|
626 | } |
---|
627 | } |
---|
628 | Int i, j, nalOrVcl; |
---|
629 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
630 | { |
---|
631 | WRITE_FLAG( hrd->getFixedPicRateFlag( i ) ? 1 : 0, "fixed_pic_rate_general_flag"); |
---|
632 | Bool fixedPixRateWithinCvsFlag = true; |
---|
633 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
634 | { |
---|
635 | fixedPixRateWithinCvsFlag = hrd->getFixedPicRateWithinCvsFlag( i ); |
---|
636 | WRITE_FLAG( hrd->getFixedPicRateWithinCvsFlag( i ) ? 1 : 0, "fixed_pic_rate_within_cvs_flag"); |
---|
637 | } |
---|
638 | if( fixedPixRateWithinCvsFlag ) |
---|
639 | { |
---|
640 | WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ), "elemental_duration_in_tc_minus1"); |
---|
641 | } |
---|
642 | else |
---|
643 | { |
---|
644 | WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0, "low_delay_hrd_flag"); |
---|
645 | } |
---|
646 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
647 | { |
---|
648 | WRITE_UVLC( hrd->getCpbCntMinus1( i ), "cpb_cnt_minus1"); |
---|
649 | } |
---|
650 | |
---|
651 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
652 | { |
---|
653 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
654 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
655 | { |
---|
656 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
657 | { |
---|
658 | WRITE_UVLC( hrd->getBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_value_minus1"); |
---|
659 | WRITE_UVLC( hrd->getCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_value_minus1"); |
---|
660 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
661 | { |
---|
662 | WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1"); |
---|
663 | WRITE_UVLC( hrd->getDuBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_du_value_minus1"); |
---|
664 | } |
---|
665 | WRITE_FLAG( hrd->getCbrFlag( i, j, nalOrVcl ) ? 1 : 0, "cbr_flag"); |
---|
666 | } |
---|
667 | } |
---|
668 | } |
---|
669 | } |
---|
670 | } |
---|
671 | |
---|
672 | Void TEncCavlc::codeSPS( const TComSPS* pcSPS ) |
---|
673 | { |
---|
674 | |
---|
675 | const ChromaFormat format = pcSPS->getChromaFormatIdc(); |
---|
676 | const Bool chromaEnabled = isChromaEnabled(format); |
---|
677 | |
---|
678 | #if ENC_DEC_TRACE |
---|
679 | #if NH_MV_ENC_DEC_TRAC |
---|
680 | tracePSHeader( "SPS", pcSPS->getLayerId() ); |
---|
681 | #else |
---|
682 | xTraceSPSHeader (); |
---|
683 | #endif |
---|
684 | #endif |
---|
685 | WRITE_CODE( pcSPS->getVPSId (), 4, "sps_video_parameter_set_id" ); |
---|
686 | #if NH_MV |
---|
687 | if ( pcSPS->getLayerId() == 0 ) |
---|
688 | { |
---|
689 | #endif |
---|
690 | WRITE_CODE( pcSPS->getMaxTLayers() - 1, 3, "sps_max_sub_layers_minus1" ); |
---|
691 | #if NH_MV |
---|
692 | } |
---|
693 | else |
---|
694 | { |
---|
695 | WRITE_CODE( pcSPS->getSpsExtOrMaxSubLayersMinus1( ), 3, "sps_ext_or_max_sub_layers_minus1" ); |
---|
696 | } |
---|
697 | if ( !pcSPS->getMultiLayerExtSpsFlag() ) |
---|
698 | { |
---|
699 | #endif |
---|
700 | WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "sps_temporal_id_nesting_flag" ); |
---|
701 | codePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
702 | #if NH_MV |
---|
703 | } |
---|
704 | #endif |
---|
705 | WRITE_UVLC( pcSPS->getSPSId (), "sps_seq_parameter_set_id" ); |
---|
706 | #if NH_MV |
---|
707 | if ( pcSPS->getMultiLayerExtSpsFlag() ) |
---|
708 | { |
---|
709 | WRITE_FLAG( pcSPS->getUpdateRepFormatFlag( ) ? 1 : 0 , "update_rep_format_flag" ); |
---|
710 | if ( pcSPS->getUpdateRepFormatFlag() ) |
---|
711 | { |
---|
712 | WRITE_CODE( pcSPS->getSpsRepFormatIdx( ), 8, "sps_rep_format_idx" ); |
---|
713 | } |
---|
714 | } |
---|
715 | else |
---|
716 | { |
---|
717 | #endif |
---|
718 | WRITE_UVLC( Int(pcSPS->getChromaFormatIdc ()), "chroma_format_idc" ); |
---|
719 | if( format == CHROMA_444 ) |
---|
720 | { |
---|
721 | WRITE_FLAG( 0, "separate_colour_plane_flag"); |
---|
722 | } |
---|
723 | |
---|
724 | WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (), "pic_width_in_luma_samples" ); |
---|
725 | WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" ); |
---|
726 | Window conf = pcSPS->getConformanceWindow(); |
---|
727 | |
---|
728 | WRITE_FLAG( conf.getWindowEnabledFlag(), "conformance_window_flag" ); |
---|
729 | if (conf.getWindowEnabledFlag()) |
---|
730 | { |
---|
731 | WRITE_UVLC( conf.getWindowLeftOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_left_offset" ); |
---|
732 | WRITE_UVLC( conf.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_right_offset" ); |
---|
733 | WRITE_UVLC( conf.getWindowTopOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_top_offset" ); |
---|
734 | WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" ); |
---|
735 | } |
---|
736 | #if NH_MV |
---|
737 | } |
---|
738 | #endif |
---|
739 | #if NH_MV |
---|
740 | if ( !pcSPS->getMultiLayerExtSpsFlag() ) |
---|
741 | { |
---|
742 | #endif |
---|
743 | |
---|
744 | WRITE_UVLC( pcSPS->getBitDepth(CHANNEL_TYPE_LUMA) - 8, "bit_depth_luma_minus8" ); |
---|
745 | |
---|
746 | WRITE_UVLC( chromaEnabled ? (pcSPS->getBitDepth(CHANNEL_TYPE_CHROMA) - 8):0, "bit_depth_chroma_minus8" ); |
---|
747 | #if NH_MV |
---|
748 | } |
---|
749 | #endif |
---|
750 | WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" ); |
---|
751 | #if NH_MV |
---|
752 | if ( !pcSPS->getMultiLayerExtSpsFlag()) |
---|
753 | { |
---|
754 | #endif |
---|
755 | |
---|
756 | const Bool subLayerOrderingInfoPresentFlag = 1; |
---|
757 | WRITE_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
758 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
759 | { |
---|
760 | WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i) - 1, "sps_max_dec_pic_buffering_minus1[i]" ); |
---|
761 | WRITE_UVLC( pcSPS->getNumReorderPics(i), "sps_max_num_reorder_pics[i]" ); |
---|
762 | #if NH_MV |
---|
763 | WRITE_UVLC( pcSPS->getSpsMaxLatencyIncreasePlus1(i), "sps_max_latency_increase_plus1[i]" ); |
---|
764 | #else |
---|
765 | WRITE_UVLC( pcSPS->getMaxLatencyIncreasePlus1(i), "sps_max_latency_increase_plus1[i]" ); |
---|
766 | #endif |
---|
767 | if (!subLayerOrderingInfoPresentFlag) |
---|
768 | { |
---|
769 | break; |
---|
770 | } |
---|
771 | } |
---|
772 | #if NH_MV |
---|
773 | } |
---|
774 | #endif |
---|
775 | |
---|
776 | assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() ); |
---|
777 | WRITE_UVLC( pcSPS->getLog2MinCodingBlockSize() - 3, "log2_min_luma_coding_block_size_minus3" ); |
---|
778 | WRITE_UVLC( pcSPS->getLog2DiffMaxMinCodingBlockSize(), "log2_diff_max_min_luma_coding_block_size" ); |
---|
779 | WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2, "log2_min_luma_transform_block_size_minus2" ); |
---|
780 | WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_luma_transform_block_size" ); |
---|
781 | WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthInter() - 1, "max_transform_hierarchy_depth_inter" ); |
---|
782 | WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthIntra() - 1, "max_transform_hierarchy_depth_intra" ); |
---|
783 | WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0, "scaling_list_enabled_flag" ); |
---|
784 | if(pcSPS->getScalingListFlag()) |
---|
785 | { |
---|
786 | #if NH_MV |
---|
787 | if ( pcSPS->getMultiLayerExtSpsFlag() ) |
---|
788 | { |
---|
789 | WRITE_FLAG( pcSPS->getSpsInferScalingListFlag( ) ? 1 : 0 , "sps_infer_scaling_list_flag" ); |
---|
790 | } |
---|
791 | |
---|
792 | if ( pcSPS->getSpsInferScalingListFlag() ) |
---|
793 | { |
---|
794 | WRITE_CODE( pcSPS->getSpsScalingListRefLayerId( ), 6, "sps_scaling_list_ref_layer_id" ); |
---|
795 | } |
---|
796 | else |
---|
797 | { |
---|
798 | #endif |
---|
799 | |
---|
800 | WRITE_FLAG( pcSPS->getScalingListPresentFlag() ? 1 : 0, "sps_scaling_list_data_present_flag" ); |
---|
801 | if(pcSPS->getScalingListPresentFlag()) |
---|
802 | { |
---|
803 | codeScalingList( pcSPS->getScalingList() ); |
---|
804 | } |
---|
805 | #if NH_MV |
---|
806 | } |
---|
807 | #endif |
---|
808 | } |
---|
809 | WRITE_FLAG( pcSPS->getUseAMP() ? 1 : 0, "amp_enabled_flag" ); |
---|
810 | WRITE_FLAG( pcSPS->getUseSAO() ? 1 : 0, "sample_adaptive_offset_enabled_flag"); |
---|
811 | |
---|
812 | WRITE_FLAG( pcSPS->getUsePCM() ? 1 : 0, "pcm_enabled_flag"); |
---|
813 | if( pcSPS->getUsePCM() ) |
---|
814 | { |
---|
815 | WRITE_CODE( pcSPS->getPCMBitDepth(CHANNEL_TYPE_LUMA) - 1, 4, "pcm_sample_bit_depth_luma_minus1" ); |
---|
816 | WRITE_CODE( chromaEnabled ? (pcSPS->getPCMBitDepth(CHANNEL_TYPE_CHROMA) - 1) : 0, 4, "pcm_sample_bit_depth_chroma_minus1" ); |
---|
817 | WRITE_UVLC( pcSPS->getPCMLog2MinSize() - 3, "log2_min_pcm_luma_coding_block_size_minus3" ); |
---|
818 | WRITE_UVLC( pcSPS->getPCMLog2MaxSize() - pcSPS->getPCMLog2MinSize(), "log2_diff_max_min_pcm_luma_coding_block_size" ); |
---|
819 | WRITE_FLAG( pcSPS->getPCMFilterDisableFlag()?1 : 0, "pcm_loop_filter_disable_flag"); |
---|
820 | } |
---|
821 | |
---|
822 | assert( pcSPS->getMaxTLayers() > 0 ); |
---|
823 | |
---|
824 | const TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
825 | |
---|
826 | WRITE_UVLC(rpsList->getNumberOfReferencePictureSets(), "num_short_term_ref_pic_sets" ); |
---|
827 | for(Int i=0; i < rpsList->getNumberOfReferencePictureSets(); i++) |
---|
828 | { |
---|
829 | const TComReferencePictureSet*rps = rpsList->getReferencePictureSet(i); |
---|
830 | codeShortTermRefPicSet( rps,false, i); |
---|
831 | } |
---|
832 | #if NH_MV |
---|
833 | WRITE_FLAG( pcSPS->getLongTermRefPicsPresentFlag() ? 1 : 0, "long_term_ref_pics_present_flag" ); |
---|
834 | if (pcSPS->getLongTermRefPicsPresentFlag()) |
---|
835 | #else |
---|
836 | WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_present_flag" ); |
---|
837 | if (pcSPS->getLongTermRefsPresent()) |
---|
838 | #endif |
---|
839 | { |
---|
840 | WRITE_UVLC(pcSPS->getNumLongTermRefPicSPS(), "num_long_term_ref_pics_sps" ); |
---|
841 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
842 | { |
---|
843 | WRITE_CODE( pcSPS->getLtRefPicPocLsbSps(k), pcSPS->getBitsForPOC(), "lt_ref_pic_poc_lsb_sps"); |
---|
844 | WRITE_FLAG( pcSPS->getUsedByCurrPicLtSPSFlag(k), "used_by_curr_pic_lt_sps_flag[i]"); |
---|
845 | } |
---|
846 | } |
---|
847 | WRITE_FLAG( pcSPS->getSPSTemporalMVPEnabledFlag() ? 1 : 0, "sps_temporal_mvp_enabled_flag" ); |
---|
848 | |
---|
849 | WRITE_FLAG( pcSPS->getUseStrongIntraSmoothing(), "strong_intra_smoothing_enable_flag" ); |
---|
850 | |
---|
851 | WRITE_FLAG( pcSPS->getVuiParametersPresentFlag(), "vui_parameters_present_flag" ); |
---|
852 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
853 | { |
---|
854 | codeVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
855 | } |
---|
856 | |
---|
857 | #if !NH_MV |
---|
858 | Bool sps_extension_present_flag=false; |
---|
859 | Bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS]={false}; |
---|
860 | |
---|
861 | sps_extension_flags[SPS_EXT__REXT] = pcSPS->getSpsRangeExtension().settingsDifferFromDefaults(); |
---|
862 | |
---|
863 | // Other SPS extension flags checked here. |
---|
864 | |
---|
865 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) |
---|
866 | { |
---|
867 | sps_extension_present_flag|=sps_extension_flags[i]; |
---|
868 | } |
---|
869 | |
---|
870 | WRITE_FLAG( (sps_extension_present_flag?1:0), "sps_extension_present_flag" ); |
---|
871 | |
---|
872 | if (sps_extension_present_flag) |
---|
873 | { |
---|
874 | #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
875 | static const TChar *syntaxStrings[]={ "sps_range_extension_flag", |
---|
876 | "sps_multilayer_extension_flag", |
---|
877 | "sps_extension_6bits[0]", |
---|
878 | "sps_extension_6bits[1]", |
---|
879 | "sps_extension_6bits[2]", |
---|
880 | "sps_extension_6bits[3]", |
---|
881 | "sps_extension_6bits[4]", |
---|
882 | "sps_extension_6bits[5]" }; |
---|
883 | #endif |
---|
884 | |
---|
885 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) |
---|
886 | { |
---|
887 | WRITE_FLAG( sps_extension_flags[i]?1:0, syntaxStrings[i] ); |
---|
888 | } |
---|
889 | |
---|
890 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. |
---|
891 | { |
---|
892 | if (sps_extension_flags[i]) |
---|
893 | { |
---|
894 | switch (SPSExtensionFlagIndex(i)) |
---|
895 | { |
---|
896 | case SPS_EXT__REXT: |
---|
897 | { |
---|
898 | const TComSPSRExt &spsRangeExtension=pcSPS->getSpsRangeExtension(); |
---|
899 | |
---|
900 | WRITE_FLAG( (spsRangeExtension.getTransformSkipRotationEnabledFlag() ? 1 : 0), "transform_skip_rotation_enabled_flag"); |
---|
901 | WRITE_FLAG( (spsRangeExtension.getTransformSkipContextEnabledFlag() ? 1 : 0), "transform_skip_context_enabled_flag"); |
---|
902 | WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT) ? 1 : 0), "implicit_rdpcm_enabled_flag" ); |
---|
903 | WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT) ? 1 : 0), "explicit_rdpcm_enabled_flag" ); |
---|
904 | WRITE_FLAG( (spsRangeExtension.getExtendedPrecisionProcessingFlag() ? 1 : 0), "extended_precision_processing_flag" ); |
---|
905 | WRITE_FLAG( (spsRangeExtension.getIntraSmoothingDisabledFlag() ? 1 : 0), "intra_smoothing_disabled_flag" ); |
---|
906 | WRITE_FLAG( (spsRangeExtension.getHighPrecisionOffsetsEnabledFlag() ? 1 : 0), "high_precision_offsets_enabled_flag" ); |
---|
907 | WRITE_FLAG( (spsRangeExtension.getPersistentRiceAdaptationEnabledFlag() ? 1 : 0), "persistent_rice_adaptation_enabled_flag" ); |
---|
908 | WRITE_FLAG( (spsRangeExtension.getCabacBypassAlignmentEnabledFlag() ? 1 : 0), "cabac_bypass_alignment_enabled_flag" ); |
---|
909 | break; |
---|
910 | } |
---|
911 | default: |
---|
912 | assert(sps_extension_flags[i]==false); // Should never get here with an active SPS extension flag. |
---|
913 | break; |
---|
914 | } |
---|
915 | } |
---|
916 | } |
---|
917 | } |
---|
918 | #else |
---|
919 | WRITE_FLAG( pcSPS->getSpsExtensionPresentFlag(), "sps_extension_present_flag" ); |
---|
920 | |
---|
921 | if ( pcSPS->getSpsExtensionPresentFlag() ) |
---|
922 | { |
---|
923 | WRITE_FLAG( pcSPS->getSpsRangeExtensionsFlag( ) ? 1 : 0 , "sps_range_extensions_flag" ); |
---|
924 | WRITE_FLAG( pcSPS->getSpsMultilayerExtensionFlag( ) ? 1 : 0 , "sps_multilayer_extension_flag" ); |
---|
925 | WRITE_FLAG( pcSPS->getSps3dExtensionFlag( ) ? 1 : 0 , "sps_3d_extension_flag" ); |
---|
926 | WRITE_CODE( pcSPS->getSpsExtension5bits( ) , 5 , "sps_extension_5bits" ); |
---|
927 | } |
---|
928 | |
---|
929 | if ( pcSPS->getSpsRangeExtensionsFlag() ) |
---|
930 | { |
---|
931 | const TComSPSRExt &spsRangeExtension=pcSPS->getSpsRangeExtension(); |
---|
932 | |
---|
933 | WRITE_FLAG( (spsRangeExtension.getTransformSkipRotationEnabledFlag() ? 1 : 0), "transform_skip_rotation_enabled_flag"); |
---|
934 | WRITE_FLAG( (spsRangeExtension.getTransformSkipContextEnabledFlag() ? 1 : 0), "transform_skip_context_enabled_flag"); |
---|
935 | WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT) ? 1 : 0), "implicit_rdpcm_enabled_flag" ); |
---|
936 | WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT) ? 1 : 0), "explicit_rdpcm_enabled_flag" ); |
---|
937 | WRITE_FLAG( (spsRangeExtension.getExtendedPrecisionProcessingFlag() ? 1 : 0), "extended_precision_processing_flag" ); |
---|
938 | WRITE_FLAG( (spsRangeExtension.getIntraSmoothingDisabledFlag() ? 1 : 0), "intra_smoothing_disabled_flag" ); |
---|
939 | WRITE_FLAG( (spsRangeExtension.getHighPrecisionOffsetsEnabledFlag() ? 1 : 0), "high_precision_offsets_enabled_flag" ); |
---|
940 | WRITE_FLAG( (spsRangeExtension.getPersistentRiceAdaptationEnabledFlag() ? 1 : 0), "persistent_rice_adaptation_enabled_flag" ); |
---|
941 | WRITE_FLAG( (spsRangeExtension.getCabacBypassAlignmentEnabledFlag() ? 1 : 0), "cabac_bypass_alignment_enabled_flag" ); |
---|
942 | } |
---|
943 | |
---|
944 | if ( pcSPS->getSpsMultilayerExtensionFlag() ) |
---|
945 | { |
---|
946 | codeSPSExtension( pcSPS ); |
---|
947 | } |
---|
948 | |
---|
949 | #if NH_3D |
---|
950 | if ( pcSPS->getSps3dExtensionFlag() ) |
---|
951 | { |
---|
952 | codeSPS3dExtension( pcSPS ); |
---|
953 | } |
---|
954 | |
---|
955 | #endif |
---|
956 | #endif |
---|
957 | xWriteRbspTrailingBits(); |
---|
958 | } |
---|
959 | |
---|
960 | #if NH_MV |
---|
961 | Void TEncCavlc::codeSPSExtension( const TComSPS* pcSPS ) |
---|
962 | { |
---|
963 | WRITE_FLAG( pcSPS->getInterViewMvVertConstraintFlag() ? 1 : 0, "inter_view_mv_vert_constraint_flag" ); |
---|
964 | } |
---|
965 | |
---|
966 | |
---|
967 | Void TEncCavlc::codePpsMultilayerExtension(const TComPPS* pcPPS) |
---|
968 | { |
---|
969 | WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag( ) ? 1 : 0 , "poc_reset_info_present_flag" ); |
---|
970 | WRITE_FLAG( pcPPS->getPpsInferScalingListFlag( ) ? 1 : 0 , "pps_infer_scaling_list_flag" ); |
---|
971 | if (pcPPS->getPpsInferScalingListFlag()) |
---|
972 | { |
---|
973 | WRITE_CODE( pcPPS->getPpsScalingListRefLayerId( ), 6, "pps_scaling_list_ref_layer_id" ); |
---|
974 | } |
---|
975 | WRITE_UVLC( 0, "num_ref_loc_offsets" ); |
---|
976 | WRITE_FLAG( 0 , "colour_mapping_enabled_flag" ); |
---|
977 | |
---|
978 | } |
---|
979 | |
---|
980 | #endif |
---|
981 | |
---|
982 | #if NH_3D |
---|
983 | Void TEncCavlc::codeSPS3dExtension( const TComSPS* pcSPS ) |
---|
984 | { |
---|
985 | const TComSps3dExtension* sps3dExt = pcSPS->getSps3dExtension(); |
---|
986 | for( Int d = 0; d <= 1; d++ ) |
---|
987 | { |
---|
988 | WRITE_FLAG( sps3dExt->getIvDiMcEnabledFlag( d ) ? 1 : 0 , "iv_di_mc_enabled_flag" ); |
---|
989 | WRITE_FLAG( sps3dExt->getIvMvScalEnabledFlag( d ) ? 1 : 0 , "iv_mv_scal_enabled_flag" ); |
---|
990 | if( d == 0 ) |
---|
991 | { |
---|
992 | WRITE_UVLC( sps3dExt->getLog2IvmcSubPbSizeMinus3( d ), "log2_sub_pb_size_minus3" ); |
---|
993 | WRITE_FLAG( sps3dExt->getIvResPredEnabledFlag( d ) ? 1 : 0 , "iv_res_pred_enabled_flag" ); |
---|
994 | WRITE_FLAG( sps3dExt->getDepthRefEnabledFlag( d ) ? 1 : 0 , "depth_ref_enabled_flag" ); |
---|
995 | WRITE_FLAG( sps3dExt->getVspMcEnabledFlag( d ) ? 1 : 0 , "vsp_mc_enabled_flag" ); |
---|
996 | WRITE_FLAG( sps3dExt->getDbbpEnabledFlag( d ) ? 1 : 0 , "dbbp_enabled_flag" ); |
---|
997 | } |
---|
998 | else |
---|
999 | { |
---|
1000 | WRITE_FLAG( sps3dExt->getTexMcEnabledFlag( d ) ? 1 : 0 , "tex_mc_enabled_flag" ); |
---|
1001 | WRITE_UVLC( sps3dExt->getLog2TexmcSubPbSizeMinus3( d ), "log2_texmc_sub_pb_size_minus3" ); |
---|
1002 | WRITE_FLAG( sps3dExt->getIntraContourEnabledFlag( d ) ? 1 : 0 , "intra_contour_enabled_flag" ); |
---|
1003 | WRITE_FLAG( sps3dExt->getIntraDcOnlyWedgeEnabledFlag( d ) ? 1 : 0 , "intra_dc_only_wedge_enabled_flag" ); |
---|
1004 | WRITE_FLAG( sps3dExt->getCqtCuPartPredEnabledFlag( d ) ? 1 : 0 , "cqt_cu_part_pred_enabled_flag" ); |
---|
1005 | WRITE_FLAG( sps3dExt->getInterDcOnlyEnabledFlag( d ) ? 1 : 0 , "inter_dc_only_enabled_flag" ); |
---|
1006 | WRITE_FLAG( sps3dExt->getSkipIntraEnabledFlag( d ) ? 1 : 0 , "skip_intra_enabled_flag" ); |
---|
1007 | } |
---|
1008 | } |
---|
1009 | } |
---|
1010 | #endif |
---|
1011 | |
---|
1012 | |
---|
1013 | Void TEncCavlc::codeVPS( const TComVPS* pcVPS ) |
---|
1014 | { |
---|
1015 | #if ENC_DEC_TRACE |
---|
1016 | #if NH_MV_ENC_DEC_TRAC |
---|
1017 | tracePSHeader( "VPS", getEncTop()->getLayerId() ); |
---|
1018 | #else |
---|
1019 | xTraceVPSHeader(); |
---|
1020 | #endif |
---|
1021 | #endif |
---|
1022 | WRITE_CODE( pcVPS->getVPSId(), 4, "vps_video_parameter_set_id" ); |
---|
1023 | #if NH_MV |
---|
1024 | WRITE_FLAG( pcVPS->getVpsBaseLayerInternalFlag( ) ? 1 : 0 , "vps_base_layer_internal_flag" ); |
---|
1025 | WRITE_FLAG( pcVPS->getVpsBaseLayerAvailableFlag( ) ? 1 : 0 , "vps_base_layer_available_flag" ); |
---|
1026 | #else |
---|
1027 | WRITE_FLAG( 1, "vps_base_layer_internal_flag" ); |
---|
1028 | WRITE_FLAG( 1, "vps_base_layer_available_flag" ); |
---|
1029 | #endif |
---|
1030 | #if NH_MV |
---|
1031 | WRITE_CODE( pcVPS->getMaxLayersMinus1(), 6, "vps_max_layers_minus1" ); |
---|
1032 | #else |
---|
1033 | WRITE_CODE( 0, 6, "vps_max_layers_minus1" ); |
---|
1034 | #endif |
---|
1035 | WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "vps_max_sub_layers_minus1" ); |
---|
1036 | WRITE_FLAG( pcVPS->getTemporalNestingFlag(), "vps_temporal_id_nesting_flag" ); |
---|
1037 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
1038 | WRITE_CODE( 0xffff, 16, "vps_reserved_0xffff_16bits" ); |
---|
1039 | codePTL( pcVPS->getPTL(), true, pcVPS->getMaxTLayers() - 1 ); |
---|
1040 | const Bool subLayerOrderingInfoPresentFlag = 1; |
---|
1041 | WRITE_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
1042 | for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
1043 | { |
---|
1044 | WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i) - 1, "vps_max_dec_pic_buffering_minus1[i]" ); |
---|
1045 | WRITE_UVLC( pcVPS->getNumReorderPics(i), "vps_max_num_reorder_pics[i]" ); |
---|
1046 | WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "vps_max_latency_increase_plus1[i]" ); |
---|
1047 | if (!subLayerOrderingInfoPresentFlag) |
---|
1048 | { |
---|
1049 | break; |
---|
1050 | } |
---|
1051 | } |
---|
1052 | |
---|
1053 | assert( pcVPS->getNumHrdParameters() <= MAX_VPS_NUM_HRD_PARAMETERS ); |
---|
1054 | #if NH_MV |
---|
1055 | assert( pcVPS->getVpsMaxLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 ); |
---|
1056 | WRITE_CODE( pcVPS->getVpsMaxLayerId(), 6, "vps_max_layer_id" ); |
---|
1057 | WRITE_UVLC( pcVPS->getVpsNumLayerSetsMinus1(), "vps_num_layer_sets_minus1" ); |
---|
1058 | for( UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx ++ ) |
---|
1059 | { |
---|
1060 | // Operation point set |
---|
1061 | for( UInt i = 0; i <= pcVPS->getVpsMaxLayerId(); i ++ ) |
---|
1062 | { |
---|
1063 | #else |
---|
1064 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
1065 | WRITE_CODE( pcVPS->getMaxNuhReservedZeroLayerId(), 6, "vps_max_layer_id" ); |
---|
1066 | WRITE_UVLC( pcVPS->getMaxOpSets() - 1, "vps_num_layer_sets_minus1" ); |
---|
1067 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
1068 | { |
---|
1069 | // Operation point set |
---|
1070 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
1071 | { |
---|
1072 | // Only applicable for version 1 |
---|
1073 | // pcVPS->setLayerIdIncludedFlag( true, opsIdx, i ); |
---|
1074 | #endif |
---|
1075 | WRITE_FLAG( pcVPS->getLayerIdIncludedFlag( opsIdx, i ) ? 1 : 0, "layer_id_included_flag[opsIdx][i]" ); |
---|
1076 | } |
---|
1077 | } |
---|
1078 | const TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
1079 | WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(), "vps_timing_info_present_flag"); |
---|
1080 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
1081 | { |
---|
1082 | WRITE_CODE(timingInfo->getNumUnitsInTick(), 32, "vps_num_units_in_tick"); |
---|
1083 | WRITE_CODE(timingInfo->getTimeScale(), 32, "vps_time_scale"); |
---|
1084 | WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(), "vps_poc_proportional_to_timing_flag"); |
---|
1085 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
1086 | { |
---|
1087 | WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(), "vps_num_ticks_poc_diff_one_minus1"); |
---|
1088 | } |
---|
1089 | WRITE_UVLC( pcVPS->getNumHrdParameters(), "vps_num_hrd_parameters" ); |
---|
1090 | |
---|
1091 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
1092 | { |
---|
1093 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
1094 | { |
---|
1095 | // Only applicable for version 1 |
---|
1096 | WRITE_UVLC( pcVPS->getHrdOpSetIdx( i ), "hrd_layer_set_idx" ); |
---|
1097 | if( i > 0 ) |
---|
1098 | { |
---|
1099 | WRITE_FLAG( pcVPS->getCprmsPresentFlag( i ) ? 1 : 0, "cprms_present_flag[i]" ); |
---|
1100 | } |
---|
1101 | codeHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
1102 | } |
---|
1103 | } |
---|
1104 | } |
---|
1105 | #if NH_MV |
---|
1106 | WRITE_FLAG( pcVPS->getVpsExtensionFlag(), "vps_extension_flag" ); |
---|
1107 | m_pcBitIf->writeAlignOne(); |
---|
1108 | codeVPSExtension( pcVPS ); |
---|
1109 | #if NH_3D |
---|
1110 | WRITE_FLAG( 1, "vps_extension2_flag" ); |
---|
1111 | WRITE_FLAG( 1, "vps_3d_extension_flag" ); |
---|
1112 | m_pcBitIf->writeAlignOne(); |
---|
1113 | codeVPS3dExtension( pcVPS ); |
---|
1114 | WRITE_FLAG( 0, "vps_extension3_flag" ); |
---|
1115 | #else |
---|
1116 | WRITE_FLAG( 0, "vps_extension2_flag" ); |
---|
1117 | #endif |
---|
1118 | #else |
---|
1119 | WRITE_FLAG( 0, "vps_extension_flag" ); |
---|
1120 | #endif |
---|
1121 | |
---|
1122 | //future extensions here.. |
---|
1123 | xWriteRbspTrailingBits(); |
---|
1124 | } |
---|
1125 | |
---|
1126 | #if NH_MV |
---|
1127 | Void TEncCavlc::codeVPSExtension( const TComVPS *pcVPS ) |
---|
1128 | { |
---|
1129 | if( pcVPS->getMaxLayersMinus1() > 0 && pcVPS->getVpsBaseLayerInternalFlag() ) |
---|
1130 | { |
---|
1131 | codePTL( pcVPS->getPTL( 1 ),0, pcVPS->getMaxSubLayersMinus1() ); |
---|
1132 | } |
---|
1133 | |
---|
1134 | WRITE_FLAG( pcVPS->getSplittingFlag() ? 1 : 0, "splitting_flag" ); |
---|
1135 | |
---|
1136 | for( Int type = 0; type < MAX_NUM_SCALABILITY_TYPES; type++ ) |
---|
1137 | { |
---|
1138 | WRITE_FLAG( pcVPS->getScalabilityMaskFlag( type ) ? 1 : 0, "scalability_mask_flag[i]" ); |
---|
1139 | } |
---|
1140 | |
---|
1141 | for( Int sIdx = 0; sIdx < pcVPS->getNumScalabilityTypes( ) - ( pcVPS->getSplittingFlag() ? 1 : 0 ); sIdx++ ) |
---|
1142 | { |
---|
1143 | WRITE_CODE( pcVPS->getDimensionIdLen( sIdx ) - 1 , 3, "dimension_id_len_minus1[j]"); |
---|
1144 | } |
---|
1145 | |
---|
1146 | if ( pcVPS->getSplittingFlag() ) |
---|
1147 | { |
---|
1148 | assert( pcVPS->getDimensionIdLen( pcVPS->getNumScalabilityTypes( ) - 1 ) == pcVPS->inferLastDimsionIdLenMinus1() + 1 ); |
---|
1149 | } |
---|
1150 | |
---|
1151 | WRITE_FLAG( pcVPS->getVpsNuhLayerIdPresentFlag() ? 1 : 0, "vps_nuh_layer_id_present_flag"); |
---|
1152 | |
---|
1153 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1154 | { |
---|
1155 | if ( pcVPS->getVpsNuhLayerIdPresentFlag() ) |
---|
1156 | { |
---|
1157 | WRITE_CODE( pcVPS->getLayerIdInNuh( i ), 6, "layer_id_in_nuh[i]"); |
---|
1158 | } |
---|
1159 | else |
---|
1160 | { |
---|
1161 | assert( pcVPS->getLayerIdInNuh( i ) == i ); |
---|
1162 | } |
---|
1163 | |
---|
1164 | assert( pcVPS->getLayerIdInVps( pcVPS->getLayerIdInNuh( i ) ) == i ); |
---|
1165 | |
---|
1166 | for( Int j = 0; j < pcVPS->getNumScalabilityTypes() ; j++ ) |
---|
1167 | { |
---|
1168 | if ( !pcVPS->getSplittingFlag() ) |
---|
1169 | { |
---|
1170 | WRITE_CODE( pcVPS->getDimensionId( i, j ), pcVPS->getDimensionIdLen( j ), "dimension_id[i][j]"); |
---|
1171 | } |
---|
1172 | else |
---|
1173 | { |
---|
1174 | assert( pcVPS->getDimensionId( i, j ) == pcVPS->inferDimensionId( i, j ) ); |
---|
1175 | } |
---|
1176 | } |
---|
1177 | } |
---|
1178 | |
---|
1179 | WRITE_CODE( pcVPS->getViewIdLen( ), 4, "view_id_len" ); |
---|
1180 | |
---|
1181 | if ( pcVPS->getViewIdLen( ) > 0 ) |
---|
1182 | { |
---|
1183 | for( Int i = 0; i < pcVPS->getNumViews(); i++ ) |
---|
1184 | { |
---|
1185 | WRITE_CODE( pcVPS->getViewIdVal( i ), pcVPS->getViewIdLen( ), "view_id_val[i]" ); |
---|
1186 | } |
---|
1187 | } |
---|
1188 | else |
---|
1189 | { |
---|
1190 | for( Int i = 0; i < pcVPS->getNumViews(); i++ ) |
---|
1191 | { |
---|
1192 | assert( pcVPS->getViewIdVal( i ) == 0 ); |
---|
1193 | } |
---|
1194 | } |
---|
1195 | |
---|
1196 | |
---|
1197 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1198 | { |
---|
1199 | for( Int j = 0; j < i; j++ ) |
---|
1200 | { |
---|
1201 | WRITE_FLAG( pcVPS->getDirectDependencyFlag( i, j ), "direct_dependency_flag[i][j]" ); |
---|
1202 | } |
---|
1203 | } |
---|
1204 | |
---|
1205 | if ( pcVPS->getNumIndependentLayers() > 1 ) |
---|
1206 | { |
---|
1207 | WRITE_UVLC( pcVPS->getNumAddLayerSets( ), "num_add_layer_sets" ); |
---|
1208 | } |
---|
1209 | for (Int i = 0; i < pcVPS->getNumAddLayerSets(); i++) |
---|
1210 | { |
---|
1211 | for (Int j = 1; j < pcVPS->getNumIndependentLayers(); j++) |
---|
1212 | { |
---|
1213 | WRITE_CODE( pcVPS->getHighestLayerIdxPlus1( i, j ), pcVPS->getHighestLayerIdxPlus1Len( j ) , "highest_layer_idx_plus1" ); |
---|
1214 | } |
---|
1215 | |
---|
1216 | } |
---|
1217 | |
---|
1218 | |
---|
1219 | WRITE_FLAG( pcVPS->getVpsSubLayersMaxMinus1PresentFlag( ) ? 1 : 0 , "vps_sub_layers_max_minus1_present_flag" ); |
---|
1220 | if ( pcVPS->getVpsSubLayersMaxMinus1PresentFlag() ) |
---|
1221 | { |
---|
1222 | for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1223 | { |
---|
1224 | WRITE_CODE( pcVPS->getSubLayersVpsMaxMinus1( i ), 3, "sub_layers_vps_max_minus1" ); |
---|
1225 | pcVPS->checkSubLayersVpsMaxMinus1( i ); |
---|
1226 | } |
---|
1227 | } |
---|
1228 | else |
---|
1229 | { |
---|
1230 | for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1231 | { |
---|
1232 | assert( pcVPS->getSubLayersVpsMaxMinus1( i ) + 1 == pcVPS->getMaxTLayers( ) ); |
---|
1233 | } |
---|
1234 | } |
---|
1235 | WRITE_FLAG( pcVPS->getMaxTidRefPresentFlag( ) ? 1 : 0 , "max_tid_ref_present_flag" ); |
---|
1236 | |
---|
1237 | if ( pcVPS->getMaxTidRefPresentFlag() ) |
---|
1238 | { |
---|
1239 | for( Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1240 | { |
---|
1241 | for( Int j = i + 1; j <= pcVPS->getMaxLayersMinus1(); j++ ) |
---|
1242 | { |
---|
1243 | if ( pcVPS->getDirectDependencyFlag(j,i) ) |
---|
1244 | { |
---|
1245 | WRITE_CODE( pcVPS->getMaxTidIlRefPicsPlus1( i, j ), 3, "max_tid_il_ref_pics_plus1" ); |
---|
1246 | } |
---|
1247 | } |
---|
1248 | } |
---|
1249 | } |
---|
1250 | |
---|
1251 | WRITE_FLAG( pcVPS->getAllRefLayersActiveFlag( ) ? 1 : 0 , "all_ref_layers_active_flag" ); |
---|
1252 | WRITE_UVLC( pcVPS->getVpsNumProfileTierLevelMinus1( ), "vps_num_profile_tier_level_minus1" ); |
---|
1253 | |
---|
1254 | Int offsetVal = ( pcVPS->getMaxLayersMinus1() > 0 && pcVPS->getVpsBaseLayerInternalFlag() ) ? 2 : 1; |
---|
1255 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 2 : 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
1256 | { |
---|
1257 | WRITE_FLAG( pcVPS->getVpsProfilePresentFlag( i ) ? 1 : 0, "vps_profile_present_flag[i]" ); |
---|
1258 | codePTL( pcVPS->getPTL( offsetVal ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers() - 1 ); |
---|
1259 | offsetVal++; |
---|
1260 | } |
---|
1261 | |
---|
1262 | |
---|
1263 | if (pcVPS->getNumLayerSets() > 1) |
---|
1264 | { |
---|
1265 | WRITE_UVLC( pcVPS->getNumAddOlss( ), "num_add_olss" ); |
---|
1266 | WRITE_CODE( pcVPS->getDefaultOutputLayerIdc( ), 2, "default_output_layer_idc" ); |
---|
1267 | } |
---|
1268 | |
---|
1269 | assert( pcVPS->getOutputLayerFlag(0, 0) == pcVPS->inferOutputLayerFlag( 0, 0 )); |
---|
1270 | assert( pcVPS->getLayerSetIdxForOlsMinus1( 0 ) == -1 ); |
---|
1271 | |
---|
1272 | |
---|
1273 | if (pcVPS->getVpsBaseLayerInternalFlag() ) |
---|
1274 | { |
---|
1275 | assert( pcVPS->getProfileTierLevelIdx(0,0) == pcVPS->inferProfileTierLevelIdx(0,0) ); |
---|
1276 | } |
---|
1277 | |
---|
1278 | |
---|
1279 | for( Int i = 1; i < pcVPS->getNumOutputLayerSets( ); i++ ) |
---|
1280 | { |
---|
1281 | if( pcVPS->getNumLayerSets() > 2 && i >= pcVPS->getNumLayerSets( ) ) |
---|
1282 | { |
---|
1283 | WRITE_CODE( pcVPS->getLayerSetIdxForOlsMinus1( i ), pcVPS->getLayerSetIdxForOlsMinus1Len( i ) , "layer_set_idx_for_ols_minus1[i]" ); |
---|
1284 | } |
---|
1285 | |
---|
1286 | if ( i > pcVPS->getVpsNumLayerSetsMinus1() || pcVPS->getDefaultOutputLayerIdc() == 2 ) |
---|
1287 | { |
---|
1288 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx( i ) ); j++ ) |
---|
1289 | { |
---|
1290 | WRITE_FLAG( pcVPS->getOutputLayerFlag( i, j) ? 1 : 0, "output_layer_flag" ); |
---|
1291 | } |
---|
1292 | } |
---|
1293 | else |
---|
1294 | { |
---|
1295 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx( i ) ) - 1; j++ ) |
---|
1296 | { |
---|
1297 | assert( pcVPS->getOutputLayerFlag( i , j ) == pcVPS->inferOutputLayerFlag( i, j )); |
---|
1298 | } |
---|
1299 | } |
---|
1300 | |
---|
1301 | for ( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx(i)); j++ ) |
---|
1302 | { |
---|
1303 | if (pcVPS->getNecessaryLayerFlag( i, j ) && pcVPS->getVpsNumProfileTierLevelMinus1() > 0 ) |
---|
1304 | { |
---|
1305 | WRITE_CODE( pcVPS->getProfileTierLevelIdx( i, j ), pcVPS->getProfileTierLevelIdxLen() ,"profile_tier_level_idx[ i ][ j ]" ); |
---|
1306 | } |
---|
1307 | if (pcVPS->getNecessaryLayerFlag( i, j ) && pcVPS->getVpsNumProfileTierLevelMinus1() == 0 ) |
---|
1308 | { |
---|
1309 | assert( pcVPS->getProfileTierLevelIdx( i , j ) == pcVPS->inferProfileTierLevelIdx( i, j ) ); |
---|
1310 | } |
---|
1311 | |
---|
1312 | } |
---|
1313 | if( pcVPS->getNumOutputLayersInOutputLayerSet( i ) == 1 && pcVPS->getNumDirectRefLayers( pcVPS->getOlsHighestOutputLayerId( i ) ) > 0 ) |
---|
1314 | { |
---|
1315 | WRITE_FLAG( pcVPS->getAltOutputLayerFlag( i ) ? 1 : 0 , "alt_output_layer_flag[ i ]" ); |
---|
1316 | } |
---|
1317 | } |
---|
1318 | |
---|
1319 | WRITE_UVLC( pcVPS->getVpsNumRepFormatsMinus1( ), "vps_num_rep_formats_minus1" ); |
---|
1320 | |
---|
1321 | for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ ) |
---|
1322 | { |
---|
1323 | const TComRepFormat* curRepFormat = pcVPS->getRepFormat(i); |
---|
1324 | const TComRepFormat* prevRepFormat = i > 0 ? pcVPS->getRepFormat( i - 1) : NULL; |
---|
1325 | codeRepFormat( i, curRepFormat , prevRepFormat); |
---|
1326 | } |
---|
1327 | |
---|
1328 | if ( pcVPS->getVpsNumRepFormatsMinus1() > 0 ) |
---|
1329 | { |
---|
1330 | WRITE_FLAG( pcVPS->getRepFormatIdxPresentFlag( ) ? 1 : 0 , "rep_format_idx_present_flag" ); |
---|
1331 | } |
---|
1332 | |
---|
1333 | if( pcVPS->getRepFormatIdxPresentFlag() ) |
---|
1334 | { |
---|
1335 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1336 | { |
---|
1337 | WRITE_CODE( pcVPS->getVpsRepFormatIdx(i), pcVPS->getVpsRepFormatIdxLen(), "vps_rep_format_idx[i]" ); |
---|
1338 | } |
---|
1339 | } |
---|
1340 | else |
---|
1341 | { |
---|
1342 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1343 | { |
---|
1344 | assert( pcVPS->getVpsRepFormatIdx( i ) == pcVPS->inferVpsRepFormatIdx( i ) ); |
---|
1345 | } |
---|
1346 | } |
---|
1347 | |
---|
1348 | WRITE_FLAG( pcVPS->getMaxOneActiveRefLayerFlag( ) ? 1 : 0, "max_one_active_ref_layer_flag" ); |
---|
1349 | WRITE_FLAG( pcVPS->getVpsPocLsbAlignedFlag( ) ? 1 : 0 , "vps_poc_lsb_aligned_flag" ); |
---|
1350 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1351 | { |
---|
1352 | if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) == 0 ) |
---|
1353 | { |
---|
1354 | WRITE_FLAG( pcVPS->getPocLsbNotPresentFlag( i ) ? 1 : 0 , "poc_lsb_not_present_flag" ); |
---|
1355 | } |
---|
1356 | } |
---|
1357 | |
---|
1358 | codeDpbSize( pcVPS ); |
---|
1359 | |
---|
1360 | WRITE_UVLC( pcVPS->getDirectDepTypeLenMinus2 ( ), "direct_dep_type_len_minus2"); |
---|
1361 | |
---|
1362 | WRITE_FLAG( pcVPS->getDefaultDirectDependencyFlag( ) ? 1 : 0 , "default_direct_dependency_flag" ); |
---|
1363 | if ( pcVPS->getDefaultDirectDependencyFlag( ) ) |
---|
1364 | { |
---|
1365 | WRITE_CODE( pcVPS->getDefaultDirectDependencyType( ), pcVPS->getDirectDepTypeLenMinus2( ) + 2 , "default_direct_dependency_type" ); |
---|
1366 | } |
---|
1367 | |
---|
1368 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 2; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1369 | { |
---|
1370 | for( Int j = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; j < i; j++ ) |
---|
1371 | { |
---|
1372 | if (pcVPS->getDirectDependencyFlag( i, j) ) |
---|
1373 | { |
---|
1374 | if ( pcVPS->getDefaultDirectDependencyFlag( ) ) |
---|
1375 | { |
---|
1376 | assert( pcVPS->getDirectDependencyType( i, j ) == pcVPS->getDefaultDirectDependencyType( ) ); |
---|
1377 | } |
---|
1378 | else |
---|
1379 | { |
---|
1380 | assert ( pcVPS->getDirectDependencyType( i, j ) != -1 ); |
---|
1381 | WRITE_CODE( pcVPS->getDirectDependencyType( i, j ),pcVPS->getDirectDepTypeLenMinus2( ) + 2, "direct_dependency_type[i][j]" ); |
---|
1382 | } |
---|
1383 | } |
---|
1384 | } |
---|
1385 | } |
---|
1386 | WRITE_UVLC( 0, "vps_non_vui_extension_length" ); |
---|
1387 | |
---|
1388 | |
---|
1389 | |
---|
1390 | |
---|
1391 | WRITE_FLAG( pcVPS->getVpsVuiPresentFlag() ? 1 : 0 , "vps_vui_present_flag" ); |
---|
1392 | if( pcVPS->getVpsVuiPresentFlag() ) |
---|
1393 | { |
---|
1394 | m_pcBitIf->writeAlignOne(); // vps_vui_alignment_bit_equal_to_one |
---|
1395 | codeVPSVUI( pcVPS ); |
---|
1396 | } |
---|
1397 | else |
---|
1398 | { |
---|
1399 | const TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
1400 | assert( pcVPSVUI ); |
---|
1401 | assert( !pcVPSVUI->getCrossLayerIrapAlignedFlag() ); |
---|
1402 | } |
---|
1403 | |
---|
1404 | } |
---|
1405 | |
---|
1406 | Void TEncCavlc::codeVideoSignalInfo( const TComVideoSignalInfo* pcVideoSignalInfo ) |
---|
1407 | { |
---|
1408 | assert( pcVideoSignalInfo ); |
---|
1409 | WRITE_CODE( pcVideoSignalInfo->getVideoVpsFormat( ), 3, "video_vps_format" ); |
---|
1410 | WRITE_FLAG( pcVideoSignalInfo->getVideoFullRangeVpsFlag( ) ? 1 : 0 , "video_full_range_vps_flag" ); |
---|
1411 | WRITE_CODE( pcVideoSignalInfo->getColourPrimariesVps( ), 8, "colour_primaries_vps" ); |
---|
1412 | WRITE_CODE( pcVideoSignalInfo->getTransferCharacteristicsVps( ), 8, "transfer_characteristics_vps" ); |
---|
1413 | WRITE_CODE( pcVideoSignalInfo->getMatrixCoeffsVps( ), 8, "matrix_coeffs_vps" ); |
---|
1414 | } |
---|
1415 | |
---|
1416 | Void TEncCavlc::codeDpbSize( const TComVPS* vps ) |
---|
1417 | { |
---|
1418 | const TComDpbSize * dpbSize = vps->getDpbSize(); |
---|
1419 | |
---|
1420 | for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
1421 | { |
---|
1422 | Int currLsIdx = vps->olsIdxToLsIdx( i ); |
---|
1423 | WRITE_FLAG( dpbSize->getSubLayerFlagInfoPresentFlag( i ) ? 1 : 0 , "sub_layer_flag_info_present_flag" ); |
---|
1424 | for( Int j = 0; j <= vps->getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ ) |
---|
1425 | { |
---|
1426 | if( j > 0 && dpbSize->getSubLayerFlagInfoPresentFlag( i ) ) |
---|
1427 | { |
---|
1428 | WRITE_FLAG( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) ? 1 : 0 , "sub_layer_dpb_info_present_flag" ); |
---|
1429 | } |
---|
1430 | if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) ) |
---|
1431 | { |
---|
1432 | for( Int k = 0; k < vps->getNumLayersInIdList( currLsIdx ); k++ ) |
---|
1433 | { |
---|
1434 | if ( vps->getNecessaryLayerFlag( i, k ) && ( vps->getVpsBaseLayerInternalFlag() || ( vps->getLayerSetLayerIdList(vps->olsIdxToLsIdx(i),k) != 0 ) )) |
---|
1435 | { |
---|
1436 | WRITE_UVLC( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ), "max_vps_dec_pic_buffering_minus1" ); |
---|
1437 | } |
---|
1438 | else |
---|
1439 | { |
---|
1440 | if ( vps->getNecessaryLayerFlag( i, k ) && ( j == 0 ) && ( k == 0 ) ) |
---|
1441 | { |
---|
1442 | assert( dpbSize->getMaxVpsDecPicBufferingMinus1(i ,k, j ) == 0 ); |
---|
1443 | } |
---|
1444 | } |
---|
1445 | } |
---|
1446 | WRITE_UVLC( dpbSize->getMaxVpsNumReorderPics( i, j ), "max_vps_num_reorder_pics" ); |
---|
1447 | WRITE_UVLC( dpbSize->getMaxVpsLatencyIncreasePlus1( i, j ), "max_vps_latency_increase_plus1" ); |
---|
1448 | } |
---|
1449 | else |
---|
1450 | { |
---|
1451 | if ( j > 0 ) |
---|
1452 | { |
---|
1453 | for( Int k = 0; k < vps->getNumLayersInIdList( vps->olsIdxToLsIdx( i ) ); k++ ) |
---|
1454 | { |
---|
1455 | if ( vps->getNecessaryLayerFlag(i, k ) ) |
---|
1456 | { |
---|
1457 | assert( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ) == dpbSize->getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) ); |
---|
1458 | } |
---|
1459 | } |
---|
1460 | assert( dpbSize->getMaxVpsNumReorderPics ( i, j ) == dpbSize->getMaxVpsNumReorderPics ( i, j - 1 ) ); |
---|
1461 | assert( dpbSize->getMaxVpsLatencyIncreasePlus1( i, j ) == dpbSize->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); |
---|
1462 | } |
---|
1463 | } |
---|
1464 | } |
---|
1465 | } |
---|
1466 | } |
---|
1467 | |
---|
1468 | Void TEncCavlc::codeRepFormat( Int i, const TComRepFormat* pcRepFormat, const TComRepFormat* pcPrevRepFormat ) |
---|
1469 | { |
---|
1470 | assert( pcRepFormat ); |
---|
1471 | |
---|
1472 | WRITE_CODE( pcRepFormat->getPicWidthVpsInLumaSamples( ), 16, "pic_width_vps_in_luma_samples" ); |
---|
1473 | WRITE_CODE( pcRepFormat->getPicHeightVpsInLumaSamples( ), 16, "pic_height_vps_in_luma_samples" ); |
---|
1474 | WRITE_FLAG( pcRepFormat->getChromaAndBitDepthVpsPresentFlag( ) ? 1 : 0 , "chroma_and_bit_depth_vps_present_flag" ); |
---|
1475 | |
---|
1476 | pcRepFormat->checkChromaAndBitDepthVpsPresentFlag( i ); |
---|
1477 | |
---|
1478 | if ( pcRepFormat->getChromaAndBitDepthVpsPresentFlag() ) |
---|
1479 | { |
---|
1480 | WRITE_CODE( pcRepFormat->getChromaFormatVpsIdc( ), 2, "chroma_format_vps_idc" ); |
---|
1481 | |
---|
1482 | if ( pcRepFormat->getChromaFormatVpsIdc() == 3 ) |
---|
1483 | { |
---|
1484 | WRITE_FLAG( pcRepFormat->getSeparateColourPlaneVpsFlag( ) ? 1 : 0 , "separate_colour_plane_vps_flag" ); |
---|
1485 | } |
---|
1486 | WRITE_CODE( pcRepFormat->getBitDepthVpsLumaMinus8( ), 4, "bit_depth_vps_luma_minus8" ); |
---|
1487 | WRITE_CODE( pcRepFormat->getBitDepthVpsChromaMinus8( ), 4, "bit_depth_vps_chroma_minus8" ); |
---|
1488 | } |
---|
1489 | else |
---|
1490 | { |
---|
1491 | pcRepFormat->checkInferChromaAndBitDepth(pcPrevRepFormat ); |
---|
1492 | } |
---|
1493 | WRITE_FLAG( pcRepFormat->getConformanceWindowVpsFlag( ) ? 1 : 0 , "conformance_window_vps_flag" ); |
---|
1494 | if ( pcRepFormat->getConformanceWindowVpsFlag() ) |
---|
1495 | { |
---|
1496 | WRITE_UVLC( pcRepFormat->getConfWinVpsLeftOffset( ), "conf_win_vps_left_offset" ); |
---|
1497 | WRITE_UVLC( pcRepFormat->getConfWinVpsRightOffset( ), "conf_win_vps_right_offset" ); |
---|
1498 | WRITE_UVLC( pcRepFormat->getConfWinVpsTopOffset( ), "conf_win_vps_top_offset" ); |
---|
1499 | WRITE_UVLC( pcRepFormat->getConfWinVpsBottomOffset( ), "conf_win_vps_bottom_offset" ); |
---|
1500 | } |
---|
1501 | } |
---|
1502 | |
---|
1503 | Void TEncCavlc::codeVPSVUI( const TComVPS* pcVPS ) |
---|
1504 | { |
---|
1505 | assert( pcVPS ); |
---|
1506 | |
---|
1507 | const TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
1508 | |
---|
1509 | assert( pcVPSVUI ); |
---|
1510 | |
---|
1511 | |
---|
1512 | WRITE_FLAG( pcVPSVUI->getCrossLayerPicTypeAlignedFlag( ) ? 1 : 0 , "cross_layer_pic_type_aligned_flag" ); |
---|
1513 | if ( !pcVPSVUI->getCrossLayerPicTypeAlignedFlag() ) |
---|
1514 | { |
---|
1515 | WRITE_FLAG( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) ? 1 : 0 , "cross_layer_irap_aligned_flag" ); |
---|
1516 | } |
---|
1517 | if( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) ) |
---|
1518 | { |
---|
1519 | WRITE_FLAG( pcVPSVUI->getAllLayersIdrAlignedFlag( ) ? 1 : 0 , "all_layers_idr_aligned_flag" ); |
---|
1520 | } |
---|
1521 | WRITE_FLAG( pcVPSVUI->getBitRatePresentVpsFlag( ) ? 1 : 0 , "bit_rate_present_vps_flag" ); |
---|
1522 | WRITE_FLAG( pcVPSVUI->getPicRatePresentVpsFlag( ) ? 1 : 0 , "pic_rate_present_vps_flag" ); |
---|
1523 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) || pcVPSVUI->getPicRatePresentVpsFlag( ) ) |
---|
1524 | { |
---|
1525 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i < pcVPS->getNumLayerSets(); i++ ) |
---|
1526 | { |
---|
1527 | for( Int j = 0; j <= pcVPS->getMaxSubLayersInLayerSetMinus1( i ); j++ ) |
---|
1528 | { |
---|
1529 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) ) |
---|
1530 | { |
---|
1531 | WRITE_FLAG( pcVPSVUI->getBitRatePresentFlag( i, j ) ? 1 : 0 , "bit_rate_present_flag" ); |
---|
1532 | } |
---|
1533 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) ) |
---|
1534 | { |
---|
1535 | WRITE_FLAG( pcVPSVUI->getPicRatePresentFlag( i, j ) ? 1 : 0 , "pic_rate_present_flag" ); |
---|
1536 | } |
---|
1537 | if( pcVPSVUI->getBitRatePresentFlag( i, j ) ) |
---|
1538 | { |
---|
1539 | WRITE_CODE( pcVPSVUI->getAvgBitRate( i, j ), 16, "avg_bit_rate" ); |
---|
1540 | WRITE_CODE( pcVPSVUI->getMaxBitRate( i, j ), 16, "max_bit_rate" ); |
---|
1541 | } |
---|
1542 | if( pcVPSVUI->getPicRatePresentFlag( i, j ) ) |
---|
1543 | { |
---|
1544 | WRITE_CODE( pcVPSVUI->getConstantPicRateIdc( i, j ), 2, "constant_pic_rate_idc" ); |
---|
1545 | WRITE_CODE( pcVPSVUI->getAvgPicRate( i, j ), 16, "avg_pic_rate" ); |
---|
1546 | } |
---|
1547 | } |
---|
1548 | } |
---|
1549 | } |
---|
1550 | |
---|
1551 | WRITE_FLAG( pcVPSVUI->getVideoSignalInfoIdxPresentFlag( ) ? 1 : 0 , "video_signal_info_idx_present_flag" ); |
---|
1552 | if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() ) |
---|
1553 | { |
---|
1554 | WRITE_CODE( pcVPSVUI->getVpsNumVideoSignalInfoMinus1( ), 4, "vps_num_video_signal_info_minus1" ); |
---|
1555 | } |
---|
1556 | else |
---|
1557 | { |
---|
1558 | assert( pcVPSVUI->getVpsNumVideoSignalInfoMinus1() == pcVPS->getMaxLayersMinus1() - ( pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1) ); |
---|
1559 | } |
---|
1560 | |
---|
1561 | for( Int i = 0; i <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1(); i++ ) |
---|
1562 | { |
---|
1563 | assert( pcVPSVUI->getVideoSignalInfo( i ) != NULL ); |
---|
1564 | const TComVideoSignalInfo* curVideoSignalInfo = pcVPSVUI->getVideoSignalInfo( i ); |
---|
1565 | codeVideoSignalInfo( curVideoSignalInfo ); |
---|
1566 | |
---|
1567 | } |
---|
1568 | |
---|
1569 | if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 ) |
---|
1570 | { |
---|
1571 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1572 | { |
---|
1573 | WRITE_CODE( pcVPSVUI->getVpsVideoSignalInfoIdx( i ), 4, "vps_video_signal_info_idx" ); |
---|
1574 | } |
---|
1575 | } |
---|
1576 | WRITE_FLAG( pcVPSVUI->getTilesNotInUseFlag( ) ? 1 : 0 , "tiles_not_in_use_flag" ); |
---|
1577 | if( !pcVPSVUI->getTilesNotInUseFlag() ) |
---|
1578 | { |
---|
1579 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1580 | { |
---|
1581 | WRITE_FLAG( pcVPSVUI->getTilesInUseFlag( i ) ? 1 : 0 , "tiles_in_use_flag[i]" ); |
---|
1582 | if( pcVPSVUI->getTilesInUseFlag( i ) ) |
---|
1583 | { |
---|
1584 | WRITE_FLAG( pcVPSVUI->getLoopFilterNotAcrossTilesFlag( i ) ? 1 : 0, "loop_filter_not_across_tiles_flag[i]" ); |
---|
1585 | } |
---|
1586 | } |
---|
1587 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 2; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1588 | { |
---|
1589 | for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) ; j++ ) |
---|
1590 | { |
---|
1591 | Int layerIdx = pcVPS->getLayerIdInVps(pcVPS->getIdRefLayer(pcVPS->getLayerIdInNuh( i ) , j )); |
---|
1592 | if( pcVPSVUI->getTilesInUseFlag( i ) && pcVPSVUI->getTilesInUseFlag( layerIdx ) ) |
---|
1593 | { |
---|
1594 | WRITE_FLAG( pcVPSVUI->getTileBoundariesAlignedFlag( i, j ) ? 1 : 0 , "tile_boundaries_aligned_flag[i][j]" ); |
---|
1595 | } |
---|
1596 | } |
---|
1597 | } |
---|
1598 | } |
---|
1599 | |
---|
1600 | WRITE_FLAG( pcVPSVUI->getWppNotInUseFlag( ) ? 1 : 0 , "wpp_not_in_use_flag" ); |
---|
1601 | |
---|
1602 | if( !pcVPSVUI->getWppNotInUseFlag( ) ) |
---|
1603 | { |
---|
1604 | for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1605 | { |
---|
1606 | WRITE_FLAG( pcVPSVUI->getWppInUseFlag( i ) ? 1 : 0 , "wpp_in_use_flag[i]" ); |
---|
1607 | } |
---|
1608 | } |
---|
1609 | WRITE_FLAG( pcVPSVUI->getSingleLayerForNonIrapFlag( ) ? 1 : 0 , "single_layer_for_non_irap_flag" ); |
---|
1610 | WRITE_FLAG( pcVPSVUI->getHigherLayerIrapSkipFlag( ) ? 1 : 0 , "higher_layer_irap_skip_flag" ); |
---|
1611 | WRITE_FLAG( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ? 1 : 0 , "ilp_restricted_ref_layers_flag" ); |
---|
1612 | |
---|
1613 | if( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ) |
---|
1614 | { |
---|
1615 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1616 | { |
---|
1617 | for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ); j++ ) |
---|
1618 | { |
---|
1619 | if( pcVPS->getVpsBaseLayerInternalFlag() || pcVPS->getIdRefLayer( pcVPS->getLayerIdInNuh( i ), j ) > 0 ) |
---|
1620 | { |
---|
1621 | WRITE_UVLC( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ), "min_spatial_segment_offset_plus1" ); |
---|
1622 | if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 ) |
---|
1623 | { |
---|
1624 | WRITE_FLAG( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) ? 1 : 0 , "ctu_based_offset_enabled_flag" ); |
---|
1625 | if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) ) |
---|
1626 | { |
---|
1627 | WRITE_UVLC( pcVPSVUI->getMinHorizontalCtuOffsetPlus1( i, j ), "min_horizontal_ctu_offset_plus1" ); |
---|
1628 | } |
---|
1629 | } |
---|
1630 | } |
---|
1631 | } |
---|
1632 | } |
---|
1633 | } |
---|
1634 | |
---|
1635 | |
---|
1636 | WRITE_FLAG( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) ? 1 : 0 , "vps_vui_bsp_hrd_present_flag" ); |
---|
1637 | if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) ) |
---|
1638 | { |
---|
1639 | codeVpsVuiBspHrdParameters( pcVPS ); |
---|
1640 | } |
---|
1641 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1642 | { |
---|
1643 | if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i )) == 0 ) |
---|
1644 | { |
---|
1645 | WRITE_FLAG( pcVPSVUI->getBaseLayerParameterSetCompatibilityFlag( i ) ? 1 : 0 , "base_layer_parameter_set_compatibility_flag" ); |
---|
1646 | } |
---|
1647 | } |
---|
1648 | } |
---|
1649 | |
---|
1650 | Void TEncCavlc::codeVpsVuiBspHrdParameters( const TComVPS* pcVPS ) |
---|
1651 | { |
---|
1652 | assert( pcVPS ); |
---|
1653 | |
---|
1654 | const TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
1655 | |
---|
1656 | assert( pcVPSVUI ); |
---|
1657 | |
---|
1658 | const TComVpsVuiBspHrdParameters* vpsVuiBspHrdP = pcVPSVUI->getVpsVuiBspHrdParameters(); |
---|
1659 | |
---|
1660 | assert ( vpsVuiBspHrdP ); |
---|
1661 | |
---|
1662 | WRITE_UVLC( vpsVuiBspHrdP->getVpsNumAddHrdParams( ), "vps_num_add_hrd_params" ); |
---|
1663 | |
---|
1664 | for( Int i = pcVPS->getNumHrdParameters(); i < pcVPS->getNumHrdParameters() + vpsVuiBspHrdP->getVpsNumAddHrdParams(); i++ ) |
---|
1665 | { |
---|
1666 | if( i > 0 ) |
---|
1667 | { |
---|
1668 | WRITE_FLAG( vpsVuiBspHrdP->getCprmsAddPresentFlag( i ) ? 1 : 0 , "cprms_add_present_flag" ); |
---|
1669 | } |
---|
1670 | WRITE_UVLC( vpsVuiBspHrdP->getNumSubLayerHrdMinus1( i ), "num_sub_layer_hrd_minus1" ); |
---|
1671 | const TComHRD* hrdParameters = vpsVuiBspHrdP->getHrdParametermeters( i ); |
---|
1672 | codeHrdParameters( hrdParameters, vpsVuiBspHrdP->getCprmsAddPresentFlag( i ), vpsVuiBspHrdP->getNumSubLayerHrdMinus1( i ) ); |
---|
1673 | } |
---|
1674 | |
---|
1675 | for( Int h = 1; h < pcVPS->getNumOutputLayerSets(); h++ ) |
---|
1676 | { |
---|
1677 | WRITE_UVLC( vpsVuiBspHrdP->getNumSignalledPartitioningSchemes( h ), "num_signalled_partitioning_schemes" ); |
---|
1678 | |
---|
1679 | for( Int j = 1; j < vpsVuiBspHrdP->getNumSignalledPartitioningSchemes( h ) + 1; j++ ) |
---|
1680 | { |
---|
1681 | WRITE_UVLC( vpsVuiBspHrdP->getNumPartitionsInSchemeMinus1( h, j ), "num_partitions_in_scheme_minus1" ); |
---|
1682 | for( Int k = 0; k <= vpsVuiBspHrdP->getNumPartitionsInSchemeMinus1( h, j ); k++ ) |
---|
1683 | { |
---|
1684 | for( Int r = 0; r < pcVPS->getNumLayersInIdList(pcVPS->olsIdxToLsIdx( h ) ) ; r++ ) |
---|
1685 | { |
---|
1686 | WRITE_FLAG( vpsVuiBspHrdP->getLayerIncludedInPartitionFlag( h, j, k, r ) ? 1 : 0 , "layer_included_in_partition_flag" ); |
---|
1687 | } |
---|
1688 | } |
---|
1689 | } |
---|
1690 | for( Int i = 0; i < vpsVuiBspHrdP->getNumSignalledPartitioningSchemes( h ) + 1; i++ ) |
---|
1691 | { |
---|
1692 | for( Int t = 0; t <= pcVPS->getMaxSubLayersInLayerSetMinus1( pcVPS->olsIdxToLsIdx( h ) ); t++ ) |
---|
1693 | { |
---|
1694 | WRITE_UVLC( vpsVuiBspHrdP->getNumBspSchedulesMinus1( h, i, t ), "num_bsp_schedules_minus1" ); |
---|
1695 | for( Int j = 0; j <= vpsVuiBspHrdP->getNumBspSchedulesMinus1( h, i, t ); j++ ) |
---|
1696 | { |
---|
1697 | for( Int k = 0; k <= vpsVuiBspHrdP->getNumPartitionsInSchemeMinus1( h, j ); k++ ) |
---|
1698 | { |
---|
1699 | WRITE_CODE( vpsVuiBspHrdP->getBspHrdIdx( h, i, t, j, k ), vpsVuiBspHrdP->getBspHrdIdxLen( pcVPS ), "bsp_hrd_idx" ); |
---|
1700 | WRITE_UVLC( vpsVuiBspHrdP->getBspSchedIdx( h, i, t, j, k ), "bsp_sched_idx" ); |
---|
1701 | } |
---|
1702 | } |
---|
1703 | } |
---|
1704 | } |
---|
1705 | } |
---|
1706 | } |
---|
1707 | #endif |
---|
1708 | |
---|
1709 | #if NH_3D |
---|
1710 | Void TEncCavlc::codeVPS3dExtension( const TComVPS* pcVPS ) |
---|
1711 | { |
---|
1712 | WRITE_UVLC( pcVPS->getCpPrecision( ), "cp_precision" ); |
---|
1713 | for (Int n = 1; n < pcVPS->getNumViews(); n++) |
---|
1714 | { |
---|
1715 | Int i = pcVPS->getViewOIdxList( n ); |
---|
1716 | Int iInVps = pcVPS->getVoiInVps( i ); |
---|
1717 | WRITE_CODE( pcVPS->getNumCp( iInVps ), 6, "num_cp" ); |
---|
1718 | |
---|
1719 | if( pcVPS->getNumCp( iInVps ) > 0 ) |
---|
1720 | { |
---|
1721 | WRITE_FLAG( pcVPS->getCpInSliceSegmentHeaderFlag( iInVps ) ? 1 : 0 , "cp_in_slice_segment_header_flag" ); |
---|
1722 | for( Int m = 0; m < pcVPS->getNumCp( iInVps ); m++ ) |
---|
1723 | { |
---|
1724 | WRITE_UVLC( pcVPS->getCpRefVoi( iInVps, m ), "cp_ref_voi" ); |
---|
1725 | if( !pcVPS->getCpInSliceSegmentHeaderFlag( iInVps ) ) |
---|
1726 | { |
---|
1727 | Int j = pcVPS->getCpRefVoi( iInVps, m ); |
---|
1728 | Int jInVps = pcVPS->getVoiInVps( j ); |
---|
1729 | WRITE_SVLC( pcVPS->getVpsCpScale ( iInVps, jInVps ), "vps_cp_scale" ); |
---|
1730 | WRITE_SVLC( pcVPS->getVpsCpOff ( iInVps, jInVps ), "vps_cp_off" ); |
---|
1731 | WRITE_SVLC( pcVPS->getVpsCpInvScale( iInVps, jInVps ) + pcVPS->getVpsCpScale( iInVps, jInVps ), "vps_cp_inv_scale_plus_scale" ); |
---|
1732 | WRITE_SVLC( pcVPS->getVpsCpInvOff ( iInVps, jInVps ) + pcVPS->getVpsCpOff ( iInVps, jInVps ), "vps_cp_inv_off_plus_off" ); |
---|
1733 | } |
---|
1734 | } |
---|
1735 | } |
---|
1736 | } |
---|
1737 | } |
---|
1738 | #endif |
---|
1739 | |
---|
1740 | |
---|
1741 | Void TEncCavlc::codeSliceHeader ( TComSlice* pcSlice ) |
---|
1742 | { |
---|
1743 | #if NH_MV |
---|
1744 | const TComVPS* vps = pcSlice->getVPS(); |
---|
1745 | #endif |
---|
1746 | |
---|
1747 | #if ENC_DEC_TRACE |
---|
1748 | #if NH_MV |
---|
1749 | tracePSHeader( "Slice", pcSlice->getLayerId() ); |
---|
1750 | #else |
---|
1751 | xTraceSliceHeader (); |
---|
1752 | #endif |
---|
1753 | #endif |
---|
1754 | |
---|
1755 | const ChromaFormat format = pcSlice->getSPS()->getChromaFormatIdc(); |
---|
1756 | const UInt numberValidComponents = getNumberValidComponents(format); |
---|
1757 | const Bool chromaEnabled = isChromaEnabled(format); |
---|
1758 | |
---|
1759 | //calculate number of bits required for slice address |
---|
1760 | Int maxSliceSegmentAddress = pcSlice->getPic()->getNumberOfCtusInFrame(); |
---|
1761 | Int bitsSliceSegmentAddress = 0; |
---|
1762 | while(maxSliceSegmentAddress>(1<<bitsSliceSegmentAddress)) |
---|
1763 | { |
---|
1764 | bitsSliceSegmentAddress++; |
---|
1765 | } |
---|
1766 | const Int ctuTsAddress = pcSlice->getSliceSegmentCurStartCtuTsAddr(); |
---|
1767 | |
---|
1768 | //write slice address |
---|
1769 | const Int sliceSegmentRsAddress = pcSlice->getPic()->getPicSym()->getCtuTsToRsAddrMap(ctuTsAddress); |
---|
1770 | #if NH_MV |
---|
1771 | // This should actually be done somewhere else and not in writing process. |
---|
1772 | pcSlice->setFirstSliceSegementInPicFlag( sliceSegmentRsAddress==0 ); |
---|
1773 | WRITE_FLAG( pcSlice->getFirstSliceSegementInPicFlag() , "first_slice_segment_in_pic_flag" ); |
---|
1774 | #else |
---|
1775 | WRITE_FLAG( sliceSegmentRsAddress==0, "first_slice_segment_in_pic_flag" ); |
---|
1776 | #endif |
---|
1777 | if ( pcSlice->getRapPicFlag() ) |
---|
1778 | { |
---|
1779 | WRITE_FLAG( pcSlice->getNoOutputPriorPicsFlag() ? 1 : 0, "no_output_of_prior_pics_flag" ); |
---|
1780 | } |
---|
1781 | #if H_3D_PPS_FIX_DEPTH |
---|
1782 | if( pcSlice->getIsDepth() ) |
---|
1783 | { |
---|
1784 | WRITE_UVLC( 1, "slice_pic_parameter_set_id" ); |
---|
1785 | } |
---|
1786 | else |
---|
1787 | #endif |
---|
1788 | WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "slice_pic_parameter_set_id" ); |
---|
1789 | if ( pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag() && (sliceSegmentRsAddress!=0) ) |
---|
1790 | { |
---|
1791 | WRITE_FLAG( pcSlice->getDependentSliceSegmentFlag() ? 1 : 0, "dependent_slice_segment_flag" ); |
---|
1792 | } |
---|
1793 | if(sliceSegmentRsAddress>0) |
---|
1794 | { |
---|
1795 | WRITE_CODE( sliceSegmentRsAddress, bitsSliceSegmentAddress, "slice_segment_address" ); |
---|
1796 | } |
---|
1797 | if ( !pcSlice->getDependentSliceSegmentFlag() ) |
---|
1798 | { |
---|
1799 | #if NH_MV |
---|
1800 | Int esb = 0; //Don't use i, otherwise will shadow something below |
---|
1801 | |
---|
1802 | if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
1803 | { |
---|
1804 | esb++; |
---|
1805 | WRITE_FLAG( pcSlice->getDiscardableFlag( ) ? 1 : 0 , "discardable_flag" ); |
---|
1806 | if (pcSlice->getDiscardableFlag( )) |
---|
1807 | { |
---|
1808 | assert(pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && |
---|
1809 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && |
---|
1810 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && |
---|
1811 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && |
---|
1812 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); |
---|
1813 | } |
---|
1814 | } |
---|
1815 | |
---|
1816 | if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
1817 | { |
---|
1818 | esb++; |
---|
1819 | WRITE_FLAG( pcSlice->getCrossLayerBlaFlag( ) ? 1 : 0 , "cross_layer_bla_flag" ); |
---|
1820 | } |
---|
1821 | pcSlice->checkCrossLayerBlaFlag( ); |
---|
1822 | |
---|
1823 | for (; esb < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++) |
---|
1824 | #else |
---|
1825 | for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1826 | #endif |
---|
1827 | { |
---|
1828 | WRITE_FLAG(0, "slice_reserved_flag[]"); |
---|
1829 | } |
---|
1830 | |
---|
1831 | |
---|
1832 | |
---|
1833 | WRITE_UVLC( pcSlice->getSliceType(), "slice_type" ); |
---|
1834 | |
---|
1835 | if( pcSlice->getPPS()->getOutputFlagPresentFlag() ) |
---|
1836 | { |
---|
1837 | WRITE_FLAG( pcSlice->getPicOutputFlag() ? 1 : 0, "pic_output_flag" ); |
---|
1838 | } |
---|
1839 | |
---|
1840 | #if NH_MV |
---|
1841 | if ( (pcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( pcSlice->getLayerIdInVps())) || !pcSlice->getIdrPicFlag() ) |
---|
1842 | { |
---|
1843 | Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); |
---|
1844 | WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "slice_pic_order_cnt_lsb"); |
---|
1845 | pcSlice->setSlicePicOrderCntLsb( picOrderCntLSB ); |
---|
1846 | } |
---|
1847 | |
---|
1848 | #endif |
---|
1849 | |
---|
1850 | if( !pcSlice->getIdrPicFlag() ) |
---|
1851 | { |
---|
1852 | #if !NH_MV |
---|
1853 | Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); |
---|
1854 | WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "slice_pic_order_cnt_lsb"); |
---|
1855 | #endif |
---|
1856 | const TComReferencePictureSet* rps = pcSlice->getRPS(); |
---|
1857 | |
---|
1858 | // check for bitstream restriction stating that: |
---|
1859 | // If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
1860 | // Ideally this process should not be repeated for each slice in a picture |
---|
1861 | if (pcSlice->isIRAP()) |
---|
1862 | { |
---|
1863 | for (Int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++) |
---|
1864 | { |
---|
1865 | assert (!rps->getUsed(picIdx)); |
---|
1866 | } |
---|
1867 | } |
---|
1868 | |
---|
1869 | if(pcSlice->getRPSidx() < 0) |
---|
1870 | { |
---|
1871 | WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); |
---|
1872 | codeShortTermRefPicSet( rps, true, pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()); |
---|
1873 | } |
---|
1874 | else |
---|
1875 | { |
---|
1876 | WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag"); |
---|
1877 | Int numBits = 0; |
---|
1878 | while ((1 << numBits) < pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
1879 | { |
---|
1880 | numBits++; |
---|
1881 | } |
---|
1882 | if (numBits > 0) |
---|
1883 | { |
---|
1884 | WRITE_CODE( pcSlice->getRPSidx(), numBits, "short_term_ref_pic_set_idx" ); |
---|
1885 | } |
---|
1886 | } |
---|
1887 | #if NH_MV |
---|
1888 | if(pcSlice->getSPS()->getLongTermRefPicsPresentFlag()) |
---|
1889 | #else |
---|
1890 | if(pcSlice->getSPS()->getLongTermRefsPresent()) |
---|
1891 | #endif |
---|
1892 | { |
---|
1893 | Int numLtrpInSH = rps->getNumberOfLongtermPictures(); |
---|
1894 | Int ltrpInSPS[MAX_NUM_REF_PICS]; |
---|
1895 | Int numLtrpInSPS = 0; |
---|
1896 | UInt ltrpIndex; |
---|
1897 | Int counter = 0; |
---|
1898 | // WARNING: The following code only works only if a matching long-term RPS is |
---|
1899 | // found in the SPS for ALL long-term pictures |
---|
1900 | // The problem is that the SPS coded long-term pictures are moved to the |
---|
1901 | // beginning of the list which causes a mismatch when no reference picture |
---|
1902 | // list reordering is used |
---|
1903 | // NB: Long-term coding is currently not supported in general by the HM encoder |
---|
1904 | for(Int k = rps->getNumberOfPictures()-1; k > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; k--) |
---|
1905 | { |
---|
1906 | if (findMatchingLTRP(pcSlice, <rpIndex, rps->getPOC(k), rps->getUsed(k))) |
---|
1907 | { |
---|
1908 | ltrpInSPS[numLtrpInSPS] = ltrpIndex; |
---|
1909 | numLtrpInSPS++; |
---|
1910 | } |
---|
1911 | else |
---|
1912 | { |
---|
1913 | counter++; |
---|
1914 | } |
---|
1915 | } |
---|
1916 | numLtrpInSH -= numLtrpInSPS; |
---|
1917 | // check that either all long-term pictures are coded in SPS or in slice header (no mixing) |
---|
1918 | assert (numLtrpInSH==0 || numLtrpInSPS==0); |
---|
1919 | |
---|
1920 | Int bitsForLtrpInSPS = 0; |
---|
1921 | while (pcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
1922 | { |
---|
1923 | bitsForLtrpInSPS++; |
---|
1924 | } |
---|
1925 | if (pcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
1926 | { |
---|
1927 | WRITE_UVLC( numLtrpInSPS, "num_long_term_sps"); |
---|
1928 | } |
---|
1929 | WRITE_UVLC( numLtrpInSH, "num_long_term_pics"); |
---|
1930 | // Note that the LSBs of the LT ref. pic. POCs must be sorted before. |
---|
1931 | // Not sorted here because LT ref indices will be used in setRefPicList() |
---|
1932 | Int prevDeltaMSB = 0, prevLSB = 0; |
---|
1933 | Int offset = rps->getNumberOfNegativePictures() + rps->getNumberOfPositivePictures(); |
---|
1934 | counter = 0; |
---|
1935 | // Warning: If some pictures are moved to ltrpInSPS, i is referring to a wrong index |
---|
1936 | // (mapping would be required) |
---|
1937 | for(Int i=rps->getNumberOfPictures()-1 ; i > offset-1; i--, counter++) |
---|
1938 | { |
---|
1939 | if (counter < numLtrpInSPS) |
---|
1940 | { |
---|
1941 | if (bitsForLtrpInSPS > 0) |
---|
1942 | { |
---|
1943 | WRITE_CODE( ltrpInSPS[counter], bitsForLtrpInSPS, "lt_idx_sps[i]"); |
---|
1944 | } |
---|
1945 | } |
---|
1946 | else |
---|
1947 | { |
---|
1948 | WRITE_CODE( rps->getPocLSBLT(i), pcSlice->getSPS()->getBitsForPOC(), "poc_lsb_lt"); |
---|
1949 | WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); |
---|
1950 | } |
---|
1951 | WRITE_FLAG( rps->getDeltaPocMSBPresentFlag(i), "delta_poc_msb_present_flag"); |
---|
1952 | |
---|
1953 | if(rps->getDeltaPocMSBPresentFlag(i)) |
---|
1954 | { |
---|
1955 | Bool deltaFlag = false; |
---|
1956 | // First LTRP from SPS || First LTRP from SH || curr LSB != prev LSB |
---|
1957 | if( (i == rps->getNumberOfPictures()-1) || (i == rps->getNumberOfPictures()-1-numLtrpInSPS) || (rps->getPocLSBLT(i) != prevLSB) ) |
---|
1958 | { |
---|
1959 | deltaFlag = true; |
---|
1960 | } |
---|
1961 | if(deltaFlag) |
---|
1962 | { |
---|
1963 | WRITE_UVLC( rps->getDeltaPocMSBCycleLT(i), "delta_poc_msb_cycle_lt[i]" ); |
---|
1964 | } |
---|
1965 | else |
---|
1966 | { |
---|
1967 | Int differenceInDeltaMSB = rps->getDeltaPocMSBCycleLT(i) - prevDeltaMSB; |
---|
1968 | assert(differenceInDeltaMSB >= 0); |
---|
1969 | WRITE_UVLC( differenceInDeltaMSB, "delta_poc_msb_cycle_lt[i]" ); |
---|
1970 | } |
---|
1971 | prevLSB = rps->getPocLSBLT(i); |
---|
1972 | prevDeltaMSB = rps->getDeltaPocMSBCycleLT(i); |
---|
1973 | } |
---|
1974 | } |
---|
1975 | } |
---|
1976 | if (pcSlice->getSPS()->getSPSTemporalMVPEnabledFlag()) |
---|
1977 | { |
---|
1978 | #if NH_MV |
---|
1979 | WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" ); |
---|
1980 | #else |
---|
1981 | WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" ); |
---|
1982 | #endif |
---|
1983 | } |
---|
1984 | } |
---|
1985 | #if NH_MV |
---|
1986 | Bool interLayerPredLayerIdcPresentFlag = false; |
---|
1987 | Int layerId = pcSlice->getLayerId(); |
---|
1988 | #if NH_3D |
---|
1989 | if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumRefListLayers( layerId ) > 0 ) |
---|
1990 | #else |
---|
1991 | if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 ) |
---|
1992 | #endif |
---|
1993 | { |
---|
1994 | WRITE_FLAG( pcSlice->getInterLayerPredEnabledFlag( ) ? 1 : 0 , "inter_layer_pred_enabled_flag" ); |
---|
1995 | #if NH_3D |
---|
1996 | if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumRefListLayers( layerId ) > 1 ) |
---|
1997 | #else |
---|
1998 | if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 ) |
---|
1999 | #endif |
---|
2000 | { |
---|
2001 | if( !vps->getMaxOneActiveRefLayerFlag()) |
---|
2002 | { |
---|
2003 | WRITE_CODE( pcSlice->getNumInterLayerRefPicsMinus1( ), pcSlice->getNumInterLayerRefPicsMinus1Len( ), "num_inter_layer_ref_pics_minus1" ); |
---|
2004 | } |
---|
2005 | #if NH_3D |
---|
2006 | if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumRefListLayers( layerId ) ) |
---|
2007 | #else |
---|
2008 | if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) ) |
---|
2009 | #endif |
---|
2010 | { |
---|
2011 | interLayerPredLayerIdcPresentFlag = true; |
---|
2012 | for( Int idx = 0; idx < pcSlice->getNumActiveRefLayerPics(); idx++ ) |
---|
2013 | { |
---|
2014 | WRITE_CODE( pcSlice->getInterLayerPredLayerIdc( idx ), pcSlice->getInterLayerPredLayerIdcLen( ), "inter_layer_pred_layer_idc" ); |
---|
2015 | } |
---|
2016 | } |
---|
2017 | } |
---|
2018 | } |
---|
2019 | if ( !interLayerPredLayerIdcPresentFlag ) |
---|
2020 | { |
---|
2021 | for( Int i = 0; i < pcSlice->getNumActiveRefLayerPics(); i++ ) |
---|
2022 | { |
---|
2023 | assert( pcSlice->getInterLayerPredLayerIdc( i ) == pcSlice->getRefLayerPicIdc( i ) ); |
---|
2024 | } |
---|
2025 | } |
---|
2026 | #endif |
---|
2027 | |
---|
2028 | #if NH_3D |
---|
2029 | if( getEncTop()->decProcAnnexI() ) |
---|
2030 | { |
---|
2031 | if ( pcSlice->getInCmpPredAvailFlag() ) |
---|
2032 | { |
---|
2033 | WRITE_FLAG( pcSlice->getInCompPredFlag(), "in_comp_pred_flag" ); |
---|
2034 | } |
---|
2035 | } |
---|
2036 | #endif |
---|
2037 | |
---|
2038 | if(pcSlice->getSPS()->getUseSAO()) |
---|
2039 | { |
---|
2040 | WRITE_FLAG( pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA), "slice_sao_luma_flag" ); |
---|
2041 | if (chromaEnabled) |
---|
2042 | { |
---|
2043 | WRITE_FLAG( pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA), "slice_sao_chroma_flag" ); |
---|
2044 | } |
---|
2045 | } |
---|
2046 | |
---|
2047 | //check if numrefidxes match the defaults. If not, override |
---|
2048 | |
---|
2049 | if (!pcSlice->isIntra()) |
---|
2050 | { |
---|
2051 | Bool overrideFlag = (pcSlice->getNumRefIdx( REF_PIC_LIST_0 )!=pcSlice->getPPS()->getNumRefIdxL0DefaultActive()||(pcSlice->isInterB()&&pcSlice->getNumRefIdx( REF_PIC_LIST_1 )!=pcSlice->getPPS()->getNumRefIdxL1DefaultActive())); |
---|
2052 | #if H_3D_PPS_FIX_DEPTH |
---|
2053 | overrideFlag |= (pcSlice->getIsDepth() && !pcSlice->getViewIndex()); |
---|
2054 | #endif |
---|
2055 | WRITE_FLAG( overrideFlag ? 1 : 0, "num_ref_idx_active_override_flag"); |
---|
2056 | if (overrideFlag) |
---|
2057 | { |
---|
2058 | WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1, "num_ref_idx_l0_active_minus1" ); |
---|
2059 | if (pcSlice->isInterB()) |
---|
2060 | { |
---|
2061 | WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1, "num_ref_idx_l1_active_minus1" ); |
---|
2062 | } |
---|
2063 | else |
---|
2064 | { |
---|
2065 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
2066 | } |
---|
2067 | } |
---|
2068 | } |
---|
2069 | else |
---|
2070 | { |
---|
2071 | pcSlice->setNumRefIdx(REF_PIC_LIST_0, 0); |
---|
2072 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
2073 | } |
---|
2074 | #if H_3D_PPS_FIX_DEPTH |
---|
2075 | if( (pcSlice->getPPS()->getListsModificationPresentFlag() || (pcSlice->getIsDepth() && !pcSlice->getViewIndex())) && pcSlice->getNumRpsCurrTempList() > 1) |
---|
2076 | #else |
---|
2077 | if( pcSlice->getPPS()->getListsModificationPresentFlag() && pcSlice->getNumRpsCurrTempList() > 1) |
---|
2078 | #endif |
---|
2079 | { |
---|
2080 | TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); |
---|
2081 | if(!pcSlice->isIntra()) |
---|
2082 | { |
---|
2083 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0, "ref_pic_list_modification_flag_l0" ); |
---|
2084 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0()) |
---|
2085 | { |
---|
2086 | Int numRpsCurrTempList0 = pcSlice->getNumRpsCurrTempList(); |
---|
2087 | if (numRpsCurrTempList0 > 1) |
---|
2088 | { |
---|
2089 | Int length = 1; |
---|
2090 | numRpsCurrTempList0 --; |
---|
2091 | while ( numRpsCurrTempList0 >>= 1) |
---|
2092 | { |
---|
2093 | length ++; |
---|
2094 | } |
---|
2095 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++) |
---|
2096 | { |
---|
2097 | WRITE_CODE( refPicListModification->getRefPicSetIdxL0(i), length, "list_entry_l0"); |
---|
2098 | } |
---|
2099 | } |
---|
2100 | } |
---|
2101 | } |
---|
2102 | if(pcSlice->isInterB()) |
---|
2103 | { |
---|
2104 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag_l1" ); |
---|
2105 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1()) |
---|
2106 | { |
---|
2107 | Int numRpsCurrTempList1 = pcSlice->getNumRpsCurrTempList(); |
---|
2108 | if ( numRpsCurrTempList1 > 1 ) |
---|
2109 | { |
---|
2110 | Int length = 1; |
---|
2111 | numRpsCurrTempList1 --; |
---|
2112 | while ( numRpsCurrTempList1 >>= 1) |
---|
2113 | { |
---|
2114 | length ++; |
---|
2115 | } |
---|
2116 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++) |
---|
2117 | { |
---|
2118 | WRITE_CODE( refPicListModification->getRefPicSetIdxL1(i), length, "list_entry_l1"); |
---|
2119 | } |
---|
2120 | } |
---|
2121 | } |
---|
2122 | } |
---|
2123 | } |
---|
2124 | |
---|
2125 | if (pcSlice->isInterB()) |
---|
2126 | { |
---|
2127 | WRITE_FLAG( pcSlice->getMvdL1ZeroFlag() ? 1 : 0, "mvd_l1_zero_flag"); |
---|
2128 | } |
---|
2129 | |
---|
2130 | if(!pcSlice->isIntra()) |
---|
2131 | { |
---|
2132 | if (!pcSlice->isIntra() && pcSlice->getPPS()->getCabacInitPresentFlag()) |
---|
2133 | { |
---|
2134 | SliceType sliceType = pcSlice->getSliceType(); |
---|
2135 | SliceType encCABACTableIdx = pcSlice->getEncCABACTableIdx(); |
---|
2136 | Bool encCabacInitFlag = (sliceType!=encCABACTableIdx && encCABACTableIdx!=I_SLICE) ? true : false; |
---|
2137 | pcSlice->setCabacInitFlag( encCabacInitFlag ); |
---|
2138 | WRITE_FLAG( encCabacInitFlag?1:0, "cabac_init_flag" ); |
---|
2139 | } |
---|
2140 | } |
---|
2141 | |
---|
2142 | if ( pcSlice->getEnableTMVPFlag() ) |
---|
2143 | { |
---|
2144 | if ( pcSlice->getSliceType() == B_SLICE ) |
---|
2145 | { |
---|
2146 | WRITE_FLAG( pcSlice->getColFromL0Flag(), "collocated_from_l0_flag" ); |
---|
2147 | } |
---|
2148 | |
---|
2149 | if ( pcSlice->getSliceType() != I_SLICE && |
---|
2150 | ((pcSlice->getColFromL0Flag()==1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0)>1)|| |
---|
2151 | (pcSlice->getColFromL0Flag()==0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1)>1))) |
---|
2152 | { |
---|
2153 | WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" ); |
---|
2154 | } |
---|
2155 | } |
---|
2156 | if ( (pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pcSlice->getPPS()->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) ) |
---|
2157 | { |
---|
2158 | xCodePredWeightTable( pcSlice ); |
---|
2159 | } |
---|
2160 | #if NH_3D |
---|
2161 | else if( pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE ) |
---|
2162 | && !pcSlice->getIsDepth() && vps->getNumRefListLayers( layerId ) > 0 |
---|
2163 | && getEncTop()->decProcAnnexI() |
---|
2164 | ) |
---|
2165 | { |
---|
2166 | WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "slice_ic_enable_flag" ); |
---|
2167 | if( pcSlice->getApplyIC() ) |
---|
2168 | { |
---|
2169 | WRITE_FLAG( pcSlice->getIcSkipParseFlag() ? 1 : 0, "slice_ic_disabled_merge_zero_idx_flag" ); |
---|
2170 | } |
---|
2171 | } |
---|
2172 | assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS_MEM); |
---|
2173 | #else |
---|
2174 | assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS); |
---|
2175 | #endif |
---|
2176 | if (!pcSlice->isIntra()) |
---|
2177 | { |
---|
2178 | #if NH_3D |
---|
2179 | WRITE_UVLC( ( ( pcSlice->getMpiFlag( ) || pcSlice->getIvMvPredFlag( ) || pcSlice->getViewSynthesisPredFlag( ) ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS ) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand"); |
---|
2180 | #else |
---|
2181 | WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand"); |
---|
2182 | #endif |
---|
2183 | } |
---|
2184 | Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 ); |
---|
2185 | WRITE_SVLC( iCode, "slice_qp_delta" ); |
---|
2186 | if (pcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
2187 | { |
---|
2188 | if (numberValidComponents > COMPONENT_Cb) |
---|
2189 | { |
---|
2190 | WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb), "slice_cb_qp_offset" ); |
---|
2191 | } |
---|
2192 | if (numberValidComponents > COMPONENT_Cr) |
---|
2193 | { |
---|
2194 | WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr), "slice_cr_qp_offset" ); |
---|
2195 | } |
---|
2196 | assert(numberValidComponents <= COMPONENT_Cr+1); |
---|
2197 | } |
---|
2198 | |
---|
2199 | if (pcSlice->getPPS()->getPpsRangeExtension().getChromaQpOffsetListEnabledFlag()) |
---|
2200 | { |
---|
2201 | WRITE_FLAG(pcSlice->getUseChromaQpAdj(), "cu_chroma_qp_offset_enabled_flag"); |
---|
2202 | } |
---|
2203 | |
---|
2204 | if (pcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
2205 | { |
---|
2206 | if (pcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag() ) |
---|
2207 | { |
---|
2208 | WRITE_FLAG(pcSlice->getDeblockingFilterOverrideFlag(), "deblocking_filter_override_flag"); |
---|
2209 | } |
---|
2210 | if (pcSlice->getDeblockingFilterOverrideFlag()) |
---|
2211 | { |
---|
2212 | WRITE_FLAG(pcSlice->getDeblockingFilterDisable(), "slice_deblocking_filter_disabled_flag"); |
---|
2213 | if(!pcSlice->getDeblockingFilterDisable()) |
---|
2214 | { |
---|
2215 | WRITE_SVLC (pcSlice->getDeblockingFilterBetaOffsetDiv2(), "slice_beta_offset_div2"); |
---|
2216 | WRITE_SVLC (pcSlice->getDeblockingFilterTcOffsetDiv2(), "slice_tc_offset_div2"); |
---|
2217 | } |
---|
2218 | } |
---|
2219 | } |
---|
2220 | |
---|
2221 | Bool isSAOEnabled = pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA) || (chromaEnabled && pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA))); |
---|
2222 | Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable()); |
---|
2223 | |
---|
2224 | if(pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
2225 | { |
---|
2226 | WRITE_FLAG(pcSlice->getLFCrossSliceBoundaryFlag()?1:0, "slice_loop_filter_across_slices_enabled_flag"); |
---|
2227 | } |
---|
2228 | #if NH_3D |
---|
2229 | if (getEncTop()->decProcAnnexI() ) |
---|
2230 | { |
---|
2231 | Int voiInVps = vps->getVoiInVps( pcSlice->getViewIndex() ); |
---|
2232 | if( vps->getCpInSliceSegmentHeaderFlag( voiInVps ) ) |
---|
2233 | { |
---|
2234 | for( Int m = 0; m < vps->getNumCp( voiInVps ); m++ ) |
---|
2235 | { |
---|
2236 | Int jInVps = vps->getVoiInVps( vps->getCpRefVoi( voiInVps, m )); |
---|
2237 | WRITE_SVLC( pcSlice->getCpScale ( jInVps ) , "cp_scale" ); |
---|
2238 | WRITE_SVLC( pcSlice->getCpOff ( jInVps ) , "cp_off" ); |
---|
2239 | WRITE_SVLC( pcSlice->getCpInvScale( jInVps ) + pcSlice->getCpScale( jInVps ) , "cp_inv_scale_plus_scale" ); |
---|
2240 | WRITE_SVLC( pcSlice->getCpInvOff ( jInVps ) + pcSlice->getCpOff ( jInVps ) , "cp_inv_off_plus_off" ); |
---|
2241 | } |
---|
2242 | } |
---|
2243 | } |
---|
2244 | #endif |
---|
2245 | |
---|
2246 | } |
---|
2247 | #if !NH_MV |
---|
2248 | if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag()) |
---|
2249 | { |
---|
2250 | WRITE_UVLC(0,"slice_segment_header_extension_length"); |
---|
2251 | } |
---|
2252 | #else |
---|
2253 | if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag()) |
---|
2254 | { |
---|
2255 | // Derive the value of PocMsbValRequiredFlag |
---|
2256 | |
---|
2257 | // Determine value of SH extension length. |
---|
2258 | Int shExtnLengthInBit = 0; |
---|
2259 | if (pcSlice->getPPS()->getPocResetInfoPresentFlag()) |
---|
2260 | { |
---|
2261 | shExtnLengthInBit += 2; |
---|
2262 | } |
---|
2263 | if (pcSlice->getPocResetIdc() > 0) |
---|
2264 | { |
---|
2265 | shExtnLengthInBit += 6; |
---|
2266 | } |
---|
2267 | if (pcSlice->getPocResetIdc() == 3) |
---|
2268 | { |
---|
2269 | shExtnLengthInBit += (pcSlice->getSPS()->getBitsForPOC() + 1); |
---|
2270 | } |
---|
2271 | |
---|
2272 | |
---|
2273 | if( !pcSlice->getPocMsbValRequiredFlag() && pcSlice->getVPS()->getVpsPocLsbAlignedFlag() ) |
---|
2274 | { |
---|
2275 | shExtnLengthInBit++; // For poc_msb_val_present_flag |
---|
2276 | } |
---|
2277 | else |
---|
2278 | { |
---|
2279 | if( pcSlice->getPocMsbValRequiredFlag() ) |
---|
2280 | { |
---|
2281 | pcSlice->setPocMsbCycleValPresentFlag( true ); |
---|
2282 | } |
---|
2283 | else |
---|
2284 | { |
---|
2285 | pcSlice->setPocMsbCycleValPresentFlag( false ); |
---|
2286 | } |
---|
2287 | } |
---|
2288 | |
---|
2289 | if( pcSlice->getPocMsbCycleValPresentFlag() ) |
---|
2290 | { |
---|
2291 | // Int iMaxPOClsb = 1<< pcSlice->getSPS()->getBitsForPOC(); currently unused |
---|
2292 | |
---|
2293 | UInt lengthVal = 1; |
---|
2294 | UInt tempVal = pcSlice->getPocMsbCycleVal() + 1; |
---|
2295 | assert ( tempVal ); |
---|
2296 | while( 1 != tempVal ) |
---|
2297 | { |
---|
2298 | tempVal >>= 1; |
---|
2299 | lengthVal += 2; |
---|
2300 | } |
---|
2301 | shExtnLengthInBit += lengthVal; |
---|
2302 | } |
---|
2303 | Int shExtnAdditionalBits = 0; |
---|
2304 | if(shExtnLengthInBit % 8 != 0) |
---|
2305 | { |
---|
2306 | shExtnAdditionalBits = 8 - (shExtnLengthInBit % 8); |
---|
2307 | } |
---|
2308 | pcSlice->setSliceSegmentHeaderExtensionLength((shExtnLengthInBit + shExtnAdditionalBits) / 8); |
---|
2309 | |
---|
2310 | |
---|
2311 | WRITE_UVLC( pcSlice->getSliceSegmentHeaderExtensionLength( ), "slice_segment_header_extension_length" ); |
---|
2312 | UInt posFollSliceSegHeaderExtLen = m_pcBitIf->getNumberOfWrittenBits(); |
---|
2313 | if( pcSlice->getPPS()->getPocResetInfoPresentFlag() ) |
---|
2314 | { |
---|
2315 | WRITE_CODE( pcSlice->getPocResetIdc( ), 2, "poc_reset_idc" ); |
---|
2316 | } |
---|
2317 | else |
---|
2318 | { |
---|
2319 | assert( pcSlice->getPocResetIdc( ) == 0 ); |
---|
2320 | } |
---|
2321 | |
---|
2322 | pcSlice->checkPocResetIdc(); |
---|
2323 | |
---|
2324 | if( pcSlice->getPocResetIdc() != 0 ) |
---|
2325 | { |
---|
2326 | WRITE_CODE( pcSlice->getPocResetPeriodId( ), 6, "poc_reset_period_id" ); |
---|
2327 | } |
---|
2328 | |
---|
2329 | if( pcSlice->getPocResetIdc() == 3 ) |
---|
2330 | { |
---|
2331 | WRITE_FLAG( pcSlice->getFullPocResetFlag( ) ? 1 : 0 , "full_poc_reset_flag" ); |
---|
2332 | WRITE_CODE( pcSlice->getPocLsbVal( ), pcSlice->getPocLsbValLen() , "poc_lsb_val" ); |
---|
2333 | } |
---|
2334 | pcSlice->checkPocLsbVal(); |
---|
2335 | |
---|
2336 | if( !pcSlice->getPocMsbValRequiredFlag() && pcSlice->getVPS()->getVpsPocLsbAlignedFlag() ) |
---|
2337 | { |
---|
2338 | WRITE_FLAG( pcSlice->getPocMsbCycleValPresentFlag( ) ? 1 : 0 , "poc_msb_cycle_val_present_flag" ); |
---|
2339 | } |
---|
2340 | else |
---|
2341 | { |
---|
2342 | assert( pcSlice->getPocMsbCycleValPresentFlag() == pcSlice->inferPocMsbCycleValPresentFlag( ) ); |
---|
2343 | } |
---|
2344 | |
---|
2345 | if( pcSlice->getPocMsbCycleValPresentFlag() ) |
---|
2346 | { |
---|
2347 | WRITE_UVLC( pcSlice->getPocMsbCycleVal( ), "poc_msb_cycle_val" ); |
---|
2348 | } |
---|
2349 | |
---|
2350 | while( ( m_pcBitIf->getNumberOfWrittenBits() - posFollSliceSegHeaderExtLen ) < pcSlice->getSliceSegmentHeaderExtensionLength() * 8 ) |
---|
2351 | { |
---|
2352 | WRITE_FLAG( 0, "slice_segment_header_extension_data_bit" ); |
---|
2353 | } |
---|
2354 | |
---|
2355 | assert( ( m_pcBitIf->getNumberOfWrittenBits() - posFollSliceSegHeaderExtLen ) == pcSlice->getSliceSegmentHeaderExtensionLength() * 8 ); |
---|
2356 | } |
---|
2357 | #endif |
---|
2358 | |
---|
2359 | } |
---|
2360 | |
---|
2361 | Void TEncCavlc::codePTL( const TComPTL* pcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1) |
---|
2362 | { |
---|
2363 | if(profilePresentFlag) |
---|
2364 | { |
---|
2365 | codeProfileTier(pcPTL->getGeneralPTL(), false); // general_... |
---|
2366 | } |
---|
2367 | WRITE_CODE( Int(pcPTL->getGeneralPTL()->getLevelIdc()), 8, "general_level_idc" ); |
---|
2368 | |
---|
2369 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2370 | { |
---|
2371 | WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" ); |
---|
2372 | WRITE_FLAG( pcPTL->getSubLayerLevelPresentFlag(i), "sub_layer_level_present_flag[i]" ); |
---|
2373 | } |
---|
2374 | |
---|
2375 | if (maxNumSubLayersMinus1 > 0) |
---|
2376 | { |
---|
2377 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
2378 | { |
---|
2379 | WRITE_CODE(0, 2, "reserved_zero_2bits"); |
---|
2380 | } |
---|
2381 | } |
---|
2382 | |
---|
2383 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2384 | { |
---|
2385 | if( pcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
2386 | { |
---|
2387 | codeProfileTier(pcPTL->getSubLayerPTL(i), true); // sub_layer_... |
---|
2388 | } |
---|
2389 | if( pcPTL->getSubLayerLevelPresentFlag(i) ) |
---|
2390 | { |
---|
2391 | WRITE_CODE( Int(pcPTL->getSubLayerPTL(i)->getLevelIdc()), 8, "sub_layer_level_idc[i]" ); |
---|
2392 | } |
---|
2393 | } |
---|
2394 | } |
---|
2395 | |
---|
2396 | #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
2397 | Void TEncCavlc::codeProfileTier( const ProfileTierLevel* ptl, const Bool bIsSubLayer ) |
---|
2398 | #define PTL_TRACE_TEXT(txt) bIsSubLayer?("sub_layer_" txt) : ("general_" txt) |
---|
2399 | #else |
---|
2400 | Void TEncCavlc::codeProfileTier( const ProfileTierLevel* ptl, const Bool /*bIsSubLayer*/ ) |
---|
2401 | #define PTL_TRACE_TEXT(txt) txt |
---|
2402 | #endif |
---|
2403 | { |
---|
2404 | WRITE_CODE( ptl->getProfileSpace(), 2 , PTL_TRACE_TEXT("profile_space" )); |
---|
2405 | WRITE_FLAG( ptl->getTierFlag()==Level::HIGH, PTL_TRACE_TEXT("tier_flag" )); |
---|
2406 | WRITE_CODE( Int(ptl->getProfileIdc()), 5 , PTL_TRACE_TEXT("profile_idc" )); |
---|
2407 | for(Int j = 0; j < 32; j++) |
---|
2408 | { |
---|
2409 | WRITE_FLAG( ptl->getProfileCompatibilityFlag(j), PTL_TRACE_TEXT("profile_compatibility_flag[][j]" )); |
---|
2410 | } |
---|
2411 | |
---|
2412 | WRITE_FLAG(ptl->getProgressiveSourceFlag(), PTL_TRACE_TEXT("progressive_source_flag" )); |
---|
2413 | WRITE_FLAG(ptl->getInterlacedSourceFlag(), PTL_TRACE_TEXT("interlaced_source_flag" )); |
---|
2414 | WRITE_FLAG(ptl->getNonPackedConstraintFlag(), PTL_TRACE_TEXT("non_packed_constraint_flag" )); |
---|
2415 | WRITE_FLAG(ptl->getFrameOnlyConstraintFlag(), PTL_TRACE_TEXT("frame_only_constraint_flag" )); |
---|
2416 | |
---|
2417 | #if NH_MV |
---|
2418 | if( ptl->getV2ConstraintsPresentFlag() ) |
---|
2419 | { |
---|
2420 | WRITE_FLAG( ptl->getMax12bitConstraintFlag ( ) ? 1 : 0 , "max_12bit_constraint_flag" ); |
---|
2421 | WRITE_FLAG( ptl->getMax10bitConstraintFlag ( ) ? 1 : 0 , "max_10bit_constraint_flag" ); |
---|
2422 | WRITE_FLAG( ptl->getMax8bitConstraintFlag ( ) ? 1 : 0 , "max_8bit_constraint_flag" ); |
---|
2423 | WRITE_FLAG( ptl->getMax422chromaConstraintFlag ( ) ? 1 : 0 , "max_422chroma_constraint_flag" ); |
---|
2424 | WRITE_FLAG( ptl->getMax420chromaConstraintFlag ( ) ? 1 : 0 , "max_420chroma_constraint_flag" ); |
---|
2425 | WRITE_FLAG( ptl->getMaxMonochromeConstraintFlag ( ) ? 1 : 0 , "max_monochrome_constraint_flag" ); |
---|
2426 | WRITE_FLAG( ptl->getIntraConstraintFlag ( ) ? 1 : 0 , "intra_constraint_flag" ); |
---|
2427 | WRITE_FLAG( ptl->getOnePictureOnlyConstraintFlag ( ) ? 1 : 0 , "one_picture_only_constraint_flag" ); |
---|
2428 | WRITE_FLAG( ptl->getLowerBitRateConstraintFlag ( ) ? 1 : 0 , "lower_bit_rate_constraint_flag" ); |
---|
2429 | WRITE_CODE( 0, 16, "XXX_reserved_zero_34bits[0..15]"); |
---|
2430 | WRITE_CODE( 0, 16, "XXX_reserved_zero_34bits[16..31]"); |
---|
2431 | WRITE_CODE( 0, 2 , "XXX_reserved_zero_34bits[32..33]"); |
---|
2432 | } |
---|
2433 | else |
---|
2434 | { |
---|
2435 | WRITE_CODE( 0, 16, "XXX_reserved_zero_43bits[0..15]"); |
---|
2436 | WRITE_CODE( 0, 16, "XXX_reserved_zero_43bits[16..31]"); |
---|
2437 | WRITE_CODE( 0, 11, "XXX_reserved_zero_43bits[32..42]"); |
---|
2438 | } |
---|
2439 | if( ptl->getInbldPresentFlag() ) |
---|
2440 | { |
---|
2441 | WRITE_FLAG( ptl->getInbldFlag( ) ? 1 : 0 , "inbld_flag" ); |
---|
2442 | } |
---|
2443 | else |
---|
2444 | { |
---|
2445 | WRITE_FLAG(0, "reserved_zero_bit"); |
---|
2446 | } |
---|
2447 | #else |
---|
2448 | if (ptl->getProfileIdc() == Profile::MAINREXT || ptl->getProfileIdc() == Profile::HIGHTHROUGHPUTREXT ) |
---|
2449 | { |
---|
2450 | const UInt bitDepthConstraint=ptl->getBitDepthConstraint(); |
---|
2451 | WRITE_FLAG(bitDepthConstraint<=12, PTL_TRACE_TEXT("max_12bit_constraint_flag" )); |
---|
2452 | WRITE_FLAG(bitDepthConstraint<=10, PTL_TRACE_TEXT("max_10bit_constraint_flag" )); |
---|
2453 | WRITE_FLAG(bitDepthConstraint<= 8, PTL_TRACE_TEXT("max_8bit_constraint_flag" )); |
---|
2454 | const ChromaFormat chromaFmtConstraint=ptl->getChromaFormatConstraint(); |
---|
2455 | WRITE_FLAG(chromaFmtConstraint==CHROMA_422||chromaFmtConstraint==CHROMA_420||chromaFmtConstraint==CHROMA_400, PTL_TRACE_TEXT("max_422chroma_constraint_flag" )); |
---|
2456 | WRITE_FLAG(chromaFmtConstraint==CHROMA_420||chromaFmtConstraint==CHROMA_400, PTL_TRACE_TEXT("max_420chroma_constraint_flag" )); |
---|
2457 | WRITE_FLAG(chromaFmtConstraint==CHROMA_400, PTL_TRACE_TEXT("max_monochrome_constraint_flag")); |
---|
2458 | WRITE_FLAG(ptl->getIntraConstraintFlag(), PTL_TRACE_TEXT("intra_constraint_flag" )); |
---|
2459 | WRITE_FLAG(ptl->getOnePictureOnlyConstraintFlag(), PTL_TRACE_TEXT("one_picture_only_constraint_flag")); |
---|
2460 | WRITE_FLAG(ptl->getLowerBitRateConstraintFlag(), PTL_TRACE_TEXT("lower_bit_rate_constraint_flag" )); |
---|
2461 | WRITE_CODE(0 , 16, PTL_TRACE_TEXT("reserved_zero_34bits[0..15]" )); |
---|
2462 | WRITE_CODE(0 , 16, PTL_TRACE_TEXT("reserved_zero_34bits[16..31]" )); |
---|
2463 | WRITE_CODE(0 , 2, PTL_TRACE_TEXT("reserved_zero_34bits[32..33]" )); |
---|
2464 | } |
---|
2465 | else if (ptl->getProfileIdc() == Profile::MAIN10) |
---|
2466 | { |
---|
2467 | WRITE_CODE(0x00 , 7, PTL_TRACE_TEXT("reserved_zero_7bits" )); |
---|
2468 | WRITE_FLAG(ptl->getOnePictureOnlyConstraintFlag(), PTL_TRACE_TEXT("one_picture_only_constraint_flag")); |
---|
2469 | WRITE_CODE(0x0000 , 16, PTL_TRACE_TEXT("reserved_zero_35bits[0..15]" )); |
---|
2470 | WRITE_CODE(0x0000 , 16, PTL_TRACE_TEXT("reserved_zero_35bits[16..31]" )); |
---|
2471 | WRITE_CODE(0x0 , 3, PTL_TRACE_TEXT("reserved_zero_35bits[32..34]" )); |
---|
2472 | } |
---|
2473 | else |
---|
2474 | { |
---|
2475 | WRITE_CODE(0x0000 , 16, PTL_TRACE_TEXT("reserved_zero_43bits[0..15]" )); |
---|
2476 | WRITE_CODE(0x0000 , 16, PTL_TRACE_TEXT("reserved_zero_43bits[16..31]" )); |
---|
2477 | WRITE_CODE(0x000 , 11, PTL_TRACE_TEXT("reserved_zero_43bits[32..42]" )); |
---|
2478 | } |
---|
2479 | WRITE_FLAG(false, PTL_TRACE_TEXT("inbld_flag" )); |
---|
2480 | #undef PTL_TRACE_TEXT |
---|
2481 | #endif |
---|
2482 | } |
---|
2483 | |
---|
2484 | /** |
---|
2485 | * Write tiles and wavefront substreams sizes for the slice header (entry points). |
---|
2486 | * |
---|
2487 | * \param pSlice TComSlice structure that contains the substream size information. |
---|
2488 | */ |
---|
2489 | Void TEncCavlc::codeTilesWPPEntryPoint( TComSlice* pSlice ) |
---|
2490 | { |
---|
2491 | if (!pSlice->getPPS()->getTilesEnabledFlag() && !pSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) |
---|
2492 | { |
---|
2493 | return; |
---|
2494 | } |
---|
2495 | UInt maxOffset = 0; |
---|
2496 | for(Int idx=0; idx<pSlice->getNumberOfSubstreamSizes(); idx++) |
---|
2497 | { |
---|
2498 | UInt offset=pSlice->getSubstreamSize(idx); |
---|
2499 | if ( offset > maxOffset ) |
---|
2500 | { |
---|
2501 | maxOffset = offset; |
---|
2502 | } |
---|
2503 | } |
---|
2504 | |
---|
2505 | // Determine number of bits "offsetLenMinus1+1" required for entry point information |
---|
2506 | UInt offsetLenMinus1 = 0; |
---|
2507 | while (maxOffset >= (1u << (offsetLenMinus1 + 1))) |
---|
2508 | { |
---|
2509 | offsetLenMinus1++; |
---|
2510 | assert(offsetLenMinus1 + 1 < 32); |
---|
2511 | } |
---|
2512 | |
---|
2513 | WRITE_UVLC(pSlice->getNumberOfSubstreamSizes(), "num_entry_point_offsets"); |
---|
2514 | if (pSlice->getNumberOfSubstreamSizes()>0) |
---|
2515 | { |
---|
2516 | WRITE_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
2517 | |
---|
2518 | for (UInt idx=0; idx<pSlice->getNumberOfSubstreamSizes(); idx++) |
---|
2519 | { |
---|
2520 | WRITE_CODE(pSlice->getSubstreamSize(idx)-1, offsetLenMinus1+1, "entry_point_offset_minus1"); |
---|
2521 | } |
---|
2522 | } |
---|
2523 | } |
---|
2524 | |
---|
2525 | Void TEncCavlc::codeTerminatingBit ( UInt /*uilsLast*/ ) |
---|
2526 | { |
---|
2527 | } |
---|
2528 | |
---|
2529 | Void TEncCavlc::codeSliceFinish () |
---|
2530 | { |
---|
2531 | } |
---|
2532 | |
---|
2533 | Void TEncCavlc::codeMVPIdx ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ ) |
---|
2534 | { |
---|
2535 | assert(0); |
---|
2536 | } |
---|
2537 | |
---|
2538 | Void TEncCavlc::codePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2539 | { |
---|
2540 | assert(0); |
---|
2541 | } |
---|
2542 | |
---|
2543 | Void TEncCavlc::codePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
2544 | { |
---|
2545 | assert(0); |
---|
2546 | } |
---|
2547 | |
---|
2548 | Void TEncCavlc::codeMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
2549 | { |
---|
2550 | assert(0); |
---|
2551 | } |
---|
2552 | |
---|
2553 | Void TEncCavlc::codeMergeIndex ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
2554 | { |
---|
2555 | assert(0); |
---|
2556 | } |
---|
2557 | |
---|
2558 | #if NH_3D |
---|
2559 | Void TEncCavlc::codeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
2560 | { |
---|
2561 | assert(0); |
---|
2562 | } |
---|
2563 | |
---|
2564 | Void TEncCavlc::codeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
2565 | { |
---|
2566 | assert(0); |
---|
2567 | } |
---|
2568 | #endif |
---|
2569 | |
---|
2570 | Void TEncCavlc::codeInterModeFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiEncMode*/ ) |
---|
2571 | { |
---|
2572 | assert(0); |
---|
2573 | } |
---|
2574 | |
---|
2575 | Void TEncCavlc::codeCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
2576 | { |
---|
2577 | assert(0); |
---|
2578 | } |
---|
2579 | |
---|
2580 | Void TEncCavlc::codeSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
2581 | { |
---|
2582 | assert(0); |
---|
2583 | } |
---|
2584 | #if NH_3D |
---|
2585 | Void TEncCavlc::codeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
2586 | { |
---|
2587 | assert(0); |
---|
2588 | } |
---|
2589 | #endif |
---|
2590 | |
---|
2591 | Void TEncCavlc::codeSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2592 | { |
---|
2593 | assert(0); |
---|
2594 | } |
---|
2595 | |
---|
2596 | Void TEncCavlc::codeTransformSubdivFlag( UInt /*uiSymbol*/, UInt /*uiCtx*/ ) |
---|
2597 | { |
---|
2598 | assert(0); |
---|
2599 | } |
---|
2600 | |
---|
2601 | Void TEncCavlc::codeQtCbf( TComTU& /*rTu*/, const ComponentID /*compID*/, const Bool /*lowestLevel*/ ) |
---|
2602 | { |
---|
2603 | assert(0); |
---|
2604 | } |
---|
2605 | |
---|
2606 | Void TEncCavlc::codeQtRootCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
2607 | { |
---|
2608 | assert(0); |
---|
2609 | } |
---|
2610 | |
---|
2611 | Void TEncCavlc::codeQtCbfZero( TComTU& /*rTu*/, const ChannelType /*chType*/ ) |
---|
2612 | { |
---|
2613 | assert(0); |
---|
2614 | } |
---|
2615 | Void TEncCavlc::codeQtRootCbfZero( ) |
---|
2616 | { |
---|
2617 | assert(0); |
---|
2618 | } |
---|
2619 | |
---|
2620 | Void TEncCavlc::codeTransformSkipFlags (TComTU& /*rTu*/, ComponentID /*component*/ ) |
---|
2621 | { |
---|
2622 | assert(0); |
---|
2623 | } |
---|
2624 | |
---|
2625 | /** Code I_PCM information. |
---|
2626 | * \param pcCU pointer to CU |
---|
2627 | * \param uiAbsPartIdx CU index |
---|
2628 | * \returns Void |
---|
2629 | */ |
---|
2630 | Void TEncCavlc::codeIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
2631 | { |
---|
2632 | assert(0); |
---|
2633 | } |
---|
2634 | |
---|
2635 | Void TEncCavlc::codeIntraDirLumaAng( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, Bool /*isMultiple*/) |
---|
2636 | { |
---|
2637 | assert(0); |
---|
2638 | } |
---|
2639 | |
---|
2640 | Void TEncCavlc::codeIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
2641 | { |
---|
2642 | assert(0); |
---|
2643 | } |
---|
2644 | |
---|
2645 | Void TEncCavlc::codeInterDir( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
2646 | { |
---|
2647 | assert(0); |
---|
2648 | } |
---|
2649 | |
---|
2650 | Void TEncCavlc::codeRefFrmIdx( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ ) |
---|
2651 | { |
---|
2652 | assert(0); |
---|
2653 | } |
---|
2654 | |
---|
2655 | Void TEncCavlc::codeMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ ) |
---|
2656 | { |
---|
2657 | assert(0); |
---|
2658 | } |
---|
2659 | |
---|
2660 | Void TEncCavlc::codeCrossComponentPrediction( TComTU& /*rTu*/, ComponentID /*compID*/ ) |
---|
2661 | { |
---|
2662 | assert(0); |
---|
2663 | } |
---|
2664 | |
---|
2665 | Void TEncCavlc::codeDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
2666 | { |
---|
2667 | Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx ); |
---|
2668 | |
---|
2669 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); |
---|
2670 | iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2); |
---|
2671 | |
---|
2672 | xWriteSvlc( iDQp ); |
---|
2673 | |
---|
2674 | return; |
---|
2675 | } |
---|
2676 | |
---|
2677 | Void TEncCavlc::codeChromaQpAdjustment( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) |
---|
2678 | { |
---|
2679 | assert(0); |
---|
2680 | } |
---|
2681 | |
---|
2682 | Void TEncCavlc::codeCoeffNxN ( TComTU& /*rTu*/, TCoeff* /*pcCoef*/, const ComponentID /*compID*/ ) |
---|
2683 | { |
---|
2684 | assert(0); |
---|
2685 | } |
---|
2686 | |
---|
2687 | Void TEncCavlc::estBit( estBitsSbacStruct* /*pcEstBitsCabac*/, Int /*width*/, Int /*height*/, ChannelType /*chType*/, COEFF_SCAN_TYPE /*scanType*/ ) |
---|
2688 | { |
---|
2689 | // printf("error : no VLC mode support in this version\n"); |
---|
2690 | return; |
---|
2691 | } |
---|
2692 | |
---|
2693 | // ==================================================================================================================== |
---|
2694 | // Protected member functions |
---|
2695 | // ==================================================================================================================== |
---|
2696 | |
---|
2697 | //! Code weighted prediction tables |
---|
2698 | Void TEncCavlc::xCodePredWeightTable( TComSlice* pcSlice ) |
---|
2699 | { |
---|
2700 | WPScalingParam *wp; |
---|
2701 | const ChromaFormat format = pcSlice->getPic()->getChromaFormat(); |
---|
2702 | const UInt numberValidComponents = getNumberValidComponents(format); |
---|
2703 | const Bool bChroma = isChromaEnabled(format); |
---|
2704 | const Int iNbRef = (pcSlice->getSliceType() == B_SLICE ) ? (2) : (1); |
---|
2705 | Bool bDenomCoded = false; |
---|
2706 | UInt uiTotalSignalledWeightFlags = 0; |
---|
2707 | |
---|
2708 | if ( (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPred()) ) |
---|
2709 | { |
---|
2710 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) // loop over l0 and l1 syntax elements |
---|
2711 | { |
---|
2712 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
2713 | |
---|
2714 | // NOTE: wp[].uiLog2WeightDenom and wp[].bPresentFlag are actually per-channel-type settings. |
---|
2715 | |
---|
2716 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2717 | { |
---|
2718 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2719 | if ( !bDenomCoded ) |
---|
2720 | { |
---|
2721 | Int iDeltaDenom; |
---|
2722 | WRITE_UVLC( wp[COMPONENT_Y].uiLog2WeightDenom, "luma_log2_weight_denom" ); |
---|
2723 | |
---|
2724 | if( bChroma ) |
---|
2725 | { |
---|
2726 | assert(wp[COMPONENT_Cb].uiLog2WeightDenom == wp[COMPONENT_Cr].uiLog2WeightDenom); // check the channel-type settings are consistent across components. |
---|
2727 | iDeltaDenom = (wp[COMPONENT_Cb].uiLog2WeightDenom - wp[COMPONENT_Y].uiLog2WeightDenom); |
---|
2728 | WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); |
---|
2729 | } |
---|
2730 | bDenomCoded = true; |
---|
2731 | } |
---|
2732 | WRITE_FLAG( wp[COMPONENT_Y].bPresentFlag, iNumRef==0?"luma_weight_l0_flag[i]":"luma_weight_l1_flag[i]" ); |
---|
2733 | uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag; |
---|
2734 | } |
---|
2735 | if (bChroma) |
---|
2736 | { |
---|
2737 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2738 | { |
---|
2739 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2740 | assert(wp[COMPONENT_Cb].bPresentFlag == wp[COMPONENT_Cr].bPresentFlag); // check the channel-type settings are consistent across components. |
---|
2741 | WRITE_FLAG( wp[COMPONENT_Cb].bPresentFlag, iNumRef==0?"chroma_weight_l0_flag[i]":"chroma_weight_l1_flag[i]" ); |
---|
2742 | uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag; |
---|
2743 | } |
---|
2744 | } |
---|
2745 | |
---|
2746 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2747 | { |
---|
2748 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2749 | if ( wp[COMPONENT_Y].bPresentFlag ) |
---|
2750 | { |
---|
2751 | Int iDeltaWeight = (wp[COMPONENT_Y].iWeight - (1<<wp[COMPONENT_Y].uiLog2WeightDenom)); |
---|
2752 | WRITE_SVLC( iDeltaWeight, iNumRef==0?"delta_luma_weight_l0[i]":"delta_luma_weight_l1[i]" ); |
---|
2753 | WRITE_SVLC( wp[COMPONENT_Y].iOffset, iNumRef==0?"luma_offset_l0[i]":"luma_offset_l1[i]" ); |
---|
2754 | } |
---|
2755 | |
---|
2756 | if ( bChroma ) |
---|
2757 | { |
---|
2758 | if ( wp[COMPONENT_Cb].bPresentFlag ) |
---|
2759 | { |
---|
2760 | for ( Int j = COMPONENT_Cb ; j < numberValidComponents ; j++ ) |
---|
2761 | { |
---|
2762 | assert(wp[COMPONENT_Cb].uiLog2WeightDenom == wp[COMPONENT_Cr].uiLog2WeightDenom); |
---|
2763 | Int iDeltaWeight = (wp[j].iWeight - (1<<wp[COMPONENT_Cb].uiLog2WeightDenom)); |
---|
2764 | WRITE_SVLC( iDeltaWeight, iNumRef==0?"delta_chroma_weight_l0[i]":"delta_chroma_weight_l1[i]" ); |
---|
2765 | |
---|
2766 | Int range=pcSlice->getSPS()->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1<<pcSlice->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA))/2 : 128; |
---|
2767 | Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
2768 | Int iDeltaChroma = (wp[j].iOffset - pred); |
---|
2769 | WRITE_SVLC( iDeltaChroma, iNumRef==0?"delta_chroma_offset_l0[i]":"delta_chroma_offset_l1[i]" ); |
---|
2770 | } |
---|
2771 | } |
---|
2772 | } |
---|
2773 | } |
---|
2774 | } |
---|
2775 | assert(uiTotalSignalledWeightFlags<=24); |
---|
2776 | } |
---|
2777 | } |
---|
2778 | |
---|
2779 | /** code quantization matrix |
---|
2780 | * \param scalingList quantization matrix information |
---|
2781 | */ |
---|
2782 | Void TEncCavlc::codeScalingList( const TComScalingList &scalingList ) |
---|
2783 | { |
---|
2784 | //for each size |
---|
2785 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2786 | { |
---|
2787 | const Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries. |
---|
2788 | |
---|
2789 | for(UInt listId = 0; listId < SCALING_LIST_NUM; listId+=predListStep) |
---|
2790 | { |
---|
2791 | Bool scalingListPredModeFlag = scalingList.getScalingListPredModeFlag(sizeId, listId); |
---|
2792 | WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" ); |
---|
2793 | if(!scalingListPredModeFlag)// Copy Mode |
---|
2794 | { |
---|
2795 | if (sizeId == SCALING_LIST_32x32) |
---|
2796 | { |
---|
2797 | // adjust the code, to cope with the missing chroma entries |
---|
2798 | WRITE_UVLC( ((Int)listId - (Int)scalingList.getRefMatrixId (sizeId,listId)) / (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES), "scaling_list_pred_matrix_id_delta"); |
---|
2799 | } |
---|
2800 | else |
---|
2801 | { |
---|
2802 | WRITE_UVLC( (Int)listId - (Int)scalingList.getRefMatrixId (sizeId,listId), "scaling_list_pred_matrix_id_delta"); |
---|
2803 | } |
---|
2804 | } |
---|
2805 | else// DPCM Mode |
---|
2806 | { |
---|
2807 | xCodeScalingList(&scalingList, sizeId, listId); |
---|
2808 | } |
---|
2809 | } |
---|
2810 | } |
---|
2811 | return; |
---|
2812 | } |
---|
2813 | /** code DPCM |
---|
2814 | * \param scalingList quantization matrix information |
---|
2815 | * \param sizeId size index |
---|
2816 | * \param listId list index |
---|
2817 | */ |
---|
2818 | Void TEncCavlc::xCodeScalingList(const TComScalingList* scalingList, UInt sizeId, UInt listId) |
---|
2819 | { |
---|
2820 | Int coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
2821 | UInt* scan = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][sizeId==0 ? 2 : 3][sizeId==0 ? 2 : 3]; |
---|
2822 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
2823 | Int data; |
---|
2824 | const Int *src = scalingList->getScalingListAddress(sizeId, listId); |
---|
2825 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2826 | { |
---|
2827 | WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8"); |
---|
2828 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
2829 | } |
---|
2830 | for(Int i=0;i<coefNum;i++) |
---|
2831 | { |
---|
2832 | data = src[scan[i]] - nextCoef; |
---|
2833 | nextCoef = src[scan[i]]; |
---|
2834 | if(data > 127) |
---|
2835 | { |
---|
2836 | data = data - 256; |
---|
2837 | } |
---|
2838 | if(data < -128) |
---|
2839 | { |
---|
2840 | data = data + 256; |
---|
2841 | } |
---|
2842 | |
---|
2843 | WRITE_SVLC( data, "scaling_list_delta_coef"); |
---|
2844 | } |
---|
2845 | } |
---|
2846 | Bool TEncCavlc::findMatchingLTRP ( TComSlice* pcSlice, UInt *ltrpsIndex, Int ltrpPOC, Bool usedFlag ) |
---|
2847 | { |
---|
2848 | // Bool state = true, state2 = false; |
---|
2849 | Int lsb = ltrpPOC & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); |
---|
2850 | for (Int k = 0; k < pcSlice->getSPS()->getNumLongTermRefPicSPS(); k++) |
---|
2851 | { |
---|
2852 | if ( (lsb == pcSlice->getSPS()->getLtRefPicPocLsbSps(k)) && (usedFlag == pcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(k)) ) |
---|
2853 | { |
---|
2854 | *ltrpsIndex = k; |
---|
2855 | return true; |
---|
2856 | } |
---|
2857 | } |
---|
2858 | return false; |
---|
2859 | } |
---|
2860 | |
---|
2861 | Void TEncCavlc::codeExplicitRdpcmMode( TComTU& /*rTu*/, const ComponentID /*compID*/ ) |
---|
2862 | { |
---|
2863 | assert(0); |
---|
2864 | } |
---|
2865 | #if NH_3D |
---|
2866 | Void TEncCavlc::codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
2867 | { |
---|
2868 | assert(0); |
---|
2869 | } |
---|
2870 | |
---|
2871 | Void TEncCavlc::codeDBBPFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
2872 | { |
---|
2873 | assert(0); |
---|
2874 | } |
---|
2875 | #endif |
---|
2876 | |
---|
2877 | |
---|
2878 | //! \} |
---|