OSDN Git Service

Deprecate packed misc packed header
[android-x86/hardware-intel-common-libva.git] / va / va_enc_hevc.h
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_enc_hevc.h
27  * \brief The HEVC encoding API
28  *
29  * This file contains the \ref api_enc_hevc "HEVC encoding API".
30  *
31  */
32
33 #ifndef VA_ENC_HEVC_H
34 #define VA_ENC_HEVC_H
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 #include <stdint.h>
41
42 /**
43  * \defgroup api_enc_hevc HEVC encoding API
44  *
45  * @{
46  */
47
48 /**
49  * @name Picture flags
50  *
51  * Those flags flags are meant to signal when a picture marks the end
52  * of a sequence, a stream, or even both at once.
53  *
54  * @{
55  */
56 /**
57  * \brief Marks the last picture in the sequence.
58  *
59  * i.e. the driver appends \c end_of_seq() NAL unit to the encoded frame.
60  */
61 #define HEVC_LAST_PICTURE_EOSEQ     0x01
62 /**
63  * \brief Marks the last picture in the stream.
64  *
65  * i.e. the driver appends \c end_of_stream() NAL unit to the encoded frame.
66  */
67 #define HEVC_LAST_PICTURE_EOSTREAM  0x02
68 /**@}*/
69
70 /**
71  * \brief Packed header types specific to HEVC encoding.
72  *
73  * Types of packed headers generally used for HEVC encoding. Each
74  * associated packed header data buffer shall contain the start code
75  * prefix 0x000001 followed by the complete NAL unit, thus also
76  * including the \c nal_unit_type.
77  *
78  * Note: the start code prefix can contain an arbitrary number of leading
79  * zeros. The driver will skip them for emulation prevention bytes insertion,
80  * if necessary.
81  */
82 typedef enum {
83     /**
84      * \brief Packed Video Parameter Set (VPS).
85      *
86      * The corresponding packed header data buffer shall contain the
87      * complete video_parameter_set_rbsp() syntax element.
88      *
89      * Note: packed \c nal_unit_type shall be equal to 32.
90      */
91     VAEncPackedHeaderHEVC_VPS   = VAEncPackedHeaderSequence,
92     /**
93      * \brief Packed Sequence Parameter Set (SPS).
94      *
95      * The corresponding packed header data buffer shall contain the
96      * complete seq_parameter_set_rbsp() syntax element.
97      *
98      * Note: packed \c nal_unit_type shall be equal to 33.
99      */
100     VAEncPackedHeaderHEVC_SPS   = VAEncPackedHeaderSequence,
101     /**
102      * \brief Packed Picture Parameter Set (PPS).
103      *
104      * The corresponding packed header data buffer shall contain the
105      * complete pic_parameter_set_rbsp() syntax element.
106      *
107      * Note: packed \c nal_unit_type shall be equal to 34.
108      */
109     VAEncPackedHeaderHEVC_PPS   = VAEncPackedHeaderPicture,
110     /**
111      * \brief Packed slice header.
112      *
113      * The corresponding packed header data buffer shall contain the
114      * \c slice_header() syntax element only, along with any start
115      * code prefix and NAL unit type preceeding it. i.e. this means
116      * that the buffer does not contain any of the \c slice_data() or
117      * the \c rbsp_slice_trailing_bits().
118      *
119      * Note: packed \c nal_unit_type shall be equal to 0 to 9 (non-IRAP
120      * picture), or 16 to 21 (IRAP picture).
121      */
122     VAEncPackedHeaderHEVC_Slice = VAEncPackedHeaderSlice,
123     /**
124      * \brief Packed Supplemental Enhancement Information (SEI).
125      *
126      * The corresponding packed header data buffer shall contain the
127      * complete sei_rbsp() syntax element, thus including several
128      * sei_message() elements if necessary.
129      *
130      * Note: packed \c nal_unit_type shall be equal to 39 or 40.
131      *
132      * @deprecated
133      * This is a deprecated packed header flag, All applications can use
134      * \c VA_ENC_PACKED_HEADER_RAW_DATA to pass the corresponding packed
135      * SEI header data buffer to the driver
136      */
137     VAEncPackedHeaderHEVC_SEI  va_deprecated_enum = (VAEncPackedHeaderMiscMask | 1),
138 } VAEncPackedHeaderTypeHEVC;
139
140 /**
141  * \brief Sequence parameter for HEVC encoding in main & main 10
142  * profiles.
143  *
144  * This structure holds information for \c seq_parameter_set_data() as
145  * defined by the HEVC specification.
146  *
147  * If packed sequence headers mode is used, i.e. if the encoding
148  * pipeline was configured with the #VA_ENC_PACKED_HEADER_SEQUENCE
149  * flag, then the driver expects two more buffers to be provided to
150  * the same \c vaRenderPicture() as this buffer:
151  * - a #VAEncPackedHeaderParameterBuffer with type set to
152  *   VAEncPackedHeaderType::VAEncPackedHeaderSequence ;
153  * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
154  *   header data.
155  *
156  * If \c seq_scaling_matrix_present_flag is set to \c 1, then a
157  * #VAQMatrixBufferHEVC buffer shall also be provided within the same
158  * \c vaRenderPicture() call as this sequence parameter buffer.
159  */
160 typedef struct _VAEncSequenceParameterBufferHEVC {
161     /** \brief Same as the HEVC bitstream syntax element.
162      *  value range [1..2].
163      */
164     uint8_t     general_profile_idc;
165     /** \brief Same as the HEVC bitstream syntax element.
166      *  general_level_idc shall be set equal to a value of 30 times the level
167      *  numbers allowed [1, 2, 2.1, 3, 3.1, 4, 4.1, 5, 5.1, 5.2, 6, 6.1, 6.2]
168      */
169     uint8_t     general_level_idc;
170     /** \brief Same as the HEVC bitstream syntax element.
171      *  Only value 0 is allowed for level value below 4, exclusive.
172      */
173     uint8_t     general_tier_flag;
174     /** \brief Period between I frames. */
175     uint32_t    intra_period;
176     /** \brief Period between IDR frames. */
177     uint32_t    intra_idr_period;
178     /** \brief Period between I/P frames. */
179     uint32_t    ip_period;
180     /**
181      * \brief Initial bitrate set for this sequence in CBR or VBR modes.
182      *
183      * This field represents the initial bitrate value for this
184      * sequence if CBR or VBR mode is used, i.e. if the encoder
185      * pipeline was created with a #VAConfigAttribRateControl
186      * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
187      *
188      * The bitrate can be modified later on through
189      * #VAEncMiscParameterRateControl buffers.
190      */
191     uint32_t    bits_per_second;
192     /** \brief Picture width in pixel samples.
193      *  Its value must be multiple of min CU size.
194      */
195     uint16_t    pic_width_in_luma_samples;
196     /** \brief Picture height in pixel samples.
197      *  Its value must be multiple of min CU size.
198      */
199     uint16_t    pic_height_in_luma_samples;
200
201     union {
202         struct {
203             /** \brief Same as the HEVC bitstream syntax element. */
204             uint32_t    chroma_format_idc                              : 2;
205             /** \brief Same as the HEVC bitstream syntax element. */
206             uint32_t    separate_colour_plane_flag                     : 1;
207             /** \brief Same as the HEVC bitstream syntax element. */
208             uint32_t    bit_depth_luma_minus8                          : 3;
209             /** \brief Same as the HEVC bitstream syntax element. */
210             uint32_t    bit_depth_chroma_minus8                        : 3;
211             /** \brief Same as the HEVC bitstream syntax element. */
212             uint32_t    scaling_list_enabled_flag                      : 1;
213             /** \brief Same as the HEVC bitstream syntax element. */
214             uint32_t    strong_intra_smoothing_enabled_flag            : 1;
215             /** \brief Same as the HEVC bitstream syntax element. */
216             uint32_t    amp_enabled_flag                               : 1;
217             /** \brief Same as the HEVC bitstream syntax element. */
218             uint32_t    sample_adaptive_offset_enabled_flag            : 1;
219             /** \brief Same as the HEVC bitstream syntax element. */
220             uint32_t    pcm_enabled_flag                               : 1;
221             /** \brief Same as the HEVC bitstream syntax element. */
222             uint32_t    pcm_loop_filter_disabled_flag                  : 1;
223             /** \brief Same as the HEVC bitstream syntax element. */
224             uint32_t    sps_temporal_mvp_enabled_flag                  : 1;
225
226             uint32_t    reserved_bits                                  : 16;
227         } bits;
228         uint32_t value;
229     } seq_fields;
230
231     /** \brief Same as the HEVC bitstream syntax element.
232      *  value range [0..3]
233      */
234     uint8_t     log2_min_luma_coding_block_size_minus3;
235
236     /** \brief Same as the HEVC bitstream syntax element.
237      */
238     uint8_t     log2_diff_max_min_luma_coding_block_size;
239
240     /** \brief Same as the HEVC bitstream syntax element.
241      *  value range [0..3]
242      */
243     uint8_t     log2_min_transform_block_size_minus2;
244
245     /** \brief Same as the HEVC bitstream syntax element.
246      */
247     uint8_t     log2_diff_max_min_transform_block_size;
248
249     /** \brief Same as the HEVC bitstream syntax element.
250      *  value range [2]
251      */
252     uint8_t     max_transform_hierarchy_depth_inter;
253
254     /** \brief Same as the HEVC bitstream syntax element.
255      *  value range [2]
256      */
257     uint8_t     max_transform_hierarchy_depth_intra;
258
259     /** \brief Same as the HEVC bitstream syntax element. */
260     uint32_t    pcm_sample_bit_depth_luma_minus1;
261
262     /** \brief Same as the HEVC bitstream syntax element. */
263     uint32_t    pcm_sample_bit_depth_chroma_minus1;
264
265     /** \brief Same as the HEVC bitstream syntax element. */
266     uint32_t    log2_min_pcm_luma_coding_block_size_minus3;
267
268     /** \brief Derived from the HEVC bitstream syntax element.
269     *  log2_min_pcm_luma_coding_block_size_minus3 +
270     *  log2_diff_max_min_pcm_luma_coding_block_size
271     */
272     uint32_t    log2_max_pcm_luma_coding_block_size_minus3;
273
274     /** @name VUI parameters (optional) */
275     /**@{*/
276     /** \brief Same as the HEVC bitstream syntax element. */
277     uint8_t     vui_parameters_present_flag;
278     union {
279         struct {
280             /** \brief Same as the HEVC bitstream syntax element. */
281             uint32_t    aspect_ratio_info_present_flag                 : 1;
282             /** \brief Same as the HEVC bitstream syntax element. */
283             uint32_t    neutral_chroma_indication_flag                 : 1;
284             /** \brief Same as the HEVC bitstream syntax element. */
285             uint32_t    field_seq_flag                                 : 1;
286             /** \brief Same as the HEVC bitstream syntax element. */
287             uint32_t    vui_timing_info_present_flag                   : 1;
288             /** \brief Same as the HEVC bitstream syntax element. */
289             uint32_t    bitstream_restriction_flag                     : 1;
290             /** \brief Same as the HEVC bitstream syntax element. */
291             uint32_t    tiles_fixed_structure_flag                     : 1;
292             /** \brief Same as the HEVC bitstream syntax element. */
293             uint32_t    motion_vectors_over_pic_boundaries_flag        : 1;
294             /** \brief Same as the HEVC bitstream syntax element. */
295             uint32_t    restricted_ref_pic_lists_flag                  : 1;
296             /** \brief Range: 0 to 16, inclusive. */
297             uint32_t    log2_max_mv_length_horizontal                  : 5;
298             /** \brief Range: 0 to 16, inclusive. */
299             uint32_t    log2_max_mv_length_vertical                    : 5;
300         } bits;
301         uint32_t value;
302     } vui_fields;
303     /** \brief Same as the HEVC bitstream syntax element. */
304     uint8_t     aspect_ratio_idc;
305     /** \brief Same as the HEVC bitstream syntax element. */
306     uint32_t    sar_width;
307     /** \brief Same as the HEVC bitstream syntax element. */
308     uint32_t    sar_height;
309     /** \brief Same as the HEVC bitstream syntax element. */
310     uint32_t    vui_num_units_in_tick;
311     /** \brief Same as the HEVC bitstream syntax element. */
312     uint32_t    vui_time_scale;
313     /** \brief Same as the HEVC bitstream syntax element. */
314     uint16_t    min_spatial_segmentation_idc;
315     /** \brief Same as the HEVC bitstream syntax element. */
316     uint8_t     max_bytes_per_pic_denom;
317     /** \brief Same as the HEVC bitstream syntax element. */
318     uint8_t     max_bits_per_min_cu_denom;
319     /**@}*/
320 } VAEncSequenceParameterBufferHEVC;
321
322 /****************************
323  * HEVC data structures
324  ****************************/
325 /**
326  * \brief Picture parameter for HEVC encoding in main & main 10
327  * profiles.
328  *
329  * This structure holds information for \c pic_parameter_set_rbsp() as
330  * defined by the HEVC specification.
331  *
332  * If packed picture headers mode is used, i.e. if the encoding
333  * pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE
334  * flag, then the driver expects two more buffers to be provided to
335  * the same \c vaRenderPicture() as this buffer:
336  * - a #VAEncPackedHeaderParameterBuffer with type set to
337  *   VAEncPackedHeaderType::VAEncPackedHeaderPicture ;
338  * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
339  *   header data.
340  *
341  * If \c pic_scaling_matrix_present_flag is set to \c 1, then a
342  * #VAQMatrixBufferHEVC buffer shall also be provided within the same
343  * \c vaRenderPicture() call as this picture parameter buffer.
344  */
345 typedef struct _VAEncPictureParameterBufferHEVC {
346     /**
347      * \brief Information about the picture to be encoded.
348      *
349      * See #VAPictureHEVC for further description of each field.
350      * Note that decoded_curr_pic.picture_id represents the reconstructed
351      * (decoded) picture. User provides a scratch VA surface ID here.
352      * Long term reference and RPS related fields should be set to 0
353      * and ignored.
354      */
355     VAPictureHEVC   decoded_curr_pic;
356     /**
357      * \brief Decoded Picture Buffer (DPB).
358      *
359      * This array represents the list of reconstructed (decoded)
360      * frames used as reference. It is important to keep track of
361      * reconstructed frames so that they can be used later on as
362      * reference for P or B-frames encoding.
363      */
364     VAPictureHEVC   reference_frames[15];
365     /**
366      * \brief Output encoded bitstream.
367      *
368      * \ref coded_buf has type #VAEncCodedBufferType. It should be
369      * large enough to hold the compressed NAL slice and possibly VPS, SPS
370      * and PPS NAL units, and other NAL units such as SEI.
371      */
372     VABufferID      coded_buf;
373
374     /** \brief collocated reference picture buffer index of ReferenceFrames[].
375      * Please note it is different from HEVC syntac element collocated_ref_idx.
376      * When  the HEVC syntax element slice_temporal_mvp_enable_flag takes value 0,
377      * collocated_ref_pic_index should take value 0xFF. .
378      * Range: [0..14, 0xFF]
379      */
380     uint8_t         collocated_ref_pic_index;
381
382     /**
383      * \brief OR'd flags describing whether the picture is the last one or not.
384      *
385      * This fields holds 0 if the picture to be encoded is not the last
386      * one in the stream or sequence. Otherwise, it is a combination of
387      * \ref HEVC_LAST_PICTURE_EOSEQ or \ref HEVC_LAST_PICTURE_EOSTREAM.
388      */
389     uint8_t         last_picture;
390
391     /** \brief \c init_qp_minus26 + 26. */
392     uint8_t         pic_init_qp;
393
394     /** \brief Corresponds to HEVC syntax element of the same name. */
395     uint8_t         diff_cu_qp_delta_depth;
396
397     /** \brief Corresponds to HEVC syntax element of the same name. */
398     int8_t          pps_cb_qp_offset;
399
400     /** \brief Corresponds to HEVC syntax element of the same name. */
401     int8_t          pps_cr_qp_offset;
402
403     /** \brief Corresponds to HEVC syntax element of the same name. */
404     uint8_t         num_tile_columns_minus1;
405
406     /** \brief Corresponds to HEVC syntax element of the same name. */
407     uint8_t         num_tile_rows_minus1;
408
409     /** \brief Corresponds to HEVC syntax element of the same name. */
410     uint8_t         column_width_minus1[19];
411
412     /** \brief Corresponds to HEVC syntax element of the same name. */
413     uint8_t         row_height_minus1[21];
414
415     /** \brief Corresponds to HEVC syntax element of the same name. */
416     uint8_t         log2_parallel_merge_level_minus2;
417
418     /** \brief Application may set the CTU bit size limit based on
419      *  spec requirement (A.3.2), or other value for special purpose.
420      *  If the value is set 0, no bit size limit is checked.
421      */
422     uint8_t         ctu_max_bitsize_allowed;
423
424     /** \brief Maximum reference index for reference picture list 0.
425      *   value range: [0..14].
426      */
427     uint8_t         num_ref_idx_l0_default_active_minus1;
428
429     /** \brief Maximum reference index for reference picture list 1.
430      *  value range: [0..14].
431      */
432     uint8_t         num_ref_idx_l1_default_active_minus1;
433
434     /** \brief PPS header
435      *  Used by GPU to generate new slice headers in slice size control.
436      *  value range: [0..63].
437      */
438     uint8_t         slice_pic_parameter_set_id;
439
440     /** \brief NAL unit type
441      *  Used by GPU to generate new slice headers in slice size control.
442      *  value range: [0..63].
443      */
444     uint8_t         nal_unit_type;
445
446     union {
447         struct {
448             /** \brief Is picture an IDR picture? */
449             uint32_t    idr_pic_flag                                   : 1;
450             /** \brief Picture type.
451              *  I  - 1;
452              *  P  - 2;
453              *  B  - 3;
454              *  B1 - 4;
455              *  B2 - 5;
456              * B1 and B2 are frame types for hierachical B, explanation
457              * can refer to num_b_in_gop[].
458              */
459             uint32_t    coding_type                                    : 3;
460             /** \brief Is picture a reference picture? */
461             uint32_t    reference_pic_flag                             : 1;
462             /** \brief Corresponds to HEVC syntax element of the same name. */
463             uint32_t    dependent_slice_segments_enabled_flag          : 1;
464             /** \brief Corresponds to HEVC syntax element of the same name. */
465             uint32_t    sign_data_hiding_enabled_flag                  : 1;
466             /** \brief Corresponds to HEVC syntax element of the same name. */
467             uint32_t    constrained_intra_pred_flag                    : 1;
468             /** \brief Corresponds to HEVC syntax element of the same name. */
469             uint32_t    transform_skip_enabled_flag                    : 1;
470             /** \brief Corresponds to HEVC syntax element of the same name. */
471             uint32_t    cu_qp_delta_enabled_flag                       : 1;
472             /** \brief Corresponds to HEVC syntax element of the same name. */
473             uint32_t    weighted_pred_flag                             : 1;
474             /** \brief Corresponds to HEVC syntax element of the same name. */
475             uint32_t    weighted_bipred_flag                           : 1;
476             /** \brief Corresponds to HEVC syntax element of the same name. */
477             uint32_t    transquant_bypass_enabled_flag                 : 1;
478             /** \brief Corresponds to HEVC syntax element of the same name. */
479             uint32_t    tiles_enabled_flag                             : 1;
480             /** \brief Corresponds to HEVC syntax element of the same name. */
481             uint32_t    entropy_coding_sync_enabled_flag               : 1;
482             /** \brief Corresponds to HEVC syntax element of the same name. */
483             uint32_t    loop_filter_across_tiles_enabled_flag          : 1;
484             /** \brief Corresponds to HEVC syntax element of the same name. */
485             uint32_t    pps_loop_filter_across_slices_enabled_flag     : 1;
486             /** \brief A combination of HEVC syntax element of
487              *  sps_scaling_list_data_present_flag and
488              *  pps_scaling_list_data_present_flag
489              *  when scaling_list_enable_flag is 0, it must be 0.
490              */
491             uint32_t    scaling_list_data_present_flag                 : 1;
492             /** \brief indicate the current picture contains significant
493              *  screen contents (text, characters, etc.) or animated image.
494              *  GPU may want to treat them differently from normal video.
495              *  For example, encoder may choose a small transform unit size
496              *  and may use transform skip mode.
497              */
498             uint32_t    screen_content_flag                            : 1;
499             /**
500              *  When either weighted_pred_flag or weighted_bipred_flag is
501              *  turned on, the flag enable_gpu_weighted_prediction requests
502              *  GPU to determine weighted prediction factors. In this case,
503              *  the following parameters in slice control data structure
504              *  shall be ignored:
505              *  luma_log2_weight_denom, delta_chroma_log2_weight_denom,
506              *  luma_offset_l0[15], luma_offset_l1[15],
507              *  delta_luma_weight_l0[15], delta_luma_weight_l1[15],
508              *  chroma_offset_l0[15][2], chroma_offset_l1[15][2],
509              *  and delta_chroma_weight_l0[15][2], delta_chroma_weight_l1[15][2].
510              */
511             uint32_t    enable_gpu_weighted_prediction                 : 1;
512             /** \brief HEVC syntax element in slice segment header
513              *  GPU uses it to generate new slice headers in slice size control.
514              */
515             uint32_t    no_output_of_prior_pics_flag                   : 1;
516             uint32_t    reserved                                       : 11;
517         } bits;
518         uint32_t        value;
519     } pic_fields;
520 } VAEncPictureParameterBufferHEVC;
521
522 /**
523  * \brief Slice parameter for HEVC encoding in main & main 10 profiles.
524  *
525  * This structure holds information for \c
526  * slice_segment_layer_rbsp() as defined by the HEVC
527  * specification.
528  *
529  * If packed slice headers mode is used, i.e. if the encoding
530  * pipeline was configured with the #VA_ENC_PACKED_HEADER_SLICE
531  * flag, then the driver expects two more buffers to be provided to
532  * the same \c vaRenderPicture() as this buffer:
533  * - a #VAEncPackedHeaderParameterBuffer with type set to
534  *   VAEncPackedHeaderType::VAEncPackedHeaderSlice ;
535  * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
536  *   header data.
537  *
538  */
539 typedef struct _VAEncSliceParameterBufferHEVC {
540     /** \brief Starting CTU address for this slice. */
541     uint32_t        slice_segment_address;
542     /** \brief Number of CTUs in this slice. */
543     uint32_t        num_ctu_in_slice;
544
545     /** \brief Slice type.
546      *  Corresponds to HEVC syntax element of the same name.
547      */
548     uint8_t         slice_type;
549     /** \brief Same as the HEVC bitstream syntax element. */
550     uint8_t         slice_pic_parameter_set_id;
551
552     /** \brief Maximum reference index for reference picture list 0.
553      *  Range: 0 to 14, inclusive.
554      */
555     uint8_t         num_ref_idx_l0_active_minus1;
556     /** \brief Maximum reference index for reference picture list 1.
557      *  Range: 0 to 14, inclusive.
558      */
559     uint8_t         num_ref_idx_l1_active_minus1;
560     /** \brief Reference picture list 0 (for P slices). */
561     VAPictureHEVC   ref_pic_list0[15];
562     /** \brief Reference picture list 1 (for B slices). */
563     VAPictureHEVC   ref_pic_list1[15];
564     /**@}*/
565
566     /** @name pred_weight_table() */
567     /**@{*/
568     /** \brief Same as the HEVC bitstream syntax element. */
569     uint8_t         luma_log2_weight_denom;
570     /** \brief Same as the HEVC bitstream syntax element. */
571     int8_t          delta_chroma_log2_weight_denom;
572     /** \brief Same as the HEVC bitstream syntax element. */
573     int8_t          delta_luma_weight_l0[15];
574     /** \brief Same as the HEVC bitstream syntax element. */
575     int8_t          luma_offset_l0[15];
576     /** \brief Same as the HEVC bitstream syntax element. */
577     int8_t          delta_chroma_weight_l0[15][2];
578     /** \brief Same as the HEVC spec variable ChromaOffsetL0[]. */
579     int8_t          chroma_offset_l0[15][2];
580     /** \brief Same as the HEVC bitstream syntax element. */
581     int8_t          delta_luma_weight_l1[15];
582     /** \brief Same as the HEVC bitstream syntax element. */
583     int8_t          luma_offset_l1[15];
584     /** \brief Same as the HEVC bitstream syntax element. */
585     int8_t          delta_chroma_weight_l1[15][2];
586     /** \brief Same as the HEVC spec variable ChromaOffsetL1[]. */
587     int8_t          chroma_offset_l1[15][2];
588     /**@}*/
589
590     /** \brief Corresponds to HEVC spec variable MaxNumMergeCand.
591      *  Range: [1..5].
592      */
593     uint8_t         max_num_merge_cand;
594
595     /** \brief Same as the HEVC bitstream syntax element. */
596     int8_t          slice_qp_delta;
597
598     /** \brief Same as the HEVC bitstream syntax element. */
599     int8_t          slice_cb_qp_offset;
600
601     /** \brief Same as the HEVC bitstream syntax element. */
602     int8_t          slice_cr_qp_offset;
603
604     /** \brief Same as the HEVC bitstream syntax element. */
605     int8_t          slice_beta_offset_div2;
606
607     /** \brief Same as the HEVC bitstream syntax element. */
608     int8_t          slice_tc_offset_div2;
609
610     union {
611         struct {
612             /** \brief Indicates if current slice is the last one in picture */
613             uint32_t    last_slice_of_pic_flag                         : 1;
614             /** \brief Corresponds to HEVC syntax element of the same name */
615             uint32_t    dependent_slice_segment_flag                   : 1;
616             /** \brief Corresponds to HEVC syntax element of the same name */
617             uint32_t    colour_plane_id                                : 2;
618             /** \brief Corresponds to HEVC syntax element of the same name. */
619             uint32_t    slice_temporal_mvp_enabled_flag                : 1;
620             /** \brief Corresponds to HEVC syntax element of the same name. */
621             uint32_t    slice_sao_luma_flag                            : 1;
622             /** \brief Corresponds to HEVC syntax element of the same name. */
623             uint32_t    slice_sao_chroma_flag                          : 1;
624             /** \brief Corresponds to HEVC syntax element of the same name.
625              *  if this flag is set to 0, num_ref_idx_l0_active_minus1 should be
626              *  equal to num_ref_idx_l0_default_active_minus1
627              *  as well as for that for l1.
628              */
629             uint32_t    num_ref_idx_active_override_flag               : 1;
630             /** \brief Corresponds to HEVC syntax element of the same name. */
631             uint32_t    mvd_l1_zero_flag                               : 1;
632             /** \brief Corresponds to HEVC syntax element of the same name. */
633             uint32_t    cabac_init_flag                             : 1;
634             /** \brief Corresponds to HEVC syntax element of the same name. */
635             uint32_t    slice_deblocking_filter_disabled_flag          : 2;
636             /** \brief Corresponds to HEVC syntax element of the same name. */
637             uint32_t    slice_loop_filter_across_slices_enabled_flag   : 1;
638             /** \brief Corresponds to HEVC syntax element of the same name. */
639             uint32_t    collocated_from_l0_flag                        : 1;
640         } bits;
641         uint32_t        value;
642     } slice_fields;
643     /**@}*/
644 } VAEncSliceParameterBufferHEVC;
645
646 /**
647  * \brief HEVC Quantization Matrix Buffer Structure
648  *
649  * This structure is sent once per frame,
650  * and only when scaling_list_enabled_flag = 1 and scaling_list_data_present_flag = 1.
651  * Only when scaling_list_data_present_flag = 1, app still
652  * needs to send in this structure. When scaling_list_enabled_flag = 1 and
653  * scaling_list_data_present_flag = 0, driver is responsible to generate
654  * the default scaling list values.
655  *
656  * Matrix entries are in raster scan order which follows HEVC spec.
657  */
658 typedef struct _VAQMatrixBufferHEVC
659 {
660     /**
661      * \brief scaling lists,
662      * corresponds to same HEVC spec syntax element
663      * ScalingList[ i ][ MatrixID ][ j ].
664      *
665      * \brief 4x4 scaling,
666      */
667     uint8_t             scaling_lists_4x4[3][2][16];
668     /**
669      * \brief 8x8 scaling,
670      */
671     uint8_t             scaling_lists_8x8[3][2][64];
672     /**
673      * \brief 16x16 scaling,
674      * correspongs i = 2, MatrixID is in the range of 0 to 5,
675      * inclusive. And j is in the range of 0 to 63, inclusive.
676      */
677     uint8_t             scaling_lists_16x16[3][2][64];
678     /**
679      * \brief 32x32 scaling,
680      * correspongs i = 3, MatrixID is in the range of 0 to 1,
681      * inclusive. And j is in the range of 0 to 63, inclusive.
682      */
683     uint8_t             scaling_lists_32x32[2][64];
684     /**
685      * \brief DC values of the 16x16 scaling lists,
686      * corresponds to HEVC spec syntax
687      * scaling_list_dc_coef_minus8[ sizeID - 2 ][ matrixID ] + 8
688      * with sizeID = 2 and matrixID in the range of 0 to 5, inclusive.
689      */
690     uint8_t             scaling_list_dc_16x16[3][2];
691     /**
692      * \brief DC values of the 32x32 scaling lists,
693      * corresponds to HEVC spec syntax
694      * scaling_list_dc_coef_minus8[ sizeID - 2 ][ matrixID ] + 8
695      * with sizeID = 3 and matrixID in the range of 0 to 1, inclusive.
696      */
697     uint8_t             scaling_list_dc_32x32[2];
698 } VAQMatrixBufferHEVC;
699
700 /**@}*/
701
702 #ifdef __cplusplus
703 }
704 #endif
705
706 #endif /* VA_ENC_HEVC_H */