| 1 | /* |
| 2 | * Copyright (c) 2007-2017 Intel Corporation. All Rights Reserved. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the |
| 6 | * "Software"), to deal in the Software without restriction, including |
| 7 | * without limitation the rights to use, copy, modify, merge, publish, |
| 8 | * distribute, sub license, and/or sell copies of the Software, and to |
| 9 | * permit persons to whom the Software is furnished to do so, subject to |
| 10 | * the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice (including the |
| 13 | * next paragraph) shall be included in all copies or substantial portions |
| 14 | * of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
| 19 | * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR |
| 20 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 21 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 22 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | /** |
| 26 | * \file va_fei_hevc.h |
| 27 | * \brief The FEI encoding HEVC special API |
| 28 | */ |
| 29 | |
| 30 | |
| 31 | #ifndef __VA_FEI_HEVC_H__ |
| 32 | #define __VA_FEI_HEVC_H__ |
| 33 | |
| 34 | #ifdef __cplusplus |
| 35 | extern "C" { |
| 36 | #endif |
| 37 | |
| 38 | #include <stdint.h> |
| 39 | #include "va_fei.h" |
| 40 | |
| 41 | /** |
| 42 | * \defgroup api_fei_hevc HEVC FEI encoding API |
| 43 | * |
| 44 | * @{ |
| 45 | */ |
| 46 | |
| 47 | /** \brief FEI frame level control buffer for HEVC */ |
| 48 | typedef struct _VAEncMiscParameterFEIFrameControlHEVC { |
| 49 | /* one of the VAConfigAttribFEIFunctionType values */ |
| 50 | uint32_t function; |
| 51 | /** \brief CTB control input buffer. It is valid only when per_ctb_input |
| 52 | * is set to 1. The data in this buffer correspond to the input source. CTB is in raster scan order, |
| 53 | * each CTB control data structure is defined by VAEncFEICTBControlHEVC. |
| 54 | * Buffer size shall not be less than the number of CTBs multiplied by |
| 55 | * sizeof(VAEncFEICTBControlHEVC). |
| 56 | */ |
| 57 | VABufferID ctb_ctrl; |
| 58 | /** \brief CTB cmd per CTB data output of ENC |
| 59 | * it is reserved for CTB level information |
| 60 | * it should include CU split information and other CTB datas . |
| 61 | * Each CTB block has one CTB cmd data. |
| 62 | */ |
| 63 | VABufferID ctb_cmd; |
| 64 | /** \brief CU record data output of ENC |
| 65 | * it is reserved for CU level information |
| 66 | * it should include CU detail data. include mode,MV, reference etc. |
| 67 | * Each CTB block has one CU record data. |
| 68 | */ |
| 69 | VABufferID cu_record; |
| 70 | /** \brief distortion output of ENC or ENC_PAK. |
| 71 | * Each CTB has one distortion data with VAEncFEIDistortionHevc |
| 72 | * Buffer size shall not be less than the number of CTBs multiplied by |
| 73 | * sizeof(VAEncFEIDistortionHevc). |
| 74 | */ |
| 75 | VABufferID distortion; |
| 76 | /** \brief Qp input buffer. It is valid only when per_block_qp is set to 1. |
| 77 | * The data in this buffer correspond to the input source. |
| 78 | * One Qp per block block is in raster scan order, each Qp is a signed char (8-bit) value. |
| 79 | **/ |
| 80 | VABufferID qp; |
| 81 | /** \brief MV predictor. It is valid only when mv_predictor_input is set to non-zero. |
| 82 | * Each CTB block has one or more pair of motion vectors and the corresponding |
| 83 | * reference indexes as defined by VAEncFEIMVPredictorHEVC. 32x32 block is in raster scan order. |
| 84 | * Buffer size shall not be less than the number of 16x16 blocks multiplied by |
| 85 | * sizeof(VAEncFEIMVPredictorHEVC). */ |
| 86 | VABufferID mv_predictor; |
| 87 | |
| 88 | /** \brief number of MV predictors L0 and L1. the maximum number of motion vector predictor for a 16x16, 32x32 or |
| 89 | * 64x64 block is four, it must not be greater than maximum supported MV predictor, |
| 90 | **/ |
| 91 | uint32_t num_mv_predictors_l0 : 16; |
| 92 | uint32_t num_mv_predictors_l1 : 16; |
| 93 | |
| 94 | /** \brief control parameters */ |
| 95 | uint32_t search_path : 8; |
| 96 | uint32_t len_sp : 8; |
| 97 | uint32_t reserved0 : 16; |
| 98 | |
| 99 | /** \brief multi pred l0/1 |
| 100 | * 0000: no internal MV predictor will be used |
| 101 | * 0001: spatial MV predictors |
| 102 | * 0100/1000: Reserved |
| 103 | **/ |
| 104 | uint32_t multi_pred_l0 : 4; |
| 105 | uint32_t multi_pred_l1 : 4; |
| 106 | /** \brief defines the motion vector precision, like integer/half/quarter pel. |
| 107 | * 00b: integer pel |
| 108 | * 01b: half-pel |
| 109 | * 10b: reserved |
| 110 | * 11b: quarter-pel |
| 111 | */ |
| 112 | uint32_t sub_pel_mode : 2; |
| 113 | uint32_t adaptive_search : 1; |
| 114 | /** \brief mv_predictor_input |
| 115 | * 000: MV predictor disabled |
| 116 | * 001: MV predictor enabled per 16x16 block |
| 117 | * 010: MV predictor enabled per 32x32 block |
| 118 | * 011: MV predictor enabled per 64x64 block |
| 119 | * 111: MV predictor enabled, block size can vary and is determined by BlockSize in motion vector predictor buffer |
| 120 | * 100/101/110: Reserved |
| 121 | **/ |
| 122 | uint32_t mv_predictor_input : 3; |
| 123 | /** \brief enables per CTB or CU qp */ |
| 124 | uint32_t per_block_qp : 1; |
| 125 | /** \brief enables the per CTB input , if 1, need ctb_ctrl to be a real surface ID*/ |
| 126 | uint32_t per_ctb_input : 1; |
| 127 | /** when this flag is set, extra distortion between current CTB and co-located CTB is provided. |
| 128 | * Extra distortion output has performance impact, set it only when it is needed */ |
| 129 | uint32_t colocated_ctb_distortion : 1; |
| 130 | /** brief specifies whether this CTB should be forced to split to remove Inter big LCU: do not check Inter 32x32 |
| 131 | * PUs. Every 32x32 LCU is split at least once. It can be used to improved performance. |
| 132 | * 0: ENC determined block type |
| 133 | * 1: Force to split |
| 134 | **/ |
| 135 | uint32_t force_lcu_split : 1; |
| 136 | /** \brief enables CU64x64 check */ |
| 137 | uint32_t enable_cu64_check : 1; |
| 138 | /** \brief enables CU64x64 asymmetric motion partition check */ |
| 139 | uint32_t enable_cu64_amp_check : 1; |
| 140 | /** \brief specifies if check the 64x64 merge candidate |
| 141 | * 0: after skip check, |
| 142 | * 1: only skip check for 64x64 |
| 143 | Default: 0. This field is used by LCU64 bi-directional. |
| 144 | **/ |
| 145 | uint32_t cu64_skip_check_only : 1; |
| 146 | uint32_t reserved1 : 11; |
| 147 | /** specifies the search region width in pixels. |
| 148 | * When bidirectional search is enabled, this applies to both search regions */ |
| 149 | uint32_t ref_width : 8; |
| 150 | /** specifies the reference region height in pixels. When bidirectional search is enabled, |
| 151 | * this applies to both search regions. */ |
| 152 | uint32_t ref_height : 8; |
| 153 | /** \brief search window similar for AVC |
| 154 | * defines predefined search windows. If it is selected, RefWidth, RefHeight, LenSP and SearchPath are ignored. |
| 155 | * 0 : not use predefined search window |
| 156 | * 1 : Tiny – (4 SUs) 24x24 window diamond search |
| 157 | * 2 : Small – (9 SUs) 28x28 window diamond search |
| 158 | * 3 : Diamond – (16 SUs) 48x40 window diamond search |
| 159 | * 4 : Large Diamond – (32 SUs) 48x40 window diamond search |
| 160 | * 5 : Exhaustive – 48x40 window full search |
| 161 | * 6 : (64 SUs) 64x64 window full search |
| 162 | * Note: option 1, 2, 3 and 4 are valid only when CAP parameter SearchWindow64Support is 0. |
| 163 | * And option 6 is valid only when SearchWindow64Support is 1.*/ |
| 164 | uint32_t search_window : 8; |
| 165 | /** \brief number of internal MV predictors for IME searches */ |
| 166 | uint32_t max_num_ime_search_center : 3; |
| 167 | /** \brief fast intra prediction enabling bit. It is used as a trade-off between speed and quality. |
| 168 | * The flag will be ignored if it's unsupported in the driver*/ |
| 169 | uint32_t fast_intra_mode : 1; |
| 170 | uint32_t reserved2 : 4; |
| 171 | |
| 172 | /** \brief specifies number of splits that encoder could be run concurrently |
| 173 | * 1: level 1, default value |
| 174 | * 2: level 2 |
| 175 | * 4: level 3 |
| 176 | **/ |
| 177 | uint32_t num_concurrent_enc_frame_partition : 8; |
| 178 | uint32_t reserved3 : 24; |
| 179 | |
| 180 | /** \brief max frame size control with multi passes QP setting */ |
| 181 | uint32_t max_frame_size; |
| 182 | /** \brief number of passes, every pass has different QP */ |
| 183 | uint32_t num_passes; |
| 184 | /** \brief delta QP list for every pass */ |
| 185 | uint8_t *delta_qp; |
| 186 | |
| 187 | uint32_t reserved4[2]; |
| 188 | } VAEncMiscParameterFEIFrameControlHEVC; |
| 189 | |
| 190 | /** \brief Application can use this definition as reference to allocate the buffer |
| 191 | * based on MaxNumPredictor returned from attribute VAConfigAttribFEIMVPredictors query. |
| 192 | * this buffer allocation is always based on 16x16 block even block size is indicated as 32x32 or 64x64, and buffer |
| 193 | * layout is always in 32x32 block raster scan order even block size is 16x16 or 64x64. If 32x32 block size is set, |
| 194 | * only the data in the first 16x16 block (block 0) is used for 32x32 block. If 64x64 block size is set |
| 195 | * MV layout is still in 32x32 raster scan order, the same as 32x32 and the first 16x16 |
| 196 | * block within each 32x32 block needs to have intended MV data (four 32x32 blocks will have the same MV data in the |
| 197 | * correspondent first 16x16 block). Data structure for each 16x16 block is defined as below (same as AVC except |
| 198 | * BlockSize/Reserved bits). |
| 199 | **/ |
| 200 | typedef struct _VAEncFEIMVPredictorHEVC { |
| 201 | /** \brief Feference index corresponding to the entry of RefPicList0 & RefPicList1 in slice header (final reference |
| 202 | * list). Note that RefPicList0 & RefPicList1 needs to be the same for all slices. |
| 203 | * Ref0xIndex – RefPicList0; Ref1xIndex – RefPicList1; x – 0 ~ MaxNumPredictor */ |
| 204 | struct { |
| 205 | uint8_t ref_idx_l0 : 4; |
| 206 | uint8_t ref_idx_l1 : 4; |
| 207 | } ref_idx[4]; /* index is predictor number */ |
| 208 | /** \brief Valid only when MVPredictor is set to 011 for HEVC. Only valid in the first 16x16 block. |
| 209 | * 00: MV predictor disabled for this 32x32 block |
| 210 | * 01: MV predictor enabled per 16x16 block for this 32x32 block |
| 211 | * 10: MV predictor enabled per 32x32 block, the rest of 16x16 block data within this 32x32 block are ignored |
| 212 | * 11: Reserved */ |
| 213 | uint32_t block_size : 2; |
| 214 | uint32_t reserved : 30; |
| 215 | |
| 216 | VAMotionVector mv[4]; /* MaxNumPredictor is 4 */ |
| 217 | } VAEncFEIMVPredictorHEVC; //40 bytes |
| 218 | |
| 219 | /** \brief FEI CTB level control data structure */ |
| 220 | typedef struct _VAEncFEICTBControlHEVC { |
| 221 | // DWORD 0 |
| 222 | uint32_t force_to_intra : 1; |
| 223 | uint32_t force_to_inter : 1; |
| 224 | uint32_t force_to_skip : 1; |
| 225 | /** \brief force all coeff to zero */ |
| 226 | uint32_t force_to_zero_coeff : 1; |
| 227 | uint32_t reserved0 : 28; |
| 228 | // DWORD 1 |
| 229 | uint32_t reserved1; |
| 230 | // DWORD 2 |
| 231 | uint32_t reserved2; |
| 232 | // DWORD 3 |
| 233 | uint32_t reserved3; |
| 234 | } VAEncFEICTBControlHEVC; |
| 235 | |
| 236 | /** \brief VAEncFEIDistortionHevc defines the data structure for VAEncFEIDistortionBufferType per CTB block. |
| 237 | * It is output buffer of ENC and ENC_PAK modes, The CTB block is in raster scan order. |
| 238 | * Buffer size shall not be less than the number of CTB blocks multiple by sizeof(VAEncFEIDistortionHevc). |
| 239 | **/ |
| 240 | typedef struct _VAEncFEIDistortionHevc { |
| 241 | /** best CTB distortion */ |
| 242 | uint32_t best_distortion; |
| 243 | /** only when colocated_ctb_distortion in VAEncMiscParameterFEIFrameControlHEVC is set */ |
| 244 | uint32_t colocated_ctb_distortion; |
| 245 | } VAEncFEIDistortionHevc; |
| 246 | #ifdef __cplusplus |
| 247 | } |
| 248 | #endif |
| 249 | |
| 250 | #endif |
| 251 | |
| 252 | |