| 1 |
/* |
| 2 |
* Copyright (c) 2007-2012 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_enc_vp8.h |
| 27 |
* \brief VP8 encoding API |
| 28 |
* |
| 29 |
* This file contains the \ref api_enc_vp8 "VP8 encoding API". |
| 30 |
*/ |
| 31 |
|
| 32 |
#ifndef VA_ENC_VP8_H |
| 33 |
#define VA_ENC_VP8_H |
| 34 |
|
| 35 |
#ifdef __cplusplus |
| 36 |
extern "C" { |
| 37 |
#endif |
| 38 |
|
| 39 |
/** |
| 40 |
* \defgroup api_enc_vp8 VP8 encoding API |
| 41 |
* |
| 42 |
* @{ |
| 43 |
*/ |
| 44 |
|
| 45 |
/** |
| 46 |
* \brief VP8 Encoding Sequence Parameter Buffer Structure |
| 47 |
* |
| 48 |
* This structure conveys sequence level parameters. |
| 49 |
* |
| 50 |
*/ |
| 51 |
typedef struct _VAEncSequenceParameterBufferVP8 { |
| 52 |
/* frame width in pixels */ |
| 53 |
uint32_t frame_width; |
| 54 |
/* frame height in pixels */ |
| 55 |
uint32_t frame_height; |
| 56 |
/* horizontal scale */ |
| 57 |
uint32_t frame_width_scale; |
| 58 |
/* vertical scale */ |
| 59 |
uint32_t frame_height_scale; |
| 60 |
|
| 61 |
/* whether to enable error resilience features */ |
| 62 |
uint32_t error_resilient; |
| 63 |
/* auto keyframe placement, non-zero means enable auto keyframe placement */ |
| 64 |
uint32_t kf_auto; |
| 65 |
/* keyframe minimum interval */ |
| 66 |
uint32_t kf_min_dist; |
| 67 |
/* keyframe maximum interval */ |
| 68 |
uint32_t kf_max_dist; |
| 69 |
|
| 70 |
|
| 71 |
/* RC related fields. RC modes are set with VAConfigAttribRateControl */ |
| 72 |
/* For VP8, CBR implies HRD conformance and VBR implies no HRD conformance */ |
| 73 |
|
| 74 |
/** |
| 75 |
* Initial bitrate set for this sequence in CBR or VBR modes. |
| 76 |
* |
| 77 |
* This field represents the initial bitrate value for this |
| 78 |
* sequence if CBR or VBR mode is used, i.e. if the encoder |
| 79 |
* pipeline was created with a #VAConfigAttribRateControl |
| 80 |
* attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR. |
| 81 |
* |
| 82 |
* The bitrate can be modified later on through |
| 83 |
* #VAEncMiscParameterRateControl buffers. |
| 84 |
*/ |
| 85 |
uint32_t bits_per_second; |
| 86 |
/* Period between I frames. */ |
| 87 |
uint32_t intra_period; |
| 88 |
|
| 89 |
/* reference and reconstructed frame buffers |
| 90 |
* Used for driver auto reference management when configured through |
| 91 |
* VAConfigAttribEncAutoReference. |
| 92 |
*/ |
| 93 |
VASurfaceID reference_frames[4]; |
| 94 |
|
| 95 |
/** \brief Reserved bytes for future use, must be zero */ |
| 96 |
uint32_t va_reserved[VA_PADDING_LOW]; |
| 97 |
} VAEncSequenceParameterBufferVP8; |
| 98 |
|
| 99 |
|
| 100 |
/** |
| 101 |
* \brief VP8 Encoding Picture Parameter Buffer Structure |
| 102 |
* |
| 103 |
* This structure conveys picture level parameters. |
| 104 |
* |
| 105 |
*/ |
| 106 |
typedef struct _VAEncPictureParameterBufferVP8 { |
| 107 |
/* surface to store reconstructed frame */ |
| 108 |
VASurfaceID reconstructed_frame; |
| 109 |
|
| 110 |
/* |
| 111 |
* surfaces to store reference frames in non auto reference mode |
| 112 |
* VA_INVALID_SURFACE can be used to denote an invalid reference frame. |
| 113 |
*/ |
| 114 |
VASurfaceID ref_last_frame; |
| 115 |
VASurfaceID ref_gf_frame; |
| 116 |
VASurfaceID ref_arf_frame; |
| 117 |
|
| 118 |
/* buffer to store coded data */ |
| 119 |
VABufferID coded_buf; |
| 120 |
|
| 121 |
union { |
| 122 |
struct { |
| 123 |
/* force this frame to be a keyframe */ |
| 124 |
uint32_t force_kf : 1; |
| 125 |
/* don't reference the last frame */ |
| 126 |
uint32_t no_ref_last : 1; |
| 127 |
/* don't reference the golden frame */ |
| 128 |
uint32_t no_ref_gf : 1; |
| 129 |
/* don't reference the alternate reference frame */ |
| 130 |
uint32_t no_ref_arf : 1; |
| 131 |
/* The temporal id the frame belongs to. */ |
| 132 |
uint32_t temporal_id : 8; |
| 133 |
/** |
| 134 |
* following two flags indicate the reference order |
| 135 |
* LastRef is specified by 01b; |
| 136 |
* GoldRef is specified by 10b; |
| 137 |
* AltRef is specified by 11b; |
| 138 |
* first_ref specifies the reference frame which is searched first. |
| 139 |
* second_ref specifies the reference frame which is searched second |
| 140 |
* if there is. |
| 141 |
*/ |
| 142 |
uint32_t first_ref : 2; |
| 143 |
uint32_t second_ref : 2; |
| 144 |
/** \brief Reserved for future use, must be zero */ |
| 145 |
uint32_t reserved : 16; |
| 146 |
} bits; |
| 147 |
uint32_t value; |
| 148 |
} ref_flags; |
| 149 |
|
| 150 |
union { |
| 151 |
struct { |
| 152 |
/* version */ |
| 153 |
uint32_t frame_type : 1; |
| 154 |
uint32_t version : 3; |
| 155 |
/* show_frame */ |
| 156 |
uint32_t show_frame : 1; |
| 157 |
/* color_space */ |
| 158 |
uint32_t color_space : 1; |
| 159 |
/* 0: bicubic, 1: bilinear, other: none */ |
| 160 |
uint32_t recon_filter_type : 2; |
| 161 |
/* 0: no loop fitler, 1: simple loop filter */ |
| 162 |
uint32_t loop_filter_type : 2; |
| 163 |
/* 0: disabled, 1: normal, 2: simple */ |
| 164 |
uint32_t auto_partitions : 1; |
| 165 |
/* same as log2_nbr_of_dct_partitions in frame header syntax */ |
| 166 |
uint32_t num_token_partitions : 2; |
| 167 |
|
| 168 |
/** |
| 169 |
* The following fields correspond to the same VP8 syntax elements |
| 170 |
* in the frame header. |
| 171 |
*/ |
| 172 |
/** |
| 173 |
* 0: clamping of reconstruction pixels is disabled, |
| 174 |
* 1: clamping enabled. |
| 175 |
*/ |
| 176 |
uint32_t clamping_type : 1; |
| 177 |
/* indicate segmentation is enabled for the current frame. */ |
| 178 |
uint32_t segmentation_enabled : 1; |
| 179 |
/** |
| 180 |
* Determines if the MB segmentation map is updated in the current |
| 181 |
* frame. |
| 182 |
*/ |
| 183 |
uint32_t update_mb_segmentation_map : 1; |
| 184 |
/** |
| 185 |
* Indicates if the segment feature data is updated in the current |
| 186 |
* frame. |
| 187 |
*/ |
| 188 |
uint32_t update_segment_feature_data : 1; |
| 189 |
/** |
| 190 |
* indicates if the MB level loop filter adjustment is enabled for |
| 191 |
* the current frame (0 off, 1 on). |
| 192 |
*/ |
| 193 |
uint32_t loop_filter_adj_enable : 1; |
| 194 |
/** |
| 195 |
* Determines whether updated token probabilities are used only for |
| 196 |
* this frame or until further update. |
| 197 |
* It may be used by application to enable error resilient mode. |
| 198 |
* In this mode probability updates are allowed only at Key Frames. |
| 199 |
*/ |
| 200 |
uint32_t refresh_entropy_probs : 1; |
| 201 |
/** |
| 202 |
* Determines if the current decoded frame refreshes the golden frame. |
| 203 |
*/ |
| 204 |
uint32_t refresh_golden_frame : 1; |
| 205 |
/** |
| 206 |
* Determines if the current decoded frame refreshes the alternate |
| 207 |
* reference frame. |
| 208 |
*/ |
| 209 |
uint32_t refresh_alternate_frame : 1; |
| 210 |
/** |
| 211 |
* Determines if the current decoded frame refreshes the last frame |
| 212 |
* reference buffer. |
| 213 |
*/ |
| 214 |
uint32_t refresh_last : 1; |
| 215 |
/** |
| 216 |
* Determines if the golden reference is replaced by another reference. |
| 217 |
*/ |
| 218 |
uint32_t copy_buffer_to_golden : 2; |
| 219 |
/** |
| 220 |
* Determines if the alternate reference is replaced by another reference. |
| 221 |
*/ |
| 222 |
uint32_t copy_buffer_to_alternate : 2; |
| 223 |
/** |
| 224 |
* Controls the sign of motion vectors when the golden frame is referenced. |
| 225 |
*/ |
| 226 |
uint32_t sign_bias_golden : 1; |
| 227 |
/** |
| 228 |
* Controls the sign of motion vectors when the alternate frame is |
| 229 |
* referenced. |
| 230 |
*/ |
| 231 |
uint32_t sign_bias_alternate : 1; |
| 232 |
/** |
| 233 |
* Enables or disables the skipping of macroblocks containing no |
| 234 |
* non-zero coefficients. |
| 235 |
*/ |
| 236 |
uint32_t mb_no_coeff_skip : 1; |
| 237 |
/** |
| 238 |
* Enforces unconditional per-MB loop filter delta update setting frame |
| 239 |
* header flags mode_ref_lf_delta_update, all mb_mode_delta_update_flag[4], |
| 240 |
* and all ref_frame_delta_update_flag[4] to 1. |
| 241 |
* Since loop filter deltas are not automatically refreshed to default |
| 242 |
* values at key frames, dropped frame with delta update may prevent |
| 243 |
* correct decoding from the next key frame. |
| 244 |
* Encoder application is advised to set this flag to 1 at key frames. |
| 245 |
*/ |
| 246 |
uint32_t forced_lf_adjustment : 1; |
| 247 |
uint32_t reserved : 2; |
| 248 |
} bits; |
| 249 |
uint32_t value; |
| 250 |
} pic_flags; |
| 251 |
|
| 252 |
/** |
| 253 |
* Contains a list of 4 loop filter level values (updated value if applicable) |
| 254 |
* controlling the deblocking filter strength. Each entry represents a segment. |
| 255 |
* When segmentation is disabled, use entry 0. |
| 256 |
* When loop_filter_level is 0, loop filter shall be disabled. |
| 257 |
*/ |
| 258 |
int8_t loop_filter_level[4]; |
| 259 |
|
| 260 |
/** |
| 261 |
* Contains a list of 4 delta values for reference frame based MB-level |
| 262 |
* loop filter adjustment. |
| 263 |
* If no update, then set to 0. |
| 264 |
*/ |
| 265 |
int8_t ref_lf_delta[4]; |
| 266 |
|
| 267 |
/** |
| 268 |
* Contains a list of 4 delta values for coding mode based MB-level loop |
| 269 |
* filter adjustment. |
| 270 |
* If no update, then set to 0. |
| 271 |
*/ |
| 272 |
int8_t mode_lf_delta[4]; |
| 273 |
|
| 274 |
/** |
| 275 |
* Controls the deblocking filter sensitivity. |
| 276 |
* Corresponds to the same VP8 syntax element in frame header. |
| 277 |
*/ |
| 278 |
uint8_t sharpness_level; |
| 279 |
|
| 280 |
/** |
| 281 |
* Application supplied maximum clamp value for Qindex used in quantization. |
| 282 |
* Qindex will not be allowed to exceed this value. |
| 283 |
* It has a valid range [0..127] inclusive. |
| 284 |
*/ |
| 285 |
uint8_t clamp_qindex_high; |
| 286 |
|
| 287 |
/** |
| 288 |
* Application supplied minimum clamp value for Qindex used in quantization. |
| 289 |
* Qindex will not be allowed to be lower than this value. |
| 290 |
* It has a valid range [0..127] inclusive. |
| 291 |
* Condition clamp_qindex_low <= clamp_qindex_high must be guaranteed, |
| 292 |
* otherwise they are ignored. |
| 293 |
*/ |
| 294 |
uint8_t clamp_qindex_low; |
| 295 |
|
| 296 |
/** \brief Reserved bytes for future use, must be zero */ |
| 297 |
uint32_t va_reserved[VA_PADDING_LOW]; |
| 298 |
} VAEncPictureParameterBufferVP8; |
| 299 |
|
| 300 |
|
| 301 |
/** |
| 302 |
* \brief VP8 MB Segmentation ID Buffer |
| 303 |
* |
| 304 |
* application provides buffer containing the initial segmentation id for each |
| 305 |
* MB, in raster scan order. Rate control may reassign it. |
| 306 |
* For an 640x480 video, the buffer has 1200 entries. |
| 307 |
* the value of each entry should be in the range [0..3], inclusive. |
| 308 |
* If segmentation is not enabled, application does not need to provide it. |
| 309 |
*/ |
| 310 |
typedef struct _VAEncMBMapBufferVP8 { |
| 311 |
/** |
| 312 |
* number of MBs in the frame. |
| 313 |
* It is also the number of entries of mb_segment_id[]; |
| 314 |
*/ |
| 315 |
uint32_t num_mbs; |
| 316 |
/** |
| 317 |
* per MB Segmentation ID Buffer |
| 318 |
*/ |
| 319 |
uint8_t *mb_segment_id; |
| 320 |
|
| 321 |
/** \brief Reserved bytes for future use, must be zero */ |
| 322 |
uint32_t va_reserved[VA_PADDING_LOW]; |
| 323 |
} VAEncMBMapBufferVP8; |
| 324 |
|
| 325 |
|
| 326 |
/** |
| 327 |
* \brief VP8 Quantization Matrix Buffer Structure |
| 328 |
* |
| 329 |
* Contains quantization index for yac(0-3) for each segment and quantization |
| 330 |
* index deltas, ydc(0), y2dc(1), y2ac(2), uvdc(3), uvac(4) that are applied |
| 331 |
* to all segments. When segmentation is disabled, only quantization_index[0] |
| 332 |
* will be used. This structure is sent once per frame. |
| 333 |
*/ |
| 334 |
typedef struct _VAQMatrixBufferVP8 { |
| 335 |
uint16_t quantization_index[4]; |
| 336 |
int16_t quantization_index_delta[5]; |
| 337 |
|
| 338 |
/** \brief Reserved bytes for future use, must be zero */ |
| 339 |
uint32_t va_reserved[VA_PADDING_LOW]; |
| 340 |
} VAQMatrixBufferVP8; |
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
/**@}*/ |
| 345 |
|
| 346 |
#ifdef __cplusplus |
| 347 |
} |
| 348 |
#endif |
| 349 |
|
| 350 |
#endif /* VA_ENC_VP8_H */ |