1 /*
2 * Copyright (c) 2017-2024, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file     codec_def_encode_avc.h
24 //! \brief    Defines encode AVC types and macros shared by CodecHal, MHW, and DDI layer
25 //! \details  Applies to AVC encode only. Should not contain any DDI specific code.
26 //!
27 #ifndef __CODEC_DEF_ENCODE_AVC_H__
28 #define __CODEC_DEF_ENCODE_AVC_H__
29 
30 #include "codec_def_common_avc.h"
31 #include "codec_def_common_encode.h"
32 #include "codec_def_common.h"
33 #include "codec_def_encode.h"
34 
35 #define CODEC_AVC_NUM_MAX_DIRTY_RECT        4
36 #define CODEC_AVC_NUM_QP                    52
37 
38 #define CODEC_AVC_MAX_QP 51
39 #define CODEC_AVC_MIN_QP_LP 10
40 
41 #define CODEC_AVC_NUM_WP_FRAME              8
42 #define CODEC_AVC_MAX_FORWARD_WP_FRAME      6
43 #define CODEC_AVC_MAX_BACKWARD_WP_FRAME     2
44 #define CODEC_AVC_WP_OUTPUT_L0_START        0
45 #define CODEC_AVC_WP_OUTPUT_L1_START        6
46 
47 #define ENCODE_VDENC_AVC_MAX_ROI_NUMBER_G9            3        // Max 4  regions including non-ROI - used from DDI
48 #define ENCODE_VDENC_AVC_MAX_ROI_NUMBER_ADV          16        // Max 16 regions including non-ROI - used from DDI
49 #define ENCODE_VDENC_AVC_MIN_ROI_DELTA_QP_G9         -8        // Min delta QP for VDEnc ROI
50 #define ENCODE_VDENC_AVC_MAX_ROI_DELTA_QP_G9          7        // Max delta QP for VDEnc ROI
51 
52 #define ENCODE_DP_AVC_MAX_ROI_NUMBER               4
53 #define ENCODE_DP_AVC_MAX_ROI_NUM_BRC              8
54 
55 #define ENCODE_VDENC_AVC_MAX_ROI_NUMBER            3
56 
57 #define ENCODE_AVC_MAX_SLICES_SUPPORTED      256 // Limted to 256 due to memory constraints.
58 
59 //AVC
60 #define CODECHAL_ENCODE_AVC_ROI_WIDTH_SCALE_FACTOR          16
61 #define CODECHAL_ENCODE_AVC_ROI_FRAME_HEIGHT_SCALE_FACTOR   16
62 #define CODECHAL_ENCODE_AVC_ROI_FIELD_HEIGHT_SCALE_FACTOR   32
63 #define CODECHAL_ENCODE_AVC_MAX_ROI_NUMBER                  4
64 #define CODECHAL_ENCODE_AVC_MAX_SLICE_QP                    (CODEC_AVC_NUM_QP - 1) // 0 - 51 inclusive
65 #define CODECHAL_ENCODE_AVC_MAX_ICQ_QUALITYFACTOR           51
66 #define CODECHAL_ENCODE_AVC_MIN_ICQ_QUALITYFACTOR           1
67 #define CODECHAL_ENCODE_AVC_MAX_SLICES_SUPPORTED            256
68 #define CODECHAL_ENCODE_AVC_MIN_STREAM_BUFFER_ALIGNMENT     4096
69 #define CODECHAL_DEBUG_ENCODE_AVC_NAL_START_CODE_SEI        0x00000106
70 #define CODECHAL_DEBUG_ENCODE_AVC_NAL_START_CODE_PPS        0x00000128
71 #define CODECHAL_ENCODE_AVC_MI_COPY_MEM_MEM_CMD_ALIGNMENT   4
72 
73 typedef struct _CODECHAL_ENCODE_AVC_ROUNDING_PARAMS
74 {
75     bool       bEnableCustomRoudingIntra;
76     bool       bEnableCustomRoudingInter;
77     uint32_t   dwRoundingIntra;
78     uint32_t   dwRoundingInter;
79 } CODECHAL_ENCODE_AVC_ROUNDING_PARAMS, *PCODECHAL_ENCODE_AVC_ROUNDING_PARAMS;
80 
81 // video quality control parameters
82 typedef struct _CODECHAL_ENCODE_AVC_QUALITY_CTRL_PARAMS
83 {
84     union
85     {
86         struct
87         {
88             // Disables skip check for ENC.
89             unsigned int skipCheckDisable : 1;
90             // Indicates app will override default driver FTQ settings using FTQEnable.
91             unsigned int FTQOverride : 1;
92             // Enables/disables FTQ.
93             unsigned int FTQEnable : 1;
94             // Indicates the app will provide the Skip Threshold LUT to use when FTQ is
95             // enabled (FTQSkipThresholdLUT), else default driver thresholds will be used.
96             unsigned int FTQSkipThresholdLUTInput : 1;
97             // Indicates the app will provide the Skip Threshold LUT to use when FTQ is
98             // disabled (NonFTQSkipThresholdLUT), else default driver thresholds will be used.
99             unsigned int NonFTQSkipThresholdLUTInput : 1;
100             // Control to enable the ENC mode decision algorithm to bias to fewer B Direct/Skip types.
101             // Applies only to B frames, all other frames will ignore this setting.
102             unsigned int directBiasAdjustmentEnable : 1;
103             // Enables global motion bias.
104             unsigned int globalMotionBiasAdjustmentEnable : 1;
105             // MV cost scaling ratio for HME predictors.  It is used when
106             // globalMotionBiasAdjustmentEnable == 1, else it is ignored.  Values are:
107             //      0: set MV cost to be 0 for HME predictor.
108             //      1: scale MV cost to be ? of the default value for HME predictor.
109             //      2: scale MV cost to be ? of the default value for HME predictor.
110             //      3: scale MV cost to be 1/8 of the default value for HME predictor.
111             unsigned int HMEMVCostScalingFactor : 2;
112             //disable HME
113             unsigned int HMEDisable                         : 1;
114             //disable Super HME
115             unsigned int SuperHMEDisable                    : 1;
116             //disable Ultra HME
117             unsigned int UltraHMEDisable                    : 1;
118             // Force RepartitionCheck
119             unsigned int ForceRepartitionCheck              : 2;
120 
121         };
122         unsigned int encControls;
123     };
124 
125     // Maps QP to skip thresholds when FTQ is enabled.  Valid range is 0-255.
126     unsigned char FTQSkipThresholdLUT[CODEC_AVC_NUM_QP];
127     // Maps QP to skip thresholds when FTQ is disabled.  Valid range is 0-65535.
128     unsigned short NonFTQSkipThresholdLUT[CODEC_AVC_NUM_QP];
129     // Reserved for future use.
130     unsigned int reserved[8];
131 } CODECHAL_ENCODE_AVC_QUALITY_CTRL_PARAMS, *PCODECHAL_ENCODE_AVC_QUALITY_CTRL_PARAMS;
132 
133 // AVC VUI Parameters
134 typedef struct _CODECHAL_ENCODE_AVC_VUI_PARAMS
135 {
136     uint32_t          aspect_ratio_info_present_flag          : 1;
137     uint32_t          overscan_info_present_flag              : 1;
138     uint32_t          overscan_appropriate_flag               : 1;
139     uint32_t          video_signal_type_present_flag          : 1;
140     uint32_t          video_full_range_flag                   : 1;
141     uint32_t          colour_description_present_flag         : 1;
142     uint32_t          chroma_loc_info_present_flag            : 1;
143     uint32_t          timing_info_present_flag                : 1;
144     uint32_t          fixed_frame_rate_flag                   : 1;
145     uint32_t          nal_hrd_parameters_present_flag         : 1;
146     uint32_t          vcl_hrd_parameters_present_flag         : 1;
147     uint32_t          low_delay_hrd_flag                      : 1;
148     uint32_t          pic_struct_present_flag                 : 1;
149     uint32_t          bitstream_restriction_flag              : 1;
150     uint32_t          motion_vectors_over_pic_boundaries_flag : 1;
151     uint32_t                                                    : 17;
152     uint16_t          sar_width;
153     uint16_t          sar_height;
154     uint8_t           aspect_ratio_idc;
155     uint8_t           video_format;
156     uint8_t           colour_primaries;
157     uint8_t           transfer_characteristics;
158     uint8_t           matrix_coefficients;
159     uint8_t           chroma_sample_loc_type_top_field;
160     uint8_t           chroma_sample_loc_type_bottom_field;
161     uint8_t           max_bytes_per_pic_denom;
162     uint8_t           max_bits_per_mb_denom;
163     uint8_t           log2_max_mv_length_horizontal;
164     uint8_t           log2_max_mv_length_vertical;
165     uint8_t           num_reorder_frames;
166     uint32_t          num_units_in_tick;
167     uint32_t          time_scale;
168     uint8_t           max_dec_frame_buffering;
169 
170     //HRD parameters
171     uint8_t           cpb_cnt_minus1;
172     uint8_t           bit_rate_scale;
173     uint8_t           cpb_size_scale;
174     uint32_t          bit_rate_value_minus1[32];
175     uint32_t          cpb_size_value_minus1[32];
176     uint32_t          cbr_flag; // bit 0 represent SchedSelIdx 0 and so on
177     uint8_t           initial_cpb_removal_delay_length_minus1;
178     uint8_t           cpb_removal_delay_length_minus1;
179     uint8_t           dpb_output_delay_length_minus1;
180     uint8_t           time_offset_length;
181 } CODECHAL_ENCODE_AVC_VUI_PARAMS, *PCODECHAL_ENCODE_AVC_VUI_PARAMS;
182 
183 typedef enum
184 {
185     CODECHAL_ENCODE_AVC_NAL_UT_RESERVED  = 0x00, // Unspecified
186     CODECHAL_ENCODE_AVC_NAL_UT_SLICE     = 0x01, // Coded Slice - slice_layer_no_partioning_rbsp
187     CODECHAL_ENCODE_AVC_NAL_UT_DPA       = 0x02, // Coded Data partition A - dpa_layer_rbsp
188     CODECHAL_ENCODE_AVC_NAL_UT_DPB       = 0x03, // Coded Data partition B - dpa_layer_rbsp
189     CODECHAL_ENCODE_AVC_NAL_UT_DPC       = 0x04, // Coded Data partition C - dpa_layer_rbsp
190     CODECHAL_ENCODE_AVC_NAL_UT_IDR_SLICE = 0x05, // Coded Slice of a IDR Picture - slice_layer_no_partioning_rbsp
191     CODECHAL_ENCODE_AVC_NAL_UT_SEI       = 0x06, // Supplemental Enhancement Information - sei_rbsp
192     CODECHAL_ENCODE_AVC_NAL_UT_SPS       = 0x07, // Sequence Parameter Set - seq_parameter_set_rbsp
193     CODECHAL_ENCODE_AVC_NAL_UT_PPS       = 0x08, // Picture Parameter Set - pic_parameter_set_rbsp
194     CODECHAL_ENCODE_AVC_NAL_UT_AUD       = 0x09, // Access Unit Delimiter - access_unit_delimiter_rbsp
195     CODECHAL_ENCODE_AVC_NAL_UT_EOSEQ     = 0x0a, // End of sequence - end_of_seq_rbsp
196     CODECHAL_ENCODE_AVC_NAL_UT_EOSTREAM  = 0x0b, // End of stream - end_of_stream_rbsp
197     CODECHAL_ENCODE_AVC_NAL_UT_FILL      = 0x0c, // Filler data - filler_data_rbsp
198     CODECHAL_ENCODE_AVC_NAL_UT_SEQEXT    = 0x0d, // Sequence parameter set extension - seq_parameter_set_extension_rbsp
199     CODECHAL_ENCODE_AVC_NAL_UT_PREFIX    = 0x0e, // Prefix NAL unit in scalable extension - prefix_nal_unit_rbsp
200     CODECHAL_ENCODE_AVC_NAL_UT_SUBSEQ    = 0x0f, // Subset sequence parameter set - subset_seq_parameter_set_rbsp
201     /* 0x10..0x12 - Reserved */
202     CODECHAL_ENCODE_AVC_NAL_UT_LAYERNOPART = 0x13, // Coded slice of an auxiliary coded picture without paritioning - slice_layer_without_partitioning_rbsp
203     CODECHAL_ENCODE_AVC_NAL_UT_LAYERSCALEEXT = 0x14, // Coded slice in scalable extension - slice_layer_in_scalable_extension_rbsp
204     /* 0x15..0x17 - Reserved */
205     /* 0x18..0x1f - Unspcified */
206 
207     //this should be the last element of this enum
208     //chagne this value if NAL unit type increased
209     CODECHAL_ENCODE_AVC_MAX_NAL_TYPE = 0x1f,
210 } CODECHAL_ENCODE_AVC_NAL_UNIT_TYPE;
211 
212 // Range 0...4: all slices of the current picture can have differing slice type
213 enum
214 {
215     SLICE_P = 0,
216     SLICE_B = 1,
217     SLICE_I = 2,
218     SLICE_SP = 3,
219     SLICE_SI = 4
220 };
221 // Range 5...9: all slices of the current picture have the same slice type
222 enum
223 {
224     FRAME_P = SLICE_P + 5,
225     FRAME_B = SLICE_B + 5,
226     FRAME_I = SLICE_I + 5,
227     FRAME_SP = SLICE_SP + 5,
228     FRAME_SI = SLICE_SI + 5
229 };
230 typedef enum
231 {
232     CODECHAL_ENCODE_AVC_SINGLE_PASS = 0,
233     CODECHAL_ENCODE_AVC_ICHAT       = 1,
234     CODECHAL_ENCODE_AVC_CAPTURE     = 4,
235     CODECHAL_ENCODE_AVC_APM         = 20
236 } CODECHAL_ENCODE_AVC_ENCODER_USAGE;
237 
238 const uint8_t Slice_Type[10] = { SLICE_P, SLICE_B, SLICE_I, SLICE_SP, SLICE_SI, SLICE_P, SLICE_B, SLICE_I, SLICE_SP, SLICE_SI };
239 
240 typedef struct _CODEC_ROI_MAP
241 {
242     char                PriorityLevelOrDQp; // [-3..3] or [-51..51]
243     uint8_t             NumRect;
244     CODEC_ROI           Rect[16];   // disconnected areas which have same PriorityLevelOrDQp
245 } CODEC_ROI_MAP, *PCODEC_ROI_MAP;
246 
247 typedef struct _CODEC_PIC_REORDER
248 {
249     uint32_t           PicNum;
250     uint32_t           POC;
251     uint8_t            ReorderPicNumIDC;
252     uint8_t            DiffPicNumMinus1;
253     uint32_t           LongTermPicNum;
254     CODEC_PICTURE      Picture;
255 } CODEC_PIC_REORDER, *PCODEC_PIC_REORDER;
256 
257 typedef struct _CODEC_SLICE_MMCO
258 {
259     uint8_t  MmcoIDC;
260     uint32_t DiffPicNumMinus1;
261     uint32_t LongTermPicNum;
262     uint32_t LongTermFrameIdx;
263     uint32_t MaxLongTermFrameIdxPlus1;
264 } CODEC_SLICE_MMCO, *PCODEC_SLICE_MMCO;
265 
266 /*! \brief Provides the sequence-level parameters of a compressed picture for AVC encoding.
267 *
268 *   The framework is expected to only send a sequence parameter compressed buffer for the first picture(first Execute() call) in a sequence, associated with a RAP(IDR, CRA, BLA) picture.
269 */
270 typedef struct _CODEC_AVC_ENCODE_SEQUENCE_PARAMS
271 {
272     uint16_t          FrameWidth;         //!< Width of the frame in pixels.
273     uint16_t          FrameHeight;        //!< Height of the frame in pixels.
274     uint8_t           Profile;            //!< Same as AVC syntax parameter profile_idc.
275     uint8_t           Level;              //!< Same as AVC syntax parameter level_idc.
276 
277     uint16_t          GopPicSize;         //!< Distance between IRAP pictures.
278     /*! \brief Distance between anchor frames (I or P).
279     *
280     *    Here, P may also means low delay B (GPB) frames.
281     *    Programming Note: GopPicSize > GopRefDist should be ensured by application. It is required by BRC.
282     */
283     uint16_t          GopRefDist;
284     uint16_t          GopOptFlag  : 2;
285     uint16_t                      : 6;
286 
287     uint8_t           TargetUsage;
288     /*! \brief Specifies rate control method.
289     *
290     *    \n 0: CQP, if set, internal BRC, multi-pass and panic mode will be disabled
291     *    \n 1: CBR
292     *    \n 2: VBR
293     *    \n 3: CQP, see above
294     *    \n 4: AVBR, if set, HRD compliance is not guaranteed. Buffering period SEI and picture timing SEI messages are not necessary for AVBR.
295     *    \n 5: Reserved
296     *    \n 6: Reserved
297     *    \n 7: Reserved
298     *    \n 8: LA, look ahead
299     *    \n 9: ICQ (Intelligent Constant Quality)
300     *    \n 10: VCM, defined for video converencing
301     *    \n 11: LA_ICQ
302     *    \n 12: LA_EXT, defined for server transcoding usage, 1 input video sequence generates several sequences with different bitrate
303     *    \n 13: LA_HRD, defined for server and client usage, lookahead with HRD and strict handling of maximum bitrate window
304     *    \n 14: QVBR (Quality Regulated VBR)
305     *    \n Programming note: Define the minimum value as indicated above for AVBR accuracy & convergence, clamp any value that is less than the minimum value to the minimum value.  Define the maximum value for AVBR accuracy as 100 (10%) and for AVBR convergence as 500, clamp any value that is greater than the maximum value to the maximum value. The maximum & minimum value may be adjusted when necessary. If bResetBRC is set to 1 for a non-I picture, driver shall not insert SPS into bitstream.  Driver needs to calculate the maximum allowed frame size per profile/level for all RateControlMethod except CQP, and use the calculated value to program kernel for non AVBR modes; for AVBR mode, driver needs to clamp the upper bound of UserMaxFrameSize to the calculated value and use the clamped UserMaxFrameSize to program kernel.  If IWD_VBR is set, driver programs it the same as VBR except not to enable panic mode.
306     */
307     uint8_t           RateControlMethod;
308     uint32_t          TargetBitRate;      //!< Target bit rate in bit per second
309     uint32_t          MaxBitRate;         //!< Maximum bit rate in bit per second
310     /*! \brief Minimun bit rate in bit per second.
311     *
312     *   This is used in VBR control. For CBR control, this field is ignored.
313     */
314     uint32_t          MinBitRate;
315     uint16_t          FramesPer100Sec;                        //!< Total frames per 100 second (frame rate fps * 100).
316     uint32_t          InitVBVBufferFullnessInBit;             //!< Initial VBV buffer fullness in bits.
317     /*! \brief VBV buffer size in bit unit.
318     *
319     *   The AVC spec defines a max coded picture buffer size for each level.
320     */
321     uint32_t          VBVBufferSizeInBit;
322     /*! \brief Specifies number of reference frames.
323     *
324     *    Should not be greater than driver reported max number of references.
325     */
326     uint8_t           NumRefFrames;
327 
328     /*! \brief Same as AVC syntax element.
329     *
330     *   Should not be greater than max SPS set reported by driver.
331     */
332     uint8_t           seq_parameter_set_id;
333     uint8_t           chroma_format_idc;                      //!< Same as AVC syntax element.
334     uint8_t           bit_depth_luma_minus8;                  //!< Same as AVC syntax element.
335     uint8_t           bit_depth_chroma_minus8;                //!< Same as AVC syntax element.
336     uint8_t           log2_max_frame_num_minus4;              //!< Same as AVC syntax element.
337     uint8_t           pic_order_cnt_type;                     //!< Same as AVC syntax element.
338     uint8_t           log2_max_pic_order_cnt_lsb_minus4;      //!< Same as AVC syntax element.
339     uint8_t           num_ref_frames_in_pic_order_cnt_cycle;  //!< Same as AVC syntax element.
340     int32_t           offset_for_non_ref_pic;                 //!< Same as AVC syntax element.
341     int32_t           offset_for_top_to_bottom_field;         //!< Same as AVC syntax element.
342     int32_t           offset_for_ref_frame[256];              //!< Same as AVC syntax element.
343     uint16_t          frame_crop_left_offset;                 //!< Same as AVC syntax element.
344     uint16_t          frame_crop_right_offset;                //!< Same as AVC syntax element.
345     uint16_t          frame_crop_top_offset;                  //!< Same as AVC syntax element.
346     uint16_t          frame_crop_bottom_offset;               //!< Same as AVC syntax element.
347 
348     uint16_t          seq_scaling_list_present_flag[12];          //!< Same as AVC syntax element.
349     uint16_t          seq_scaling_matrix_present_flag     : 1;    //!< Same as AVC syntax element.
350     uint16_t          delta_pic_order_always_zero_flag    : 1;    //!< Same as AVC syntax element.
351     uint16_t          frame_mbs_only_flag                 : 1;    //!< Same as AVC syntax element.
352     uint16_t          direct_8x8_inference_flag           : 1;    //!< Same as AVC syntax element.
353     uint16_t          vui_parameters_present_flag         : 1;    //!< Same as AVC syntax element.
354     uint16_t          frame_cropping_flag                 : 1;    //!< Same as AVC syntax element.
355     /*! \brief Specifies that encoded slices returned fit within the slice size specified in the picture parameter set for AVC.
356     *
357     *    When enabled, this overrides the slice structures specified by the application using slice level parameters.
358     */
359     uint16_t          EnableSliceLevelRateCtrl            : 1;
360     uint16_t                                              : 8;
361     union
362     {
363         struct
364         {
365             uint32_t           bInitBRC                     : 1;
366             /*! \brief Indicate if a BRC reset is desired to set a new bit rate or frame rate.
367             *
368             *   This setting is only valid if RateControlMethod is AVBR, VBR, CBR, VCM, ICQ, CQL or QVBR and the current picture is an I picture. If the frame resolution is changed, it should be set with IDR picture. It should not be set when RateControlMethod is CBR or CQP. The following table indicates which BRC parameters can be changed via a BRC reset.
369             *
370             *  \n BRC Parameters       Changes allowed via reset
371             *  \n Profile & Level               Yes
372             *  \n UserMaxFrameSize              Yes
373             *  \n InitVBVBufferFullnessInBit    No
374             *  \n TargetBitRate                 Yes
375             *  \n VBVBufferSizeInBit            No
376             *  \n MaxBitRate                    Yes
377             *  \n FramesPer100Sec *             No
378             *  \n RateControlMethod             No
379             *  \n GopPicSize                    No
380             *  \n GopRefDist                    No
381             *  \n GopOptFlag                    Yes
382             *  \n FrameWidth                    No
383             *  \n FrameHeight                   No
384             *  \n Note: when resolution (FrameWidth and/or FrameHeight) changes, framework should re-start a new bit stream and not using BRC reset.
385             */
386             uint32_t           bResetBRC                    : 1;
387             /*! \brief Indicates that current SPS is just a BRC parameter update, not a SPS change to be inserted into the bitstream.
388             *
389             *    When set to 1, current SPS will not be packed and inserted into bitstream by the driver.
390             */
391             uint32_t           bNoAcceleratorSPSInsertion   : 1;
392             /*! \brief Indicates the global search options.
393             *
394             *    It is only valid if EnhancedEncInput is reported during capability checking:
395             *        \n - 0: Default - option internally selected based on target usage
396             *        \n - 1: Long - SHME enabled
397             *        \n - 2: Medium - HME only enabled, SHME disabled
398             *        \n - 3: Short - SHME/HME disabled
399             */
400             uint32_t           GlobalSearch                 : 2;
401             /*! \brief Indicates the local search options.
402             *
403             *    It is only valid if EnhancedEncInput is reported during capability checking:
404             *        \n - 0: Default - option internally selected based on target usage
405             *        \n - 1: Tiny – MaxLenSP = 4, Reference Window = 24x24 SP = Spiral
406             *        \n - 2: Small – MaxLenSP = 9, Reference Window = 28x28 SP = Spiral
407             *        \n - 3: Square – MaxLenSP = 16, Reference Window = 32x32 SP = Spiral
408             *        \n - 4: Diamond – MaxLenSP = 16, Reference Window = 48x40 SP = Diamond
409             *        \n - 5: Large Diamond – MaxLenSP = 30, Reference Window = 48x40 SP = Diamond
410             *        \n - 6: Exhaustive – MaxLenSP = 57, Reference Window = 48x40 SP = Spiral
411             *        \n - 7: Heavy Horizontal – MaxLenSP = 57, Reference Window = 64x32 SP = Spiral
412             *        \n - 8: Heavy Vertical – MaxLenSP = 57, Reference Window = 32x64 SP = Spiral
413             */
414             uint32_t           LocalSearch                  : 4;
415             /*! \brief Indicates early skip control.
416             *
417             *    It is only valid if EnhancedEncInput is reported during capability checking:
418             *        \n - 0: Default, decided internally
419             *        \n - 1: EarlySkip enabled
420             *        \n - 2: EarlySkip disabled
421             */
422             uint32_t           EarlySkip                    : 2;
423             uint32_t           Reserved0                    : 1;
424             /*! \brief Indicates that MB BRC is enabled.
425             *
426             *    It is only valid if MBBRCSupport is reported during capability checking:
427             *        \n - 0: Default, decided internally based on target usage.
428             *        \n - 1: MB BRC enabled.
429             *        \n - 2: MB BRC disabled.
430             *        \n - Other values are Reserved.
431             *    \n Currently MB BRC can be applied to all bit rate control methods except CQP.
432             */
433             uint32_t           MBBRC                        : 4;
434             /*! \brief Indicates trellis control.
435             *
436             *    The Trellis_I, Trellis_P and Trellis_B settings may be combined using bitwise OR like "Trellis_I | Trellis_P" to enable Trellis for I & P.  If Trellis_Disabled is set with any combination, Trellis will be disabled.
437             *        \n - 0: Trellis_Default – Trellis decided internally.
438             *        \n - 1: Trellis_Disabled – Trellis disabled for all frames/fields.
439             *        \n - 2: Trellis_I – Trellis enabled for I frames/fields.
440             *        \n - 4: Trellis_P – Trellis enabled for P frames/fields.
441             *        \n - 8: Trellis_B – Trellis enabled for B frames/fields.
442             */
443             uint32_t           Trellis                      : 4;
444             /*! \brief Indicates current sequence is encoded for Temporal Scalability.
445             *    The driver may or may not use this flag.  For example, for VME+PAK AVC encoder MSDK handles all header insertion to indicate a temporal id in the SVC ext slice header and this flag is not used.  However, for VDEnc AVC encoder in certain cases BRC is required to know if the current frames are being encoded for temporal scalability and therefore will have extra SVC ext added in the slice header.
446             *        \n - 0: Default, current sequence is not encoded for Temporal Scalability.
447             *        \n - 1: current sequence is encoded is encoded for Temporal Scalability.
448             */
449             uint32_t           bTemporalScalability         : 1;
450             /*! \brief Indicates ROI[] value is in delta QP or priority.
451             *
452             *    It is valid only when parameter NumROI is greater than 0 and either ROIDeltaQPSupport or ROIBRCPriorityLevelSupport equals to 1.
453             *        \n - 0: Default, ROI[] value is in priority.
454             *        \n - 1: ROI[] value is in delta QP.
455             *    \n Currently only ROIValueInDeltaQP equal 1 is validated for CQP
456             */
457             uint32_t           ROIValueInDeltaQP            : 1;
458             /*! \brief Indicates larger P/B frame size than UserMaxPBFrameSize may be used.
459             *
460             *    if enabled, BRC may decide a larger P or B frame size than what UserMaxPBFrameSize dictates when the scene change is detected.
461             *        \n - 0: Default, normal BRC.
462             *        \n - 1: BRC may decide larger P/B frame size.
463             */
464             uint32_t           bAutoMaxPBFrameSizeForSceneChange : 1;
465             /* Control the force panic mode through DDI other than user feature key */
466             uint32_t           bForcePanicModeControl       : 1;
467             uint32_t           bPanicModeDisable            : 1;
468 
469             /*! \brief Enables streaming buffer in LLC
470             *
471             *        \n - 0 : streaming buffer by LLC is disabled.
472             *        \n - 1 : streaming buffer by LLC is enabled.
473             */
474             uint32_t           EnableStreamingBufferLLC     : 1;
475             /*! \brief Enables streaming buffer in DDR
476             *
477             *        \n - 0 : streaming buffer by DDR is disabled.
478             *        \n - 1 : streaming buffer by DDR is enabled.
479             */
480             uint32_t           EnableStreamingBufferDDR     : 1;
481             /*! \brief Indicates whether or not the encoding is in hierarchical GOP structure, for both RA B and LD B frame types
482             *
483             *        \n - 0 : BRC would treat it as flat structure.
484             *        \n - 1 : hierarchical structure.
485             *    \n In another word, this flag is equivalent to Qp Modulation enabling flag. If HierarchicalFlag == 1, app would enable Qp modulation for either random access or low delay hierarchical structure.
486             */
487             uint32_t           HierarchicalFlag             : 1;
488             /*! \brief Indicates whether or not the encoding is in low delay mode.
489             *
490             *        \n - 0 : the non-base temporal layers should be coded as random access B frames.
491             *        \n - 1 : no random access B will be coded. And the coding type could be only I or P.
492             *    \n Note: this flag only indicates the frame coding type, and is not related to BRC low delay mode.
493             */
494             uint32_t           LowDelayMode                 : 1;
495             /*! \brief Indicates if current encodin gis lookahead pass.
496             *
497             *        \n - 0 : the current encoding is in the actual encoding pass, and one of the BRC modes (CBR, VBR, etc.) should be selected.
498             *        \n - 1 : the current encoding is in the lookahead pass.
499             *    \n Valid only when LookAheadAnalysisSupport in CAP is on and LookAheadDepth > 0.
500             */
501             uint32_t           bLookAheadPhase              : 1;
502             uint32_t           Reserved1                    : 2;
503         };
504         uint32_t            sFlags;
505     };
506     /*! \brief Framework defined maximum frame size in bytes for I frames.
507     *
508     *    Applicable for all RateControlMethod values except CQP; guarantees that the compressed frame size will be less than this value. If UserMaxPBFrameSize equals 0, UserMaxIFrameSize will be used for all frame types. Maximum allowed frame size per profile/level will be calculated in driver and be used when UserMaxIFrameSize and UserMaxPBFrameSize are both set to 0.
509     */
510     uint32_t            UserMaxFrameSize;
511     /*! \brief Framework defined maximum frame size in bytes for P & B frames.
512     *
513     *    Applicable for all RateControlMethod values except CQP; guarantees that the compressed frame size will be less than this value. If UserMaxPBFrameSize equals 0, UserMaxIFrameSize will be used for all frame types. Maximum allowed frame size per profile/level will be calculated in driver and be used when UserMaxIFrameSize and UserMaxPBFrameSize are both set to 0.
514     */
515     uint32_t            UserMaxPBFrameSize;
516     /*! \brief Indicates the measure of quality for ICQ and QVBR
517     *
518     *    The range is from 1 – 51, with 1 being the best quality.
519     */
520     uint16_t           ICQQualityFactor;
521     /*! \brief Indicates the bitrate accuracy for AVBR
522     *
523     *    The range is [1, 100], 1 means one percent, and so on.
524     */
525     uint32_t           AVBRAccuracy;
526     /*! \brief Indicates the bitrate convergence period for AVBR
527     *
528     *    The unit is frame.
529     */
530     uint32_t          AVBRConvergence;
531 
532     /*! \brief Indicates the uncompressed input color space
533     *
534     *   Valid only when input is ARGB format.
535     */
536     ENCODE_INPUT_COLORSPACE     InputColorSpace;
537     /*! \brief Provides a hint to encoder about the scenario for the encoding session.
538     *
539     *   BRC algorithm may tune differently based on this info.
540     */
541     ENCODE_SCENARIO             ScenarioInfo;
542     ENCODE_CONTENT              ContentInfo;                    //!< Provides a hint to encoder about the content for the encoding session.
543 
544     /*! \brief Indicates the tolerance the application has to variations in the frame size.
545     *
546     *   It affects the BRC algorithm used, but may or may not have an effect based on the combination of other BRC parameters.  Only valid when the driver reports support for FrameSizeToleranceSupport.
547     */
548     ENCODE_FRAMESIZE_TOLERANCE  FrameSizeTolerance;
549 
550     /*! \brief Indicates BRC Sliding window size in terms of number of frames.
551     *
552     *   Defined for CBR and VBR. For other BRC modes or CQP, values are ignored.
553     */
554     uint16_t  SlidingWindowSize;
555 
556     /*! \brief Indicates maximun bit rate Kbit per second within the sliding window during.
557     *
558     *  Defined for CBR and VBR. For other BRC modes or CQP, values are ignored.
559     */
560     uint32_t  MaxBitRatePerSlidingWindow;
561 
562     /*! \brief Indicates minimun bit rate Kbit per second within the sliding window during.
563     *
564     *  Defined for CBR and VBR. For other BRC modes or CQP, values are ignored.
565     */
566     uint32_t  MinBitRatePerSlidingWindow;
567 
568     /*! \brief Indicates number of frames to lookahead.
569     *
570     *    Range is [0~127]. Default is 0 which means lookahead disabled. Valid only when LookaheadBRCSupport is 1. When not 0, application should send LOOKAHEADDATA buffer to driver.
571     */
572     uint8_t   LookaheadDepth;
573 
574     uint8_t            constraint_set0_flag               : 1;    //!< Same as AVC syntax element.
575     uint8_t            constraint_set1_flag               : 1;    //!< Same as AVC syntax element.
576     uint8_t            constraint_set2_flag               : 1;    //!< Same as AVC syntax element.
577     uint8_t            constraint_set3_flag               : 1;    //!< Same as AVC syntax element.
578     uint8_t                                               : 4;
579     uint8_t           separate_colour_plane_flag;                 //!< Same as AVC syntax element.
580     bool              qpprime_y_zero_transform_bypass_flag;       //!< Same as AVC syntax element.
581     bool              gaps_in_frame_num_value_allowed_flag;       //!< Same as AVC syntax element.
582     uint16_t          pic_width_in_mbs_minus1;                    //!< Same as AVC syntax element.
583     uint16_t          pic_height_in_map_units_minus1;             //!< Same as AVC syntax element.
584     bool              mb_adaptive_frame_field_flag;               //!< Same as AVC syntax element.
585 } CODEC_AVC_ENCODE_SEQUENCE_PARAMS, *PCODEC_AVC_ENCODE_SEQUENCE_PARAMS;
586 
587 typedef struct _CODEC_AVC_ENCODE_USER_FLAGS
588 {
589     union
590     {
591         struct
592         {
593             /*! \brief Indicates that raw pictures should be used as references instead of recon pictures.
594             *
595             *   Setting to 1 may improve performance at the cost of image quality.  The accelerator may or may not support toggling this value on a per frame basis.
596             */
597             uint32_t    bUseRawPicForRef                        : 1;
598             /*! \brief Indicates whether or not the driver will pack non-slice headers.
599             *
600             *   Applies to ENC + PAK mode only. This flag is only valid only when AcceleratorHeaderPacking = 1, and driver does the header packing.
601             *        \n - 0: Accelerator will pack AU delimiter, SPS (including VUI if present), PPS, SEI messages if present, end of sequence if indicated, and end of stream if indicated, along with coded slice to form a complete bitstream.
602             *        \n - 1: Accelerator will just pack coded slice (slice header + data), like in PAK only mode, and the application will pack the rest of the headers.
603             */
604             uint32_t    bDisableAcceleratorHeaderPacking        : 1;
605             /*! \brief Indicates whether or not the driver will try to introduce reordering.
606             *
607             *   Applies to ENC + PAK mode only. This flag is only valid only when AcceleratorHeaderPacking = 1, and driver does the header packing.
608             *        \n - 0: Accelerator will try to optimize the order of reference frames in the lists and generate ref_pic_list_modification part of slice header if necessary.
609             *        \n - 1: Accelerator will use reference picture list as is (e.g. it can be prepared by the app) to generate ref_pic_list_modification part of slice header if necessary.
610             */
611             uint32_t    bDisableAcceleratorRefPicListReordering : 1;
612             uint32_t                                            : 4;
613             uint32_t    bDisableSubMBPartition                  : 1;    //!< Indicates that sub MB partitioning should be disabled.
614             /*! \brief Inidicates whether or not emulation byte are inserted.
615             *
616             *   If 1, accelerator will perform start code prefix (0x 00 00 01/02/03/00) search and emulation byte (0x 03) insertion on packed header data. This doesn’t apply to packed slice header data. Packed slice header data must not have emulation byte inserted, accelerator will always perform start code prefix search and emulation byte (0x 03) insertion on packed slice header data.
617             *   Note: If cabac_zero_word insertion compliance is required, this value should be set to 0.  This means the application must perform emulation prevention byte insertion in the frame header.  This is due to the restriction in MFX_PAK_INSERT_OBJECT HeaderLengthExcludeFrmSize cannot allow EmulationFlag to be true.
618             */
619             uint32_t    bEmulationByteInsertion                 : 1;
620             /*! \brief Specifies the type of intra refresh used.
621             *
622             *    Effective only when RollingINtraRefresh capability in use. Applies to P pictures only (not valid with IBP). When used field encoding, B frames, and multiple references are not allowed.
623             *        \n - 0 : disabled
624             *        \n - 1 : enabled in colum
625             *        \n - 2 : enabled in row
626             *        \n - 3 : enabled in region
627             */
628             uint32_t    bEnableRollingIntraRefresh              : 2;
629 
630             /*! \brief Specifies if Slice Level Reporitng may be requested for this frame
631             *
632             *    If this flag is set, then slice level parameter reporting will be set up for this frame.  Only valid if SliceLevelReportSupport is reported in ENCODE_CAPS, else this flag is ignored.
633             *
634             */
635             uint32_t    bEnableSliceLevelReport                 : 1;
636 
637             /*! \brief Specifies if integer mode searching is performed
638             *
639             *    when set to 1, integer mode searching is performed
640             *
641             */
642             uint32_t    bDisableSubpixel                        : 1;
643 
644             /*! \brief Specifies if the overlapped operation of intra refresh is disabled
645             *
646             *    It is valid only when bEnableRollingIntraRefresh is on.
647             *    \n - 0 : default, overlapped Intra refresh is applied
648             *    \n - 1 : intra refresh without overlap operation
649             *
650             */
651             uint32_t    bDisableRollingIntraRefreshOverlap      : 1;
652 
653             /*! \brief Specifies whether extra partition decision refinement is done after the initial partition decision candidate is determined.
654             *
655             *    It has performance tradeoff for better quality.
656             *    \n - 0 : DEFAULT - Follow driver default settings.
657             *    \n - 1 : FORCE_ENABLE - Enable this feature totally for all cases.
658             *    \n - 2 : FORCE_DISABLE - Disable this feature totally for all cases.
659             */
660             uint32_t    ForceRepartitionCheck                   : 2;
661             uint32_t    bReserved                               : 16;
662         };
663         uint32_t        Value;
664     };
665 } CODEC_AVC_ENCODE_USER_FLAGS, *PCODEC_AVC_ENCODE_USER_FLAGS;
666 
667 typedef struct _CODEC_AVC_ENCODE_FORCE_SKIP_PARAMS
668 {
669     uint32_t    Enable;
670     uint32_t    Xpos;
671     uint32_t    Ypos;
672     uint32_t    Width;
673     uint32_t    Height;
674 
675 } CODEC_AVC_ENCODE_FORCE_SKIP_PARAMS, *PCODEC_AVC_ENCODE_FORCE_SKIP_PARAMS;
676 
677 /*! \brief Provides the picture-level parameters of a compressed picture for AVC encoding.
678 */
679 typedef struct _CODEC_AVC_ENCODE_PIC_PARAMS
680 {
681     /*! \brief Specifies the uncompressed source surface of the frame for the current picture to be encode.
682     *
683     *    The PicFlags regarding reference usage are expected to be valid at this time.
684     */
685     CODEC_PICTURE   CurrOriginalPic;
686     /*! \brief Specifies the uncompressed surface of the reconstructed frame for the current encoded picture.
687     *
688     *    The PicFlags regarding reference usage are expected to be valid at this time.
689     *    The recon surface may be of different format and different bit depth from that of source.
690     *    The framework needs to specify it through chroma_format_idc and bit_depth_luma_minus8 and
691     *    bit_depth_chroma_minus8 in SPS data structure.
692     */
693     CODEC_PICTURE   CurrReconstructedPic;
694     /*! \brief Specifies picture coding type.
695     *
696     *    \n 1: I picture
697     *    \n 2: P picture
698     *    \n 3: B picture
699     */
700     uint8_t         CodingType;
701     /*! \brief Specifies that field mode coding is in use.
702     *
703     *    Top or bottom field indicated by CurrOriginalPic.PicFlags.
704     */
705     uint8_t         FieldCodingFlag         : 1;
706     /*! \brief Specifies that MBAFF coding mode is in  use.
707     *
708     *    It shall not be set if NoFieldFrame flag is reported in CodingLimit during capability checking.
709     */
710     uint8_t         FieldFrameCodingFlag    : 1;
711     uint8_t                                 : 6;
712     /*! \brief Specifies the number of slices per frame or per field in field coding.
713     *
714     *    Note the restriction on slice based on the SliceStructure reported during capability checking.
715     */
716     uint32_t        NumSlice;
717 
718     /*! \brief Quantization parameter for Y.
719     *
720     *    Valid range is 0 - 51. If QpY is set to -1, driver will use an internal default value when CQP is not set, otherwise, driver will return error. Please note that, QpY is a frame level QP. QP for each slice is determined by QpY + slice_qp_delta. And QpY + slice_qp_delta should be also in the range of 0 – 51, inclusive.
721     */
722     char            QpY;
723     /*! \brief Each entry of the list specifies the frame index of the reference pictures.
724     *
725     *   The value of FrameIdx specifies the index of RefFrameList structure. And valid value range is [0..14, 0x7F]. Invalid entries are indicated by setting PicFlags to PICTURE_INVALID.
726     *   RefFrameList[] should include all the reference pictures in DPB, which means either the picture is referred by current picture or future pictures, it should have a valid entry in it.
727     */
728     CODEC_PICTURE   RefFrameList[CODEC_AVC_MAX_NUM_REF_FRAME];
729     /*! \brief Denotes "used for reference" frames as defined in the AVC specification.
730     *
731     *   The flag is accessed by:
732     *        \n - FlagTop(i) = (UsedForReferenceFlags >> (2 * i)) & 1
733     *        \n - FlagBottom(i) = (UsedForReferenceFlags >> (2 * i + 1)) & 1
734     *   \n If FlagTop(i) is 1, the top field or frame numger i is marked as "used for reference"; if FlagBottom(i) is 1 then then bottom field of frame i is marked as "used for reference". If either is 0 then the frame is not marked as "used for reference".
735     */
736     uint32_t        UsedForReferenceFlags;
737     /*! \brief Contains the picture order counts (POC) for the current frame
738     *
739     *   If field_pic_flag is 0:
740     *        \n - CurrFieldOrderCnt[0] contains the top field order count for the current picture
741     *        \n - CurrFieldOrderCnt[1] contains the bottom field order count for the current picture
742     *   \n If field_pic_flag is 1 and CurrPic.PicFlags indicates that this is a top field:
743     *        \n - CurrFieldOrderCnt[0] contains the top field order count for the current picture
744     *        \n - CurrFieldOrderCnt[1]
745     *   \n If field_pic_flag is 1 and CurrPic.PicFlags indicates that this is a bottom field:
746     *        \n - CurrFieldOrderCnt[0] should be 0 or ignored
747     *        \n - CurrFieldOrderCnt[1] contains the bottom field order count for the current picture
748     */
749     int32_t         CurrFieldOrderCnt[2];
750     /*! \brief Contains the POCs for the reference frames in RefFrameList.
751     *
752     *   For each entry FieldOrderCntList[i][j]:
753     *        \n - i: the picture index
754     *        \n - j: 0 specifies the top field order count and 1 specifies the bottom field order count
755     *   \n If a entry i in RefFrameList is not relevant (it is not used for reference) or valid, the entry FieldOrderCount[i][0 and 1] should be 0.
756     */
757     int32_t         FieldOrderCntList[16][2];
758     uint16_t        frame_num;                      //!< Same as AVC syntax element.
759     bool            bLastPicInSeq;                  //!< Indicate whether to insert sequence closing NAL unit.
760     bool            bLastPicInStream;               //!< Indicate whether to insert stream closing NAL unit.
761 
762     CODEC_AVC_ENCODE_USER_FLAGS     UserFlags;
763     CODEC_AVC_ENCODE_FORCE_SKIP_PARAMS  ForceSkip;
764     bool                                bStreamOutEnbleSinglePassvdenc;
765     bool                                bHMEActiveCtrlFrmApp;
766     bool                                bHMEActive;
767 
768     /*! \brief Arbitrary number set by the host decoder to use as a tag in the status report feedback data.
769     *
770     *   The value should not equal 0, and should be different in each call to Execute.
771     */
772     uint32_t        StatusReportFeedbackNumber;
773 
774     uint8_t         bIdrPic;                        //!< Indicates that the current picture is IDR.
775     uint8_t         pic_parameter_set_id;           //!< Same as AVC syntax element.
776     uint8_t         seq_parameter_set_id;           //!< Same as AVC syntax element.
777     uint8_t         num_ref_idx_l0_active_minus1;   //!< Same as AVC syntax element.
778     uint8_t         num_ref_idx_l1_active_minus1;   //!< Same as AVC syntax element.
779     char            chroma_qp_index_offset;         //!< Same as AVC syntax element.
780     char            second_chroma_qp_index_offset;  //!< Same as AVC syntax element.
781 
782     uint16_t        pic_scaling_list_present_flag[12];      //!< Same as AVC syntax element.
783     uint16_t        entropy_coding_mode_flag        : 1;    //!< Same as AVC syntax element.
784     uint16_t        pic_order_present_flag          : 1;    //!< Same as AVC syntax element.
785     uint16_t        weighted_pred_flag              : 1;    //!< Same as AVC syntax element.
786     uint16_t        weighted_bipred_idc             : 2;    //!< Same as AVC syntax element.
787     uint16_t        constrained_intra_pred_flag     : 1;    //!< Same as AVC syntax element.
788     uint16_t        transform_8x8_mode_flag         : 1;    //!< Same as AVC syntax element.
789     uint16_t        pic_scaling_matrix_present_flag : 1;    //!< Same as AVC syntax element.
790     uint16_t        RefPicFlag                      : 1;    //!< Indicates that the current picture (raw or recon) may be used as a reference for encoding other pictures.
791     /*! \brief Indicates how precise the framework would like BRC to be to reach the ideal requested framesize.
792     *
793     *    The driver will internally make programming decisions based on this parameter, it will be a tradeoff between performance and precision.  This flag is ignored if BRC is not enabled (CQP mode).
794     *        \n - 0: default precision (normal)
795     *        \n - 1: lowest precision
796     *        \n - 2: normal precision
797     *        \n - 3: highest precision
798     */
799     uint16_t        BRCPrecision                    : 2;
800     /*! \brief Indicates that the allocated source buffer format is a swizzle format from display.
801     *
802     *    Framework still allocates the buffer as a standard FOURCC format. The swizzled format will be reported as supported for the encoder configuration during capability reporting.
803     *    \n Source/Raw Allocated Buffer Format, DisplayFormatSwizzle, Layout Format in Buffer
804     *        \n - YUY2, 0, YUY2
805     *        \n - YUY2, 1, 2YUY (Y0U0Y1V0)
806     *        \n - AYUV, 0, AYUV
807     *        \n - AYUV, 1, YUXV
808     */
809     uint16_t        bDisplayFormatSwizzle           : 1;
810     uint16_t                                        : 3;
811 
812     uint8_t         num_slice_groups_minus1;                //!< Same as AVC syntax element.
813     char            pic_init_qp_minus26;                    //!< Same as AVC syntax element.
814     char            pic_init_qs_minus26;                    //!< Same as AVC syntax element.
815     bool            deblocking_filter_control_present_flag; //!< Same as AVC syntax element.
816     bool            redundant_pic_cnt_present_flag;         //!< Same as AVC syntax element.
817 
818     // Parameters for RollingI feature
819     bool            bDisableRollingIntraRefreshOverlap;
820     uint8_t         EnableRollingIntraRefresh;
821     uint8_t         IntraRefreshMBNum;
822     uint8_t         IntraRefreshMBx;
823     uint8_t         IntraRefreshMBy;
824     uint8_t         IntraRefreshUnitinMB;
825     char            IntraRefreshQPDelta;
826     uint32_t        FirstPFrameIntraInsertionSize;
827 
828     /*! \brief Indicates the maximum size of each slice in Bytes.
829     *
830     *    This is valid only when EnableSliceLevelRateCtrl is enabled in the sequence level.
831     */
832     uint32_t        SliceSizeInBytes;
833 
834     /*! \brief Number of Region Of Interest (ROI).
835     *
836     *    Value range is 0 to 16 inclusively. If no ROI to be set, this value shall be set to 0.
837     */
838     uint8_t         NumROI;
839     uint8_t         NumDirtyROI;                        //!< Number of dirty ROIs [0...4]
840     uint8_t         NumDeltaQpForNonRectROI;            //!< Number of DeltaQP for non-rectangular ROIs [0...16]
841     /*! \brief Dictates the value of delta QP for any ROI should be within [MinDeltaQp..MaxDeltaQp]
842     *
843     *    Applies only to BRC case.
844     */
845     char            MaxDeltaQp;
846     /*! \brief Dictates the value of delta QP for any ROI should be within [MinDeltaQp..MaxDeltaQp]
847     *
848     *    Applies only to BRC case.
849     */
850     char            MinDeltaQp;
851     /*! \brief Determine possible DeltaQP values for NonRectROI. For BRC case values should be within [MinDeltaQp..MaxDeltaQp]
852     *
853     *    QP value for the MB is represented by NonRectROIDeltaQpList[QpData - 1],
854     *    where QpData - UCHAR in ENCODE_MBQPDATA structure.
855     *    if QpData == 0, the block is in the background, and slice QP (QpY + slice_qp_delta) is applied on this MB.
856     */
857     char            NonRectROIDeltaQpList[16];
858     /*! \brief Defines ROI settings.
859     *
860     *    Value entries are ROI[0] up to ROI[NumROI – 1], inclusively, if NumROI > 0. And it can be ignored otherwise.
861     */
862     CODEC_ROI       ROI[16];
863     /*! \brief Distinct delta QP values assigned to the ROI
864     *
865     *    Value entries are distinct and within [MinDeltaQp..MaxDeltaQp].
866     */
867     int8_t ROIDistinctDeltaQp[16];
868     /*! \brief Number of distinct delta QP values assigned to the ROI
869     */
870     int8_t NumROIDistinctDeltaQp;
871     /*! \brief indicate native ROI / force QP ROI to be used.
872     */
873     bool        bNativeROI;
874     /*! \brief Defines dirty ROI settings.
875     *
876     *    Value entries are DirtyROI[0] up DirtyROI ROI[NumROI – 1], inclusively, if NumDirtyROI > 0. And it can be ignored otherwise.
877     */
878     CODEC_ROI       DirtyROI[CODEC_AVC_NUM_MAX_DIRTY_RECT];
879 
880     CODEC_ROI_MAP   ROIMapArray[16];
881 
882     /*! \brief Specifies skip frames.
883     *
884     *    0: Encode as normal, no skip.
885     *    1: One or more frames were skipped prior to the current frame, encode the current frame as normal.  The driver will pass the NumSkipFrames and SizeSkipFrames to BRC for adjustment.
886     */
887     uint8_t         SkipFrameFlag;
888     /*! \brief The number of frames skipped prior to the current frame.
889     *
890     *    Valid when SkipFlag = 1.
891     */
892     uint8_t         NumSkipFrames;
893     /*! \brief Differs in meaning based on value of SkipFrameFlag
894     *
895     *    SkipFrameFlag = 1, the size of the skipped frames in bits.
896     *    Note: Currently kernel only supports 16 bits for SizeSkipFrames.
897     */
898     uint32_t        SizeSkipFrames;
899 
900     /*! \brief Specifies the minimum Qp to be used for BRC.
901     *
902     *    BRCMaxQp and BRCMinQp may be set at a per frame type (I, P, B) granularity.
903     *    BRCMaxQp and BRCMinQp should be set to zero if Qp control is not desired.
904     *    If non-zero min/max QP is passed for I-frame, it will be used for I, P and B frames.
905     *    If non-zero min/max QP is passed for P-frame also, then P and B frame will be updated to this. I-frame remains unchanged.
906     *    If non-zero min/max QP is passed for B-frame also, then B-frame will be updated to this. I and P frame remains unchanged.
907     *    If new QP values are passed in between the sequence, then it will be updated for that frame-type and any other frame types that are not explicitly set. Eg. if min/max QP for P-frame was passed separately, and an update for I-frame is received, then only I-frame values are updated.  P and B will continue to use old values.  But, if P-frame and B-frame were never explicitly set then updating I-frame will also update P and B.
908     *    If the application wants to keep the current non-zero min/max QP settings, then min/max QP should be set to zero, so the driver will not change previously set values and continue to use them.
909     *    Min QP is expected to be less than or equal to Max QP.  Driver clamps max QP to [1, 51] and min QP to [1, max QP].  Zero QP is not used.
910     *    Only single PAK pass is supported plus the IPCM pass.  Panic mode is disabled.  This is because min/maxQP requirement conflicts with the HRD compliancy requirement, so the HRD compliancy restriction is relaxed.
911     */
912     uint8_t         ucMinimumQP;
913     uint8_t         ucMaximumQP;    //!< Specifies the maximum Qp to be used for BRC.
914 
915     uint32_t        dwZMvThreshold; //!< Used for static frame detection.
916 
917     /*! \brief Indicates that an HMEOffset will be sent by the application in HMEOffset for each reference.
918     *
919     *    This offset will be added to the co-located (0, 0) location before HME search is performed.  This is only valid if HMEOffsetSupport is reported as supported as a capability, else this flag is ignored.
920     */
921     bool            bEnableHMEOffset;
922     /*! \brief Specifies the HME offsets.
923     *
924     *    Curently the supported range is -128 to +127, programmed in 4x downscaled HME precision, not the original size. HMEOffset[i][j] where:
925     *        \n - i – RefFrameList Index
926     *        \n - j – 0 = x, 1 = y Coordinates
927     *    \n So for example, HMEOffset[i] specifies the (x, y) offset corresponding to the ith entry in RefFrameList.
928     *    Programming Note: The HME offset must be a multiple of 4x4 to align to the 4x4 HME block, so the driver must align the application supplied value.
929     */
930     int16_t         HMEOffset[16][2][2];
931 
932     /*! \brief Specifies Inter MB partition modes that will be disabled.
933     *
934     *    SubMbPartMask is only valid when bEnableSubMbPartMask is true. Bit0~6 indicate inter 16x16, 16x8, 8x16, 8x8, 8x4, 4x8, 4x4.
935     */
936     bool            bEnableSubMbPartMask;
937     uint8_t         SubMbPartMask;
938 
939     /*! \brief Specifies motion search modes that will be used.
940     *
941     *    SubPelMode is only valid when bEnableSubPelMode is true. Following are valid values of SubPelMode:
942     *    0:Integer mode searching
943     *    1:Half-pel mode searching
944     *    2:Reserved
945     *    3:Quarter-pel mode searching
946     */
947     bool            bEnableSubPelMode;
948     uint8_t         SubPelMode;
949 
950     /*! \brief Specifies whether extra partition decision refinement is done after the initial partition decision candidate is determined.
951     *
952     *    It has performance tradeoff for better quality.
953     *    \n - 0 : DEFAULT - Follow driver default settings.
954     *    \n - 1 : FORCE_ENABLE - Enable this feature totally for all cases.
955     *    \n - 2 : FORCE_DISABLE - Disable this feature totally for all cases.
956     */
957     uint32_t        ForceRepartitionCheck;
958 
959     /*! \brief Specifies force-to-skip for HRD compliance in BRC kernel that will be disabled.
960     *
961     *    bDisableFrameSkip is only valid for P/B frames
962     *    0: force-to-skip will be enabled as required in BRC kernel. Default value.
963     *    1: force-to-skip will be disabled in BRC kernel.
964     */
965     bool            bDisableFrameSkip;
966 
967     /*! \brief Maximum frame size for all frame types in bytes.
968     *
969     *    Applicable for CQP and multi PAK. If dwMaxFrameSize > 0, driver will do multiple PAK and adjust QP
970     *    (frame level QP + slice_qp_delta) to make the compressed frame size to be less than this value.
971     *    If dwMaxFrameSize equals 0, driver will not do multiple PAK and do not adjust QP.
972     */
973     uint32_t        dwMaxFrameSize;
974 
975     /*! \brief Total pass number for multiple PAK.
976     *
977     *    Valid range is 0 - 4. If dwNumPasses is set to 0, driver will not do multiple PAK and do not adjust
978     *    QP (frame level QP + slice_qp_delta), otherwise, driver will do multiple times PAK and in each time
979     *    the QP will be adjust according deltaQp parameters.
980     */
981     uint32_t        dwNumPasses;
982 
983     /*! \brief Delta QP array for each PAK pass.
984     *
985     *    This pointer points to an array of deltaQp, the max array size for AVC encoder is 4. The valid range
986     *    for each deltaQp is 0 - 51. If the value is out of this valid range, driver will return error.
987     *    Otherwise, driver will adjust QP (frame level QP + slice_qp_delta) by adding this value in each PAK pass.
988     */
989     uint8_t        *pDeltaQp;
990 
991     /*! \brief Specifies target frame size in TCBRC mode.
992     *
993     *    If TCBRCSupport == 1, this parameter enables "Transport Controlled BRC mode" and indicates the desired frame size in bytes.
994     *      - If the value equals 0, the BRC mode defined in RateControlMethod will take control for that certain frame.
995     *    If TCBRCSupport == 0, this parameter will be ignored and should be set to 0. The BRC mode defined in RateControlMethod will be applied.
996     */
997     uint32_t        TargetFrameSize;
998 
999     /*! \brief Indicates if GPU polling based sync is enabled.
1000     *
1001     *  Applicaiton sets to 1 to enable GPU polling based sync in driver.
1002     */
1003     bool            bEnableSync;
1004 
1005     /*! \brief Indicates if the current frame is repeat frame.
1006     *
1007     *  Applicaiton sets to 1 if current frame is repeat frame.
1008     */
1009     bool            bRepeatFrame;
1010 
1011     /*! \brief Indicates if enable QP adjustment for current frame.
1012     *
1013     *  Applicaiton sets to 1 to enable QP adjustment for current frame in CQP mode.
1014     *  When QP adjustment is enabled, driver calls MBBRC kernel to adjust per MB QP for perceptual quality in CQP mode.
1015     */
1016     bool            bEnableQpAdjustment;
1017 
1018     /*! \brief Indicates marker coordinates in raw surface for GPU polling based sync.
1019     *
1020     *  In unite of bytes. Valid for encoders which report SyncSupport capability as true.
1021     */
1022     uint16_t        SyncMarkerX;
1023     uint16_t        SyncMarkerY;
1024 
1025     /*! \brief Point to marker value for GPU polling based sync.
1026     *
1027     *  Valid for encoders which report SyncSupport capability as true.
1028     */
1029     uint8_t         *pSyncMarkerValue;
1030 
1031     /*! \brief Indicates marker value for GPU polling based sync.
1032     *
1033     *  In unit of bytes. Should be larger than or equal to 4. Valid for encoders which report SyncSupport capability as true.
1034     */
1035     uint32_t        SyncMarkerSize;
1036 
1037     /*! \brief hierarchical level plus one for pyramid encoding.
1038     *
1039     *  When HierarchLevelPlus1 > 0, HierarchLevelPlus1 – 1 indicates the current frame’s hierarchical level.
1040     *  And it is for both random access and low delay hierarchical structure.
1041     *  HierarchLevelPlus1 == 0 can be treated as meaningless. It is defined as a legacy reason for HEVC.
1042     */
1043     uint8_t         HierarchLevelPlus1;
1044 
1045     /*! \brief QP modulation strength for BRC
1046     *
1047     *  Suggestion of the strength of applying Qp delta for the frame specified when Qp modulation is enabled (HierarchicalFlag == 1).
1048     *  This is a relative number. BRC could use it to infer final delta Qp values for hierarchical frames in mini Gop structure.
1049     *  Default value 0 means no suggestion for Qp modulation
1050     */
1051     uint8_t         QpModulationStrength;
1052 
1053     /*! \brief StatusReportEnable
1054     *
1055     *  Request features to be enabled at status report.
1056     *  FrameStats: FRAME_STATS_INFO enabled in ENCODE_QUERY_STATUS_PARAMS.
1057     *  BlockStats: BLOCK_STATS_INFO enabled in ENCODE_QUERY_STATUS_PARAMS.
1058     */
1059     union
1060     {
1061         struct
1062         {
1063             uint16_t FrameStats : 1;
1064             uint16_t BlockStats : 1;
1065             uint16_t reserved : 14;
1066         } fields;
1067         uint16_t value;
1068     } StatusReportEnable;
1069 
1070     /*! \brief quality information report enable flags.
1071     */
1072     union
1073     {
1074         struct
1075         {
1076             uint8_t enable_frame : 1;
1077             uint8_t reserved : 7;
1078         } fields;
1079         uint8_t value;
1080     } QualityInfoSupportFlags;
1081 } CODEC_AVC_ENCODE_PIC_PARAMS, *PCODEC_AVC_ENCODE_PIC_PARAMS;
1082 
1083 /*! \brief Slice-level parameters of a compressed picture for AVC encoding.
1084 */
1085 typedef struct _CODEC_AVC_ENCODE_SLICE_PARAMS
1086 {
1087     /*! \brief Specifies the number of macroblocks for this slice.
1088     *
1089     *    Note the slice height restriction in picture parameter structure.
1090     */
1091     uint32_t        NumMbsForSlice;
1092     /*! \brief Specifies the reference picture lists 0 and 1
1093     *
1094     *    Contains field/frame information concerning the reference in PicFlags. RefPicList[i][j]:
1095     *        \n - i: the reference picture list (0 or 1)
1096     *        \n - j: if the PicFlags are not PICTURE_INVALID, the index variable j is a reference to entry j in the reference picture list.
1097     */
1098     CODEC_PICTURE   RefPicList[CODEC_AVC_NUM_REF_LISTS][CODEC_MAX_NUM_REF_FIELD];
1099     /*! \brief Specifies the weights and offsets used for explicit mode weighted prediction.
1100     *
1101     *    Weigths[i][j][k][m]:
1102     *        \n - i: the reference picture list (0 or 1)
1103     *        \n - j: reference to entry j in RefPicList (has range [0...31])
1104     *        \n - k: the YUV component (0 = luma, 1 = Cb chroma, 2 = Cr chroma)
1105     *        \n - m: the weight or offset used in the weighted prediction process (0 = weight, 1 = offset)
1106     */
1107     int16_t         Weights[2][32][3][2];
1108 
1109     uint32_t        first_mb_in_slice;                          //!< Same as AVC syntax element.
1110     uint8_t         slice_type;                                 //!< Same as AVC syntax element.
1111     uint8_t         pic_parameter_set_id;                       //!< Same as AVC syntax element.
1112     uint16_t        direct_spatial_mv_pred_flag         : 1;    //!< Same as AVC syntax element.
1113     uint16_t        num_ref_idx_active_override_flag    : 1;    //!< Same as AVC syntax element.
1114     uint16_t        long_term_reference_flag            : 1;    //!< Same as AVC syntax element.
1115     uint16_t                                            : 13;
1116     uint16_t        idr_pic_id;                                 //!< Same as AVC syntax element.
1117     uint16_t        pic_order_cnt_lsb;                          //!< Same as AVC syntax element.
1118     int32_t         delta_pic_order_cnt_bottom;                 //!< Same as AVC syntax element.
1119     int32_t         delta_pic_order_cnt[2];                     //!< Same as AVC syntax element.
1120     uint8_t         num_ref_idx_l0_active_minus1;               //!< Same as AVC syntax element.
1121     uint8_t         num_ref_idx_l1_active_minus1;               //!< Same as AVC syntax element.
1122     uint8_t         num_ref_idx_l0_active_minus1_from_DDI;
1123     uint8_t         num_ref_idx_l1_active_minus1_from_DDI;
1124     uint8_t         luma_log2_weight_denom;                     //!< Same as AVC syntax element.
1125     uint8_t         chroma_log2_weight_denom;                   //!< Same as AVC syntax element.
1126     uint8_t         cabac_init_idc;                             //!< Same as AVC syntax element.
1127     char            slice_qp_delta;                             //!< Same as AVC syntax element.
1128     uint8_t         disable_deblocking_filter_idc;              //!< Same as AVC syntax element.
1129     char            slice_alpha_c0_offset_div2;                 //!< Same as AVC syntax element.
1130     char            slice_beta_offset_div2;                     //!< Same as AVC syntax element.
1131     uint32_t        slice_id;                                   //!< Same as AVC syntax element.
1132     /*! \brief Indicates that the weighting factors for the luma component are present.
1133     *
1134     *    luma_weight_flag[i] is interpreted as corresponding to L0 when i=0 and L1 when i=1.  Each bit n of luma_weight_flag[i] corresponds to the nth entry in reference list i.  The framework must obey the caps the driver reported in MaxNum_WeightedPredL0/L1.
1135     */
1136     uint32_t        luma_weight_flag[2];
1137     /*! \brief Indicates that the weighting factors for the chroma component are present.
1138     *
1139     *    chroma_weight_flag[i] is interpreted as corresponding to L0 when i=0 and L1 when i=1.  Each bit n of chroma_weight_flag[i] corresponds to the nth entry in reference list i. The framework must obey the caps the driver reported in MaxNum_WeightedPredL0/L1.
1140     */
1141     uint32_t        chroma_weight_flag[2];
1142 
1143     CODEC_PIC_REORDER PicOrder[2][32];                       //!< Set by the driver
1144 
1145     uint8_t         colour_plane_id;                         //!< Same as AVC syntax element.
1146     uint32_t        frame_num;                               //!< Same as AVC syntax element.
1147     bool            field_pic_flag;                          //!< Same as AVC syntax element.
1148     bool            bottom_field_flag;                       //!< Same as AVC syntax element.
1149     uint8_t         redundant_pic_cnt;                       //!< Same as AVC syntax element.
1150     char            sp_for_switch_flag;                      //!< Same as AVC syntax element.
1151     char            slice_qs_delta;                          //!< Same as AVC syntax element.
1152     uint8_t         ref_pic_list_reordering_flag_l0     : 1; //!< Same as AVC syntax element.
1153     uint8_t         ref_pic_list_reordering_flag_l1     : 1; //!< Same as AVC syntax element.
1154     uint8_t         no_output_of_prior_pics_flag        : 1; //!< Same as AVC syntax element.
1155     uint8_t         adaptive_ref_pic_marking_mode_flag  : 1; //!< Same as AVC syntax element.
1156     uint8_t                                             : 3;
1157     uint32_t        MaxFrameNum; //!< Set by the driver: 1 << (pSeqParams[pPicParams->seq_parameter_set_id].log2_max_frame_num_minus4 + 4);
1158     uint8_t         NumReorder;  //!< Set by the driver
1159 
1160     /*! \brief MMCO can be used when AcceleratorHeaderPacking = 1 i.e. driver does slice header packing.
1161     *
1162     *    Driver does not generate memory_management_control_operation commands itself but they can be provided by the app.
1163     *    If adaptive_ref_pic_marking_mode_flag = 1 these commands will be packed into slice header
1164     */
1165     CODEC_SLICE_MMCO MMCO[32];
1166 
1167 } CODEC_AVC_ENCODE_SLICE_PARAMS, *PCODEC_AVC_ENCODE_SLICE_PARAMS;
1168 
1169 // H.264 Inverse Quantization Weight Scale
1170 typedef struct _CODEC_AVC_ENCODE_IQ_WEIGTHSCALE_LISTS
1171 {
1172     uint8_t         WeightScale4x4[6][16];
1173     uint8_t         WeightScale8x8[2][64];
1174 } CODEC_AVC_ENCODE_IQ_WEIGTHSCALE_LISTS, *PCODEC_AVC_ENCODE_IQ_WEIGTHSCALE_LISTS;
1175 
1176 // used for PAFF case, 0: frame, 1: tff field, 2: invalid, 3: bff field
1177 typedef enum _CODEC_AVC_PIC_CODING_TYPE_VALUE
1178 {
1179     CODEC_AVC_PIC_CODING_TYPE_FRAME     = 0x0,
1180     CODEC_AVC_PIC_CODING_TYPE_TFF_FIELD = 0x1,
1181     CODEC_AVC_PIC_CODING_TYPE_INVALID   = 0x2,
1182     CODEC_AVC_PIC_CODING_TYPE_BFF_FIELD = 0x3
1183 } CODEC_AVC_PIC_CODING_TYPE_VALUE;
1184 
1185 //!
1186 //! \struct    CodecEncodeAvcFeiPicParams
1187 //! \brief     Codec encode AVC FEI pic params
1188 //!
1189 struct CodecEncodeAvcFeiPicParams
1190 {
1191     MOS_RESOURCE                resMBCtrl;              // input MB control buffer
1192     MOS_RESOURCE                resMVData;              // ENC MV output buffer or PAK MV input buffer
1193     MOS_RESOURCE                resMBCode;              // ENC MBCode output buffer or PAK MBCode input buffer
1194     MOS_RESOURCE                resMVPredictor;         // input MV predictor surface
1195     MOS_RESOURCE                resMBQp;                // input QP per MB surface
1196     MOS_RESOURCE                resDistortion;          // ENC or ENC_PAK Distortion output surface
1197     uint32_t                    NumMVPredictorsL0;
1198     uint32_t                    NumMVPredictorsL1;
1199 
1200     bool                        MbCodeMvEnable;
1201     bool                        DistortionEnable;
1202 
1203     /** \brief control parameters */
1204     uint32_t                    SearchPath;
1205     uint32_t                    LenSP;
1206 
1207     uint32_t                    SubMBPartMask;
1208     uint32_t                    IntraPartMask;
1209     bool                        MultiPredL0;
1210     bool                        MultiPredL1;
1211     uint32_t                    SubPelMode;
1212     uint32_t                    InterSAD;
1213     uint32_t                    IntraSAD;
1214     uint32_t                    DistortionType;
1215     bool                        RepartitionCheckEnable;
1216     bool                        AdaptiveSearch;
1217     bool                        MVPredictorEnable;
1218     bool                        bMBQp;
1219     bool                        bPerMBInput;
1220     bool                        bMBSizeCtrl;
1221     uint32_t                    RefWidth;
1222     uint32_t                    RefHeight;
1223     uint32_t                    SearchWindow;
1224 
1225     //add for mutlple pass pak
1226     uint32_t                    dwMaxFrameSize;
1227     uint32_t                    dwNumPasses;     //number of QPs
1228     uint8_t                    *pDeltaQp;        //list of detla QPs
1229 };
1230 
1231 typedef struct _CODECHAL_ENCODE_AVC_PACK_PIC_HEADER_PARAMS
1232 {
1233     PBSBuffer                               pBsBuffer;
1234     PCODEC_AVC_ENCODE_PIC_PARAMS            pPicParams;     // pAvcPicParams[ucPPSIdx]
1235     PCODEC_AVC_ENCODE_SEQUENCE_PARAMS       pSeqParams;     // pAvcSeqParams[ucSPSIdx]
1236     PCODECHAL_ENCODE_AVC_VUI_PARAMS         pAvcVuiParams;
1237     PCODEC_AVC_IQ_MATRIX_PARAMS             pAvcIQMatrixParams;
1238     PCODECHAL_NAL_UNIT_PARAMS               *ppNALUnitParams;
1239     CodechalEncodeSeiData*                  pSeiData;
1240     uint32_t                                dwFrameHeight;
1241     uint32_t                                dwOriFrameHeight;
1242     uint16_t                                wPictureCodingType;
1243     bool                                    bNewSeq;
1244     bool                                   *pbNewPPSHeader;
1245     bool                                   *pbNewSeqHeader;
1246 } CODECHAL_ENCODE_AVC_PACK_PIC_HEADER_PARAMS, *PCODECHAL_ENCODE_AVC_PACK_PIC_HEADER_PARAMS;
1247 
1248 typedef struct _CODECHAL_ENCODE_AVC_VALIDATE_NUM_REFS_PARAMS
1249 {
1250     PCODEC_AVC_ENCODE_SEQUENCE_PARAMS       pSeqParams;     // pAvcSeqParams[ucSPSIdx]
1251     PCODEC_AVC_ENCODE_PIC_PARAMS            pPicParams;
1252     PCODEC_AVC_ENCODE_SLICE_PARAMS          pAvcSliceParams;
1253     uint16_t                                wPictureCodingType;
1254     uint16_t                                wPicHeightInMB;
1255     uint16_t                                wFrameFieldHeightInMB;
1256     bool                                    bFirstFieldIPic;
1257     bool                                    bVDEncEnabled;
1258     bool                                    bPAKonly;
1259 } CODECHAL_ENCODE_AVC_VALIDATE_NUM_REFS_PARAMS, *PCODECHAL_ENCODE_AVC_VALIDATE_NUM_REFS_PARAMS;
1260 
1261 typedef struct _CODECHAL_ENCODE_AVC_TQ_INPUT_PARAMS
1262 {
1263     uint16_t  wPictureCodingType;
1264     uint8_t   ucTargetUsage;
1265     uint8_t   ucQP;
1266     bool      bBrcEnabled;
1267     bool      bVdEncEnabled;
1268 } CODECHAL_ENCODE_AVC_TQ_INPUT_PARAMS, *PCODECHAL_ENCODE_AVC_TQ_INPUT_PARAMS;
1269 
1270 typedef struct _CODECHAL_ENCODE_AVC_TQ_PARAMS
1271 {
1272     uint32_t    dwTqEnabled;
1273     uint32_t    dwTqRounding;
1274 } CODECHAL_ENCODE_AVC_TQ_PARAMS, *PCODECHAL_ENCODE_AVC_TQ_PARAMS;
1275 
1276 //!
1277 //! \enum   TrellisSetting
1278 //! \brief  Indicate the different Trellis Settings
1279 //!
1280 enum TrellisSetting
1281 {
1282     trellisInternal = 0,
1283     trellisDisabled = 1,
1284     trellisEnabledI = 2,
1285     trellisEnabledP = 4,
1286     trellisEnabledB = 8
1287 };
1288 
1289 typedef struct _CODECHAL_ENCODE_AVC_PACK_SLC_HEADER_PARAMS
1290 {
1291     PBSBuffer                               pBsBuffer;
1292     PCODEC_AVC_ENCODE_PIC_PARAMS            pPicParams;     // pAvcPicParams[ucPPSIdx]
1293     PCODEC_AVC_ENCODE_SEQUENCE_PARAMS       pSeqParams;     // pAvcSeqParams[ucSPSIdx]
1294     PCODEC_AVC_ENCODE_SLICE_PARAMS          pAvcSliceParams;
1295     PCODEC_REF_LIST                         *ppRefList;
1296     CODEC_PICTURE                           CurrPic;
1297     CODEC_PICTURE                           CurrReconPic;
1298     CODEC_AVC_ENCODE_USER_FLAGS             UserFlags;
1299     CODECHAL_ENCODE_AVC_NAL_UNIT_TYPE       NalUnitType;
1300     uint16_t                                wPictureCodingType;
1301     bool                                    bVdencEnabled;
1302 } CODECHAL_ENCODE_AVC_PACK_SLC_HEADER_PARAMS, *PCODECHAL_ENCODE_AVC_PACK_SLC_HEADER_PARAMS;
1303 
1304 #endif  // __CODEC_DEF_ENCODE_AVC_H__
1305