| 1 | /* | 
| 2 |  * Copyright (c) 2007-2011 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_h264.h | 
| 27 |  * \brief The H.264 encoding API | 
| 28 |  * | 
| 29 |  * This file contains the \ref api_enc_h264 "H.264 encoding API". | 
| 30 |  */ | 
| 31 |  | 
| 32 | #ifndef VA_ENC_H264_H | 
| 33 | #define VA_ENC_H264_H | 
| 34 |  | 
| 35 | #ifdef __cplusplus | 
| 36 | extern "C"  { | 
| 37 | #endif | 
| 38 |  | 
| 39 | /** | 
| 40 |  * \defgroup api_enc_h264 H.264 encoding API | 
| 41 |  * | 
| 42 |  * @{ | 
| 43 |  */ | 
| 44 |  | 
| 45 | /** | 
| 46 |  * @name Picture flags | 
| 47 |  * | 
| 48 |  * Those flags flags are meant to signal when a picture marks the end | 
| 49 |  * of a sequence, a stream, or even both at once. | 
| 50 |  * | 
| 51 |  * @{ | 
| 52 |  */ | 
| 53 | /** | 
| 54 |  * \brief Marks the last picture in the sequence. | 
| 55 |  * | 
| 56 |  * i.e. the driver appends \c end_of_seq() NAL unit to the encoded frame. | 
| 57 |  */ | 
| 58 | #define H264_LAST_PICTURE_EOSEQ     0x01 | 
| 59 | /** | 
| 60 |  * \brief Marks the last picture in the stream. | 
| 61 |  * | 
| 62 |  * i.e. the driver appends \c end_of_stream() NAL unit to the encoded frame. | 
| 63 |  */ | 
| 64 | #define H264_LAST_PICTURE_EOSTREAM  0x02 | 
| 65 | /**@}*/ | 
| 66 |  | 
| 67 | /** | 
| 68 |  * \brief Packed header types specific to H.264 encoding. | 
| 69 |  * | 
| 70 |  * Types of packed headers generally used for H.264 encoding. Each | 
| 71 |  * associated packed header data buffer shall contain the start code | 
| 72 |  * prefix 0x000001 followed by the complete NAL unit, thus also | 
| 73 |  * including the \c nal_unit_type. | 
| 74 |  * | 
| 75 |  * Note: the start code prefix can contain an arbitrary number of leading | 
| 76 |  * zeros. The driver will skip them for emulation prevention bytes insertion, | 
| 77 |  * if necessary. | 
| 78 |  */ | 
| 79 | typedef enum { | 
| 80 |     /** | 
| 81 |      * \brief Packed Sequence Parameter Set (SPS). | 
| 82 |      * | 
| 83 |      * The corresponding packed header data buffer shall contain the | 
| 84 |      * complete seq_parameter_set_rbsp() syntax element. | 
| 85 |      * | 
| 86 |      * Note: packed \c nal_unit_type shall be equal to 7. | 
| 87 |      */ | 
| 88 |        = VAEncPackedHeaderSequence, | 
| 89 |     /** | 
| 90 |      * \brief Packed Picture Parameter Set (PPS). | 
| 91 |      * | 
| 92 |      * The corresponding packed header data buffer shall contain the | 
| 93 |      * complete pic_parameter_set_rbsp() syntax element. | 
| 94 |      * | 
| 95 |      * Note: packed \c nal_unit_type shall be equal to 8. | 
| 96 |      */ | 
| 97 |        = VAEncPackedHeaderPicture, | 
| 98 |     /** | 
| 99 |      * \brief Packed slice header. | 
| 100 |      * | 
| 101 |      * The corresponding packed header data buffer shall contain the | 
| 102 |      * \c slice_header() syntax element only, along with any start | 
| 103 |      * code prefix and NAL unit type preceeding it. i.e. this means | 
| 104 |      * that the buffer does not contain any of the \c slice_data() or | 
| 105 |      * the \c rbsp_slice_trailing_bits(). | 
| 106 |      * | 
| 107 |      * Note: packed \c nal_unit_type shall be equal to 1 (non-IDR | 
| 108 |      * picture), or 5 (IDR picture). | 
| 109 |      */ | 
| 110 |      = VAEncPackedHeaderSlice, | 
| 111 |     /** | 
| 112 |      * \brief Packed Supplemental Enhancement Information (SEI). | 
| 113 |      * | 
| 114 |      * The corresponding packed header data buffer shall contain the | 
| 115 |      * complete sei_rbsp() syntax element, thus including several | 
| 116 |      * sei_message() elements if necessary. | 
| 117 |      * | 
| 118 |      * Note: packed \c nal_unit_type shall be equal to 6. | 
| 119 |      * | 
| 120 |      * @deprecated | 
| 121 |      * This is a deprecated packed header flag, All applications can use | 
| 122 |      * \c VA_ENC_PACKED_HEADER_RAW_DATA to pass the corresponding packed | 
| 123 |      * SEI header data buffer to the driver | 
| 124 |      */ | 
| 125 |      va_deprecated_enum  = (0x80000000 | 1), | 
| 126 | } ; | 
| 127 |  | 
| 128 | /** | 
| 129 |  * \brief Sequence parameter for H.264 encoding in baseline, main & high | 
| 130 |  * profiles. | 
| 131 |  * | 
| 132 |  * This structure holds information for \c seq_parameter_set_data() as | 
| 133 |  * defined by the H.264 specification. | 
| 134 |  * | 
| 135 |  * If packed sequence headers mode is used, i.e. if the encoding | 
| 136 |  * pipeline was configured with the #VA_ENC_PACKED_HEADER_SEQUENCE | 
| 137 |  * flag, then the driver expects two more buffers to be provided to | 
| 138 |  * the same \c vaRenderPicture() as this buffer: | 
| 139 |  * - a #VAEncPackedHeaderParameterBuffer with type set to | 
| 140 |  *   VAEncPackedHeaderType::VAEncPackedHeaderSequence ; | 
| 141 |  * - a #VAEncPackedHeaderDataBuffer which holds the actual packed | 
| 142 |  *   header data. | 
| 143 |  * | 
| 144 |  * If \c seq_scaling_matrix_present_flag is set to \c 1, then a | 
| 145 |  * #VAIQMatrixBufferH264 buffer shall also be provided within the same | 
| 146 |  * \c vaRenderPicture() call as this sequence parameter buffer. | 
| 147 |  */ | 
| 148 | typedef struct _VAEncSequenceParameterBufferH264 { | 
| 149 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 150 |     uint8_t   seq_parameter_set_id; | 
| 151 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 152 |     uint8_t   level_idc; | 
| 153 |     /** \brief Period between I frames. */ | 
| 154 |     uint32_t    intra_period; | 
| 155 |     /** \brief Period between IDR frames. */ | 
| 156 |     uint32_t    intra_idr_period; | 
| 157 |     /** \brief Period between I/P frames. */ | 
| 158 |     uint32_t    ip_period; | 
| 159 |     /** | 
| 160 |      * \brief Initial bitrate set for this sequence in CBR or VBR modes. | 
| 161 |      * | 
| 162 |      * This field represents the initial bitrate value for this | 
| 163 |      * sequence if CBR or VBR mode is used, i.e. if the encoder | 
| 164 |      * pipeline was created with a #VAConfigAttribRateControl | 
| 165 |      * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR. | 
| 166 |      * | 
| 167 |      * The bitrate can be modified later on through | 
| 168 |      * #VAEncMiscParameterRateControl buffers. | 
| 169 |      */ | 
| 170 |     uint32_t    bits_per_second; | 
| 171 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 172 |     uint32_t    max_num_ref_frames; | 
| 173 |     /** \brief Picture width in macroblocks. */ | 
| 174 |     uint16_t  picture_width_in_mbs; | 
| 175 |     /** \brief Picture height in macroblocks. */ | 
| 176 |     uint16_t  picture_height_in_mbs; | 
| 177 |  | 
| 178 |     union { | 
| 179 |         struct { | 
| 180 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 181 |             uint32_t chroma_format_idc                      : 2; | 
| 182 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 183 |             uint32_t frame_mbs_only_flag                    : 1; | 
| 184 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 185 |             uint32_t mb_adaptive_frame_field_flag           : 1; | 
| 186 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 187 |             uint32_t seq_scaling_matrix_present_flag        : 1; | 
| 188 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 189 |             uint32_t direct_8x8_inference_flag              : 1; | 
| 190 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 191 |             uint32_t log2_max_frame_num_minus4              : 4; | 
| 192 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 193 |             uint32_t pic_order_cnt_type                     : 2; | 
| 194 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 195 |             uint32_t log2_max_pic_order_cnt_lsb_minus4      : 4; | 
| 196 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 197 |             uint32_t delta_pic_order_always_zero_flag       : 1; | 
| 198 |         } bits; | 
| 199 |         uint32_t value; | 
| 200 |     } seq_fields; | 
| 201 |  | 
| 202 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 203 |     uint8_t   bit_depth_luma_minus8; | 
| 204 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 205 |     uint8_t   bit_depth_chroma_minus8; | 
| 206 |  | 
| 207 |     /** if pic_order_cnt_type == 1 */ | 
| 208 |     /**@{*/ | 
| 209 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 210 |     uint8_t   num_ref_frames_in_pic_order_cnt_cycle; | 
| 211 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 212 |     int32_t             offset_for_non_ref_pic; | 
| 213 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 214 |     int32_t             offset_for_top_to_bottom_field; | 
| 215 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 216 |     int32_t             offset_for_ref_frame[256]; | 
| 217 |     /**@}*/ | 
| 218 |  | 
| 219 |     /** @name Cropping (optional) */ | 
| 220 |     /**@{*/ | 
| 221 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 222 |     uint8_t   frame_cropping_flag; | 
| 223 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 224 |     uint32_t    frame_crop_left_offset; | 
| 225 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 226 |     uint32_t    frame_crop_right_offset; | 
| 227 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 228 |     uint32_t    frame_crop_top_offset; | 
| 229 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 230 |     uint32_t    frame_crop_bottom_offset; | 
| 231 |     /**@}*/ | 
| 232 |  | 
| 233 |     /** @name VUI parameters (optional) */ | 
| 234 |     /**@{*/ | 
| 235 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 236 |     uint8_t   vui_parameters_present_flag; | 
| 237 |     union { | 
| 238 |         struct { | 
| 239 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 240 |             uint32_t aspect_ratio_info_present_flag         : 1; | 
| 241 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 242 |             uint32_t timing_info_present_flag               : 1; | 
| 243 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 244 |             uint32_t bitstream_restriction_flag             : 1; | 
| 245 |             /** \brief Range: 0 to 16, inclusive. */ | 
| 246 |             uint32_t log2_max_mv_length_horizontal          : 5; | 
| 247 |             /** \brief Range: 0 to 16, inclusive. */ | 
| 248 |             uint32_t log2_max_mv_length_vertical            : 5; | 
| 249 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 250 |             uint32_t fixed_frame_rate_flag                  : 1; | 
| 251 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 252 |             uint32_t low_delay_hrd_flag                     : 1; | 
| 253 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 254 |             uint32_t motion_vectors_over_pic_boundaries_flag: 1; | 
| 255 |             /** \brief Reserved for future use, must be zero */ | 
| 256 |             uint32_t reserved                               : 16; | 
| 257 |         } bits; | 
| 258 |         uint32_t value; | 
| 259 |     } vui_fields; | 
| 260 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 261 |     uint8_t   aspect_ratio_idc; | 
| 262 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 263 |     uint32_t    sar_width; | 
| 264 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 265 |     uint32_t    sar_height; | 
| 266 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 267 |     uint32_t    num_units_in_tick; | 
| 268 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 269 |     uint32_t    time_scale; | 
| 270 |  | 
| 271 |     /** \brief Reserved bytes for future use, must be zero */ | 
| 272 |     uint32_t                va_reserved[VA_PADDING_LOW]; | 
| 273 |     /**@}*/ | 
| 274 | } VAEncSequenceParameterBufferH264; | 
| 275 |  | 
| 276 | /** | 
| 277 |  * \brief Picture parameter for H.264 encoding in baseline, main & high | 
| 278 |  * profiles. | 
| 279 |  * | 
| 280 |  * This structure holds information for \c pic_parameter_set_rbsp() as | 
| 281 |  * defined by the H.264 specification. | 
| 282 |  * | 
| 283 |  * If packed picture headers mode is used, i.e. if the encoding | 
| 284 |  * pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE | 
| 285 |  * flag, then the driver expects two more buffers to be provided to | 
| 286 |  * the same \c vaRenderPicture() as this buffer: | 
| 287 |  * - a #VAEncPackedHeaderParameterBuffer with type set to | 
| 288 |  *   VAEncPackedHeaderType::VAEncPackedHeaderPicture ; | 
| 289 |  * - a #VAEncPackedHeaderDataBuffer which holds the actual packed | 
| 290 |  *   header data. | 
| 291 |  * | 
| 292 |  * If \c pic_scaling_matrix_present_flag is set to \c 1, then a | 
| 293 |  * #VAIQMatrixBufferH264 buffer shall also be provided within the same | 
| 294 |  * \c vaRenderPicture() call as this picture parameter buffer. | 
| 295 |  */ | 
| 296 | typedef struct _VAEncPictureParameterBufferH264 { | 
| 297 |     /** | 
| 298 |      * \brief Information about the picture to be encoded. | 
| 299 |      * | 
| 300 |      * See #VAPictureH264 for further description of each field. | 
| 301 |      * Note that CurrPic.picture_id represents the reconstructed | 
| 302 |      * (decoded) picture. User provides a scratch VA surface ID here. | 
| 303 |      */ | 
| 304 |     VAPictureH264   CurrPic; | 
| 305 |     /** | 
| 306 |      * \brief Decoded Picture Buffer (DPB). | 
| 307 |      * | 
| 308 |      * This array represents the list of reconstructed (decoded) | 
| 309 |      * frames used as reference. It is important to keep track of | 
| 310 |      * reconstructed frames so that they can be used later on as | 
| 311 |      * reference for P or B-frames encoding. | 
| 312 |      */ | 
| 313 |     VAPictureH264   ReferenceFrames[16]; | 
| 314 |     /** | 
| 315 |      * \brief Output encoded bitstream. | 
| 316 |      * | 
| 317 |      * \ref coded_buf has type #VAEncCodedBufferType. It should be | 
| 318 |      * large enough to hold the compressed NAL slice and possibly SPS | 
| 319 |      * and PPS NAL units. | 
| 320 |      */ | 
| 321 |     VABufferID      coded_buf; | 
| 322 |  | 
| 323 |     /** \brief The picture parameter set referred to in the slice header. */ | 
| 324 |     uint8_t   pic_parameter_set_id; | 
| 325 |     /** \brief The active sequence parameter set. Range: 0 to 31, inclusive. */ | 
| 326 |     uint8_t   seq_parameter_set_id; | 
| 327 |  | 
| 328 |     /** | 
| 329 |      * \brief OR'd flags describing whether the picture is the last one or not. | 
| 330 |      * | 
| 331 |      * This fields holds 0 if the picture to be encoded is not the last | 
| 332 |      * one in the stream or sequence. Otherwise, it is a combination of | 
| 333 |      * \ref H264_LAST_PICTURE_EOSEQ or \ref H264_LAST_PICTURE_EOSTREAM. | 
| 334 |      */ | 
| 335 |     uint8_t   last_picture; | 
| 336 |  | 
| 337 |     /** \brief The picture identifier. | 
| 338 |      *   Range: 0 to \f$2^{log2\_max\_frame\_num\_minus4 + 4} - 1\f$, inclusive. | 
| 339 |      */ | 
| 340 |     uint16_t  frame_num; | 
| 341 |  | 
| 342 |     /** \brief \c pic_init_qp_minus26 + 26. */ | 
| 343 |     uint8_t   pic_init_qp; | 
| 344 |     /** \brief Maximum reference index for reference picture list 0. | 
| 345 |      *   Range: 0 to 31, inclusive. | 
| 346 |      */ | 
| 347 |     uint8_t   num_ref_idx_l0_active_minus1; | 
| 348 |     /** \brief Maximum reference index for reference picture list 1. | 
| 349 |      *  Range: 0 to 31, inclusive. | 
| 350 |      */ | 
| 351 |     uint8_t   num_ref_idx_l1_active_minus1; | 
| 352 |  | 
| 353 |     /** \brief Range: -12 to 12, inclusive. */ | 
| 354 |     int8_t     chroma_qp_index_offset; | 
| 355 |     /** \brief Range: -12 to 12, inclusive. */ | 
| 356 |     int8_t     second_chroma_qp_index_offset; | 
| 357 |  | 
| 358 |     union { | 
| 359 |         struct { | 
| 360 |             /** \brief Is picture an IDR picture? */ | 
| 361 |             uint32_t idr_pic_flag                           : 1; | 
| 362 |             /** \brief Is picture a reference picture? */ | 
| 363 |             uint32_t reference_pic_flag                     : 2; | 
| 364 |             /** \brief Selects CAVLC (0) or CABAC (1) entropy coding mode. */ | 
| 365 |             uint32_t entropy_coding_mode_flag               : 1; | 
| 366 |             /** \brief Is weighted prediction applied to P slices? */ | 
| 367 |             uint32_t weighted_pred_flag                     : 1; | 
| 368 |             /** \brief Range: 0 to 2, inclusive. */ | 
| 369 |             uint32_t weighted_bipred_idc                    : 2; | 
| 370 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 371 |             uint32_t constrained_intra_pred_flag            : 1; | 
| 372 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 373 |             uint32_t transform_8x8_mode_flag                : 1; | 
| 374 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 375 |             uint32_t deblocking_filter_control_present_flag : 1; | 
| 376 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 377 |             uint32_t redundant_pic_cnt_present_flag         : 1; | 
| 378 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 379 |             uint32_t pic_order_present_flag                 : 1; | 
| 380 |             /** \brief Same as the H.264 bitstream syntax element. */ | 
| 381 |             uint32_t pic_scaling_matrix_present_flag        : 1; | 
| 382 |         } bits; | 
| 383 |         uint32_t value; | 
| 384 |     } pic_fields; | 
| 385 |  | 
| 386 |     /** \brief Reserved bytes for future use, must be zero */ | 
| 387 |     uint32_t                va_reserved[VA_PADDING_LOW]; | 
| 388 | } VAEncPictureParameterBufferH264; | 
| 389 |  | 
| 390 | typedef struct _VAEncQPBufferH264 { | 
| 391 |     /* | 
| 392 |      * \brief This structure holds QP per 16x16 macroblock. Buffer size shall be | 
| 393 |      * sufficient to fit the slice or frame to be encoded depending on if it is a | 
| 394 |      * slice level or frame level encoding. | 
| 395 |      */ | 
| 396 |     uint8_t qp; | 
| 397 | } VAEncQPBufferH264; | 
| 398 |  | 
| 399 | /** | 
| 400 |  * \brief Slice parameter for H.264 encoding in baseline, main & high profiles. | 
| 401 |  * | 
| 402 |  * This structure holds information for \c | 
| 403 |  * slice_layer_without_partitioning_rbsp() as defined by the H.264 | 
| 404 |  * specification. | 
| 405 |  * | 
| 406 |  * If packed slice headers mode is used, i.e. if the encoding | 
| 407 |  * pipeline was configured with the #VA_ENC_PACKED_HEADER_SLICE | 
| 408 |  * flag, then the driver expects two more buffers to be provided to | 
| 409 |  * the same \c vaRenderPicture() as this buffer: | 
| 410 |  * - a #VAEncPackedHeaderParameterBuffer with type set to | 
| 411 |  *   VAEncPackedHeaderType::VAEncPackedHeaderSlice ; | 
| 412 |  * - a #VAEncPackedHeaderDataBuffer which holds the actual packed | 
| 413 |  *   header data. | 
| 414 |  * | 
| 415 |  * If per-macroblock encoder configuration is needed, \c macroblock_info | 
| 416 |  * references a buffer of type #VAEncMacroblockParameterBufferH264. This | 
| 417 |  * buffer is not passed to vaRenderPicture() and it can be re-used | 
| 418 |  * without re-allocating the whole buffer. | 
| 419 |  */ | 
| 420 | typedef struct _VAEncSliceParameterBufferH264 { | 
| 421 |     /** \brief Starting MB address for this slice. */ | 
| 422 |     uint32_t    macroblock_address; | 
| 423 |     /** \brief Number of macroblocks in this slice. */ | 
| 424 |     uint32_t    num_macroblocks; | 
| 425 |     /** | 
| 426 |      * \brief Per-MB encoder configuration buffer, or \c VA_INVALID_ID. | 
| 427 |      * | 
| 428 |      * If per-MB encoder configuration is needed, then \ref macroblock_info | 
| 429 |      * references a buffer of type #VAEncMacroblockParameterBufferH264 | 
| 430 |      * (\c VAEncMacroblockParameterBufferType). Otherwise, buffer id | 
| 431 |      * is set to \c VA_INVALID_ID and per-MB configuration is derived | 
| 432 |      * from this slice parameter. | 
| 433 |      * | 
| 434 |      * The \c macroblock_info buffer must hold \ref num_macroblocks | 
| 435 |      * elements. | 
| 436 |      */ | 
| 437 |     VABufferID      macroblock_info; | 
| 438 |     /** \brief Slice type. | 
| 439 |      *  Range: 0..2, 5..7, i.e. no switching slices. | 
| 440 |      */ | 
| 441 |     uint8_t   slice_type; | 
| 442 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 443 |     uint8_t   pic_parameter_set_id; | 
| 444 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 445 |     uint16_t  idr_pic_id; | 
| 446 |  | 
| 447 |     /** @name If pic_order_cnt_type == 0 */ | 
| 448 |     /**@{*/ | 
| 449 |     /** \brief The picture order count modulo MaxPicOrderCntLsb. */ | 
| 450 |     uint16_t  pic_order_cnt_lsb; | 
| 451 |     /** \brief Valid if \c pic_order_present_flag and this is a bottom field. */ | 
| 452 |     int32_t             delta_pic_order_cnt_bottom; | 
| 453 |     /**@}*/ | 
| 454 |     /** @name If pic_order_cnt_type == 1 && !delta_pic_order_always_zero_flag */ | 
| 455 |     /**@{*/ | 
| 456 |     /** \brief [0]: top, [1]: bottom. */ | 
| 457 |     int32_t             delta_pic_order_cnt[2]; | 
| 458 |     /**@}*/ | 
| 459 |  | 
| 460 |     /** @name If slice_type == B */ | 
| 461 |     /**@{*/ | 
| 462 |     uint8_t   direct_spatial_mv_pred_flag; | 
| 463 |     /**@}*/ | 
| 464 |  | 
| 465 |     /** @name If slice_type == P */ | 
| 466 |     /**@{*/ | 
| 467 |     /** \brief Specifies if | 
| 468 |      * \ref _VAEncPictureParameterBufferH264::num_ref_idx_l0_active_minus1 or | 
| 469 |      * \ref _VAEncPictureParameterBufferH264::num_ref_idx_l1_active_minus1 are | 
| 470 |      * overriden by the values for this slice. | 
| 471 |      */ | 
| 472 |     uint8_t   num_ref_idx_active_override_flag; | 
| 473 |     /** \brief Maximum reference index for reference picture list 0. | 
| 474 |      *  Range: 0 to 31, inclusive. | 
| 475 |      */ | 
| 476 |     uint8_t   num_ref_idx_l0_active_minus1; | 
| 477 |     /** \brief Maximum reference index for reference picture list 1. | 
| 478 |      *  Range: 0 to 31, inclusive. | 
| 479 |      */ | 
| 480 |     uint8_t   num_ref_idx_l1_active_minus1; | 
| 481 |     /** \brief Reference picture list 0 (for P slices). */ | 
| 482 |     VAPictureH264   RefPicList0[32]; | 
| 483 |     /** \brief Reference picture list 1 (for B slices). */ | 
| 484 |     VAPictureH264   RefPicList1[32]; | 
| 485 |     /**@}*/ | 
| 486 |  | 
| 487 |     /** @name pred_weight_table() */ | 
| 488 |     /**@{*/ | 
| 489 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 490 |     uint8_t   luma_log2_weight_denom; | 
| 491 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 492 |     uint8_t   chroma_log2_weight_denom; | 
| 493 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 494 |     uint8_t   luma_weight_l0_flag; | 
| 495 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 496 |     signed short    luma_weight_l0[32]; | 
| 497 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 498 |     signed short    luma_offset_l0[32]; | 
| 499 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 500 |     uint8_t   chroma_weight_l0_flag; | 
| 501 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 502 |     signed short    chroma_weight_l0[32][2]; | 
| 503 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 504 |     signed short    chroma_offset_l0[32][2]; | 
| 505 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 506 |     uint8_t   luma_weight_l1_flag; | 
| 507 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 508 |     signed short    luma_weight_l1[32]; | 
| 509 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 510 |     signed short    luma_offset_l1[32]; | 
| 511 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 512 |     uint8_t   chroma_weight_l1_flag; | 
| 513 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 514 |     signed short    chroma_weight_l1[32][2]; | 
| 515 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 516 |     signed short    chroma_offset_l1[32][2]; | 
| 517 |     /**@}*/ | 
| 518 |  | 
| 519 |     /** \brief Range: 0 to 2, inclusive. */ | 
| 520 |     uint8_t   cabac_init_idc; | 
| 521 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 522 |     int8_t     slice_qp_delta; | 
| 523 |     /** @name If deblocking_filter_control_present_flag */ | 
| 524 |     /**@{*/ | 
| 525 |     /** \brief Range: 0 to 2, inclusive. */ | 
| 526 |     uint8_t   disable_deblocking_filter_idc; | 
| 527 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 528 |     int8_t     slice_alpha_c0_offset_div2; | 
| 529 |     /** \brief Same as the H.264 bitstream syntax element. */ | 
| 530 |     int8_t     slice_beta_offset_div2; | 
| 531 |  | 
| 532 |     /** \brief Reserved bytes for future use, must be zero */ | 
| 533 |     uint32_t                va_reserved[VA_PADDING_LOW]; | 
| 534 |     /**@}*/ | 
| 535 | } VAEncSliceParameterBufferH264; | 
| 536 |  | 
| 537 | /** | 
| 538 |  * @name Macroblock neighbour availability bits | 
| 539 |  * | 
| 540 |  * \anchor api_enc_h264_mb_pred_avail_bits | 
| 541 |  * Definitions for macroblock neighbour availability bits used in | 
| 542 |  * intra prediction mode (non MBAFF only). | 
| 543 |  * | 
| 544 |  * @{ | 
| 545 |  */ | 
| 546 | /** \brief References macroblock in the top-left corner. */ | 
| 547 | #define VA_MB_PRED_AVAIL_TOP_LEFT         (1 << 2) | 
| 548 | /** \brief References macroblock above the current macroblock. */ | 
| 549 | #define VA_MB_PRED_AVAIL_TOP              (1 << 4) | 
| 550 | /** \brief References macroblock in the top-right corner. */ | 
| 551 | #define VA_MB_PRED_AVAIL_TOP_RIGHT        (1 << 3) | 
| 552 | /** \brief References macroblock on the left of the current macroblock. */ | 
| 553 | #define VA_MB_PRED_AVAIL_LEFT             (1 << 6) | 
| 554 | /**@}*/ | 
| 555 |  | 
| 556 | /** | 
| 557 |  * \brief Macroblock parameter for H.264 encoding in baseline, main & high | 
| 558 |  * profiles. | 
| 559 |  * | 
| 560 |  * This structure holds per-macroblock information. The buffer must be | 
| 561 |  * allocated with as many elements (macroblocks) as necessary to fit | 
| 562 |  * the slice to be encoded. Besides, the per-macroblock records must | 
| 563 |  * be written in a strict raster order and with no gap. i.e. every | 
| 564 |  * macroblock, regardless of its type, shall have an entry. | 
| 565 |  */ | 
| 566 | typedef struct _VAEncMacroblockParameterBufferH264 { | 
| 567 |     /** | 
| 568 |      * \brief Quantization parameter. | 
| 569 |      * | 
| 570 |      * Requested quantization parameter. Range: 0 to 51, inclusive. | 
| 571 |      * If \ref qp is set to 0xff, then the actual value is derived | 
| 572 |      * from the slice-level value: \c pic_init_qp + \c slice_qp_delta. | 
| 573 |      */ | 
| 574 |     uint8_t   qp; | 
| 575 |  | 
| 576 |     union { | 
| 577 |         /** @name Data for intra macroblock */ | 
| 578 |         /**@{*/ | 
| 579 |         union { | 
| 580 |             struct { | 
| 581 |                 /** | 
| 582 |                  * \brief Flag specified to override MB neighbour | 
| 583 |                  * availability bits from VME stage. | 
| 584 |                  * | 
| 585 |                  * This flag specifies that macroblock neighbour | 
| 586 |                  * availability bits from the VME stage are overriden | 
| 587 |                  * by the \ref pred_avail_flags hereunder. | 
| 588 |                  */ | 
| 589 |                 uint32_t    pred_avail_override_flag        : 1; | 
| 590 |                 /** | 
| 591 |                  * \brief Bitwise representation of which macroblocks | 
| 592 |                  * are available for intra prediction. | 
| 593 |                  * | 
| 594 |                  * If the slice is intra-coded, this field represents | 
| 595 |                  * the macroblocks available for intra prediction. | 
| 596 |                  * See \ref api_enc_h264_mb_pred_avail_bits | 
| 597 |                  * "macroblock neighbour availability" bit definitions. | 
| 598 |                  */ | 
| 599 |                 uint32_t    pred_avail_flags                : 8; | 
| 600 |             } bits; | 
| 601 |             uint32_t value; | 
| 602 |         } intra_fields; | 
| 603 |         /**@}*/ | 
| 604 |  | 
| 605 |         /** @name Data for inter macroblock */ | 
| 606 |         /**@{*/ | 
| 607 |         union { | 
| 608 |             struct { | 
| 609 |                 uint32_t reserved; | 
| 610 |             } bits; | 
| 611 |             uint32_t value; | 
| 612 |         } inter_fields; | 
| 613 |         /**@}*/ | 
| 614 |     } info; | 
| 615 |  | 
| 616 |     /** \brief Reserved bytes for future use, must be zero */ | 
| 617 |     uint32_t                va_reserved[VA_PADDING_LOW]; | 
| 618 | } VAEncMacroblockParameterBufferH264; | 
| 619 |  | 
| 620 | /** | 
| 621 |  * \brief MB partition modes and 1/2 1/4 motion search configuration | 
| 622 |  * | 
| 623 |  * Specifies MB partition modes that are disabled. Specifies Half-pel | 
| 624 |  * mode and Quarter-pel mode searching | 
| 625 |  */ | 
| 626 | typedef struct _VAEncMiscParameterSubMbPartPelH264 { | 
| 627 |     uint32_t disable_inter_sub_mb_partition; | 
| 628 |     union { | 
| 629 |         struct { | 
| 630 |             uint32_t disable_16x16_inter_mb_partition        : 1; | 
| 631 |             uint32_t disable_16x8_inter_mb_partition         : 1; | 
| 632 |             uint32_t disable_8x16_inter_mb_partition         : 1; | 
| 633 |             uint32_t disable_8x8_inter_mb_partition          : 1; | 
| 634 |             uint32_t disable_8x4_inter_mb_partition          : 1; | 
| 635 |             uint32_t disable_4x8_inter_mb_partition          : 1; | 
| 636 |             uint32_t disable_4x4_inter_mb_partition          : 1; | 
| 637 |             uint32_t reserved                                : 1; | 
| 638 |         } bits; | 
| 639 |         uint8_t value; | 
| 640 |     } inter_sub_mb_partition_mask; | 
| 641 |  | 
| 642 |     /** | 
| 643 |      * \brief Precison of motion search | 
| 644 |      * 0:Integer mode searching | 
| 645 |      * 1:Half-pel mode searching | 
| 646 |      * 2:Reserved | 
| 647 |      * 3:Quarter-pel mode searching | 
| 648 |      */ | 
| 649 |     uint32_t enable_sub_pel_mode; | 
| 650 |     uint8_t sub_pel_mode; | 
| 651 |     uint8_t reserved[3]; | 
| 652 | } VAEncMiscParameterSubMbPartPelH264; | 
| 653 | /**@}*/ | 
| 654 |  | 
| 655 | #ifdef __cplusplus | 
| 656 | } | 
| 657 | #endif | 
| 658 |  | 
| 659 | #endif /* VA_ENC_H264_H */ | 
| 660 |  |