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-2012, 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 | //! \ingroup TLibEncoder |
---|
43 | //! \{ |
---|
44 | |
---|
45 | #if ENC_DEC_TRACE |
---|
46 | |
---|
47 | #define WRITE_CODE( value, length, name) xWriteCodeTr ( value, length, name ) |
---|
48 | #define WRITE_UVLC( value, name) xWriteUvlcTr ( value, name ) |
---|
49 | #define WRITE_SVLC( value, name) xWriteSvlcTr ( value, name ) |
---|
50 | #define WRITE_FLAG( value, name) xWriteFlagTr ( value, name ) |
---|
51 | |
---|
52 | Void xWriteUvlcTr ( UInt value, const Char *pSymbolName); |
---|
53 | Void xWriteSvlcTr ( Int value, const Char *pSymbolName); |
---|
54 | Void xWriteFlagTr ( UInt value, const Char *pSymbolName); |
---|
55 | |
---|
56 | Void xTraceSPSHeader (TComSPS *pSPS) |
---|
57 | { |
---|
58 | fprintf( g_hTrace, "=========== Sequence Parameter Set ID: %d ===========\n", pSPS->getSPSId() ); |
---|
59 | } |
---|
60 | |
---|
61 | Void xTracePPSHeader (TComPPS *pPPS) |
---|
62 | { |
---|
63 | fprintf( g_hTrace, "=========== Picture Parameter Set ID: %d ===========\n", pPPS->getPPSId() ); |
---|
64 | } |
---|
65 | |
---|
66 | Void xTraceAPSHeader (TComAPS *pAPS) |
---|
67 | { |
---|
68 | fprintf( g_hTrace, "=========== Adaptation Parameter Set ===========\n"); |
---|
69 | } |
---|
70 | |
---|
71 | Void xTraceSliceHeader (TComSlice *pSlice) |
---|
72 | { |
---|
73 | fprintf( g_hTrace, "=========== Slice ===========\n"); |
---|
74 | } |
---|
75 | |
---|
76 | |
---|
77 | Void TEncCavlc::xWriteCodeTr (UInt value, UInt length, const Char *pSymbolName) |
---|
78 | { |
---|
79 | xWriteCode (value,length); |
---|
80 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
81 | fprintf( g_hTrace, "%-40s u(%d) : %d\n", pSymbolName, length, value ); |
---|
82 | } |
---|
83 | |
---|
84 | Void TEncCavlc::xWriteUvlcTr (UInt value, const Char *pSymbolName) |
---|
85 | { |
---|
86 | xWriteUvlc (value); |
---|
87 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
88 | fprintf( g_hTrace, "%-40s u(v) : %d\n", pSymbolName, value ); |
---|
89 | } |
---|
90 | |
---|
91 | Void TEncCavlc::xWriteSvlcTr (Int value, const Char *pSymbolName) |
---|
92 | { |
---|
93 | xWriteSvlc(value); |
---|
94 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
95 | fprintf( g_hTrace, "%-40s s(v) : %d\n", pSymbolName, value ); |
---|
96 | } |
---|
97 | |
---|
98 | Void TEncCavlc::xWriteFlagTr(UInt value, const Char *pSymbolName) |
---|
99 | { |
---|
100 | xWriteFlag(value); |
---|
101 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
102 | fprintf( g_hTrace, "%-40s u(1) : %d\n", pSymbolName, value ); |
---|
103 | } |
---|
104 | |
---|
105 | #else |
---|
106 | |
---|
107 | #define WRITE_CODE( value, length, name) xWriteCode ( value, length ) |
---|
108 | #define WRITE_UVLC( value, name) xWriteUvlc ( value ) |
---|
109 | #define WRITE_SVLC( value, name) xWriteSvlc ( value ) |
---|
110 | #define WRITE_FLAG( value, name) xWriteFlag ( value ) |
---|
111 | |
---|
112 | #endif |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | // ==================================================================================================================== |
---|
117 | // Constructor / destructor / create / destroy |
---|
118 | // ==================================================================================================================== |
---|
119 | |
---|
120 | TEncCavlc::TEncCavlc() |
---|
121 | { |
---|
122 | m_pcBitIf = NULL; |
---|
123 | m_uiCoeffCost = 0; |
---|
124 | m_bAlfCtrl = false; |
---|
125 | m_uiMaxAlfCtrlDepth = 0; |
---|
126 | |
---|
127 | m_iSliceGranularity = 0; |
---|
128 | } |
---|
129 | |
---|
130 | TEncCavlc::~TEncCavlc() |
---|
131 | { |
---|
132 | } |
---|
133 | |
---|
134 | |
---|
135 | // ==================================================================================================================== |
---|
136 | // Public member functions |
---|
137 | // ==================================================================================================================== |
---|
138 | |
---|
139 | Void TEncCavlc::resetEntropy() |
---|
140 | { |
---|
141 | } |
---|
142 | |
---|
143 | /** |
---|
144 | * marshall the SEI message sei. |
---|
145 | */ |
---|
146 | void TEncCavlc::codeSEI(const SEI& sei) |
---|
147 | { |
---|
148 | writeSEImessage(*m_pcBitIf, sei); |
---|
149 | } |
---|
150 | |
---|
151 | Void TEncCavlc::codeAPSInitInfo(TComAPS* pcAPS) |
---|
152 | { |
---|
153 | |
---|
154 | #if ENC_DEC_TRACE |
---|
155 | xTraceAPSHeader(pcAPS); |
---|
156 | #endif |
---|
157 | //APS ID |
---|
158 | WRITE_UVLC( pcAPS->getAPSID(), "aps_id" ); |
---|
159 | |
---|
160 | WRITE_FLAG( pcAPS->getScalingListEnabled()?1:0, "aps_scaling_list_data_present_flag"); |
---|
161 | //DF flag |
---|
162 | WRITE_FLAG(pcAPS->getLoopFilterOffsetInAPS()?1:0, "aps_deblocking_filter_flag"); |
---|
163 | #if !SAO_UNIT_INTERLEAVING |
---|
164 | //SAO flag |
---|
165 | WRITE_FLAG( pcAPS->getSaoEnabled()?1:0, "aps_sample_adaptive_offset_flag"); |
---|
166 | #endif |
---|
167 | #if !LCU_SYNTAX_ALF |
---|
168 | //ALF flag |
---|
169 | WRITE_FLAG( pcAPS->getAlfEnabled()?1:0, "aps_adaptive_loop_filter_flag"); |
---|
170 | #endif |
---|
171 | } |
---|
172 | #if LCU_SYNTAX_ALF |
---|
173 | Void TEncCavlc::codeAPSAlflag(UInt uiCode) |
---|
174 | { |
---|
175 | WRITE_FLAG(uiCode, "aps_adaptive_loop_filter_flag"); |
---|
176 | } |
---|
177 | #endif |
---|
178 | |
---|
179 | Void TEncCavlc::codeDFFlag(UInt uiCode, const Char *pSymbolName) |
---|
180 | { |
---|
181 | WRITE_FLAG(uiCode, pSymbolName); |
---|
182 | } |
---|
183 | Void TEncCavlc::codeDFSvlc(Int iCode, const Char *pSymbolName) |
---|
184 | { |
---|
185 | WRITE_SVLC(iCode, pSymbolName); |
---|
186 | } |
---|
187 | |
---|
188 | #if RPS_IN_SPS |
---|
189 | Void TEncCavlc::codeShortTermRefPicSet( TComSPS* pcSPS, TComReferencePictureSet* rps ) |
---|
190 | #else |
---|
191 | Void TEncCavlc::codeShortTermRefPicSet( TComPPS* pcPPS, TComReferencePictureSet* rps ) |
---|
192 | #endif |
---|
193 | { |
---|
194 | #if PRINT_RPS_INFO |
---|
195 | int lastBits = getNumberOfWrittenBits(); |
---|
196 | #endif |
---|
197 | WRITE_FLAG( rps->getInterRPSPrediction(), "inter_ref_pic_set_prediction_flag" ); // inter_RPS_prediction_flag |
---|
198 | if (rps->getInterRPSPrediction()) |
---|
199 | { |
---|
200 | Int deltaRPS = rps->getDeltaRPS(); |
---|
201 | WRITE_UVLC( rps->getDeltaRIdxMinus1(), "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
202 | WRITE_CODE( (deltaRPS >=0 ? 0: 1), 1, "delta_rps_sign" ); //delta_rps_sign |
---|
203 | WRITE_UVLC( abs(deltaRPS) - 1, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
204 | |
---|
205 | for(Int j=0; j < rps->getNumRefIdc(); j++) |
---|
206 | { |
---|
207 | Int refIdc = rps->getRefIdc(j); |
---|
208 | WRITE_CODE( (refIdc==1? 1: 0), 1, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
209 | if (refIdc != 1) |
---|
210 | { |
---|
211 | WRITE_CODE( refIdc>>1, 1, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
212 | } |
---|
213 | } |
---|
214 | } |
---|
215 | else |
---|
216 | { |
---|
217 | WRITE_UVLC( rps->getNumberOfNegativePictures(), "num_negative_pics" ); |
---|
218 | WRITE_UVLC( rps->getNumberOfPositivePictures(), "num_positive_pics" ); |
---|
219 | Int prev = 0; |
---|
220 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
221 | { |
---|
222 | WRITE_UVLC( prev-rps->getDeltaPOC(j)-1, "delta_poc_s0_minus1" ); |
---|
223 | prev = rps->getDeltaPOC(j); |
---|
224 | WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s0_flag"); |
---|
225 | } |
---|
226 | prev = 0; |
---|
227 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
228 | { |
---|
229 | WRITE_UVLC( rps->getDeltaPOC(j)-prev-1, "delta_poc_s1_minus1" ); |
---|
230 | prev = rps->getDeltaPOC(j); |
---|
231 | WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s1_flag" ); |
---|
232 | } |
---|
233 | } |
---|
234 | |
---|
235 | #if PRINT_RPS_INFO |
---|
236 | printf("irps=%d (%2d bits) ", rps->getInterRPSPrediction(), getNumberOfWrittenBits() - lastBits); |
---|
237 | rps->printDeltaPOC(); |
---|
238 | #endif |
---|
239 | } |
---|
240 | |
---|
241 | |
---|
242 | Void TEncCavlc::codePPS( TComPPS* pcPPS ) |
---|
243 | { |
---|
244 | #if ENC_DEC_TRACE |
---|
245 | xTracePPSHeader (pcPPS); |
---|
246 | #endif |
---|
247 | #if !RPS_IN_SPS |
---|
248 | TComRPSList* rpsList = pcPPS->getRPSList(); |
---|
249 | #endif |
---|
250 | |
---|
251 | WRITE_UVLC( pcPPS->getPPSId(), "pic_parameter_set_id" ); |
---|
252 | WRITE_UVLC( pcPPS->getSPSId(), "seq_parameter_set_id" ); |
---|
253 | |
---|
254 | #if MULTIBITS_DATA_HIDING |
---|
255 | WRITE_FLAG( pcPPS->getSignHideFlag(), "sign_data_hiding_flag" ); |
---|
256 | if( pcPPS->getSignHideFlag() ) |
---|
257 | { |
---|
258 | WRITE_CODE(pcPPS->getTSIG(), 4, "sign_hiding_threshold"); |
---|
259 | } |
---|
260 | #endif |
---|
261 | #if CABAC_INIT_FLAG |
---|
262 | WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0, "cabac_init_present_flag" ); |
---|
263 | #endif |
---|
264 | #if !RPS_IN_SPS |
---|
265 | // RPS is put before entropy_coding_mode_flag |
---|
266 | // since entropy_coding_mode_flag will probably be removed from the WD |
---|
267 | TComReferencePictureSet* rps; |
---|
268 | |
---|
269 | WRITE_UVLC(rpsList->getNumberOfReferencePictureSets(), "num_short_term_ref_pic_sets" ); |
---|
270 | for(UInt i=0; i < rpsList->getNumberOfReferencePictureSets(); i++) |
---|
271 | { |
---|
272 | rps = rpsList->getReferencePictureSet(i); |
---|
273 | codeShortTermRefPicSet(pcPPS,rps); |
---|
274 | } |
---|
275 | WRITE_FLAG( pcPPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_present_flag" ); |
---|
276 | #endif |
---|
277 | // entropy_coding_mode_flag |
---|
278 | // We code the entropy_coding_mode_flag, it's needed for tests. |
---|
279 | WRITE_FLAG( pcPPS->getEntropyCodingMode() ? 1 : 0, "entropy_coding_mode_flag" ); |
---|
280 | if (pcPPS->getEntropyCodingMode()) |
---|
281 | { |
---|
282 | #if !WPP_SIMPLIFICATION |
---|
283 | WRITE_UVLC( pcPPS->getEntropyCodingSynchro(), "entropy_coding_synchro" ); |
---|
284 | WRITE_FLAG( pcPPS->getCabacIstateReset() ? 1 : 0, "cabac_istate_reset" ); |
---|
285 | #endif |
---|
286 | #if !TILES_OR_ENTROPY_SYNC_IDC |
---|
287 | #if !WPP_SIMPLIFICATION |
---|
288 | if ( pcPPS->getEntropyCodingSynchro() ) |
---|
289 | #endif |
---|
290 | { |
---|
291 | WRITE_UVLC( pcPPS->getNumSubstreams()-1, "num_substreams_minus1" ); |
---|
292 | } |
---|
293 | #endif |
---|
294 | } |
---|
295 | #if !H0566_TLA |
---|
296 | WRITE_UVLC( pcPPS->getNumTLayerSwitchingFlags(), "num_temporal_layer_switching_point_flags" ); |
---|
297 | for( UInt i = 0; i < pcPPS->getNumTLayerSwitchingFlags(); i++ ) |
---|
298 | { |
---|
299 | WRITE_FLAG( pcPPS->getTLayerSwitchingFlag( i ) ? 1 : 0 , "temporal_layer_switching_point_flag" ); |
---|
300 | } |
---|
301 | #endif |
---|
302 | // num_ref_idx_l0_default_active_minus1 |
---|
303 | // num_ref_idx_l1_default_active_minus1 |
---|
304 | WRITE_SVLC( pcPPS->getPicInitQPMinus26(), "pic_init_qp_minus26"); |
---|
305 | WRITE_FLAG( pcPPS->getConstrainedIntraPred() ? 1 : 0, "constrained_intra_pred_flag" ); |
---|
306 | WRITE_FLAG( pcPPS->getEnableTMVPFlag() ? 1 : 0, "enable_temporal_mvp_flag" ); |
---|
307 | WRITE_CODE( pcPPS->getSliceGranularity(), 2, "slice_granularity"); |
---|
308 | WRITE_UVLC( pcPPS->getMaxCuDQPDepth() + pcPPS->getUseDQP(), "max_cu_qp_delta_depth" ); |
---|
309 | |
---|
310 | WRITE_SVLC( pcPPS->getChromaQpOffset(), "chroma_qp_offset" ); |
---|
311 | WRITE_SVLC( pcPPS->getChromaQpOffset2nd(), "chroma_qp_offset_2nd" ); |
---|
312 | |
---|
313 | WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
314 | WRITE_CODE( pcPPS->getWPBiPredIdc(), 2, "weighted_bipred_idc" ); // Use of Weighting Bi-Prediction (B_SLICE) |
---|
315 | #if H0388 |
---|
316 | WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0, "output_flag_present_flag" ); |
---|
317 | #endif |
---|
318 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
319 | if(pcPPS->getSPS()->getTilesOrEntropyCodingSyncIdc()==1) |
---|
320 | { |
---|
321 | #endif |
---|
322 | WRITE_FLAG( pcPPS->getColumnRowInfoPresent(), "tile_info_present_flag" ); |
---|
323 | WRITE_FLAG( pcPPS->getTileBehaviorControlPresentFlag(), "tile_control_present_flag"); |
---|
324 | if( pcPPS->getColumnRowInfoPresent() == 1 ) |
---|
325 | { |
---|
326 | WRITE_UVLC( pcPPS->getNumColumnsMinus1(), "num_tile_columns_minus1" ); |
---|
327 | WRITE_UVLC( pcPPS->getNumRowsMinus1(), "num_tile_rows_minus1" ); |
---|
328 | WRITE_FLAG( pcPPS->getUniformSpacingIdr(), "uniform_spacing_flag" ); |
---|
329 | if( pcPPS->getUniformSpacingIdr() == 0 ) |
---|
330 | { |
---|
331 | for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++) |
---|
332 | { |
---|
333 | WRITE_UVLC( pcPPS->getColumnWidth(i), "column_width" ); |
---|
334 | } |
---|
335 | for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++) |
---|
336 | { |
---|
337 | WRITE_UVLC( pcPPS->getRowHeight(i), "row_height" ); |
---|
338 | } |
---|
339 | } |
---|
340 | } |
---|
341 | |
---|
342 | if(pcPPS->getTileBehaviorControlPresentFlag() == 1) |
---|
343 | { |
---|
344 | Int iNumColTilesMinus1 = (pcPPS->getColumnRowInfoPresent() == 1)?(pcPPS->getNumColumnsMinus1()):(pcPPS->getSPS()->getNumColumnsMinus1()); |
---|
345 | Int iNumRowTilesMinus1 = (pcPPS->getColumnRowInfoPresent() == 1)?(pcPPS->getNumColumnsMinus1()):(pcPPS->getSPS()->getNumRowsMinus1()); |
---|
346 | |
---|
347 | if(iNumColTilesMinus1 !=0 || iNumRowTilesMinus1 !=0) |
---|
348 | { |
---|
349 | #if !REMOVE_TILE_DEPENDENCE |
---|
350 | WRITE_FLAG( pcPPS->getTileBoundaryIndependenceIdr(), "tile_boundary_independence_flag" ); |
---|
351 | if(pcPPS->getTileBoundaryIndependenceIdr() == 1) |
---|
352 | { |
---|
353 | #endif |
---|
354 | WRITE_FLAG( pcPPS->getLFCrossTileBoundaryFlag()?1 : 0, "loop_filter_across_tile_flag"); |
---|
355 | #if !REMOVE_TILE_DEPENDENCE |
---|
356 | } |
---|
357 | #endif |
---|
358 | } |
---|
359 | } |
---|
360 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
361 | } |
---|
362 | else if(pcPPS->getSPS()->getTilesOrEntropyCodingSyncIdc()==2) |
---|
363 | { |
---|
364 | WRITE_UVLC( pcPPS->getNumSubstreams()-1, "num_substreams_minus1" ); |
---|
365 | } |
---|
366 | #endif |
---|
367 | |
---|
368 | #if DBL_CONTROL |
---|
369 | WRITE_FLAG( pcPPS->getDeblockingFilterControlPresent()?1 : 0, "deblocking_filter_control_present_flag"); |
---|
370 | #endif |
---|
371 | #if PARALLEL_MERGE |
---|
372 | WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2"); |
---|
373 | #endif |
---|
374 | WRITE_FLAG( 0, "pps_extension_flag" ); |
---|
375 | } |
---|
376 | |
---|
377 | #if QC_MVHEVC_B0046 |
---|
378 | Void TEncCavlc::codeVPS( TComVPS* pcVPS ) |
---|
379 | { |
---|
380 | WRITE_CODE( pcVPS->getVPSId(), 4, "video_parameter_set_id" ); |
---|
381 | WRITE_FLAG( pcVPS->getTemporalNestingFlag() -1, "temporal_id_nesting_flag" ); |
---|
382 | WRITE_CODE( 0, 2, "vps_reserved_zero_2bits" ); |
---|
383 | WRITE_CODE( pcVPS->getMaxLayers() - 1, 6, "vps_max_layers_minus1" ); |
---|
384 | WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "vps_max_sub_layers_minus1" ); |
---|
385 | //to be determined |
---|
386 | //profile_tier_level( 1, vps_max_sub_layers_minus1 ); |
---|
387 | //to be modified |
---|
388 | WRITE_CODE( 0, 12, "vps_extension_offset" ); |
---|
389 | for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
390 | { |
---|
391 | WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i), "max_dec_pic_buffering[i]" ); |
---|
392 | WRITE_UVLC( pcVPS->getNumReorderPics(i), "num_reorder_pics[i]" ); |
---|
393 | WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "max_latency_increase[i]" ); |
---|
394 | } |
---|
395 | //!!!waste one bit: 3-view, 3; 2-view or more views: 1 |
---|
396 | WRITE_UVLC(pcVPS->getNumHRDParameters(), "vps_num_hrd_parameters" ); |
---|
397 | assert(pcVPS->getNumHRDParameters()==0); |
---|
398 | for ( UInt i = 0; i < pcVPS->getNumHRDParameters(); i ++) |
---|
399 | { |
---|
400 | // if( i > 0 ) |
---|
401 | //{ |
---|
402 | // WRITE_UVLC (0, "op_num_layer_id_values_minus1[ opIdx ]"); |
---|
403 | // for( i = 0; i <= op_num_layer_id_values_minus1[ opIdx ]; i++ ) |
---|
404 | // WRITE_CODE(0, 6, "op_layer_id[ opIdx ][ i ]"); |
---|
405 | //} |
---|
406 | //hrd_parameters( i = = 0, vps_max_sub_layers_minus1 ); |
---|
407 | } |
---|
408 | WRITE_CODE( 1, 1, "bit_equal_to_one" ); |
---|
409 | //btye aligned |
---|
410 | m_pcBitIf->writeAlignOne(); |
---|
411 | |
---|
412 | if(pcVPS->getMaxLayers() == 3) |
---|
413 | pcVPS->setNumAddiLayerOperationPoints (pcVPS->getMaxLayers()); //may be configured |
---|
414 | else |
---|
415 | pcVPS->setNumAddiLayerOperationPoints (1); |
---|
416 | pcVPS->setNumAddiProLevelSets (1); |
---|
417 | WRITE_CODE( pcVPS->getNumAddiLayerOperationPoints(), 8, "num_additional_layer_operation_points" ); |
---|
418 | WRITE_CODE( pcVPS->getNumAddiProLevelSets(), 8, "num_additional_profile_level_sets" ); |
---|
419 | for(UInt i=0; i <= pcVPS->getMaxLayers()-1; i++) |
---|
420 | { |
---|
421 | WRITE_CODE( 0, 4, "num_types_zero_4bits[i]" ); |
---|
422 | WRITE_CODE( 0, 4, "type_zero_4bits[i]" ); |
---|
423 | WRITE_CODE( pcVPS->getViewId(i), 8, "view_id[i]" ); |
---|
424 | if(i) |
---|
425 | { |
---|
426 | WRITE_CODE( pcVPS->getNumDirectRefLayer(i), 6, "num_direct_ref_layers[ i ]" ); |
---|
427 | for (UInt j = 0; j< pcVPS->getNumDirectRefLayer(i); j++) |
---|
428 | { |
---|
429 | WRITE_CODE( pcVPS->getDirectRefLayerId (i, j), 6, "ref_layer_id[i][j]" ); |
---|
430 | } |
---|
431 | } |
---|
432 | } |
---|
433 | for( UInt i=1; i<=pcVPS->getNumAddiProLevelSets(); i++) |
---|
434 | { |
---|
435 | //profile_tier_level |
---|
436 | } |
---|
437 | for( UInt i=1; i<= pcVPS->getNumAddiLayerOperationPoints(); i++) |
---|
438 | { |
---|
439 | if(pcVPS->getMaxLayers() == 3) |
---|
440 | { |
---|
441 | pcVPS->setNumOpLayerIdMinus1((i < pcVPS->getNumAddiLayerOperationPoints() ? 1: 2), (i-1)); |
---|
442 | } |
---|
443 | else if( i==1 ) |
---|
444 | { |
---|
445 | assert(pcVPS->getNumAddiLayerOperationPoints()==1); |
---|
446 | pcVPS->setNumOpLayerIdMinus1(pcVPS->getMaxLayers()-1, (i-1)); |
---|
447 | } |
---|
448 | WRITE_UVLC( pcVPS->getNumOpLayerIdMinus1(i-1), "op_num_layer_id_values_minus1[ opIdx ]" ); |
---|
449 | for(UInt j = 0; j <= pcVPS->getNumOpLayerIdMinus1(i-1); j++ ) |
---|
450 | { |
---|
451 | if(pcVPS->getMaxLayers() == 3 && i== 2 && j==1) |
---|
452 | pcVPS->setNumOpLayerId (2, i-1, j); |
---|
453 | else |
---|
454 | pcVPS->setNumOpLayerId (j, i-1, j); |
---|
455 | WRITE_UVLC( pcVPS->getNumOpLayerId(i-1, j), "op_layer_id[ opIdx ][ i ]" ); |
---|
456 | } |
---|
457 | if (pcVPS->getNumAddiProLevelSets()) |
---|
458 | { |
---|
459 | //profile_level_idx[ i ] |
---|
460 | } |
---|
461 | } |
---|
462 | return; |
---|
463 | } |
---|
464 | #else |
---|
465 | #if VIDYO_VPS_INTEGRATION |
---|
466 | Void TEncCavlc::codeVPS( TComVPS* pcVPS ) |
---|
467 | { |
---|
468 | WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "max_temporal_layers_minus1" ); |
---|
469 | WRITE_CODE( pcVPS->getMaxLayers() - 1, 5, "max_layers_minus1" ); |
---|
470 | WRITE_FLAG( pcVPS->getTemporalNestingFlag() - 1, "temporal_id_nesting_flag" ); |
---|
471 | WRITE_UVLC( pcVPS->getVPSId(), "video_parameter_set_id" ); |
---|
472 | for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
473 | { |
---|
474 | WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i), "max_dec_pic_buffering[i]" ); |
---|
475 | WRITE_UVLC( pcVPS->getNumReorderPics(i), "num_reorder_pics[i]" ); |
---|
476 | WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "max_latency_increase[i]" ); |
---|
477 | } |
---|
478 | |
---|
479 | WRITE_CODE( 1, 1, "bit_equal_to_one" ); |
---|
480 | |
---|
481 | if( pcVPS->getMaxLayers() - 1 > 0 ) |
---|
482 | { |
---|
483 | WRITE_UVLC( pcVPS->getExtensionType(), "extension_type" ); |
---|
484 | |
---|
485 | for(UInt i=1; i <= pcVPS->getMaxLayers()-1; i++) |
---|
486 | { |
---|
487 | WRITE_FLAG( pcVPS->getDependentFlag(i), "dependent_flag[i]" ); |
---|
488 | if( pcVPS->getDependentFlag(i) ) |
---|
489 | { |
---|
490 | WRITE_UVLC( i - pcVPS->getDependentLayer(i) - 1, "delta_reference_layer_id_minus1[i]" ); |
---|
491 | if( pcVPS->getExtensionType() == VPS_EXTENSION_TYPE_MULTI_VIEW ) |
---|
492 | { |
---|
493 | WRITE_UVLC( pcVPS->getViewId(i), "view_id[i]" ); |
---|
494 | WRITE_FLAG( pcVPS->getDepthFlag(i), "depth_flag[i]" ); |
---|
495 | WRITE_SVLC( pcVPS->getViewOrderIdx(i), "view_order_idx[i]" ); |
---|
496 | } |
---|
497 | |
---|
498 | } |
---|
499 | } |
---|
500 | #if INTER_VIEW_VECTOR_SCALING_C0115 |
---|
501 | WRITE_FLAG( pcVPS->getIVScalingFlag(), "inter_view_vector_scaling_flag" ); |
---|
502 | #endif |
---|
503 | } |
---|
504 | |
---|
505 | WRITE_FLAG( 0, "vps_extension_flag" ); |
---|
506 | |
---|
507 | //future extensions here.. |
---|
508 | |
---|
509 | return; |
---|
510 | } |
---|
511 | #endif |
---|
512 | #endif |
---|
513 | #if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068 |
---|
514 | Void TEncCavlc::codeSPS( TComSPS* pcSPS, Bool bIsDepth ) |
---|
515 | #else |
---|
516 | Void TEncCavlc::codeSPS( TComSPS* pcSPS ) |
---|
517 | #endif |
---|
518 | { |
---|
519 | #if ENC_DEC_TRACE |
---|
520 | xTraceSPSHeader (pcSPS); |
---|
521 | #endif |
---|
522 | WRITE_CODE( pcSPS->getProfileIdc (), 8, "profile_idc" ); |
---|
523 | WRITE_CODE( 0, 8, "reserved_zero_8bits" ); |
---|
524 | WRITE_CODE( pcSPS->getLevelIdc (), 8, "level_idc" ); |
---|
525 | WRITE_UVLC( pcSPS->getSPSId (), "seq_parameter_set_id" ); |
---|
526 | #if VIDYO_VPS_INTEGRATION |
---|
527 | WRITE_UVLC( pcSPS->getVPSId (), "video_parameter_set_id" ); |
---|
528 | #endif |
---|
529 | WRITE_UVLC( pcSPS->getChromaFormatIdc (), "chroma_format_idc" ); |
---|
530 | WRITE_CODE( pcSPS->getMaxTLayers() - 1, 3, "max_temporal_layers_minus1" ); |
---|
531 | WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (), "pic_width_in_luma_samples" ); |
---|
532 | WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" ); |
---|
533 | #if PIC_CROPPING |
---|
534 | WRITE_FLAG( pcSPS->getPicCroppingFlag(), "pic_cropping_flag" ); |
---|
535 | if (pcSPS->getPicCroppingFlag()) |
---|
536 | { |
---|
537 | WRITE_UVLC( pcSPS->getPicCropLeftOffset(), "pic_crop_left_offset" ); |
---|
538 | WRITE_UVLC( pcSPS->getPicCropRightOffset(), "pic_crop_right_offset" ); |
---|
539 | WRITE_UVLC( pcSPS->getPicCropTopOffset(), "pic_crop_top_offset" ); |
---|
540 | WRITE_UVLC( pcSPS->getPicCropBottomOffset(), "pic_crop_bottom_offset" ); |
---|
541 | } |
---|
542 | #endif |
---|
543 | |
---|
544 | #if FULL_NBIT |
---|
545 | WRITE_UVLC( pcSPS->getBitDepth() - 8, "bit_depth_luma_minus8" ); |
---|
546 | #else |
---|
547 | WRITE_UVLC( pcSPS->getBitIncrement(), "bit_depth_luma_minus8" ); |
---|
548 | #endif |
---|
549 | #if FULL_NBIT |
---|
550 | WRITE_UVLC( pcSPS->getBitDepth() - 8, "bit_depth_chroma_minus8" ); |
---|
551 | #else |
---|
552 | WRITE_UVLC( pcSPS->getBitIncrement(), "bit_depth_chroma_minus8" ); |
---|
553 | #endif |
---|
554 | |
---|
555 | WRITE_FLAG( pcSPS->getUsePCM() ? 1 : 0, "pcm_enabled_flag"); |
---|
556 | |
---|
557 | if( pcSPS->getUsePCM() ) |
---|
558 | { |
---|
559 | WRITE_CODE( pcSPS->getPCMBitDepthLuma() - 1, 4, "pcm_bit_depth_luma_minus1" ); |
---|
560 | WRITE_CODE( pcSPS->getPCMBitDepthChroma() - 1, 4, "pcm_bit_depth_chroma_minus1" ); |
---|
561 | } |
---|
562 | |
---|
563 | #if LOSSLESS_CODING |
---|
564 | WRITE_FLAG( (pcSPS->getUseLossless ()) ? 1 : 0, "qpprime_y_zero_transquant_bypass_flag" ); |
---|
565 | #endif |
---|
566 | |
---|
567 | WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" ); |
---|
568 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
569 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
570 | { |
---|
571 | WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i), "max_dec_pic_buffering[i]" ); |
---|
572 | WRITE_UVLC( pcSPS->getNumReorderPics(i), "num_reorder_pics[i]" ); |
---|
573 | WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i), "max_latency_increase[i]" ); |
---|
574 | } |
---|
575 | #else |
---|
576 | WRITE_UVLC( pcSPS->getMaxNumberOfReferencePictures(), "max_num_ref_pics" ); |
---|
577 | WRITE_UVLC( pcSPS->getNumReorderFrames(), "num_reorder_frames" ); |
---|
578 | WRITE_UVLC(pcSPS->getMaxDecFrameBuffering(), "max_dec_frame_buffering" ); |
---|
579 | WRITE_UVLC(pcSPS->getMaxLatencyIncrease(), "max_latency_increase" ); |
---|
580 | #endif |
---|
581 | assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() ); |
---|
582 | |
---|
583 | UInt MinCUSize = pcSPS->getMaxCUWidth() >> ( pcSPS->getMaxCUDepth()-g_uiAddCUDepth ); |
---|
584 | UInt log2MinCUSize = 0; |
---|
585 | while(MinCUSize > 1) |
---|
586 | { |
---|
587 | MinCUSize >>= 1; |
---|
588 | log2MinCUSize++; |
---|
589 | } |
---|
590 | |
---|
591 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
592 | WRITE_FLAG( pcSPS->getRestrictedRefPicListsFlag(), "restricted_ref_pic_lists_flag" ); |
---|
593 | if( pcSPS->getRestrictedRefPicListsFlag() ) |
---|
594 | { |
---|
595 | WRITE_FLAG( pcSPS->getListsModificationPresentFlag(), "lists_modification_present_flag" ); |
---|
596 | } |
---|
597 | #endif |
---|
598 | WRITE_UVLC( log2MinCUSize - 3, "log2_min_coding_block_size_minus3" ); |
---|
599 | WRITE_UVLC( pcSPS->getMaxCUDepth()-g_uiAddCUDepth, "log2_diff_max_min_coding_block_size" ); |
---|
600 | WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2, "log2_min_transform_block_size_minus2" ); |
---|
601 | WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_transform_block_size" ); |
---|
602 | |
---|
603 | if(log2MinCUSize == 3) |
---|
604 | { |
---|
605 | xWriteFlag ( (pcSPS->getDisInter4x4()) ? 1 : 0 ); |
---|
606 | } |
---|
607 | |
---|
608 | if( pcSPS->getUsePCM() ) |
---|
609 | { |
---|
610 | WRITE_UVLC( pcSPS->getPCMLog2MinSize() - 3, "log2_min_pcm_coding_block_size_minus3" ); |
---|
611 | WRITE_UVLC( pcSPS->getPCMLog2MaxSize() - pcSPS->getPCMLog2MinSize(), "log2_diff_max_min_pcm_coding_block_size" ); |
---|
612 | } |
---|
613 | WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthInter() - 1, "max_transform_hierarchy_depth_inter" ); |
---|
614 | WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthIntra() - 1, "max_transform_hierarchy_depth_intra" ); |
---|
615 | WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0, "scaling_list_enabled_flag" ); |
---|
616 | WRITE_FLAG( pcSPS->getUseLMChroma () ? 1 : 0, "chroma_pred_from_luma_enabled_flag" ); |
---|
617 | WRITE_FLAG( pcSPS->getUseDF() ? 1 : 0, "deblocking_filter_in_aps_enabled_flag"); |
---|
618 | WRITE_FLAG( pcSPS->getLFCrossSliceBoundaryFlag()?1 : 0, "seq_loop_filter_across_slices_enabled_flag"); |
---|
619 | WRITE_FLAG( pcSPS->getUseAMP(), "asymmetric_motion_partitions_enabled_flag" ); |
---|
620 | WRITE_FLAG( pcSPS->getUseNSQT(), "non_square_quadtree_enabled_flag" ); |
---|
621 | WRITE_FLAG( pcSPS->getUseSAO() ? 1 : 0, "sample_adaptive_offset_enabled_flag"); |
---|
622 | WRITE_FLAG( pcSPS->getUseALF () ? 1 : 0, "adaptive_loop_filter_enabled_flag"); |
---|
623 | #if LCU_SYNTAX_ALF |
---|
624 | if(pcSPS->getUseALF()) |
---|
625 | { |
---|
626 | WRITE_FLAG( (pcSPS->getUseALFCoefInSlice()) ? 1 : 0, "alf_coef_in_slice_flag"); |
---|
627 | } |
---|
628 | #endif |
---|
629 | |
---|
630 | if( pcSPS->getUsePCM() ) |
---|
631 | { |
---|
632 | WRITE_FLAG( pcSPS->getPCMFilterDisableFlag()?1 : 0, "pcm_loop_filter_disable_flag"); |
---|
633 | } |
---|
634 | |
---|
635 | assert( pcSPS->getMaxTLayers() > 0 ); |
---|
636 | |
---|
637 | WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "temporal_id_nesting_flag" ); |
---|
638 | |
---|
639 | #if RPS_IN_SPS |
---|
640 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
641 | TComReferencePictureSet* rps; |
---|
642 | |
---|
643 | WRITE_UVLC(rpsList->getNumberOfReferencePictureSets(), "num_short_term_ref_pic_sets" ); |
---|
644 | for(Int i=0; i < rpsList->getNumberOfReferencePictureSets(); i++) |
---|
645 | { |
---|
646 | rps = rpsList->getReferencePictureSet(i); |
---|
647 | codeShortTermRefPicSet(pcSPS,rps); |
---|
648 | } |
---|
649 | WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_present_flag" ); |
---|
650 | #endif |
---|
651 | #if !PIC_CROPPING |
---|
652 | //!!!KS: Syntax not in WD !!! |
---|
653 | |
---|
654 | xWriteUvlc ( pcSPS->getPad (0) ); |
---|
655 | xWriteUvlc ( pcSPS->getPad (1) ); |
---|
656 | #endif |
---|
657 | // AMVP mode for each depth |
---|
658 | for (Int i = 0; i < pcSPS->getMaxCUDepth(); i++) |
---|
659 | { |
---|
660 | xWriteFlag( pcSPS->getAMVPMode(i) ? 1 : 0); |
---|
661 | } |
---|
662 | |
---|
663 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
664 | Int tilesOrEntropyCodingSyncIdc = 0; |
---|
665 | if ( pcSPS->getNumColumnsMinus1() > 0 || pcSPS->getNumRowsMinus1() > 0) |
---|
666 | { |
---|
667 | tilesOrEntropyCodingSyncIdc = 1; |
---|
668 | } |
---|
669 | else if ( pcSPS->getNumSubstreams() > 1 ) |
---|
670 | { |
---|
671 | tilesOrEntropyCodingSyncIdc = 2; |
---|
672 | } |
---|
673 | pcSPS->setTilesOrEntropyCodingSyncIdc( tilesOrEntropyCodingSyncIdc ); |
---|
674 | WRITE_CODE(tilesOrEntropyCodingSyncIdc, 2, "tiles_or_entropy_coding_sync_idc"); |
---|
675 | #endif |
---|
676 | |
---|
677 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
678 | if(tilesOrEntropyCodingSyncIdc == 1) |
---|
679 | { |
---|
680 | #endif |
---|
681 | WRITE_UVLC( pcSPS->getNumColumnsMinus1(), "num_tile_columns_minus1" ); |
---|
682 | WRITE_UVLC( pcSPS->getNumRowsMinus1(), "num_tile_rows_minus1" ); |
---|
683 | WRITE_FLAG( pcSPS->getUniformSpacingIdr(), "uniform_spacing_flag" ); |
---|
684 | |
---|
685 | if( pcSPS->getUniformSpacingIdr()==0 ) |
---|
686 | { |
---|
687 | for(UInt i=0; i<pcSPS->getNumColumnsMinus1(); i++) |
---|
688 | { |
---|
689 | WRITE_UVLC( pcSPS->getColumnWidth(i), "column_width" ); |
---|
690 | } |
---|
691 | for(UInt i=0; i<pcSPS->getNumRowsMinus1(); i++) |
---|
692 | { |
---|
693 | WRITE_UVLC( pcSPS->getRowHeight(i), "row_height" ); |
---|
694 | } |
---|
695 | } |
---|
696 | |
---|
697 | if( pcSPS->getNumColumnsMinus1() !=0 || pcSPS->getNumRowsMinus1() != 0) |
---|
698 | { |
---|
699 | #if !REMOVE_TILE_DEPENDENCE |
---|
700 | WRITE_FLAG( pcSPS->getTileBoundaryIndependenceIdr(), "tile_boundary_independence_flag" ); |
---|
701 | if(pcSPS->getTileBoundaryIndependenceIdr() == 1) |
---|
702 | { |
---|
703 | #endif |
---|
704 | WRITE_FLAG( pcSPS->getLFCrossTileBoundaryFlag()?1 : 0, "loop_filter_across_tile_flag"); |
---|
705 | #if !REMOVE_TILE_DEPENDENCE |
---|
706 | } |
---|
707 | #endif |
---|
708 | } |
---|
709 | #if TILES_OR_ENTROPY_SYNC_IDC |
---|
710 | } |
---|
711 | #endif |
---|
712 | WRITE_FLAG( 1, "sps_extension_flag" ); |
---|
713 | #if !QC_MVHEVC_B0046 |
---|
714 | WRITE_FLAG( (pcSPS->getNumberOfUsableInterViewRefs() > 0) ? 1 : 0, "interview_refs_present_flag" ); |
---|
715 | if( pcSPS->getNumberOfUsableInterViewRefs() > 0 ) |
---|
716 | { |
---|
717 | WRITE_UVLC( pcSPS->getNumberOfUsableInterViewRefs() - 1, "num_usable_interview_refs_minus1" ); |
---|
718 | |
---|
719 | Int prev = 0; |
---|
720 | for( Int j = 0 ; j < pcSPS->getNumberOfUsableInterViewRefs(); j++ ) |
---|
721 | { |
---|
722 | WRITE_UVLC( prev - pcSPS->getUsableInterViewRef( j ) - 1, "delta_usable_interview_ref_minus1" ); |
---|
723 | prev = pcSPS->getUsableInterViewRef( j ); |
---|
724 | } |
---|
725 | } |
---|
726 | |
---|
727 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
728 | WRITE_FLAG( pcSPS->getUseDMM(), "enable_dmm_flag" ); |
---|
729 | #endif |
---|
730 | |
---|
731 | #if HHI_MPI |
---|
732 | if( bIsDepth ) |
---|
733 | { |
---|
734 | WRITE_FLAG( pcSPS->getUseMVI() ? 1 : 0, "use_mvi_flag" ); |
---|
735 | } |
---|
736 | #endif |
---|
737 | |
---|
738 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
739 | if( bIsDepth ) |
---|
740 | { |
---|
741 | WRITE_FLAG( pcSPS->getUseQTLPC() ? 1 : 0, "use_qtlpc_flag"); |
---|
742 | } |
---|
743 | #endif |
---|
744 | |
---|
745 | #if RWTH_SDC_DLT_B0036 |
---|
746 | if( bIsDepth ) |
---|
747 | { |
---|
748 | WRITE_FLAG( pcSPS->getUseDLT() ? 1 : 0, "use_dlt_flag" ); |
---|
749 | if( pcSPS->getUseDLT() ) |
---|
750 | { |
---|
751 | // code mapping |
---|
752 | xWriteUvlc ( pcSPS->getNumDepthValues() ); |
---|
753 | for(UInt i=0; i<pcSPS->getNumDepthValues(); i++) |
---|
754 | { |
---|
755 | xWriteUvlc( pcSPS->idx2DepthValue(i) ); |
---|
756 | } |
---|
757 | } |
---|
758 | } |
---|
759 | #endif |
---|
760 | |
---|
761 | if( pcSPS->getViewId() || pcSPS->isDepth() ) |
---|
762 | { |
---|
763 | WRITE_FLAG( 0, "base_view_flag" ); |
---|
764 | if( pcSPS->isDepth() ) |
---|
765 | { |
---|
766 | WRITE_FLAG( 1, "depth_flag" ); |
---|
767 | WRITE_UVLC( pcSPS->getViewId(), "view_id" ); |
---|
768 | WRITE_SVLC( pcSPS->getViewOrderIdx(), "view_order_idx" ); |
---|
769 | } |
---|
770 | else |
---|
771 | { |
---|
772 | WRITE_FLAG( 0, "depth_flag" ); |
---|
773 | WRITE_UVLC( pcSPS->getViewId() - 1, "view_id_minus1" ); |
---|
774 | WRITE_SVLC( pcSPS->getViewOrderIdx(), "view_order_idx" ); |
---|
775 | WRITE_UVLC( pcSPS->getCamParPrecision(), "camera_parameter_precision" ); |
---|
776 | WRITE_FLAG( pcSPS->hasCamParInSliceHeader() ? 1 : 0, "camera_parameter_in_slice_header" ); |
---|
777 | if( !pcSPS->hasCamParInSliceHeader() ) |
---|
778 | { |
---|
779 | for( UInt uiId = 0; uiId < pcSPS->getViewId(); uiId++ ) |
---|
780 | { |
---|
781 | WRITE_SVLC( pcSPS->getCodedScale ()[ uiId ], "coded_scale" ); |
---|
782 | WRITE_SVLC( pcSPS->getCodedOffset ()[ uiId ], "coded_offset" ); |
---|
783 | WRITE_SVLC( pcSPS->getInvCodedScale ()[ uiId ] + pcSPS->getCodedScale ()[ uiId ], "inverse_coded_scale_plus_coded_scale" ); |
---|
784 | WRITE_SVLC( pcSPS->getInvCodedOffset()[ uiId ] + pcSPS->getCodedOffset()[ uiId ], "inverse_coded_offset_plus_coded_offset" ); |
---|
785 | } |
---|
786 | } |
---|
787 | #if DEPTH_MAP_GENERATION |
---|
788 | WRITE_UVLC( pcSPS->getPredDepthMapGeneration(), "Pdm_generation" ); |
---|
789 | if( pcSPS->getPredDepthMapGeneration() ) |
---|
790 | { |
---|
791 | WRITE_UVLC( pcSPS->getPdmPrecision(), "Pdm_precision" ); |
---|
792 | for( UInt uiId = 0; uiId < pcSPS->getViewId(); uiId++ ) |
---|
793 | { |
---|
794 | WRITE_SVLC( pcSPS->getPdmScaleNomDelta()[ uiId ], "Pdm_scale_nom_delta" ); |
---|
795 | WRITE_SVLC( pcSPS->getPdmOffset ()[ uiId ], "Pdm_offset" ); |
---|
796 | } |
---|
797 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
798 | WRITE_UVLC( pcSPS->getMultiviewMvPredMode(), "multi_view_mv_pred_mode" ); |
---|
799 | #endif |
---|
800 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
801 | WRITE_FLAG ( pcSPS->getMultiviewResPredMode(), "multi_view_residual_pred_mode" ); |
---|
802 | #endif |
---|
803 | } |
---|
804 | #endif |
---|
805 | } |
---|
806 | } |
---|
807 | else |
---|
808 | { |
---|
809 | WRITE_FLAG( 1, "base_view_flag" ); |
---|
810 | } |
---|
811 | WRITE_FLAG( 0, "sps_extension2_flag" ); |
---|
812 | #endif |
---|
813 | } |
---|
814 | |
---|
815 | Void TEncCavlc::writeTileMarker( UInt uiTileIdx, UInt uiBitsUsed ) |
---|
816 | { |
---|
817 | xWriteCode( uiTileIdx, uiBitsUsed ); |
---|
818 | } |
---|
819 | |
---|
820 | Void TEncCavlc::codeSliceHeader ( TComSlice* pcSlice ) |
---|
821 | { |
---|
822 | #if ENC_DEC_TRACE |
---|
823 | xTraceSliceHeader (pcSlice); |
---|
824 | #endif |
---|
825 | |
---|
826 | // if( nal_ref_idc != 0 ) |
---|
827 | // dec_ref_pic_marking( ) |
---|
828 | // if( entropy_coding_mode_flag && slice_type != I) |
---|
829 | // cabac_init_idc |
---|
830 | // first_slice_in_pic_flag |
---|
831 | // if( first_slice_in_pic_flag == 0 ) |
---|
832 | // slice_address |
---|
833 | //calculate number of bits required for slice address |
---|
834 | Int maxAddrOuter = pcSlice->getPic()->getNumCUsInFrame(); |
---|
835 | Int reqBitsOuter = 0; |
---|
836 | while(maxAddrOuter>(1<<reqBitsOuter)) |
---|
837 | { |
---|
838 | reqBitsOuter++; |
---|
839 | } |
---|
840 | Int maxAddrInner = pcSlice->getPic()->getNumPartInCU()>>(2); |
---|
841 | maxAddrInner = (1<<(pcSlice->getPPS()->getSliceGranularity()<<1)); |
---|
842 | Int reqBitsInner = 0; |
---|
843 | |
---|
844 | while(maxAddrInner>(1<<reqBitsInner)) |
---|
845 | { |
---|
846 | reqBitsInner++; |
---|
847 | } |
---|
848 | Int lCUAddress; |
---|
849 | Int innerAddress; |
---|
850 | if (pcSlice->isNextSlice()) |
---|
851 | { |
---|
852 | // Calculate slice address |
---|
853 | lCUAddress = (pcSlice->getSliceCurStartCUAddr()/pcSlice->getPic()->getNumPartInCU()); |
---|
854 | innerAddress = (pcSlice->getSliceCurStartCUAddr()%(pcSlice->getPic()->getNumPartInCU()))>>((pcSlice->getSPS()->getMaxCUDepth()-pcSlice->getPPS()->getSliceGranularity())<<1); |
---|
855 | } |
---|
856 | else |
---|
857 | { |
---|
858 | // Calculate slice address |
---|
859 | lCUAddress = (pcSlice->getEntropySliceCurStartCUAddr()/pcSlice->getPic()->getNumPartInCU()); |
---|
860 | innerAddress = (pcSlice->getEntropySliceCurStartCUAddr()%(pcSlice->getPic()->getNumPartInCU()))>>((pcSlice->getSPS()->getMaxCUDepth()-pcSlice->getPPS()->getSliceGranularity())<<1); |
---|
861 | |
---|
862 | } |
---|
863 | //write slice address |
---|
864 | Int address = (pcSlice->getPic()->getPicSym()->getCUOrderMap(lCUAddress) << reqBitsInner) + innerAddress; |
---|
865 | WRITE_FLAG( address==0, "first_slice_in_pic_flag" ); |
---|
866 | |
---|
867 | #if LGE_ILLUCOMP_B0045 |
---|
868 | // IC flag is on only first_slice_in_pic |
---|
869 | if (address==0) |
---|
870 | { |
---|
871 | if( pcSlice->getSPS()->getViewId() && !pcSlice->getIsDepth() ) |
---|
872 | { |
---|
873 | WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "applying IC flag" ); |
---|
874 | } |
---|
875 | } |
---|
876 | #endif |
---|
877 | |
---|
878 | if(address>0) |
---|
879 | { |
---|
880 | WRITE_CODE( address, reqBitsOuter+reqBitsInner, "slice_address" ); |
---|
881 | } |
---|
882 | |
---|
883 | WRITE_UVLC( pcSlice->getSliceType(), "slice_type" ); |
---|
884 | Bool bEntropySlice = (!pcSlice->isNextSlice()); |
---|
885 | WRITE_FLAG( bEntropySlice ? 1 : 0, "lightweight_slice_flag" ); |
---|
886 | |
---|
887 | if (!bEntropySlice) |
---|
888 | { |
---|
889 | #if QC_MVHEVC_B0046 |
---|
890 | WRITE_UVLC( 0, "pic_parameter_set_id" ); |
---|
891 | #else |
---|
892 | WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "pic_parameter_set_id" ); |
---|
893 | #endif |
---|
894 | #if H0388 |
---|
895 | if( pcSlice->getPPS()->getOutputFlagPresentFlag() ) |
---|
896 | { |
---|
897 | WRITE_FLAG( pcSlice->getPicOutputFlag() ? 1 : 0, "pic_output_flag" ); |
---|
898 | } |
---|
899 | #endif |
---|
900 | #if QC_REM_IDV_B0046 |
---|
901 | if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR && pcSlice->getViewId() == 0) |
---|
902 | #else |
---|
903 | if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR) |
---|
904 | #endif |
---|
905 | { |
---|
906 | WRITE_UVLC( 0, "idr_pic_id" ); |
---|
907 | WRITE_FLAG( 0, "no_output_of_prior_pics_flag" ); |
---|
908 | } |
---|
909 | else |
---|
910 | { |
---|
911 | WRITE_CODE( (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC()))%(1<<pcSlice->getSPS()->getBitsForPOC()), pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb"); |
---|
912 | #if QC_REM_IDV_B0046 |
---|
913 | if( pcSlice->getPOC() == 0 && !(pcSlice->getSPS()->getViewId() && (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA))) |
---|
914 | #else |
---|
915 | if( pcSlice->getPOC() == 0 && pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDV ) |
---|
916 | #endif |
---|
917 | { |
---|
918 | TComReferencePictureSet* rps = pcSlice->getRPS(); |
---|
919 | if(pcSlice->getRPSidx() < 0) |
---|
920 | { |
---|
921 | WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); |
---|
922 | #if RPS_IN_SPS |
---|
923 | codeShortTermRefPicSet(pcSlice->getSPS(), rps); |
---|
924 | #else |
---|
925 | codeShortTermRefPicSet(pcSlice->getPPS(), rps); |
---|
926 | #endif |
---|
927 | } |
---|
928 | else |
---|
929 | { |
---|
930 | WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag"); |
---|
931 | WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" ); |
---|
932 | } |
---|
933 | #if RPS_IN_SPS |
---|
934 | if(pcSlice->getSPS()->getLongTermRefsPresent()) |
---|
935 | #else |
---|
936 | if(pcSlice->getPPS()->getLongTermRefsPresent()) |
---|
937 | #endif |
---|
938 | { |
---|
939 | WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics"); |
---|
940 | Int maxPocLsb = 1<<pcSlice->getSPS()->getBitsForPOC(); |
---|
941 | Int prev = 0; |
---|
942 | #if LTRP_MULT |
---|
943 | Int prevDeltaPocLt=0; |
---|
944 | Int currDeltaPocLt=0; |
---|
945 | #endif |
---|
946 | for(Int i=rps->getNumberOfPictures()-1 ; i > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; i--) |
---|
947 | { |
---|
948 | WRITE_UVLC((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb, "delta_poc_lsb_lt"); |
---|
949 | |
---|
950 | #if LTRP_MULT |
---|
951 | currDeltaPocLt=((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb)+prevDeltaPocLt; |
---|
952 | |
---|
953 | Int deltaMsbCycle=0; |
---|
954 | if( (i==(rps->getNumberOfPictures()-1)) ) |
---|
955 | { |
---|
956 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
957 | } |
---|
958 | else if( prevDeltaPocLt!=currDeltaPocLt ) |
---|
959 | { |
---|
960 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
961 | if( ((prevDeltaPocLt==maxPocLsb-1) && (currDeltaPocLt==maxPocLsb+1)) || ((prevDeltaPocLt==maxPocLsb-2) && (currDeltaPocLt==maxPocLsb))) |
---|
962 | { |
---|
963 | deltaMsbCycle=deltaMsbCycle-1; |
---|
964 | } |
---|
965 | } |
---|
966 | else |
---|
967 | { |
---|
968 | deltaMsbCycle=((rps->getDeltaPOC(i+1)-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
969 | } |
---|
970 | |
---|
971 | if(deltaMsbCycle>=0) |
---|
972 | { |
---|
973 | WRITE_FLAG( 1, "delta_poc_msb_present_flag"); |
---|
974 | WRITE_UVLC(deltaMsbCycle, "delta_poc_msb_cycle_lt_minus1"); |
---|
975 | } |
---|
976 | else |
---|
977 | { |
---|
978 | WRITE_FLAG( 0, "delta_poc_msb_present_flag"); |
---|
979 | } |
---|
980 | prevDeltaPocLt=currDeltaPocLt; |
---|
981 | #endif |
---|
982 | prev = rps->getDeltaPOC(i); |
---|
983 | WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); |
---|
984 | } |
---|
985 | } |
---|
986 | } |
---|
987 | if( pcSlice->getPOC() != 0 ) |
---|
988 | { |
---|
989 | TComReferencePictureSet* rps = pcSlice->getRPS(); |
---|
990 | if(pcSlice->getRPSidx() < 0) |
---|
991 | { |
---|
992 | WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); |
---|
993 | #if RPS_IN_SPS |
---|
994 | codeShortTermRefPicSet(pcSlice->getSPS(), rps); |
---|
995 | #else |
---|
996 | codeShortTermRefPicSet(pcSlice->getPPS(), rps); |
---|
997 | #endif |
---|
998 | } |
---|
999 | else |
---|
1000 | { |
---|
1001 | WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag"); |
---|
1002 | WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" ); |
---|
1003 | } |
---|
1004 | #if RPS_IN_SPS |
---|
1005 | if(pcSlice->getSPS()->getLongTermRefsPresent()) |
---|
1006 | #else |
---|
1007 | if(pcSlice->getPPS()->getLongTermRefsPresent()) |
---|
1008 | #endif |
---|
1009 | { |
---|
1010 | WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics"); |
---|
1011 | Int maxPocLsb = 1<<pcSlice->getSPS()->getBitsForPOC(); |
---|
1012 | Int prev = 0; |
---|
1013 | #if LTRP_MULT |
---|
1014 | Int prevDeltaPocLt=0; |
---|
1015 | Int currDeltaPocLt=0; |
---|
1016 | #endif |
---|
1017 | for(Int i=rps->getNumberOfPictures()-1 ; i > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; i--) |
---|
1018 | { |
---|
1019 | WRITE_UVLC((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb, "delta_poc_lsb_lt"); |
---|
1020 | |
---|
1021 | #if LTRP_MULT |
---|
1022 | currDeltaPocLt=((maxPocLsb-rps->getDeltaPOC(i)+prev)%maxPocLsb)+prevDeltaPocLt; |
---|
1023 | |
---|
1024 | Int deltaMsbCycle=0; |
---|
1025 | if( (i==(rps->getNumberOfPictures()-1)) ) |
---|
1026 | { |
---|
1027 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
1028 | } |
---|
1029 | else if( prevDeltaPocLt!=currDeltaPocLt ) |
---|
1030 | { |
---|
1031 | deltaMsbCycle=((-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
1032 | if( ((prevDeltaPocLt==maxPocLsb-1) && (currDeltaPocLt==maxPocLsb+1)) || ((prevDeltaPocLt==maxPocLsb-2) && (currDeltaPocLt==maxPocLsb))) |
---|
1033 | { |
---|
1034 | deltaMsbCycle=deltaMsbCycle-1; |
---|
1035 | } |
---|
1036 | } |
---|
1037 | else |
---|
1038 | { |
---|
1039 | deltaMsbCycle=((rps->getDeltaPOC(i+1)-rps->getDeltaPOC(i))/maxPocLsb)-1; |
---|
1040 | } |
---|
1041 | |
---|
1042 | if(deltaMsbCycle>=0) |
---|
1043 | { |
---|
1044 | WRITE_FLAG( 1, "delta_poc_msb_present_flag"); |
---|
1045 | WRITE_UVLC(deltaMsbCycle, "delta_poc_msb_cycle_lt_minus1"); |
---|
1046 | } |
---|
1047 | else |
---|
1048 | { |
---|
1049 | WRITE_FLAG( 0, "delta_poc_msb_present_flag"); |
---|
1050 | } |
---|
1051 | prevDeltaPocLt=currDeltaPocLt; |
---|
1052 | #endif |
---|
1053 | prev = rps->getDeltaPOC(i); |
---|
1054 | WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); |
---|
1055 | } |
---|
1056 | } |
---|
1057 | } |
---|
1058 | } |
---|
1059 | |
---|
1060 | if(pcSlice->getSPS()->getUseSAO() || pcSlice->getSPS()->getUseALF()|| pcSlice->getSPS()->getScalingListFlag() || pcSlice->getSPS()->getUseDF()) |
---|
1061 | { |
---|
1062 | if (pcSlice->getSPS()->getUseALF()) |
---|
1063 | { |
---|
1064 | #if !LCU_SYNTAX_ALF |
---|
1065 | if (pcSlice->getAlfEnabledFlag()) |
---|
1066 | { |
---|
1067 | assert (pcSlice->getAPS()->getAlfEnabled()); |
---|
1068 | } |
---|
1069 | #endif |
---|
1070 | WRITE_FLAG( pcSlice->getAlfEnabledFlag(), "ALF on/off flag in slice header" ); |
---|
1071 | } |
---|
1072 | if (pcSlice->getSPS()->getUseSAO()) |
---|
1073 | { |
---|
1074 | #if SAO_UNIT_INTERLEAVING |
---|
1075 | WRITE_FLAG( pcSlice->getSaoInterleavingFlag(), "SAO interleaving flag" ); |
---|
1076 | #endif |
---|
1077 | assert (pcSlice->getSaoEnabledFlag() == pcSlice->getAPS()->getSaoEnabled()); |
---|
1078 | WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "SAO on/off flag in slice header" ); |
---|
1079 | #if SAO_UNIT_INTERLEAVING |
---|
1080 | if (pcSlice->getSaoInterleavingFlag()&&pcSlice->getSaoEnabledFlag() ) |
---|
1081 | { |
---|
1082 | WRITE_FLAG( pcSlice->getAPS()->getSaoParam()->bSaoFlag[1], "SAO on/off flag for Cb in slice header" ); |
---|
1083 | WRITE_FLAG( pcSlice->getAPS()->getSaoParam()->bSaoFlag[2], "SAO on/off flag for Cr in slice header" ); |
---|
1084 | } |
---|
1085 | #endif |
---|
1086 | } |
---|
1087 | WRITE_UVLC( pcSlice->getAPS()->getAPSID(), "aps_id"); |
---|
1088 | } |
---|
1089 | |
---|
1090 | // we always set num_ref_idx_active_override_flag equal to one. this might be done in a more intelligent way |
---|
1091 | if (!pcSlice->isIntra()) |
---|
1092 | { |
---|
1093 | WRITE_FLAG( 1 , "num_ref_idx_active_override_flag"); |
---|
1094 | WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1, 3, "num_ref_idx_l0_active_minus1" ); |
---|
1095 | } |
---|
1096 | else |
---|
1097 | { |
---|
1098 | pcSlice->setNumRefIdx(REF_PIC_LIST_0, 0); |
---|
1099 | } |
---|
1100 | if (pcSlice->isInterB()) |
---|
1101 | { |
---|
1102 | WRITE_CODE( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1, 3, "num_ref_idx_l1_active_minus1" ); |
---|
1103 | } |
---|
1104 | else |
---|
1105 | { |
---|
1106 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
1107 | } |
---|
1108 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
1109 | if( pcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
1110 | { |
---|
1111 | #endif |
---|
1112 | TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); |
---|
1113 | #if H0137_0138_LIST_MODIFICATION |
---|
1114 | if( !pcSlice->isIntra() ) |
---|
1115 | { |
---|
1116 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0, "ref_pic_list_modification_flag_l0" ); |
---|
1117 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0()) |
---|
1118 | { |
---|
1119 | Int NumPocTotalCurr = pcSlice->getNumPocTotalCurrMvc(); |
---|
1120 | if (NumPocTotalCurr > 1) |
---|
1121 | { |
---|
1122 | Int length = 1; |
---|
1123 | NumPocTotalCurr --; |
---|
1124 | while ( NumPocTotalCurr >>= 1) |
---|
1125 | { |
---|
1126 | length ++; |
---|
1127 | } |
---|
1128 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); i++) |
---|
1129 | { |
---|
1130 | WRITE_CODE( refPicListModification->getRefPicSetIdxL0(i), length, "list_entry_l0"); |
---|
1131 | } |
---|
1132 | } |
---|
1133 | } |
---|
1134 | } |
---|
1135 | if(pcSlice->isInterB()) |
---|
1136 | { |
---|
1137 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag_l1" ); |
---|
1138 | if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1()) |
---|
1139 | { |
---|
1140 | Int NumPocTotalCurr = pcSlice->getNumPocTotalCurrMvc(); |
---|
1141 | if ( NumPocTotalCurr > 1 ) |
---|
1142 | { |
---|
1143 | Int length = 1; |
---|
1144 | NumPocTotalCurr --; |
---|
1145 | while ( NumPocTotalCurr >>= 1) |
---|
1146 | { |
---|
1147 | length ++; |
---|
1148 | } |
---|
1149 | for(Int i = 0; i < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); i++) |
---|
1150 | { |
---|
1151 | WRITE_CODE( refPicListModification->getRefPicSetIdxL1(i), length, "list_entry_l1"); |
---|
1152 | } |
---|
1153 | } |
---|
1154 | } |
---|
1155 | } |
---|
1156 | #else |
---|
1157 | if(!pcSlice->isIntra()) |
---|
1158 | { |
---|
1159 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0() ? 1 : 0, "ref_pic_list_modification_flag" ); |
---|
1160 | for(Int i = 0; i < refPicListModification->getNumberOfRefPicListModificationsL0(); i++) |
---|
1161 | { |
---|
1162 | WRITE_UVLC( refPicListModification->getListIdcL0(i), "ref_pic_list_modification_idc"); |
---|
1163 | WRITE_UVLC( refPicListModification->getRefPicSetIdxL0(i), "ref_pic_set_idx"); |
---|
1164 | } |
---|
1165 | if(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL0()) |
---|
1166 | WRITE_UVLC( 3, "ref_pic_list_modification_idc"); |
---|
1167 | } |
---|
1168 | if(pcSlice->isInterB()) |
---|
1169 | { |
---|
1170 | WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag" ); |
---|
1171 | for(Int i = 0; i < refPicListModification->getNumberOfRefPicListModificationsL1(); i++) |
---|
1172 | { |
---|
1173 | WRITE_UVLC( refPicListModification->getListIdcL1(i), "ref_pic_list_modification_idc"); |
---|
1174 | WRITE_UVLC( refPicListModification->getRefPicSetIdxL1(i), "ref_pic_set_idx"); |
---|
1175 | } |
---|
1176 | if(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1()) |
---|
1177 | WRITE_UVLC( 3, "ref_pic_list_modification_idc"); |
---|
1178 | } |
---|
1179 | #endif |
---|
1180 | } |
---|
1181 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
1182 | } |
---|
1183 | #endif |
---|
1184 | // ref_pic_list_combination( ) |
---|
1185 | // maybe move to own function? |
---|
1186 | if (pcSlice->isInterB()) |
---|
1187 | { |
---|
1188 | WRITE_FLAG(pcSlice->getRefPicListCombinationFlag() ? 1 : 0, "ref_pic_list_combination_flag" ); |
---|
1189 | if(pcSlice->getRefPicListCombinationFlag()) |
---|
1190 | { |
---|
1191 | WRITE_UVLC( pcSlice->getNumRefIdx(REF_PIC_LIST_C) - 1, "num_ref_idx lc_active_minus1"); |
---|
1192 | |
---|
1193 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
1194 | if( pcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
1195 | { |
---|
1196 | #endif |
---|
1197 | WRITE_FLAG( pcSlice->getRefPicListModificationFlagLC() ? 1 : 0, "ref_pic_list_modification_flag_lc" ); |
---|
1198 | if(pcSlice->getRefPicListModificationFlagLC()) |
---|
1199 | { |
---|
1200 | for (UInt i=0;i<pcSlice->getNumRefIdx(REF_PIC_LIST_C);i++) |
---|
1201 | { |
---|
1202 | WRITE_FLAG( pcSlice->getListIdFromIdxOfLC(i), "pic_from_list_0_flag" ); |
---|
1203 | #if H0137_0138_LIST_MODIFICATION |
---|
1204 | if (((pcSlice->getListIdFromIdxOfLC(i)==REF_PIC_LIST_0) && pcSlice->getNumRefIdx( REF_PIC_LIST_0 )>1 ) || ((pcSlice->getListIdFromIdxOfLC(i)==REF_PIC_LIST_1) && pcSlice->getNumRefIdx( REF_PIC_LIST_1 )>1 ) ) |
---|
1205 | { |
---|
1206 | WRITE_UVLC( pcSlice->getRefIdxFromIdxOfLC(i), "ref_idx_list_curr" ); |
---|
1207 | } |
---|
1208 | #else |
---|
1209 | WRITE_UVLC( pcSlice->getRefIdxFromIdxOfLC(i), "ref_idx_list_curr" ); |
---|
1210 | #endif |
---|
1211 | } |
---|
1212 | } |
---|
1213 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
1214 | } |
---|
1215 | #endif |
---|
1216 | } |
---|
1217 | } |
---|
1218 | |
---|
1219 | #if H0111_MVD_L1_ZERO |
---|
1220 | if (pcSlice->isInterB()) |
---|
1221 | { |
---|
1222 | WRITE_FLAG( pcSlice->getMvdL1ZeroFlag() ? 1 : 0, "mvd_l1_zero_flag"); |
---|
1223 | } |
---|
1224 | #endif |
---|
1225 | |
---|
1226 | if(pcSlice->getPPS()->getEntropyCodingMode() && !pcSlice->isIntra()) |
---|
1227 | { |
---|
1228 | #if CABAC_INIT_FLAG |
---|
1229 | if (!pcSlice->isIntra() && pcSlice->getPPS()->getCabacInitPresentFlag()) |
---|
1230 | { |
---|
1231 | SliceType sliceType = pcSlice->getSliceType(); |
---|
1232 | Int encCABACTableIdx = pcSlice->getPPS()->getEncCABACTableIdx(); |
---|
1233 | Bool encCabacInitFlag = (sliceType!=encCABACTableIdx && encCABACTableIdx!=0) ? true : false; |
---|
1234 | pcSlice->setCabacInitFlag( encCabacInitFlag ); |
---|
1235 | WRITE_FLAG( encCabacInitFlag?1:0, "cabac_init_flag" ); |
---|
1236 | } |
---|
1237 | #else |
---|
1238 | WRITE_UVLC(pcSlice->getCABACinitIDC(), "cabac_init_idc"); |
---|
1239 | #endif |
---|
1240 | } |
---|
1241 | |
---|
1242 | // if( !lightweight_slice_flag ) { |
---|
1243 | if (!bEntropySlice) |
---|
1244 | { |
---|
1245 | Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 ); |
---|
1246 | WRITE_SVLC( iCode, "slice_qp_delta" ); |
---|
1247 | #if DBL_CONTROL |
---|
1248 | if (pcSlice->getPPS()->getDeblockingFilterControlPresent()) |
---|
1249 | { |
---|
1250 | if ( pcSlice->getSPS()->getUseDF() ) |
---|
1251 | { |
---|
1252 | WRITE_FLAG(pcSlice->getInheritDblParamFromAPS(), "inherit_dbl_param_from_APS_flag"); |
---|
1253 | } |
---|
1254 | #else |
---|
1255 | WRITE_FLAG(pcSlice->getInheritDblParamFromAPS(), "inherit_dbl_param_from_APS_flag"); |
---|
1256 | #endif |
---|
1257 | if (!pcSlice->getInheritDblParamFromAPS()) |
---|
1258 | { |
---|
1259 | WRITE_FLAG(pcSlice->getLoopFilterDisable(), "loop_filter_disable"); // should be an IDC |
---|
1260 | if(!pcSlice->getLoopFilterDisable()) |
---|
1261 | { |
---|
1262 | WRITE_SVLC (pcSlice->getLoopFilterBetaOffset(), "beta_offset_div2"); |
---|
1263 | WRITE_SVLC (pcSlice->getLoopFilterTcOffset(), "tc_offset_div2"); |
---|
1264 | } |
---|
1265 | } |
---|
1266 | #if DBL_CONTROL |
---|
1267 | } |
---|
1268 | #endif |
---|
1269 | if ( pcSlice->getSliceType() == B_SLICE ) |
---|
1270 | { |
---|
1271 | WRITE_FLAG( pcSlice->getColDir(), "collocated_from_l0_flag" ); |
---|
1272 | } |
---|
1273 | |
---|
1274 | #if COLLOCATED_REF_IDX |
---|
1275 | if ( pcSlice->getSliceType() != I_SLICE && |
---|
1276 | ((pcSlice->getColDir()==0 && pcSlice->getNumRefIdx(REF_PIC_LIST_0)>1)|| |
---|
1277 | (pcSlice->getColDir()==1 && pcSlice->getNumRefIdx(REF_PIC_LIST_1)>1))) |
---|
1278 | { |
---|
1279 | WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" ); |
---|
1280 | } |
---|
1281 | #endif |
---|
1282 | |
---|
1283 | if ( (pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getSliceType()==B_SLICE) ) |
---|
1284 | { |
---|
1285 | xCodePredWeightTable( pcSlice ); |
---|
1286 | } |
---|
1287 | } |
---|
1288 | |
---|
1289 | // !!!! sytnax elements not in the WD !!!! |
---|
1290 | if (!bEntropySlice) |
---|
1291 | { |
---|
1292 | if( pcSlice->getSPS()->hasCamParInSliceHeader() ) |
---|
1293 | { |
---|
1294 | for( UInt uiId = 0; uiId < pcSlice->getSPS()->getViewId(); uiId++ ) |
---|
1295 | { |
---|
1296 | WRITE_SVLC( pcSlice->getCodedScale ()[ uiId ], "coded_scale" ); |
---|
1297 | WRITE_SVLC( pcSlice->getCodedOffset ()[ uiId ], "coded_offset" ); |
---|
1298 | WRITE_SVLC( pcSlice->getInvCodedScale ()[ uiId ] + pcSlice->getCodedScale ()[ uiId ], "inverse_coded_scale_plus_coded_scale" ); |
---|
1299 | WRITE_SVLC( pcSlice->getInvCodedOffset()[ uiId ] + pcSlice->getCodedOffset()[ uiId ], "inverse_coded_offset_plus_coded_offset" ); |
---|
1300 | } |
---|
1301 | } |
---|
1302 | } |
---|
1303 | |
---|
1304 | #if ( HHI_MPI || HHI_INTER_VIEW_MOTION_PRED ) |
---|
1305 | #if ( HHI_MPI && HHI_INTER_VIEW_MOTION_PRED ) |
---|
1306 | const int iExtraMergeCandidates = ( pcSlice->getSPS()->getUseMVI() || pcSlice->getSPS()->getMultiviewMvPredMode() ) ? 1 : 0; |
---|
1307 | #elif HHI_MPI |
---|
1308 | const int iExtraMergeCandidates = pcSlice->getSPS()->getUseMVI() ? 1 : 0; |
---|
1309 | #elif MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137 |
---|
1310 | const int iExtraMergeCandidates = ( pcSlice->getIsDepth() || pcSlice->getSPS()->getMultiviewMvPredMode() ) ? 1 : 0; |
---|
1311 | #else |
---|
1312 | const int iExtraMergeCandidates = pcSlice->getSPS()->getMultiviewMvPredMode() ? 1 : 0; |
---|
1313 | #endif |
---|
1314 | assert(pcSlice->getMaxNumMergeCand()<=(MRG_MAX_NUM_CANDS_SIGNALED+iExtraMergeCandidates)); |
---|
1315 | assert(MRG_MAX_NUM_CANDS_SIGNALED<=MRG_MAX_NUM_CANDS); |
---|
1316 | WRITE_UVLC(MRG_MAX_NUM_CANDS + iExtraMergeCandidates - pcSlice->getMaxNumMergeCand(), "maxNumMergeCand"); |
---|
1317 | #else |
---|
1318 | assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS_SIGNALED); |
---|
1319 | assert(MRG_MAX_NUM_CANDS_SIGNALED<=MRG_MAX_NUM_CANDS); |
---|
1320 | WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "maxNumMergeCand"); |
---|
1321 | #endif |
---|
1322 | } |
---|
1323 | |
---|
1324 | |
---|
1325 | Void TEncCavlc::codeTileMarkerFlag(TComSlice* pcSlice) |
---|
1326 | { |
---|
1327 | Bool bEntropySlice = (!pcSlice->isNextSlice()); |
---|
1328 | if (!bEntropySlice) |
---|
1329 | { |
---|
1330 | xWriteFlag (pcSlice->getTileMarkerFlag() ? 1 : 0 ); |
---|
1331 | } |
---|
1332 | } |
---|
1333 | |
---|
1334 | /** |
---|
1335 | - write wavefront substreams sizes for the slice header. |
---|
1336 | . |
---|
1337 | \param pcSlice Where we find the substream size information. |
---|
1338 | */ |
---|
1339 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
1340 | Void TEncCavlc::codeTilesWPPEntryPoint( TComSlice* pSlice ) |
---|
1341 | { |
---|
1342 | Int tilesOrEntropyCodingSyncIdc = pSlice->getSPS()->getTilesOrEntropyCodingSyncIdc(); |
---|
1343 | |
---|
1344 | if ( tilesOrEntropyCodingSyncIdc == 0 ) |
---|
1345 | { |
---|
1346 | return; |
---|
1347 | } |
---|
1348 | |
---|
1349 | UInt numEntryPointOffsets = 0, offsetLenMinus1 = 0, maxOffset = 0; |
---|
1350 | UInt *entryPointOffset = NULL; |
---|
1351 | if (tilesOrEntropyCodingSyncIdc == 1) // tiles |
---|
1352 | { |
---|
1353 | numEntryPointOffsets = pSlice->getTileLocationCount(); |
---|
1354 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
1355 | for (Int idx=0; idx<pSlice->getTileLocationCount(); idx++) |
---|
1356 | { |
---|
1357 | if ( idx == 0 ) |
---|
1358 | { |
---|
1359 | entryPointOffset [ idx ] = pSlice->getTileLocation( 0 ); |
---|
1360 | } |
---|
1361 | else |
---|
1362 | { |
---|
1363 | entryPointOffset [ idx ] = pSlice->getTileLocation( idx ) - pSlice->getTileLocation( idx-1 ); |
---|
1364 | } |
---|
1365 | |
---|
1366 | if ( entryPointOffset[ idx ] > maxOffset ) |
---|
1367 | { |
---|
1368 | maxOffset = entryPointOffset[ idx ]; |
---|
1369 | } |
---|
1370 | } |
---|
1371 | } |
---|
1372 | else if (tilesOrEntropyCodingSyncIdc == 2) // wavefront |
---|
1373 | { |
---|
1374 | Int numZeroSubstreamsAtEndOfSlice = 0; |
---|
1375 | UInt* pSubstreamSizes = pSlice->getSubstreamSizes(); |
---|
1376 | // Find number of zero substreams at the end of slice |
---|
1377 | for (Int idx=pSlice->getPPS()->getNumSubstreams()-2; idx>=0; idx--) |
---|
1378 | { |
---|
1379 | if ( pSubstreamSizes[ idx ] == 0 ) |
---|
1380 | { |
---|
1381 | numZeroSubstreamsAtEndOfSlice++; |
---|
1382 | } |
---|
1383 | else |
---|
1384 | { |
---|
1385 | break; |
---|
1386 | } |
---|
1387 | } |
---|
1388 | numEntryPointOffsets = pSlice->getPPS()->getNumSubstreams() - 1 - numZeroSubstreamsAtEndOfSlice; |
---|
1389 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
1390 | for (Int idx=0; idx<numEntryPointOffsets; idx++) |
---|
1391 | { |
---|
1392 | entryPointOffset[ idx ] = ( pSubstreamSizes[ idx ] >> 3 ) ; |
---|
1393 | if ( entryPointOffset[ idx ] > maxOffset ) |
---|
1394 | { |
---|
1395 | maxOffset = entryPointOffset[ idx ]; |
---|
1396 | } |
---|
1397 | } |
---|
1398 | } |
---|
1399 | |
---|
1400 | maxOffset += ((m_pcBitIf->getNumberOfWrittenBits() + 16) >> 3) + 8 + 2; // allowing for NALU header, slice header, bytes added for "offset_len_minus1" and "num_entry_point_offsets" |
---|
1401 | |
---|
1402 | // Determine number of bits "offsetLenMinus1+1" required for entry point information |
---|
1403 | offsetLenMinus1 = 0; |
---|
1404 | while (1) |
---|
1405 | { |
---|
1406 | if (maxOffset >= (1 << offsetLenMinus1) ) |
---|
1407 | { |
---|
1408 | offsetLenMinus1++; |
---|
1409 | if ( offsetLenMinus1 > 32 ) |
---|
1410 | { |
---|
1411 | FATAL_ERROR_0("exceeded 32-bits", -1); |
---|
1412 | } |
---|
1413 | } |
---|
1414 | else |
---|
1415 | { |
---|
1416 | break; |
---|
1417 | } |
---|
1418 | } |
---|
1419 | |
---|
1420 | WRITE_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); |
---|
1421 | if (numEntryPointOffsets>0) |
---|
1422 | { |
---|
1423 | WRITE_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
1424 | } |
---|
1425 | |
---|
1426 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
1427 | { |
---|
1428 | if ( idx == 0 ) |
---|
1429 | { |
---|
1430 | // Adding sizes of NALU header and slice header information to entryPointOffset[ 0 ] |
---|
1431 | Int bitDistFromNALUHdrStart = m_pcBitIf->getNumberOfWrittenBits() + 16; |
---|
1432 | entryPointOffset[ idx ] += ( bitDistFromNALUHdrStart + numEntryPointOffsets*(offsetLenMinus1+1) ) >> 3; |
---|
1433 | } |
---|
1434 | WRITE_CODE(entryPointOffset[ idx ], offsetLenMinus1+1, "entry_point_offset"); |
---|
1435 | } |
---|
1436 | |
---|
1437 | delete [] entryPointOffset; |
---|
1438 | } |
---|
1439 | #else |
---|
1440 | Void TEncCavlc::codeSliceHeaderSubstreamTable( TComSlice* pcSlice ) |
---|
1441 | { |
---|
1442 | UInt uiNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); |
---|
1443 | UInt*puiSubstreamSizes = pcSlice->getSubstreamSizes(); |
---|
1444 | |
---|
1445 | // Write header information for all substreams except the last. |
---|
1446 | for (UInt ui = 0; ui+1 < uiNumSubstreams; ui++) |
---|
1447 | { |
---|
1448 | UInt uiNumbits = puiSubstreamSizes[ui]; |
---|
1449 | |
---|
1450 | //the 2 first bits are used to give the size of the header |
---|
1451 | if ( uiNumbits < (1<<8) ) |
---|
1452 | { |
---|
1453 | xWriteCode(0, 2 ); |
---|
1454 | xWriteCode(uiNumbits, 8 ); |
---|
1455 | } |
---|
1456 | else if ( uiNumbits < (1<<16) ) |
---|
1457 | { |
---|
1458 | xWriteCode(1, 2 ); |
---|
1459 | xWriteCode(uiNumbits, 16 ); |
---|
1460 | } |
---|
1461 | else if ( uiNumbits < (1<<24) ) |
---|
1462 | { |
---|
1463 | xWriteCode(2, 2 ); |
---|
1464 | xWriteCode(uiNumbits, 24 ); |
---|
1465 | } |
---|
1466 | else if ( uiNumbits < (1<<31) ) |
---|
1467 | { |
---|
1468 | xWriteCode(3, 2 ); |
---|
1469 | xWriteCode(uiNumbits, 32 ); |
---|
1470 | } |
---|
1471 | else |
---|
1472 | { |
---|
1473 | printf("Error in codeSliceHeaderTable\n"); |
---|
1474 | exit(-1); |
---|
1475 | } |
---|
1476 | } |
---|
1477 | } |
---|
1478 | #endif |
---|
1479 | |
---|
1480 | Void TEncCavlc::codeTerminatingBit ( UInt uilsLast ) |
---|
1481 | { |
---|
1482 | } |
---|
1483 | |
---|
1484 | Void TEncCavlc::codeSliceFinish () |
---|
1485 | { |
---|
1486 | } |
---|
1487 | |
---|
1488 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
1489 | Void TEncCavlc::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList, Int iNum ) |
---|
1490 | #else |
---|
1491 | Void TEncCavlc::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
1492 | #endif |
---|
1493 | { |
---|
1494 | assert(0); |
---|
1495 | } |
---|
1496 | |
---|
1497 | Void TEncCavlc::codePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1498 | { |
---|
1499 | assert(0); |
---|
1500 | } |
---|
1501 | |
---|
1502 | Void TEncCavlc::codePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1503 | { |
---|
1504 | assert(0); |
---|
1505 | } |
---|
1506 | |
---|
1507 | Void TEncCavlc::codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1508 | { |
---|
1509 | assert(0); |
---|
1510 | } |
---|
1511 | |
---|
1512 | Void TEncCavlc::codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1513 | { |
---|
1514 | assert(0); |
---|
1515 | } |
---|
1516 | |
---|
1517 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
1518 | Void |
---|
1519 | TEncCavlc::codeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1520 | { |
---|
1521 | assert(0); |
---|
1522 | } |
---|
1523 | #endif |
---|
1524 | |
---|
1525 | Void TEncCavlc::codeAlfCtrlFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1526 | { |
---|
1527 | if (!m_bAlfCtrl) |
---|
1528 | { |
---|
1529 | return; |
---|
1530 | } |
---|
1531 | |
---|
1532 | if( pcCU->getDepth(uiAbsPartIdx) > m_uiMaxAlfCtrlDepth && !pcCU->isFirstAbsZorderIdxInDepth(uiAbsPartIdx, m_uiMaxAlfCtrlDepth)) |
---|
1533 | { |
---|
1534 | return; |
---|
1535 | } |
---|
1536 | |
---|
1537 | // get context function is here |
---|
1538 | UInt uiSymbol = pcCU->getAlfCtrlFlag( uiAbsPartIdx ) ? 1 : 0; |
---|
1539 | |
---|
1540 | xWriteFlag( uiSymbol ); |
---|
1541 | } |
---|
1542 | |
---|
1543 | Void TEncCavlc::codeApsExtensionFlag () |
---|
1544 | { |
---|
1545 | WRITE_FLAG(0, "aps_extension_flag"); |
---|
1546 | } |
---|
1547 | |
---|
1548 | Void TEncCavlc::codeAlfCtrlDepth() |
---|
1549 | { |
---|
1550 | if (!m_bAlfCtrl) |
---|
1551 | { |
---|
1552 | return; |
---|
1553 | } |
---|
1554 | |
---|
1555 | UInt uiDepth = m_uiMaxAlfCtrlDepth; |
---|
1556 | |
---|
1557 | xWriteUvlc(uiDepth); |
---|
1558 | } |
---|
1559 | |
---|
1560 | Void TEncCavlc::codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode ) |
---|
1561 | { |
---|
1562 | assert(0); |
---|
1563 | } |
---|
1564 | |
---|
1565 | Void TEncCavlc::codeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1566 | { |
---|
1567 | assert(0); |
---|
1568 | } |
---|
1569 | |
---|
1570 | #if LGE_ILLUCOMP_B0045 |
---|
1571 | Void TEncCavlc::codeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1572 | { |
---|
1573 | assert(0); |
---|
1574 | } |
---|
1575 | #endif |
---|
1576 | |
---|
1577 | Void TEncCavlc::codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1578 | { |
---|
1579 | assert(0); |
---|
1580 | } |
---|
1581 | |
---|
1582 | Void TEncCavlc::codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx ) |
---|
1583 | { |
---|
1584 | assert(0); |
---|
1585 | } |
---|
1586 | |
---|
1587 | Void TEncCavlc::codeQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) |
---|
1588 | { |
---|
1589 | assert(0); |
---|
1590 | } |
---|
1591 | |
---|
1592 | Void TEncCavlc::codeQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1593 | { |
---|
1594 | assert(0); |
---|
1595 | } |
---|
1596 | |
---|
1597 | #if BURST_IPCM |
---|
1598 | /** Code I_PCM information. |
---|
1599 | * \param pcCU pointer to CU |
---|
1600 | * \param uiAbsPartIdx CU index |
---|
1601 | * \param numIPCM the number of succesive IPCM blocks with the same size |
---|
1602 | * \param firstIPCMFlag |
---|
1603 | * \returns Void |
---|
1604 | */ |
---|
1605 | Void TEncCavlc::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag) |
---|
1606 | { |
---|
1607 | assert(0); |
---|
1608 | } |
---|
1609 | #else |
---|
1610 | /** Code I_PCM information. |
---|
1611 | * \param pcCU pointer to CU |
---|
1612 | * \param uiAbsPartIdx CU index |
---|
1613 | * \returns Void |
---|
1614 | * |
---|
1615 | * If I_PCM flag indicates that the CU is I_PCM, code its PCM alignment bits and codes. |
---|
1616 | */ |
---|
1617 | Void TEncCavlc::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx) |
---|
1618 | { |
---|
1619 | UInt uiIPCM = (pcCU->getIPCMFlag(uiAbsPartIdx) == true)? 1 : 0; |
---|
1620 | |
---|
1621 | xWriteFlag(uiIPCM); |
---|
1622 | |
---|
1623 | if (uiIPCM) |
---|
1624 | { |
---|
1625 | xWritePCMAlignZero(); |
---|
1626 | |
---|
1627 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
1628 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
1629 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
1630 | |
---|
1631 | Pel* piPCMSample; |
---|
1632 | UInt uiWidth; |
---|
1633 | UInt uiHeight; |
---|
1634 | UInt uiSampleBits; |
---|
1635 | UInt uiX, uiY; |
---|
1636 | |
---|
1637 | piPCMSample = pcCU->getPCMSampleY() + uiLumaOffset; |
---|
1638 | uiWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
1639 | uiHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
1640 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
1641 | |
---|
1642 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
1643 | { |
---|
1644 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
1645 | { |
---|
1646 | UInt uiSample = piPCMSample[uiX]; |
---|
1647 | |
---|
1648 | xWriteCode(uiSample, uiSampleBits); |
---|
1649 | } |
---|
1650 | piPCMSample += uiWidth; |
---|
1651 | } |
---|
1652 | |
---|
1653 | piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset; |
---|
1654 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
1655 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
1656 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
1657 | |
---|
1658 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
1659 | { |
---|
1660 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
1661 | { |
---|
1662 | UInt uiSample = piPCMSample[uiX]; |
---|
1663 | |
---|
1664 | xWriteCode(uiSample, uiSampleBits); |
---|
1665 | } |
---|
1666 | piPCMSample += uiWidth; |
---|
1667 | } |
---|
1668 | |
---|
1669 | piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset; |
---|
1670 | uiWidth = pcCU->getWidth(uiAbsPartIdx)/2; |
---|
1671 | uiHeight = pcCU->getHeight(uiAbsPartIdx)/2; |
---|
1672 | uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
1673 | |
---|
1674 | for(uiY = 0; uiY < uiHeight; uiY++) |
---|
1675 | { |
---|
1676 | for(uiX = 0; uiX < uiWidth; uiX++) |
---|
1677 | { |
---|
1678 | UInt uiSample = piPCMSample[uiX]; |
---|
1679 | |
---|
1680 | xWriteCode(uiSample, uiSampleBits); |
---|
1681 | } |
---|
1682 | piPCMSample += uiWidth; |
---|
1683 | } |
---|
1684 | } |
---|
1685 | } |
---|
1686 | #endif |
---|
1687 | |
---|
1688 | Void TEncCavlc::codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1689 | { |
---|
1690 | assert(0); |
---|
1691 | } |
---|
1692 | |
---|
1693 | Void TEncCavlc::codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1694 | { |
---|
1695 | assert(0); |
---|
1696 | } |
---|
1697 | |
---|
1698 | Void TEncCavlc::codeInterDir( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1699 | { |
---|
1700 | assert(0); |
---|
1701 | } |
---|
1702 | |
---|
1703 | Void TEncCavlc::codeRefFrmIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
1704 | { |
---|
1705 | assert(0); |
---|
1706 | } |
---|
1707 | |
---|
1708 | Void TEncCavlc::codeMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList ) |
---|
1709 | { |
---|
1710 | assert(0); |
---|
1711 | } |
---|
1712 | |
---|
1713 | Void TEncCavlc::codeDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
1714 | { |
---|
1715 | Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx ); |
---|
1716 | |
---|
1717 | #if H0736_AVC_STYLE_QP_RANGE |
---|
1718 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
1719 | iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2); |
---|
1720 | #endif |
---|
1721 | |
---|
1722 | xWriteSvlc( iDQp ); |
---|
1723 | |
---|
1724 | return; |
---|
1725 | } |
---|
1726 | |
---|
1727 | Void TEncCavlc::codeCoeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
1728 | { |
---|
1729 | assert(0); |
---|
1730 | } |
---|
1731 | |
---|
1732 | Void TEncCavlc::codeAlfFlag( UInt uiCode ) |
---|
1733 | { |
---|
1734 | xWriteFlag( uiCode ); |
---|
1735 | } |
---|
1736 | |
---|
1737 | Void TEncCavlc::codeAlfCtrlFlag( UInt uiSymbol ) |
---|
1738 | { |
---|
1739 | xWriteFlag( uiSymbol ); |
---|
1740 | } |
---|
1741 | |
---|
1742 | Void TEncCavlc::codeAlfUvlc( UInt uiCode ) |
---|
1743 | { |
---|
1744 | xWriteUvlc( uiCode ); |
---|
1745 | } |
---|
1746 | |
---|
1747 | Void TEncCavlc::codeAlfSvlc( Int iCode ) |
---|
1748 | { |
---|
1749 | xWriteSvlc( iCode ); |
---|
1750 | } |
---|
1751 | #if LCU_SYNTAX_ALF |
---|
1752 | /** Code the fixed length code (smaller than one max value) in OSALF |
---|
1753 | * \param idx: coded value |
---|
1754 | * \param maxValue: max value |
---|
1755 | */ |
---|
1756 | Void TEncCavlc::codeAlfFixedLengthIdx( UInt idx, UInt maxValue) |
---|
1757 | { |
---|
1758 | UInt length = 0; |
---|
1759 | assert(idx<=maxValue); |
---|
1760 | |
---|
1761 | UInt temp = maxValue; |
---|
1762 | for(UInt i=0; i<32; i++) |
---|
1763 | { |
---|
1764 | if(temp&0x1) |
---|
1765 | { |
---|
1766 | length = i+1; |
---|
1767 | } |
---|
1768 | temp = (temp >> 1); |
---|
1769 | } |
---|
1770 | |
---|
1771 | if(length) |
---|
1772 | { |
---|
1773 | xWriteCode( idx, length ); |
---|
1774 | } |
---|
1775 | } |
---|
1776 | #endif |
---|
1777 | |
---|
1778 | Void TEncCavlc::codeSaoFlag( UInt uiCode ) |
---|
1779 | { |
---|
1780 | xWriteFlag( uiCode ); |
---|
1781 | } |
---|
1782 | |
---|
1783 | Void TEncCavlc::codeSaoUvlc( UInt uiCode ) |
---|
1784 | { |
---|
1785 | xWriteUvlc( uiCode ); |
---|
1786 | } |
---|
1787 | |
---|
1788 | Void TEncCavlc::codeSaoSvlc( Int iCode ) |
---|
1789 | { |
---|
1790 | xWriteSvlc( iCode ); |
---|
1791 | } |
---|
1792 | #if SAO_UNIT_INTERLEAVING |
---|
1793 | /** Code SAO run. |
---|
1794 | * \param uiCode |
---|
1795 | * \param maxValue |
---|
1796 | */ |
---|
1797 | Void TEncCavlc::codeSaoRun( UInt uiCode, UInt maxValue) |
---|
1798 | { |
---|
1799 | UInt uiLength = 0; |
---|
1800 | if (!maxValue) |
---|
1801 | { |
---|
1802 | return; |
---|
1803 | } |
---|
1804 | assert(uiCode<=maxValue); |
---|
1805 | |
---|
1806 | for(UInt i=0; i<32; i++) |
---|
1807 | { |
---|
1808 | if(maxValue&0x1) |
---|
1809 | { |
---|
1810 | uiLength = i+1; |
---|
1811 | } |
---|
1812 | maxValue = (maxValue >> 1); |
---|
1813 | } |
---|
1814 | WRITE_CODE( uiCode, uiLength, "sao_run_diff"); |
---|
1815 | } |
---|
1816 | #endif |
---|
1817 | |
---|
1818 | Void TEncCavlc::estBit( estBitsSbacStruct* pcEstBitsCabac, Int width, Int height, TextType eTType ) |
---|
1819 | { |
---|
1820 | // printf("error : no VLC mode support in this version\n"); |
---|
1821 | return; |
---|
1822 | } |
---|
1823 | |
---|
1824 | // ==================================================================================================================== |
---|
1825 | // Protected member functions |
---|
1826 | // ==================================================================================================================== |
---|
1827 | |
---|
1828 | Void TEncCavlc::xWriteCode ( UInt uiCode, UInt uiLength ) |
---|
1829 | { |
---|
1830 | assert ( uiLength > 0 ); |
---|
1831 | m_pcBitIf->write( uiCode, uiLength ); |
---|
1832 | } |
---|
1833 | |
---|
1834 | Void TEncCavlc::xWriteUvlc ( UInt uiCode ) |
---|
1835 | { |
---|
1836 | UInt uiLength = 1; |
---|
1837 | UInt uiTemp = ++uiCode; |
---|
1838 | |
---|
1839 | assert ( uiTemp ); |
---|
1840 | |
---|
1841 | while( 1 != uiTemp ) |
---|
1842 | { |
---|
1843 | uiTemp >>= 1; |
---|
1844 | uiLength += 2; |
---|
1845 | } |
---|
1846 | |
---|
1847 | //m_pcBitIf->write( uiCode, uiLength ); |
---|
1848 | // Take care of cases where uiLength > 32 |
---|
1849 | m_pcBitIf->write( 0, uiLength >> 1); |
---|
1850 | m_pcBitIf->write( uiCode, (uiLength+1) >> 1); |
---|
1851 | } |
---|
1852 | |
---|
1853 | Void TEncCavlc::xWriteSvlc ( Int iCode ) |
---|
1854 | { |
---|
1855 | UInt uiCode; |
---|
1856 | |
---|
1857 | uiCode = xConvertToUInt( iCode ); |
---|
1858 | xWriteUvlc( uiCode ); |
---|
1859 | } |
---|
1860 | |
---|
1861 | Void TEncCavlc::xWriteFlag( UInt uiCode ) |
---|
1862 | { |
---|
1863 | m_pcBitIf->write( uiCode, 1 ); |
---|
1864 | } |
---|
1865 | |
---|
1866 | /** Write PCM alignment bits. |
---|
1867 | * \returns Void |
---|
1868 | */ |
---|
1869 | Void TEncCavlc::xWritePCMAlignZero () |
---|
1870 | { |
---|
1871 | m_pcBitIf->writeAlignZero(); |
---|
1872 | } |
---|
1873 | |
---|
1874 | Void TEncCavlc::xWriteUnaryMaxSymbol( UInt uiSymbol, UInt uiMaxSymbol ) |
---|
1875 | { |
---|
1876 | if (uiMaxSymbol == 0) |
---|
1877 | { |
---|
1878 | return; |
---|
1879 | } |
---|
1880 | xWriteFlag( uiSymbol ? 1 : 0 ); |
---|
1881 | if ( uiSymbol == 0 ) |
---|
1882 | { |
---|
1883 | return; |
---|
1884 | } |
---|
1885 | |
---|
1886 | Bool bCodeLast = ( uiMaxSymbol > uiSymbol ); |
---|
1887 | |
---|
1888 | while( --uiSymbol ) |
---|
1889 | { |
---|
1890 | xWriteFlag( 1 ); |
---|
1891 | } |
---|
1892 | if( bCodeLast ) |
---|
1893 | { |
---|
1894 | xWriteFlag( 0 ); |
---|
1895 | } |
---|
1896 | return; |
---|
1897 | } |
---|
1898 | |
---|
1899 | Void TEncCavlc::xWriteExGolombLevel( UInt uiSymbol ) |
---|
1900 | { |
---|
1901 | if( uiSymbol ) |
---|
1902 | { |
---|
1903 | xWriteFlag( 1 ); |
---|
1904 | UInt uiCount = 0; |
---|
1905 | Bool bNoExGo = (uiSymbol < 13); |
---|
1906 | |
---|
1907 | while( --uiSymbol && ++uiCount < 13 ) |
---|
1908 | { |
---|
1909 | xWriteFlag( 1 ); |
---|
1910 | } |
---|
1911 | if( bNoExGo ) |
---|
1912 | { |
---|
1913 | xWriteFlag( 0 ); |
---|
1914 | } |
---|
1915 | else |
---|
1916 | { |
---|
1917 | xWriteEpExGolomb( uiSymbol, 0 ); |
---|
1918 | } |
---|
1919 | } |
---|
1920 | else |
---|
1921 | { |
---|
1922 | xWriteFlag( 0 ); |
---|
1923 | } |
---|
1924 | return; |
---|
1925 | } |
---|
1926 | |
---|
1927 | Void TEncCavlc::xWriteEpExGolomb( UInt uiSymbol, UInt uiCount ) |
---|
1928 | { |
---|
1929 | while( uiSymbol >= (UInt)(1<<uiCount) ) |
---|
1930 | { |
---|
1931 | xWriteFlag( 1 ); |
---|
1932 | uiSymbol -= 1<<uiCount; |
---|
1933 | uiCount ++; |
---|
1934 | } |
---|
1935 | xWriteFlag( 0 ); |
---|
1936 | while( uiCount-- ) |
---|
1937 | { |
---|
1938 | xWriteFlag( (uiSymbol>>uiCount) & 1 ); |
---|
1939 | } |
---|
1940 | return; |
---|
1941 | } |
---|
1942 | |
---|
1943 | /** code explicit wp tables |
---|
1944 | * \param TComSlice* pcSlice |
---|
1945 | * \returns Void |
---|
1946 | */ |
---|
1947 | Void TEncCavlc::xCodePredWeightTable( TComSlice* pcSlice ) |
---|
1948 | { |
---|
1949 | wpScalingParam *wp; |
---|
1950 | Bool bChroma = true; // color always present in HEVC ? |
---|
1951 | Int iNbRef = (pcSlice->getSliceType() == B_SLICE ) ? (2) : (1); |
---|
1952 | Bool bDenomCoded = false; |
---|
1953 | |
---|
1954 | UInt uiMode = 0; |
---|
1955 | if ( (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getRefPicListCombinationFlag()==0 ) ) |
---|
1956 | uiMode = 1; // explicit |
---|
1957 | else if ( pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==2 ) |
---|
1958 | uiMode = 2; // implicit (does not use this mode in this syntax) |
---|
1959 | if (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPredIdc()==1 && pcSlice->getRefPicListCombinationFlag()) |
---|
1960 | uiMode = 3; // combined explicit |
---|
1961 | if(uiMode == 1) |
---|
1962 | { |
---|
1963 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
1964 | { |
---|
1965 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
1966 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
1967 | { |
---|
1968 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
1969 | if ( !bDenomCoded ) |
---|
1970 | { |
---|
1971 | Int iDeltaDenom; |
---|
1972 | WRITE_UVLC( wp[0].uiLog2WeightDenom, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
1973 | |
---|
1974 | if( bChroma ) |
---|
1975 | { |
---|
1976 | iDeltaDenom = (wp[1].uiLog2WeightDenom - wp[0].uiLog2WeightDenom); |
---|
1977 | WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
1978 | } |
---|
1979 | bDenomCoded = true; |
---|
1980 | } |
---|
1981 | |
---|
1982 | WRITE_FLAG( wp[0].bPresentFlag, "luma_weight_lX_flag" ); // u(1): luma_weight_lX_flag |
---|
1983 | |
---|
1984 | if ( wp[0].bPresentFlag ) |
---|
1985 | { |
---|
1986 | Int iDeltaWeight = (wp[0].iWeight - (1<<wp[0].uiLog2WeightDenom)); |
---|
1987 | WRITE_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_lX |
---|
1988 | WRITE_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_lX |
---|
1989 | } |
---|
1990 | |
---|
1991 | if ( bChroma ) |
---|
1992 | { |
---|
1993 | WRITE_FLAG( wp[1].bPresentFlag, "chroma_weight_lX_flag" ); // u(1): chroma_weight_lX_flag |
---|
1994 | |
---|
1995 | if ( wp[1].bPresentFlag ) |
---|
1996 | { |
---|
1997 | for ( Int j=1 ; j<3 ; j++ ) |
---|
1998 | { |
---|
1999 | Int iDeltaWeight = (wp[j].iWeight - (1<<wp[1].uiLog2WeightDenom)); |
---|
2000 | WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): delta_chroma_weight_lX |
---|
2001 | |
---|
2002 | Int iDeltaChroma = (wp[j].iOffset + ( ( (g_uiIBDI_MAX>>1)*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) - (g_uiIBDI_MAX>>1)); |
---|
2003 | WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_lX |
---|
2004 | } |
---|
2005 | } |
---|
2006 | } |
---|
2007 | } |
---|
2008 | } |
---|
2009 | } |
---|
2010 | else if (uiMode == 3) |
---|
2011 | { |
---|
2012 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(REF_PIC_LIST_C) ; iRefIdx++ ) |
---|
2013 | { |
---|
2014 | RefPicList eRefPicList = (RefPicList)pcSlice->getListIdFromIdxOfLC(iRefIdx); |
---|
2015 | Int iCombRefIdx = pcSlice->getRefIdxFromIdxOfLC(iRefIdx); |
---|
2016 | |
---|
2017 | pcSlice->getWpScaling(eRefPicList, iCombRefIdx, wp); |
---|
2018 | if ( !bDenomCoded ) |
---|
2019 | { |
---|
2020 | Int iDeltaDenom; |
---|
2021 | WRITE_UVLC( wp[0].uiLog2WeightDenom, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
2022 | |
---|
2023 | if( bChroma ) |
---|
2024 | { |
---|
2025 | iDeltaDenom = (wp[1].uiLog2WeightDenom - wp[0].uiLog2WeightDenom); |
---|
2026 | WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
2027 | } |
---|
2028 | bDenomCoded = true; |
---|
2029 | } |
---|
2030 | |
---|
2031 | WRITE_FLAG( wp[0].bPresentFlag, "luma_weight_lc_flag" ); // u(1): luma_weight_lc_flag |
---|
2032 | |
---|
2033 | if ( wp[0].bPresentFlag ) |
---|
2034 | { |
---|
2035 | Int iDeltaWeight = (wp[0].iWeight - (1<<wp[0].uiLog2WeightDenom)); |
---|
2036 | WRITE_SVLC( iDeltaWeight, "delta_luma_weight_lc" ); // se(v): delta_luma_weight_lc |
---|
2037 | WRITE_SVLC( wp[0].iOffset, "luma_offset_lc" ); // se(v): luma_offset_lc |
---|
2038 | } |
---|
2039 | if ( bChroma ) |
---|
2040 | { |
---|
2041 | WRITE_FLAG( wp[1].bPresentFlag, "chroma_weight_lc_flag" ); // u(1): luma_weight_lc_flag |
---|
2042 | |
---|
2043 | if ( wp[1].bPresentFlag ) |
---|
2044 | { |
---|
2045 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2046 | { |
---|
2047 | Int iDeltaWeight = (wp[j].iWeight - (1<<wp[1].uiLog2WeightDenom)); |
---|
2048 | WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_lc" ); // se(v): delta_chroma_weight_lc |
---|
2049 | |
---|
2050 | Int iDeltaChroma = (wp[j].iOffset + ( ( (g_uiIBDI_MAX>>1)*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) - (g_uiIBDI_MAX>>1)); |
---|
2051 | WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_lc" ); // se(v): delta_chroma_offset_lc |
---|
2052 | } |
---|
2053 | } |
---|
2054 | } |
---|
2055 | } |
---|
2056 | } |
---|
2057 | } |
---|
2058 | |
---|
2059 | /** code quantization matrix |
---|
2060 | * \param scalingList quantization matrix information |
---|
2061 | */ |
---|
2062 | Void TEncCavlc::codeScalingList( TComScalingList* scalingList ) |
---|
2063 | { |
---|
2064 | UInt listId,sizeId; |
---|
2065 | Bool scalingListPredModeFlag; |
---|
2066 | |
---|
2067 | #if SCALING_LIST_OUTPUT_RESULT |
---|
2068 | Int startBit; |
---|
2069 | Int startTotalBit; |
---|
2070 | startBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
2071 | startTotalBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
2072 | #endif |
---|
2073 | |
---|
2074 | WRITE_FLAG( scalingList->getScalingListPresentFlag (), "scaling_list_present_flag" ); |
---|
2075 | |
---|
2076 | if(scalingList->getScalingListPresentFlag () == false) |
---|
2077 | { |
---|
2078 | #if SCALING_LIST_OUTPUT_RESULT |
---|
2079 | printf("Header Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startBit); |
---|
2080 | #endif |
---|
2081 | //for each size |
---|
2082 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2083 | { |
---|
2084 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2085 | { |
---|
2086 | #if SCALING_LIST_OUTPUT_RESULT |
---|
2087 | startBit = m_pcBitIf->getNumberOfWrittenBits(); |
---|
2088 | #endif |
---|
2089 | scalingListPredModeFlag = scalingList->checkPredMode( sizeId, listId ); |
---|
2090 | WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" ); |
---|
2091 | if(!scalingListPredModeFlag)// Copy Mode |
---|
2092 | { |
---|
2093 | WRITE_UVLC( (Int)listId - (Int)scalingList->getRefMatrixId (sizeId,listId) - 1, "scaling_list_pred_matrix_id_delta"); |
---|
2094 | } |
---|
2095 | else// DPCM Mode |
---|
2096 | { |
---|
2097 | xCodeScalingList(scalingList, sizeId, listId); |
---|
2098 | } |
---|
2099 | #if SCALING_LIST_OUTPUT_RESULT |
---|
2100 | printf("Matrix [%d][%d] Bit %d\n",sizeId,listId,m_pcBitIf->getNumberOfWrittenBits() - startBit); |
---|
2101 | #endif |
---|
2102 | } |
---|
2103 | } |
---|
2104 | } |
---|
2105 | #if SCALING_LIST_OUTPUT_RESULT |
---|
2106 | else |
---|
2107 | { |
---|
2108 | printf("Header Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startTotalBit); |
---|
2109 | } |
---|
2110 | printf("Total Bit %d\n",m_pcBitIf->getNumberOfWrittenBits()-startTotalBit); |
---|
2111 | #endif |
---|
2112 | return; |
---|
2113 | } |
---|
2114 | /** code DPCM |
---|
2115 | * \param scalingList quantization matrix information |
---|
2116 | * \param sizeIdc size index |
---|
2117 | * \param listIdc list index |
---|
2118 | */ |
---|
2119 | Void TEncCavlc::xCodeScalingList(TComScalingList* scalingList, UInt sizeId, UInt listId) |
---|
2120 | { |
---|
2121 | #if SCALING_LIST |
---|
2122 | Int coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
2123 | UInt* scan = g_auiFrameScanXY [ (sizeId == 0)? 1 : 2]; |
---|
2124 | #else |
---|
2125 | Int coefNum = (Int)g_scalingListSize[sizeId]; |
---|
2126 | UInt* scan = g_auiFrameScanXY [ sizeId + 1]; |
---|
2127 | #endif |
---|
2128 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
2129 | Int data; |
---|
2130 | Int *src = scalingList->getScalingListAddress(sizeId, listId); |
---|
2131 | #if SCALING_LIST |
---|
2132 | if(sizeId > SCALING_LIST_8x8 && scalingList->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
2133 | { |
---|
2134 | WRITE_SVLC( -8, "scaling_list_dc_coef_minus8"); |
---|
2135 | } |
---|
2136 | else if(sizeId < SCALING_LIST_16x16 && scalingList->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
2137 | { |
---|
2138 | WRITE_SVLC( -8, "scaling_list_delta_coef"); |
---|
2139 | } |
---|
2140 | else |
---|
2141 | { |
---|
2142 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2143 | { |
---|
2144 | WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8"); |
---|
2145 | } |
---|
2146 | for(Int i=0;i<coefNum;i++) |
---|
2147 | { |
---|
2148 | data = src[scan[i]] - nextCoef; |
---|
2149 | nextCoef = src[scan[i]]; |
---|
2150 | if(data > 127) |
---|
2151 | { |
---|
2152 | data = data - 256; |
---|
2153 | } |
---|
2154 | if(data < -128) |
---|
2155 | { |
---|
2156 | data = data + 256; |
---|
2157 | } |
---|
2158 | |
---|
2159 | WRITE_SVLC( data, "scaling_list_delta_coef"); |
---|
2160 | } |
---|
2161 | } |
---|
2162 | #else |
---|
2163 | for(Int i=0;i<coefNum;i++) |
---|
2164 | { |
---|
2165 | data = src[scan[i]] - nextCoef; |
---|
2166 | nextCoef = src[scan[i]]; |
---|
2167 | if(data > 127) |
---|
2168 | { |
---|
2169 | data = data - 256; |
---|
2170 | } |
---|
2171 | if(data < -128) |
---|
2172 | { |
---|
2173 | data = data + 256; |
---|
2174 | } |
---|
2175 | |
---|
2176 | WRITE_SVLC( data, "delta_coef"); |
---|
2177 | } |
---|
2178 | #endif |
---|
2179 | } |
---|
2180 | Bool TComScalingList::checkPredMode(UInt sizeId, UInt listId) |
---|
2181 | { |
---|
2182 | for(Int predListIdx = (Int)listId -1 ; predListIdx >= 0; predListIdx--) |
---|
2183 | { |
---|
2184 | #if SCALING_LIST |
---|
2185 | if( !memcmp(getScalingListAddress(sizeId,listId),getScalingListAddress(sizeId, predListIdx),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
2186 | && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value |
---|
2187 | #else |
---|
2188 | if( !memcmp(getScalingListAddress(sizeId,listId),getScalingListAddress(sizeId, predListIdx),sizeof(Int)*(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
2189 | #endif |
---|
2190 | { |
---|
2191 | setRefMatrixId(sizeId, listId, predListIdx); |
---|
2192 | return false; |
---|
2193 | } |
---|
2194 | } |
---|
2195 | return true; |
---|
2196 | } |
---|
2197 | |
---|
2198 | #if RWTH_SDC_DLT_B0036 |
---|
2199 | Void TEncCavlc::codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
2200 | { |
---|
2201 | assert(0); |
---|
2202 | } |
---|
2203 | |
---|
2204 | Void TEncCavlc::codeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ) |
---|
2205 | { |
---|
2206 | assert(0); |
---|
2207 | } |
---|
2208 | |
---|
2209 | Void TEncCavlc::codeSDCPredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
2210 | { |
---|
2211 | assert(0); |
---|
2212 | } |
---|
2213 | #endif |
---|
2214 | //! \} |
---|