+/**
+ * \brief Encoding region-of-interest (ROI).
+ *
+ * The encoding ROI can be set through VAEncMiscParameterBufferROI, if the implementation
+ * supports ROI input. The ROI set through this structure is applicable only to the
+ * current frame or field, so must be sent every frame or field to be applied. The number of
+ * supported ROIs can be queried through the VAConfigAttribEncROI. The encoder will use the
+ * ROI information to adjust the QP values of the MB's that fall within the ROIs.
+ */
+typedef struct _VAEncROI
+{
+ /** \brief Defines the ROI boundary in pixels, the driver will map it to appropriate
+ * codec coding units. It is relative to frame coordinates for the frame case and
+ * to field coordinates for the field case. */
+ VARectangle roi_rectangle;
+ /**
+ * \brief ROI value
+ *
+ * \ref roi_value specifies ROI delta QP or ROI priority.
+ * -- ROI delta QP is the value that will be added on top of the frame level QP.
+ * -- ROI priority specifies the priority of a region, it can be positive (more important)
+ * or negative (less important) values and is compared with non-ROI region (taken as value 0),
+ * E.g. ROI region with \ref roi_value -3 is less important than the non-ROI region (\ref roi_value
+ * implied to be 0) which is less important than ROI region with roi_value +2. For overlapping
+ * regions, the roi_value that is first in the ROI array will have priority.
+ *
+ * \ref roi_value always specifes ROI delta QP when VAConfigAttribRateControl == VA_RC_CQP, no matter
+ * the value of \c roi_value_is_qp_delta in #VAEncMiscParameterBufferROI.
+ *
+ * \ref roi_value depends on \c roi_value_is_qp_delta in #VAEncMiscParameterBufferROI when
+ * VAConfigAttribRateControl != VA_RC_CQP. \ref roi_value specifies ROI_delta QP if \c roi_value_is_qp_delta
+ * in VAEncMiscParameterBufferROI is 1, otherwise \ref roi_value specifies ROI priority.
+ */
+ int8_t roi_value;
+} VAEncROI;
+
+typedef struct _VAEncMiscParameterBufferROI {
+ /** \brief Number of ROIs being sent.*/
+ uint32_t num_roi;
+
+ /** \brief Valid when VAConfigAttribRateControl != VA_RC_CQP, then the encoder's
+ * rate control will determine actual delta QPs. Specifies the max/min allowed delta
+ * QPs. */
+ int8_t max_delta_qp;
+ int8_t min_delta_qp;
+
+ /** \brief Pointer to a VAEncROI array with num_roi elements. It is relative to frame
+ * coordinates for the frame case and to field coordinates for the field case.*/
+ VAEncROI *roi;
+ union {
+ struct {
+ /**
+ * \brief An indication for roi value.
+ *
+ * \ref roi_value_is_qp_delta equal to 1 indicates \c roi_value in #VAEncROI should
+ * be used as ROI delta QP. \ref roi_value_is_qp_delta equal to 0 indicates \c roi_value
+ * in #VAEncROI should be used as ROI priority.
+ *
+ * \ref roi_value_is_qp_delta is only available when VAConfigAttribRateControl != VA_RC_CQP,
+ * the setting must comply with \c roi_rc_priority_support and \c roi_rc_qp_delta_support in
+ * #VAConfigAttribValEncROI. The underlying driver should ignore this field
+ * when VAConfigAttribRateControl == VA_RC_CQP.
+ */
+ uint32_t roi_value_is_qp_delta : 1;
+ uint32_t reserved : 31;
+ } bits;
+ uint32_t value;
+ } roi_flags;
+
+ /** \brief Reserved bytes for future use, must be zero */
+ uint32_t va_reserved[VA_PADDING_LOW];
+} VAEncMiscParameterBufferROI;
+/*
+ * \brief Dirty rectangle data structure for encoding.
+ *
+ * The encoding dirty rect can be set through VAEncMiscParameterBufferDirtyRect, if the
+ * implementation supports dirty rect input. The rect set through this structure is applicable
+ * only to the current frame or field, so must be sent every frame or field to be applied.
+ * The number of supported rects can be queried through the VAConfigAttribEncDirtyRect. The
+ * encoder will use the rect information to know those rectangle areas have changed while the
+ * areas not covered by dirty rect rectangles are assumed to have not changed compared to the
+ * previous picture. The encoder may do some internal optimizations.
+ */
+typedef struct _VAEncMiscParameterBufferDirtyRect
+{
+ /** \brief Number of Rectangle being sent.*/
+ uint32_t num_roi_rectangle;
+
+ /** \brief Pointer to a VARectangle array with num_roi_rectangle elements.*/
+ VARectangle *roi_rectangle;
+} VAEncMiscParameterBufferDirtyRect;
+
+/** \brief Attribute value for VAConfigAttribEncParallelRateControl */
+typedef struct _VAEncMiscParameterParallelRateControl {
+ /** brief Number of layers*/
+ uint32_t num_layers;
+ /** brief Number of B frames per layer per GOP.
+ *
+ * it should be allocated by application, and the is num_layers.
+ * num_b_in_gop[0] is the number of regular B which refers to only I or P frames. */
+ uint32_t *num_b_in_gop;
+} VAEncMiscParameterParallelRateControl;
+
+/** per frame encoder quality controls, once set they will persist for all future frames
+ *till it is updated again. */
+typedef struct _VAEncMiscParameterEncQuality
+{
+ union
+ {
+ struct
+ {
+ /** Use raw frames for reference instead of reconstructed frames.
+ * it only impact motion estimation (ME) stage, and will not impact MC stage
+ * so the reconstruct picture will can match with decode side */
+ uint32_t useRawPicForRef : 1;
+ /** Disables skip check for ME stage, it will increase the bistream size
+ * but will improve the qulity */
+ uint32_t skipCheckDisable : 1;
+ /** Indicates app will override default driver FTQ settings using FTQEnable.
+ * FTQ is forward transform quantization */
+ uint32_t FTQOverride : 1;
+ /** Enables/disables FTQ. */
+ uint32_t FTQEnable : 1;
+ /** Indicates the app will provide the Skip Threshold LUT to use when FTQ is
+ * enabled (FTQSkipThresholdLUT), else default driver thresholds will be used. */
+ uint32_t FTQSkipThresholdLUTInput : 1;
+ /** Indicates the app will provide the Skip Threshold LUT to use when FTQ is
+ * disabled (NonFTQSkipThresholdLUT), else default driver thresholds will be used. */
+ uint32_t NonFTQSkipThresholdLUTInput : 1;
+ uint32_t ReservedBit : 1;
+ /** Control to enable the ME mode decision algorithm to bias to fewer B Direct/Skip types.
+ * Applies only to B frames, all other frames will ignore this setting. */
+ uint32_t directBiasAdjustmentEnable : 1;
+ /** Enables global motion bias. global motion also is called HME (Heirarchical Motion Estimation )
+ * HME is used to handle large motions and avoiding local minima in the video encoding process
+ * down scaled the input and reference picture, then do ME. the result will be a predictor to next level HME or ME
+ * current interface divide the HME to 3 level. UltraHME , SuperHME, and HME, result of UltraHME will be input of SurperHME,
+ * result of superHME will be a input for HME. HME result will be input of ME. it is a switch for HMEMVCostScalingFactor
+ * can change the HME bias inside RDO stage*/
+ uint32_t globalMotionBiasAdjustmentEnable : 1;
+ /** MV cost scaling ratio for HME ( predictors. It is used when
+ * globalMotionBiasAdjustmentEnable == 1, else it is ignored. Values are:
+ * 0: set MV cost to be 0 for HME predictor.
+ * 1: scale MV cost to be 1/2 of the default value for HME predictor.
+ * 2: scale MV cost to be 1/4 of the default value for HME predictor.
+ * 3: scale MV cost to be 1/8 of the default value for HME predictor. */
+ uint32_t HMEMVCostScalingFactor : 2;
+ /**disable HME, if it is disabled. Super*ultraHME should also be disabled */
+ uint32_t HMEDisable : 1;
+ /**disable Super HME, if it is disabled, ultraHME should be disabled */
+ uint32_t SuperHMEDisable : 1;
+ /** disable Ultra HME */
+ uint32_t UltraHMEDisable : 1;
+ /** disable panic mode. Panic mode happened when there are extreme BRC (bit rate control) requirement
+ * frame size cant achieve the target of BRC. when Panic mode is triggered, Coefficients will
+ * be set to zero. disable panic mode will improve quality but will impact BRC */
+ uint32_t PanicModeDisable : 1;
+ /** Force RepartitionCheck
+ * 0: DEFAULT - follow driver default settings.
+ * 1: FORCE_ENABLE - enable this feature totally for all cases.
+ * 2: FORCE_DISABLE - disable this feature totally for all cases. */
+ uint32_t ForceRepartitionCheck : 2;
+
+ };
+ uint32_t encControls;
+ };
+
+ /** Maps QP to skip thresholds when FTQ is enabled. Valid range is 0-255. */
+ uint8_t FTQSkipThresholdLUT[52];
+ /** Maps QP to skip thresholds when FTQ is disabled. Valid range is 0-65535. */
+ uint16_t NonFTQSkipThresholdLUT[52];
+
+ uint32_t reserved[VA_PADDING_HIGH]; // Reserved for future use.
+
+} VAEncMiscParameterEncQuality;
+
+/**
+ * \brief Custom Encoder Rounding Offset Control.
+ * Application may use this structure to set customized rounding
+ * offset parameters for quantization.
+ * Valid when \c VAConfigAttribCustomRoundingControl equals 1.
+ */
+typedef struct _VAEncMiscParameterCustomRoundingControl
+{
+ union {
+ struct {
+ /** \brief Enable customized rounding offset for intra blocks.
+ * If 0, default value would be taken by driver for intra
+ * rounding offset.
+ */
+ uint32_t enable_custom_rouding_intra : 1 ;
+
+ /** \brief Intra rounding offset
+ * Ignored if \c enable_custom_rouding_intra equals 0.
+ */
+ uint32_t rounding_offset_intra : 7;
+
+ /** \brief Enable customized rounding offset for inter blocks.
+ * If 0, default value would be taken by driver for inter
+ * rounding offset.
+ */
+ uint32_t enable_custom_rounding_inter : 1 ;
+
+ /** \brief Inter rounding offset
+ * Ignored if \c enable_custom_rouding_inter equals 0.
+ */
+ uint32_t rounding_offset_inter : 7;
+
+ /* Reserved */
+ uint32_t reserved :16;
+ } bits;
+ uint32_t value;
+ } rounding_offset_setting;
+} VAEncMiscParameterCustomRoundingControl;
+/**