1 /* 2 * Copyright (c) 2007-2014 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_dec_vp9.h 27 * \brief The VP9 decoding API 28 * 29 * This file contains the \ref api_dec_vp9 "VP9 decoding API". 30 */ 31 32 #ifndef VA_DEC_VP9_H 33 #define VA_DEC_VP9_H 34 35 #include <stdint.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /** 42 * \defgroup api_dec_vp9 VP9 decoding API 43 * 44 * This VP9 decoding API supports 8-bit 420 format only. 45 * 46 * @{ 47 */ 48 49 50 51 52 /** 53 * \brief VP9 Decoding Picture Parameter Buffer Structure 54 * 55 * This structure conveys picture level parameters. 56 * App should send a surface with this data structure down to VAAPI once 57 * per frame. 58 * 59 */ 60 typedef struct _VADecPictureParameterBufferVP9 61 { 62 /**@{*/ 63 64 /** \brief picture width 65 * The value must be multiple of 8. 66 */ 67 uint16_t frame_width; 68 /** \brief picture height 69 * The value must be multiple of 8. 70 */ 71 uint16_t frame_height; 72 73 /** \brief Surface index of decoded current picture 74 */ 75 VASurfaceID curr_pic; 76 /** \brief Surface indices of reference frames in DPB. 77 * 78 * Each entry of the list specifies the surface index of the picture 79 * that is referred by current picture or will be referred by any future 80 * picture. 81 * Application who calls this API should update this list based on the 82 * refreshing information from VP9 bitstream. 83 */ 84 VASurfaceID reference_frames[8]; 85 86 union 87 { 88 struct 89 { 90 /** \brief flags for current picture 91 * same syntax and semantic as those in VP9 code 92 */ 93 uint32_t subsampling_x : 1; 94 uint32_t subsampling_y : 1; 95 uint32_t frame_type : 1; 96 uint32_t show_frame : 1; 97 uint32_t error_resilient_mode : 1; 98 uint32_t intra_only : 1; 99 uint32_t allow_high_precision_mv : 1; 100 uint32_t mcomp_filter_type : 3; 101 uint32_t frame_parallel_decoding_mode : 1; 102 uint32_t reset_frame_context : 2; 103 uint32_t refresh_frame_context : 1; 104 uint32_t frame_context_idx : 2; 105 uint32_t segmentation_enabled : 1; 106 107 /** \brief corresponds to variable temporal_update in VP9 code. 108 */ 109 uint32_t segmentation_temporal_update : 1; 110 /** \brief corresponds to variable update_mb_segmentation_map 111 * in VP9 code. 112 */ 113 uint32_t segmentation_update_map : 1; 114 115 /** \brief Index of reference_frames[] and points to the 116 * LAST reference frame. 117 * It corresponds to active_ref_idx[0] in VP9 code. 118 */ 119 uint32_t last_ref_frame : 3; 120 /** \brief Sign Bias of the LAST reference frame. 121 * It corresponds to ref_frame_sign_bias[LAST_FRAME] in VP9 code. 122 */ 123 uint32_t last_ref_frame_sign_bias : 1; 124 /** \brief Index of reference_frames[] and points to the 125 * GOLDERN reference frame. 126 * It corresponds to active_ref_idx[1] in VP9 code. 127 */ 128 uint32_t golden_ref_frame : 3; 129 /** \brief Sign Bias of the GOLDERN reference frame. 130 * Corresponds to ref_frame_sign_bias[GOLDERN_FRAME] in VP9 code. 131 */ 132 uint32_t golden_ref_frame_sign_bias : 1; 133 /** \brief Index of reference_frames[] and points to the 134 * ALTERNATE reference frame. 135 * Corresponds to active_ref_idx[2] in VP9 code. 136 */ 137 uint32_t alt_ref_frame : 3; 138 /** \brief Sign Bias of the ALTERNATE reference frame. 139 * Corresponds to ref_frame_sign_bias[ALTREF_FRAME] in VP9 code. 140 */ 141 uint32_t alt_ref_frame_sign_bias : 1; 142 /** \brief Lossless Mode 143 * LosslessFlag = base_qindex == 0 && 144 * y_dc_delta_q == 0 && 145 * uv_dc_delta_q == 0 && 146 * uv_ac_delta_q == 0; 147 * Where base_qindex, y_dc_delta_q, uv_dc_delta_q and uv_ac_delta_q 148 * are all variables in VP9 code. 149 */ 150 uint32_t lossless_flag : 1; 151 } bits; 152 uint32_t value; 153 } pic_fields; 154 155 /* following parameters have same syntax with those in VP9 code */ 156 uint8_t filter_level; 157 uint8_t sharpness_level; 158 159 /** \brief number of tile rows specified by (1 << log2_tile_rows). 160 * It corresponds the variable with same name in VP9 code. 161 */ 162 uint8_t log2_tile_rows; 163 /** \brief number of tile columns specified by (1 << log2_tile_columns). 164 * It corresponds the variable with same name in VP9 code. 165 */ 166 uint8_t log2_tile_columns; 167 /** \brief Number of bytes taken up by the uncompressed frame header, 168 * which corresponds to byte length of function 169 * read_uncompressed_header() in VP9 code. 170 * Specifically, it is the byte count from bit stream buffer start to 171 * the last byte of uncompressed frame header. 172 */ 173 uint8_t frame_header_length_in_bytes; 174 175 /** \brief The byte count of compressed header the bitstream buffer, 176 * which corresponds to syntax first_partition_size in code. 177 */ 178 uint16_t first_partition_size; 179 180 /** \brief The byte count of current frame in the bitstream buffer, 181 * starting from first byte of the buffer. 182 */ 183 uint32_t frame_data_size; 184 185 /** These values are segment probabilities with same names in VP9 186 * function setup_segmentation(). They should be parsed directly from 187 * bitstream by application. 188 */ 189 uint8_t mb_segment_tree_probs[7]; 190 uint8_t segment_pred_probs[3]; 191 192 /** \brief VP9 version number 193 * value can be 0 or 1. 194 */ 195 uint8_t version; 196 /**@}*/ 197 198 } VADecPictureParameterBufferVP9; 199 200 201 202 /** 203 * \brief VP9 Segmentation Parameter Data Structure 204 * 205 * This structure conveys per segment parameters. 206 * 8 of this data structure will be included in VASegmentationParameterBufferVP9 207 * and sent to API in a single buffer. 208 * 209 */ 210 typedef struct _VASegmentParameterVP9 211 { 212 /**@{*/ 213 214 union 215 { 216 struct 217 { 218 /** \brief Indicates if per segment reference frame indicator 219 * is enabled. 220 * Corresponding to variable feature_enabled when 221 * j == SEG_LVL_REF_FRAME in function setup_segmentation() VP9 code. 222 */ 223 uint16_t segment_reference_enabled : 1; 224 /** \brief Specifies per segment reference indication. 225 * 0: reserved 226 * 1: Last ref 227 * 2: golden 228 * 3: altref 229 * Value can be derived from variable data when 230 * j == SEG_LVL_REF_FRAME in function setup_segmentation() VP9 code. 231 */ 232 uint16_t segment_reference : 2; 233 /** \brief Indicates if per segment skip feature is enabled. 234 * Corresponding to variable feature_enabled when 235 * j == SEG_LVL_SKIP in function setup_segmentation() VP9 code. 236 */ 237 uint16_t segment_reference_skipped : 1; 238 } fields; 239 uint16_t value; 240 } segment_flags; 241 242 /** \brief Specifies the filter level information per segment. 243 * The value corresponds to variable lfi->lvl[seg][ref][mode] in VP9 code, 244 * where m is [ref], and n is [mode] in FilterLevel[m][n]. 245 */ 246 uint8_t filter_level[4][2]; 247 /** \brief Specifies per segment Luma AC quantization scale. 248 * Corresponding to y_dequant[qindex][1] in vp9_mb_init_quantizer() 249 * function of VP9 code. 250 */ 251 int16_t luma_ac_quant_scale; 252 /** \brief Specifies per segment Luma DC quantization scale. 253 * Corresponding to y_dequant[qindex][0] in vp9_mb_init_quantizer() 254 * function of VP9 code. 255 */ 256 int16_t luma_dc_quant_scale; 257 /** \brief Specifies per segment Chroma AC quantization scale. 258 * Corresponding to uv_dequant[qindex][1] in vp9_mb_init_quantizer() 259 * function of VP9 code. 260 */ 261 int16_t chroma_ac_quant_scale; 262 /** \brief Specifies per segment Chroma DC quantization scale. 263 * Corresponding to uv_dequant[qindex][0] in vp9_mb_init_quantizer() 264 * function of VP9 code. 265 */ 266 int16_t chroma_dc_quant_scale; 267 268 /**@}*/ 269 270 } VASegmentParameterVP9; 271 272 273 274 /** 275 * \brief VP9 Slice Parameter Buffer Structure 276 * 277 * This structure conveys parameters related to segmentation data and should be 278 * sent once per frame. 279 * 280 * When segmentation is disabled, only SegParam[0] has valid values, 281 * all other entries should be populated with 0. 282 * Otherwise, all eight entries should be valid. 283 * 284 * Slice data buffer of VASliceDataBufferType is used 285 * to send the bitstream which should include whole or part of partition 0 286 * (at least compressed header) to the end of frame. 287 * 288 */ 289 typedef struct _VASliceParameterBufferVP9 290 { 291 /**@{*/ 292 /** 293 * \brief per segment information 294 */ 295 VASegmentParameterVP9 seg_param[8]; 296 297 /**@}*/ 298 299 } VASliceParameterBufferVP9; 300 301 302 /**@}*/ 303 304 #ifdef __cplusplus 305 } 306 #endif 307 308 #endif /* VA_DEC_VP9_H */ 309