Skip to content

Commit

Permalink
va: Add encoding tuning mode
Browse files Browse the repository at this point in the history
This provides a hint to driver about the requested encode tuning
in addition to quality level number. It can be used by hardware
encoders that supports low latency encoding as a special mode instead
of setting the lowest quality level.
  • Loading branch information
nowrep committed Feb 7, 2024
1 parent a438699 commit de10470
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
25 changes: 24 additions & 1 deletion va/va.h
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,15 @@ typedef enum {
* columns supported for encoding with tile support.
*/
VAConfigAttribEncMaxTileCols = 57,
/**
* \brief Encoding tuning mode attribute. Read-only.
*
* This attribute conveys whether the driver supports different tuning modes
* for encoding. The attribute value is any combination of VA_ENC_TUNING_MODE_XXX.
*
* The tuning mode is passed to the driver using VAEncMiscParameterBufferQualityLevel.
*/
VAConfigAttribEncTuningMode = 58,
/**@}*/
VAConfigAttribTypeMax
} VAConfigAttribType;
Expand Down Expand Up @@ -2707,6 +2716,15 @@ typedef struct _VAEncMiscParameterBufferMultiPassFrameSize {
unsigned long va_reserved[VA_PADDING_LOW];
} VAEncMiscParameterBufferMultiPassFrameSize;

/** \brief Default tuning mode */
#define VA_ENC_TUNING_MODE_DEFAULT 0x00000000
/** \brief Compromise latency of video encode operations to improve quality */
#define VA_ENC_TUNING_MODE_HIGH_QUALITY 0x00000001
/** \brief Compromise quality to lower the latency of video encode operations */
#define VA_ENC_TUNING_MODE_LOW_LATENCY 0x00000002
/** \brief Compromise quality for lowest latency of video encode operations */
#define VA_ENC_TUNING_MODE_ULTRA_LOW_LATENCY 0x00000004

/**
* \brief Encoding quality level.
*
Expand All @@ -2717,15 +2735,20 @@ typedef struct _VAEncMiscParameterBufferMultiPassFrameSize {
* attribute. A lower value means higher quality, and a value of 1 represents the highest
* quality. The quality level setting is used as a trade-off between quality and speed/power
* consumption, with higher quality corresponds to lower speed and higher power consumption.
* The number of supported tuning modes can be queried through the VAConfigAttribEncTuningMode
* attribute.
*/
typedef struct _VAEncMiscParameterBufferQualityLevel {
/** \brief Encoding quality level setting. When set to 0, default quality
* level is used.
*/
uint32_t quality_level;

/** \brief Encoding tuning mode setting, see VA_ENC_TUNING_MODE_XXX */
uint32_t tuning_mode;

/** \brief Reserved bytes for future use, must be zero */
uint32_t va_reserved[VA_PADDING_LOW];
uint32_t va_reserved[VA_PADDING_LOW - 1];
} VAEncMiscParameterBufferQualityLevel;

/**
Expand Down
1 change: 1 addition & 0 deletions va/va_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ const char *vaConfigAttribTypeStr(VAConfigAttribType configAttribType)
TOSTR(VAConfigAttribEncPerBlockControl);
TOSTR(VAConfigAttribEncMaxTileRows);
TOSTR(VAConfigAttribEncMaxTileCols);
TOSTR(VAConfigAttribEncTuningMode);
case VAConfigAttribTypeMax:
break;
}
Expand Down
1 change: 1 addition & 0 deletions va/va_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -3642,6 +3642,7 @@ static void va_TraceVAEncMiscParameterBuffer(

va_TraceMsg(trace_ctx, "\t--VAEncMiscParameterBufferQualityLevel\n");
va_TraceMsg(trace_ctx, "\tquality_level = %d\n", p->quality_level);
va_TraceMsg(trace_ctx, "\ttuning_mode = %d\n", p->tuning_mode);
break;
}
case VAEncMiscParameterTypeROI: {
Expand Down

0 comments on commit de10470

Please sign in to comment.