*/
const char *vaErrorStr(VAStatus error_status);
+typedef struct _VARectangle
+{
+ short x;
+ short y;
+ unsigned short width;
+ unsigned short height;
+} VARectangle;
+
+/** \brief Generic motion vector data structure. */
+typedef struct _VAMotionVector {
+ /** \mv0[0]: horizontal motion vector for past reference */
+ /** \mv0[1]: vertical motion vector for past reference */
+ /** \mv1[0]: horizontal motion vector for future reference */
+ /** \mv1[1]: vertical motion vector for future reference */
+ int16_t mv0[2]; /* past reference */
+ int16_t mv1[2]; /* future reference */
+} VAMotionVector;
+
+/** Type of a message callback, used for both error and info log. */
+typedef void (*vaMessageCallback)(const char *message);
+
+/**
+ * Set the callback for error messages, or NULL for no logging.
+ * Returns the previous one, or NULL if it was disabled.
+ */
+vaMessageCallback vaSetErrorCallback(vaMessageCallback);
+
+/**
+ * Set the callback for info messages, or NULL for no logging.
+ * Returns the previous one, or NULL if it was disabled.
+ */
+vaMessageCallback vaSetInfoCallback(vaMessageCallback);
+
/**
* Initialization:
* A display must be obtained by calling vaGetDisplay() before calling
VADisplay dpy
);
-typedef int (*VAPrivFunc)();
+typedef int (*VAPrivFunc)(void);
/**
* Return a function pointer given a function name in the library.
VAProfileH264StereoHigh = 16,
VAProfileHEVCMain = 17,
VAProfileHEVCMain10 = 18,
- VAProfileVP9Profile0 = 19
+ VAProfileVP9Profile0 = 19,
+ VAProfileVP9Profile1 = 20,
+ VAProfileVP9Profile2 = 21,
+ VAProfileVP9Profile3 = 22
} VAProfile;
/**
VAEntrypointDeblocking = 5,
VAEntrypointEncSlice = 6, /* slice level encode */
VAEntrypointEncPicture = 7, /* pictuer encode, JPEG, etc */
+ /*
+ * For an implementation that supports a low power/high performance variant
+ * for slice level encode, it can choose to expose the
+ * VAEntrypointEncSliceLP entrypoint. Certain encoding tools may not be
+ * available with this entrypoint (e.g. interlace, MBAFF) and the
+ * application can query the encoding configuration attributes to find
+ * out more details if this entrypoint is supported.
+ */
+ VAEntrypointEncSliceLP = 8,
VAEntrypointVideoProc = 10, /**< Video pre/post-processing. */
+ /**
+ * \brief VAEntrypointFEI
+ *
+ * The purpose of FEI (Flexible Encoding Infrastructure) is to allow applications to
+ * have more controls and trade off quality for speed with their own IPs.
+ * The application can optionally provide input to ENC for extra encode control
+ * and get the output from ENC. Application can chose to modify the ENC
+ * output/PAK input during encoding, but the performance impact is significant.
+ *
+ * On top of the existing buffers for normal encode, there will be
+ * one extra input buffer (VAEncMiscParameterFEIFrameControl) and
+ * three extra output buffers (VAEncFEIMVBufferType, VAEncFEIMBModeBufferType
+ * and VAEncFEIDistortionBufferType) for VAEntrypointFEI entry function.
+ * If separate PAK is set, two extra input buffers
+ * (VAEncFEIMVBufferType, VAEncFEIMBModeBufferType) are needed for PAK input.
+ **/
+ VAEntrypointFEI = 11,
} VAEntrypoint;
/** Currently defined configuration attribute types */
* 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,
+ /**
+ * \brief Encoding extended rate control attribute. Read-only.
+ *
+ * This attribute conveys whether the driver supports any extended rate control features
+ * The attribute value is partitioned into fields as defined in the
+ * VAConfigAttribValEncRateControlExt union.
+ */
+ VAConfigAttribEncRateControlExt = 26,
+
+ /**
+ * \brief Encode function type for FEI.
+ *
+ * This attribute conveys whether the driver supports different function types for encode.
+ * It can be VA_FEI_FUNCTION_ENC, VA_FEI_FUNCTION_PAK, or VA_FEI_FUNCTION_ENC_PAK. Currently
+ * it is for FEI entry point only.
+ * Default is VA_FEI_FUNCTION_ENC_PAK.
+ */
+ VAConfigAttribFEIFunctionType = 32,
+ /**
+ * \brief Maximum number of FEI MV predictors. Read-only.
+ *
+ * This attribute determines the maximum number of MV predictors the driver
+ * can support to encode a single frame. 0 means no MV predictor is supported.
+ * Currently it is for FEI entry point only.
+ */
+ VAConfigAttribFEIMVPredictors = 33,
/**@}*/
VAConfigAttribTypeMax
} VAConfigAttribType;
#define VA_RT_FORMAT_YUV444 0x00000004
#define VA_RT_FORMAT_YUV411 0x00000008
#define VA_RT_FORMAT_YUV400 0x00000010
+/** YUV formats with more than 8 bpp */
+#define VA_RT_FORMAT_YUV420_10BPP 0x00000100
+/** RGB formats */
#define VA_RT_FORMAT_RGB16 0x00010000
#define VA_RT_FORMAT_RGB32 0x00020000
/* RGBP covers RGBP and BGRP fourcc */
#define VA_RC_CQP 0x00000010
/** \brief Variable bitrate with peak rate higher than average bitrate. */
#define VA_RC_VBR_CONSTRAINED 0x00000020
+/** \brief Macroblock based rate control. Per MB control is decided
+ * internally in the encoder. It may be combined with other RC modes, except CQP. */
+#define VA_RC_MB 0x00000080
+
/**@}*/
/** @name Attribute values for VAConfigAttribDecSliceMode */
#define VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS 0x00000000
/** \brief Driver supports a power-of-two number of rows per slice. */
#define VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS 0x00000001
-/** \brief Driver supports an arbitrary number of rows per slice. */
+/** \brief Driver supports an arbitrary number of macroblocks per slice. */
#define VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS 0x00000002
/**@}*/
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 A flag indicates whether ROI priority is supported
+ *
+ * \ref roi_rc_priority_support equal to 1 specifies the underlying driver supports
+ * ROI priority when VAConfigAttribRateControl != VA_RC_CQP, user can use \c roi_value
+ * in #VAEncROI to set ROI priority. \ref roi_rc_priority_support equal to 0 specifies
+ * the underlying driver doesn't support ROI priority.
+ *
+ * User should ignore \ref roi_rc_priority_support when VAConfigAttribRateControl == VA_RC_CQP
+ * because ROI delta QP is always required when VAConfigAttribRateControl == VA_RC_CQP.
+ */
+ unsigned int roi_rc_priority_support : 1;
+ /**
+ * \brief A flag indicates whether ROI delta QP is supported
+ *
+ * \ref roi_rc_qp_delat_support equal to 1 specifies the underlying driver supports
+ * ROI delta QP when VAConfigAttribRateControl != VA_RC_CQP, user can use \c roi_value
+ * in #VAEncROI to set ROI delta QP. \ref roi_rc_qp_delat_support equal to 0 specifies
+ * the underlying driver doesn't support ROI delta QP.
+ *
+ * User should ignore \ref roi_rc_qp_delat_support when VAConfigAttribRateControl == VA_RC_CQP
+ * because ROI delta QP is always required when VAConfigAttribRateControl == VA_RC_CQP.
+ */
+ unsigned int roi_rc_qp_delat_support : 1;
+ unsigned int reserved : 22;
+ } bits;
+ unsigned int value;
+} VAConfigAttribValEncROI;
+
+/** \brief Attribute value for VAConfigAttribEncRateControlExt */
+typedef union _VAConfigAttribValEncRateControlExt {
+ struct {
+ /**
+ * \brief The maximum number of temporal layers minus 1
+ *
+ * \ref max_num_temporal_layers_minus1 plus 1 specifies the maximum number of temporal
+ * layers that supported by the underlying driver. \ref max_num_temporal_layers_minus1
+ * equal to 0 implies the underlying driver doesn't support encoding with temporal layer.
+ */
+ unsigned int max_num_temporal_layers_minus1 : 8;
+
+ /**
+ * /brief support temporal layer bit-rate control flag
+ *
+ * \ref temporal_layer_bitrate_control_flag equal to 1 specifies the underlying driver
+ * can support bit-rate control per temporal layer when (#VAConfigAttribRateControl == #VA_RC_CBR ||
+ * #VAConfigAttribRateControl == #VA_RC_VBR).
+ *
+ * The underlying driver must set \ref temporal_layer_bitrate_control_flag to 0 when
+ * \c max_num_temporal_layers_minus1 is equal to 0
+ *
+ * To use bit-rate control per temporal layer, an application must send the right layer
+ * structure via #VAEncMiscParameterTemporalLayerStructure at the beginning of a coded sequence
+ * and then followed by #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate structures
+ * for each layer, using the \c temporal_id field as the layer identifier. Otherwise
+ * the driver doesn't use bitrate control per temporal layer if an application doesn't send the
+ * layer structure via #VAEncMiscParameterTemporalLayerStructure to the driver. The driver returns
+ * VA_STATUS_ERROR_INVALID_PARAMETER if an application sends a wrong layer structure or doesn't send
+ * #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate for each layer.
+ *
+ * The driver will ignore #VAEncMiscParameterTemporalLayerStructure and the \c temporal_id field
+ * in #VAEncMiscParameterRateControl and #VAEncMiscParameterFrameRate if
+ * \ref temporal_layer_bitrate_control_flag is equal to 0 or #VAConfigAttribRateControl == #VA_RC_CQP
+ */
+ unsigned int temporal_layer_bitrate_control_flag : 1;
+ unsigned int reserved : 23;
+ } bits;
+ unsigned int value;
+} VAConfigAttribValEncRateControlExt;
+
/**
* if an attribute is not applicable for a given
* profile/entrypoint pair, then set the value to the following
VAEncMiscParameterBufferType = 27,
VAEncMacroblockParameterBufferType = 28,
VAEncMacroblockMapBufferType = 29,
+
+ /**
+ * \brief Encoding QP buffer
+ *
+ * This buffer contains QP per MB for encoding. Currently
+ * VAEncQPBufferH264 is defined for H.264 encoding, see
+ * #VAEncQPBufferH264 for details
+ */
+ VAEncQPBufferType = 30,
/* Following are video processing buffer types */
/**
* \brief Video processing pipeline parameter buffer.
* color balance (#VAProcFilterParameterBufferColorBalance), etc.
*/
VAProcFilterParameterBufferType = 42,
+ /**
+ * \brief FEI specific buffer types
+ */
+ VAEncFEIMVBufferType = 43,
+ VAEncFEIMBCodeBufferType = 44,
+ VAEncFEIDistortionBufferType = 45,
+ VAEncFEIMBControlBufferType = 46,
+ VAEncFEIMVPredictorBufferType = 47,
VABufferTypeMax
} VABufferType;
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,
+ /** \brief Buffer type used for temporal layer structure */
+ VAEncMiscParameterTypeTemporalLayerStructure = 12,
+ /** \brief Buffer type used for FEI input frame level parameters */
+ VAEncMiscParameterTypeFEIFrameControl = 18,
} VAEncMiscParameterType;
/** \brief Packed header type. */
unsigned int data[0];
} VAEncMiscParameterBuffer;
+/** \brief Temporal layer Structure*/
+typedef struct _VAEncMiscParameterTemporalLayerStructure
+{
+ /** \brief The number of temporal layers */
+ unsigned int number_of_layers;
+ /** \brief The length of the array defining frame layer membership. Should be 1-32 */
+ unsigned int periodicity;
+ /**
+ * \brief The array indicating the layer id for each frame
+ *
+ * The layer id for the first frame in a coded sequence is always 0, so layer_id[] specifies the layer
+ * ids for frames starting from the 2nd frame.
+ */
+ unsigned int layer_id[32];
+} VAEncMiscParameterTemporalLayerStructure;
+
/** \brief Rate control parameters */
typedef struct _VAEncMiscParameterRateControl
unsigned int reset : 1;
unsigned int disable_frame_skip : 1; /* Disable frame skip in rate control mode */
unsigned int disable_bit_stuffing : 1; /* Disable bit stuffing in rate control mode */
+ unsigned int mb_rate_control : 4; /* Control VA_RC_MB 0: default, 1: enable, 2: disable, other: reserved*/
+ /*
+ * The temporal layer that the rate control parameters are specified for.
+ */
+ unsigned int temporal_id : 8;
+ unsigned int reserved : 17;
} bits;
unsigned int value;
} rc_flags;
typedef struct _VAEncMiscParameterFrameRate
{
+ /*
+ * The framerate is specified as a number of frames per second, as a
+ * fraction. The denominator of the fraction is given in the top half
+ * (the high two bytes) of the framerate field, and the numerator is
+ * given in the bottom half (the low two bytes).
+ *
+ * That is:
+ * denominator = framerate >> 16 & 0xffff;
+ * numerator = framerate & 0xffff;
+ * fps = numerator / denominator;
+ *
+ * For example, if framerate is set to (100 << 16 | 750), this is
+ * 750 / 100, hence 7.5fps.
+ *
+ * If the denominator is zero (the high two bytes are both zero) then
+ * it takes the value one instead, so the framerate is just the integer
+ * in the low 2 bytes.
+ */
unsigned int framerate;
+ union
+ {
+ struct
+ {
+ /*
+ * The temporal id the framerate parameters are specified for.
+ */
+ unsigned int temporal_id : 8;
+ unsigned int reserved : 24;
+ } bits;
+ unsigned int value;
+ } framerate_flags;
} VAEncMiscParameterFrameRate;
/**
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 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.
+ */
+ 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;
+ 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_delat_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;
+} 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.
* eliminates this copy is to pass null as "data" when calling vaCreateBuffer(),
* and then use vaMapBuffer() to map the data store from the server side to the
* client address space for access.
+ * The user must call vaDestroyBuffer() to destroy a buffer.
* Note: image buffers are created by the library, not the client. Please see
* vaCreateImage on how image buffers are managed.
*/
/**
* After this call, the buffer is deleted and this buffer_id is no longer valid
- * Only call this if the buffer is not going to be passed to vaRenderBuffer
+ *
+ * A buffer can be re-used and sent to the server by another Begin/Render/End
+ * sequence if vaDestroyBuffer() is not called with this buffer.
+ *
+ * Note re-using a shared buffer (e.g. a slice data buffer) between the host and the
+ * hardware accelerator can result in performance dropping.
*/
VAStatus vaDestroyBuffer (
VADisplay dpy,
/**
* Send decode buffers to the server.
- * Buffers are automatically destroyed afterwards
*/
VAStatus vaRenderPicture (
VADisplay dpy,
* 8-bit Y plane, followed by 8-bit 2x1 subsampled V and U planes
*/
#define VA_FOURCC_YV16 0x36315659
+/**
+ * 10-bit and 16-bit Planar YUV 4:2:0.
+ */
+#define VA_FOURCC_P010 0x30313050
+#define VA_FOURCC_P016 0x36313050
+
+/**
+ * 10-bit Planar YUV 420 and occupy the lower 10-bit.
+ */
+#define VA_FOURCC_I010 0x30313049
/* byte order */
#define VA_LSB_FIRST 1
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,
#include <va/va_enc_jpeg.h>
#include <va/va_enc_mpeg2.h>
#include <va/va_enc_vp8.h>
+#include <va/va_enc_vp9.h>
+#include <va/va_fei.h>
+#include <va/va_fei_h264.h>
#include <va/va_vpp.h>
/**@}*/