[Libva] [PATCH 3/6] Merge ROI patches from staging branch
Xiang, Haihao
haihao.xiang at intel.com
Wed May 4 02:54:53 UTC 2016
From: pylee <penne.y.lee at intel.com>
Cherry-pick'ed from:
26cc3b0: Add Region-of-Interest (ROI) support for encoder based on user provided ROI rectangles.
84b90a3: ROI updates for encoder.
Signed-off-by: pylee <penne.y.lee at intel.com>
Signed-off-by: Xiang, Haihao <haihao.xiang at intel.com>
Reviewed-By: Sean V Kelley <sean.v.kelley at intel.com>
---
va/va.h | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 80 insertions(+), 10 deletions(-)
diff --git a/va/va.h b/va/va.h
index b1caba8..dcfafbb 100644
--- a/va/va.h
+++ b/va/va.h
@@ -222,6 +222,14 @@ typedef int VAStatus; /** Return status type from functions */
*/
const char *vaErrorStr(VAStatus error_status);
+typedef struct _VARectangle
+{
+ short x;
+ short y;
+ unsigned short width;
+ unsigned short height;
+} VARectangle;
+
/**
* Initialization:
* A display must be obtained by calling vaGetDisplay() before calling
@@ -452,6 +460,17 @@ typedef enum
* externally skipped frames.
*/
VAConfigAttribEncSkipFrame = 24,
+ /**
+ * \brief Encoding region-of-interest (ROI) attribute. Read-only.
+ *
+ * This attribute conveys whether the driver supports region-of-interest (ROI) encoding,
+ * based on user provided ROI rectangles. The attribute value is partitioned into fields
+ * as defined in the VAConfigAttribValEncROI union.
+ *
+ * If ROI encoding is supported, the ROI information is passed to the driver using
+ * VAEncMiscParameterTypeROI.
+ */
+ VAConfigAttribEncROI = 25,
/**@}*/
VAConfigAttribTypeMax
} VAConfigAttribType;
@@ -565,6 +584,21 @@ typedef union _VAConfigAttribValEncJPEG {
unsigned int value;
} VAConfigAttribValEncJPEG;
+/** \brief Attribute value for VAConfigAttribEncROI */
+typedef union _VAConfigAttribValEncROI {
+ struct {
+ /** \brief The number of ROI regions supported, 0 if ROI is not supported. */
+ unsigned int num_roi_regions : 8;
+ /** \brief Indicates if ROI priority indication is supported when
+ * VAConfigAttribRateControl != VA_RC_CQP, else only ROI delta QP added on top of
+ * the frame level QP is supported when VAConfigAttribRateControl == VA_RC_CQP.
+ */
+ unsigned int roi_rc_priority_support : 1;
+ unsigned int reserved : 23;
+ } bits;
+ unsigned int value;
+} VAConfigAttribValEncROI;
+
/**
* if an attribute is not applicable for a given
* profile/entrypoint pair, then set the value to the following
@@ -1038,7 +1072,9 @@ typedef enum
VAEncMiscParameterTypeQualityLevel = 6,
/** \brief Buffer type used for sending skip frame parameters to the encoder's
* rate control, when the user has externally skipped frames. */
- VAEncMiscParameterTypeSkipFrame = 9
+ VAEncMiscParameterTypeSkipFrame = 9,
+ /** \brief Buffer type used for region-of-interest (ROI) parameters. */
+ VAEncMiscParameterTypeROI = 10
} VAEncMiscParameterType;
/** \brief Packed header type. */
@@ -1212,7 +1248,49 @@ typedef struct _VAEncMiscParameterSkipFrame {
unsigned int size_skip_frames;
} VAEncMiscParameterSkipFrame;
-/*
+/**
+ * \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 When VAConfigAttribRateControl == VA_RC_CQP then roi_value specifes the
+ * delta QP that will be added on top of the frame level QP. For other rate control
+ * modes, roi_value specifies the priority of the ROI region relative to the non-ROI
+ * 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 roi_value -3 is less important than the non-ROI region
+ * (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. */
+ char roi_value;
+} VAEncROI;
+
+typedef struct _VAEncMiscParameterBufferROI {
+ /** \brief Number of ROIs being sent.*/
+ unsigned int 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. */
+ char max_delta_qp;
+ char 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;
+} VAEncMiscParameterBufferROI;
+
+/**
* There will be cases where the bitstream buffer will not have enough room to hold
* the data for the entire slice, and the following flags will be used in the slice
* parameter to signal to the server for the possible cases.
@@ -2618,14 +2696,6 @@ VAStatus vaDeassociateSubpicture (
int num_surfaces
);
-typedef struct _VARectangle
-{
- short x;
- short y;
- unsigned short width;
- unsigned short height;
-} VARectangle;
-
/**
* Display attributes
* Display attributes are used to control things such as contrast, hue, saturation,
--
1.9.1
More information about the Libva
mailing list