1 /****************************************************************************** 2 * 3 * Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 /** 19 ******************************************************************************* 20 * @file 21 * ihevcd_defs.h 22 * 23 * @brief 24 * Definitions used in the decoder 25 * 26 * @author 27 * Harish 28 * 29 * @par List of Functions: 30 * 31 * @remarks 32 * None 33 * 34 ******************************************************************************* 35 */ 36 37 #ifndef _IHEVCD_DEFS_H_ 38 #define _IHEVCD_DEFS_H_ 39 40 41 /*****************************************************************************/ 42 /* Width and height restrictions */ 43 /*****************************************************************************/ 44 /** 45 * Minimum width supported by codec 46 */ 47 #define MIN_WD 64 48 49 /** 50 * Maximum width supported by codec 51 */ 52 53 #define MAX_WD 8448 54 55 /** 56 * Minimum height supported by codec 57 */ 58 #define MIN_HT 64 59 60 /** 61 * Maximum height supported by codec 62 */ 63 64 #define MAX_HT 4320 65 66 /*****************************************************************************/ 67 /* Padding sizes */ 68 /*****************************************************************************/ 69 /** 70 * Padding used for top of the frame 71 */ 72 #define PAD_TOP 80 73 74 /** 75 * Padding used for bottom of the frame 76 */ 77 #define PAD_BOT 80 78 79 /** 80 * Padding used at left of the frame 81 */ 82 #define PAD_LEFT 80 83 84 /** 85 * Padding used at right of the frame 86 */ 87 #define PAD_RIGHT 80 88 /** 89 * Padding for width 90 */ 91 #define PAD_WD (PAD_LEFT + PAD_RIGHT) 92 /** 93 * Padding for height 94 */ 95 #define PAD_HT (PAD_TOP + PAD_BOT) 96 97 /*****************************************************************************/ 98 /* Number of frame restrictions */ 99 /*****************************************************************************/ 100 /** 101 * Maximum number of reference buffers in DPB manager 102 */ 103 #define MAX_REF_CNT 32 104 105 /** 106 * Maximum number of CU info buffers 107 */ 108 #define MAX_CU_INFO_BUF_CNT MAX_REF_CNT 109 110 /*****************************************************************************/ 111 /* Num cores releated defs */ 112 /*****************************************************************************/ 113 /** 114 * Maximum number of cores 115 */ 116 #define MAX_NUM_CORES 8 117 118 /** 119 * Maximum number of threads for pixel processing 120 */ 121 #define MAX_PROCESS_THREADS MAX_NUM_CORES 122 123 /** If num_cores is greater than MV_PRED_NUM_CORES_THRESHOLD, then mv pred and 124 boundary strength computation is done in process side instead of parse side. 125 This ensures thread that does parsing does minimal work */ 126 #define MV_PRED_NUM_CORES_THRESHOLD 2 127 128 /*****************************************************************************/ 129 /* Profile and level restrictions */ 130 /*****************************************************************************/ 131 /** 132 * Max level supported by the codec 133 */ 134 #define MAX_LEVEL IHEVC_LEVEL_62 135 /** 136 * Min level supported by the codec 137 */ 138 139 #define MIN_LEVEL IHEVC_LEVEL_10 140 141 142 /** 143 * Maximum number of slice headers that are held in memory simultaneously 144 * For single core implementation only 1 slice header is enough. 145 * But for multi-core parsing thread needs to ensure that slice headers are 146 * stored till the last CB in a slice is decoded. 147 * Parsing thread has to wait till last CB of a slice is consumed before reusing 148 * overwriting the slice header 149 * MAX_SLICE_HDR_CNT is assumed to be a power of 2 150 */ 151 152 #define LOG2_MAX_SLICE_HDR_CNT 8 153 #define MAX_SLICE_HDR_CNT (1 << LOG2_MAX_SLICE_HDR_CNT) 154 155 /* Number of NOP instructions to wait before yielding in process thread */ 156 #define PROC_NOP_CNT (8 * 128) 157 158 159 /** Max QP delta that can be signalled */ 160 #define TU_MAX_QP_DELTA_ABS 5 161 162 /** Max QP delta context increment that can be used for CABAC context */ 163 #define CTXT_MAX_QP_DELTA_ABS 1 164 165 /* 166 * Flag whether to perform ilf at frame level or CTB level 167 */ 168 #define FRAME_ILF_PAD 0 169 170 #define MAX_NUM_CTBS_IN_FRAME (MAX_WD * MAX_HT / MIN_CTB_SIZE / MIN_CTB_SIZE) 171 172 /* Maximum slice segments allowed per frame in Level 6.2 */ 173 #define MAX_SLICE_SEGMENTS_IN_FRAME 600 174 175 /** 176 * Buffer allocated for ps_tu is re-used after RESET_TU_BUF_NCTB 177 * Set this to MAX_NUM_CTBS_IN_FRAME to disabke reuse 178 */ 179 #define RESET_TU_BUF_NCTB MAX_NUM_CTBS_IN_FRAME 180 /** 181 * Flag whether to shift the CTB for SAO 182 */ 183 #define SAO_PROCESS_SHIFT_CTB 1 184 185 /** 186 * Minimum bistream buffer size 187 */ 188 #define MIN_BITSBUF_SIZE (1024 * 1024) 189 /** 190 ***************************************************************************** 191 * Macro to compute total size required to hold on set of scaling matrices 192 ***************************************************************************** 193 */ 194 #define SCALING_MAT_SIZE(m_scaling_mat_size) \ 195 { \ 196 m_scaling_mat_size = 6 * TRANS_SIZE_4 * TRANS_SIZE_4; \ 197 m_scaling_mat_size += 6 * TRANS_SIZE_8 * TRANS_SIZE_8; \ 198 m_scaling_mat_size += 6 * TRANS_SIZE_16 * TRANS_SIZE_16; \ 199 m_scaling_mat_size += 2 * TRANS_SIZE_32 * TRANS_SIZE_32; \ 200 } 201 202 /** 203 *************************************************************************** 204 * Enum to hold various mem records being request 205 **************************************************************************** 206 */ 207 enum 208 { 209 /** 210 * Codec Object at API level 211 */ 212 MEM_REC_IV_OBJ, 213 214 /** 215 * Codec context 216 */ 217 MEM_REC_CODEC, 218 219 /** 220 * Bitstream buffer which holds emulation prevention removed bytes 221 */ 222 MEM_REC_BITSBUF, 223 224 /** 225 * Buffer to hold TU structures and coeff data 226 */ 227 MEM_REC_TU_DATA, 228 229 /** 230 * Motion vector bank 231 */ 232 MEM_REC_MVBANK, 233 234 /** 235 * Holds mem records passed to the codec. 236 */ 237 MEM_REC_BACKUP, 238 239 /** 240 * Holds VPS 241 */ 242 MEM_REC_VPS, 243 244 /** 245 * Holds SPS 246 */ 247 MEM_REC_SPS, 248 249 /** 250 * Holds PPS 251 */ 252 MEM_REC_PPS, 253 254 /** 255 * Holds Slice Headers 256 */ 257 MEM_REC_SLICE_HDR, 258 259 /** 260 * Holds tile information such as start position, widths and heights 261 */ 262 MEM_REC_TILE, 263 264 /** 265 * Holds entry point offsets for tiles and entropy sync points 266 */ 267 MEM_REC_ENTRY_OFST, 268 269 /** 270 * Holds scaling matrices 271 */ 272 MEM_REC_SCALING_MAT, 273 274 /** 275 * Holds one row skip_flag at 8x8 level used during parsing 276 */ 277 MEM_REC_PARSE_SKIP_FLAG, 278 279 /** 280 * Holds one row ctb_tree_depth at 8x8 level used during parsing 281 */ 282 MEM_REC_PARSE_CT_DEPTH, 283 284 /** 285 * Holds one row luma intra pred mode at 8x8 level used during parsing 286 */ 287 MEM_REC_PARSE_INTRA_PRED_MODE, 288 289 /** 290 * Holds intra flag at 8x8 level for entire frame 291 * This is kept at frame level so that processing thread also can use this 292 * data during intra prediction and compute BS 293 */ 294 MEM_REC_INTRA_FLAG, 295 296 /** 297 * Holds transquant bypass flag at 8x8 level for entire frame 298 * This is kept at frame level so that processing thread also can use this 299 */ 300 MEM_REC_TRANSQUANT_BYPASS_FLAG, 301 302 /** 303 * Holds thread handles 304 */ 305 MEM_REC_THREAD_HANDLE, 306 307 /** 308 * Holds memory for Process JOB Queue 309 */ 310 MEM_REC_PROC_JOBQ, 311 312 /** 313 * Contains status map indicating parse status per CTB basis 314 */ 315 MEM_REC_PARSE_MAP, 316 317 /** 318 * Contains status map indicating processing status per CTB basis 319 */ 320 MEM_REC_PROC_MAP, 321 322 /** 323 * Holds display buffer manager context 324 */ 325 MEM_REC_DISP_MGR, 326 327 /** 328 * Holds dpb manager context 329 */ 330 MEM_REC_DPB_MGR, 331 332 /** 333 * Holds top and left neighbors' pu_idx array w.r.t picture level pu array 334 */ 335 MEM_REC_PIC_PU_IDX_NEIGHBOR, 336 337 /** 338 * Holds intermediate buffers needed during processing stage 339 * Memory for process contexts is allocated in this memtab 340 */ 341 MEM_REC_PROC_SCRATCH, 342 343 /** 344 * Holds intermediate buffers needed during SAO processing 345 */ 346 MEM_REC_SAO_SCRATCH, 347 348 /** 349 * Holds buffers for vert_bs, horz_bs and QP (all frame level) 350 */ 351 MEM_REC_BS_QP, 352 353 /** 354 * Contains slice map indicatating the slice index for each CTB 355 */ 356 MEM_REC_TILE_IDX, 357 358 /** 359 * Holds buffers for array of SAO structures 360 */ 361 MEM_REC_SAO, 362 363 /** 364 * Holds picture buffer manager context and array of pic_buf_ts 365 * Also holds reference picture buffers in non-shared mode 366 */ 367 MEM_REC_REF_PIC, 368 369 370 371 /** 372 * Place holder to compute number of memory records. 373 */ 374 MEM_REC_CNT 375 /* Do not add anything below */ 376 }; 377 378 379 380 #define DISABLE_DEBLOCK_INTERVAL 8 381 #define DISABLE_SAO_INTERVAL 8 382 383 /** 384 **************************************************************************** 385 * Disable deblock levels 386 * Level 0 enables deblocking completely and level 4 disables completely 387 * Other levels are intermediate values to control deblocking level 388 **************************************************************************** 389 */ 390 enum 391 { 392 /** 393 * Enable deblocking completely 394 */ 395 DISABLE_DEBLK_LEVEL_0, 396 /** 397 * Disable only within CTB edges - Not supported currently 398 */ 399 DISABLE_DEBLK_LEVEL_1, 400 401 /** 402 * Enable deblocking once in DEBLOCK_INTERVAL number of pictures 403 * and for I slices 404 */ 405 DISABLE_DEBLK_LEVEL_2, 406 407 /** 408 * Enable deblocking only for I slices 409 */ 410 DISABLE_DEBLK_LEVEL_3, 411 412 /** 413 * Disable deblocking completely 414 */ 415 DISABLE_DEBLK_LEVEL_4 416 }; 417 418 enum 419 { 420 /** 421 * Enable deblocking completely 422 */ 423 DISABLE_SAO_LEVEL_0, 424 /** 425 * Disable only within CTB edges - Not supported currently 426 */ 427 DISABLE_SAO_LEVEL_1, 428 429 /** 430 * Enable deblocking once in DEBLOCK_INTERVAL number of pictures 431 * and for I slices 432 */ 433 DISABLE_SAO_LEVEL_2, 434 435 /** 436 * Enable deblocking only for I slices 437 */ 438 DISABLE_SAO_LEVEL_3, 439 440 /** 441 * Disable deblocking completely 442 */ 443 DISABLE_SAO_LEVEL_4 444 }; 445 446 /** 447 **************************************************************************** 448 * Number of buffers for I/O based on format 449 **************************************************************************** 450 */ 451 #define MIN_IN_BUFS 1 452 #define MIN_OUT_BUFS_420 3 453 #define MIN_OUT_BUFS_422ILE 1 454 #define MIN_OUT_BUFS_RGB565 1 455 #define MIN_OUT_BUFS_RGBA8888 1 456 #define MIN_OUT_BUFS_420SP 2 457 458 /** 459 **************************************************************************** 460 * Definitions related to MV pred mv merge 461 **************************************************************************** 462 */ 463 #define MAX_NUM_MERGE_CAND 5 464 465 #define MAX_NUM_MV_NBR 5 466 467 #define MAX_MVP_LIST_CAND 2 468 #define MAX_MVP_LIST_CAND_MEM (MAX_MVP_LIST_CAND + 1) 469 470 471 472 #endif /*_IHEVCD_DEFS_H_*/ 473