Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config attribute to advertise HEVC encoder features #385

Merged
merged 1 commit into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions va/va.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,30 @@ typedef int VAStatus; /** Return status type from functions */
#define VA_EXEC_MODE_POWER_SAVING 0x1
#define VA_EXEC_MODE_PERFORMANCE 0x2

/* Values used to describe device features. */
/** The feature is not supported by the device.
*
* Any corresponding feature flag must not be set.
*/
#define VA_FEATURE_NOT_SUPPORTED 0
/** The feature is supported by the device.
*
* The user may decide whether or not to use this feature.
*
* Note that support for a feature only indicates that the hardware
* is able to use it; whether it is actually a positive change to
* enable it in a given situation will depend on other factors
* including the input provided by the user.
*/
#define VA_FEATURE_SUPPORTED 1
/** The feature is required by the device.
*
* The device does not support not enabling this feature, so any
* corresponding feature flag must be set and any additional
* configuration needed by the feature must be supplied.
*/
#define VA_FEATURE_REQUIRED 2

/**
* Returns a short english description of error_status
*/
Expand Down Expand Up @@ -956,6 +980,26 @@ typedef enum
*/
VAConfigAttribProtectedContentUsage = 49,

/** \brief HEVC/H.265 encoding features. Read-only.
*
* This attribute describes the supported features of an
* HEVC/H.265 encoder configuration. The value returned uses the
* VAConfigAttribValEncHEVCFeatures type.
*
* If this attribute is supported by a driver then it must also
* support the VAConfigAttribEncHEVCBlockSizes attribute.
*/
VAConfigAttribEncHEVCFeatures = 50,
/** \brief HEVC/H.265 encoding block sizes. Read-only.
*
* This attribute describes the supported coding tree and transform
* block sizes of an HEVC/H.265 encoder configuration. The value
* returned uses the VAConfigAttribValEncHEVCBlockSizes type.
*
* If this attribute is supported by a driver then it must also
* support the VAConfigAttribEncHEVCFeatures attribute.
*/
VAConfigAttribEncHEVCBlockSizes = 51,
/**@}*/
VAConfigAttribTypeMax
} VAConfigAttribType;
Expand Down
187 changes: 187 additions & 0 deletions va/va_enc_hevc.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,193 @@ extern "C" {
* @{
*/

/** Attribute value for VAConfigAttribEncHEVCFeatures.
*
* This attribute decribes the supported features of an HEVC/H.265
* encoder configuration.
*
* All of the field values in this attribute are VA_FEATURE_* values,
* indicating support for the corresponding feature.
*/
typedef union VAConfigAttribValEncHEVCFeatures {
struct {
/** Separate colour planes.
*
* Allows setting separate_colour_plane_flag in the SPS.
*/
uint32_t separate_colour_planes : 2;
Copy link
Contributor

@Tianhaol Tianhaol Jan 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If from driver side, only packed is supported, planar are not supported. The meaning of 0 and 1 are not identical to Recommendation ITU-T H.265, the value returned from driver is VA_FEATURE_NOT_SUPPORTED. Are my understanding correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. VA_FEATURE_NOT_SUPPORTED from the driver indicates that the separate colour planes are not usable, so separate_colour_planes must then always be set to zero by the user.

/** Scaling lists.
*
* Allows scaling_list() elements to be present in both the SPS
* and the PPS. The decoded form of the scaling lists must also
* be supplied in a VAQMatrixBufferHEVC buffer when scaling lists
* are enabled.
*/
uint32_t scaling_lists : 2;
/** Asymmetric motion partitions.
*
* Allows setting amp_enabled_flag in the SPS.
*/
uint32_t amp : 2;
Copy link
Contributor

@Tianhaol Tianhaol Jan 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If amp is always supported by driver and cannot be disabled, how to set this field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the driver requires amp to always be enabled then it should return VA_FEATURE_REQUIRED in this field.

/** Sample adaptive offset filter.
*
* Allows setting slice_sao_luma_flag and slice_sao_chroma_flag
* in slice headers.
*/
uint32_t sao : 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Driver allows these two slice_sao_luma_flag and slice_sao_chroma_flag to be disabled/enabled respectively. How to set this field, which bit represent luma/chroma?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you thinking of hardware which supports SAO only on one type of plane but not the other? I was thinking that no such hardware would exist, but if you think it is possible then we could add separate sao_luma and sao_chroma fields to distinguish the cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rereading that, I'm now not sure that that was your question. To clarify my intended meaning:

If VAConfigAttribValEncHEVCFeatures.sao == VA_FEATURE_NOT_SUPPORTED, then the user must set both slice_sao_luma_flag and slice_sao_chroma_flag to zero.

If VAConfigAttribValEncHEVCFeatures.sao == VA_FEATURE_SUPPORTED, then the user can pick whatever values they want for slice_sao_luma_flag and slice_sao_chroma_flag, and they need not be the same.

If VAConfigAttribValEncHEVCFeatures.sao == VA_FEATURE_REQUIRED, then the user must set both slice_sao_luma_flag and slice_sao_chroma_flag to one.

Do you have/expect hardware for which that would be a problem?

/** PCM sample blocks.
*
* Allows setting pcm_enabled_flag in the SPS. When enabled
* PCM parameters must be supplied with the sequence parameters,
* including block sizes which may be further constrained as
* noted in the VAConfigAttribEncHEVCBlockSizes attribute.
*/
uint32_t pcm : 2;
/** Temporal motion vector Prediction.
*
* Allows setting slice_temporal_mvp_enabled_flag in slice
* headers.
*/
uint32_t temporal_mvp : 2;
/** Strong intra smoothing.
*
* Allows setting strong_intra_smoothing_enabled_flag in the SPS.
*/
uint32_t strong_intra_smoothing : 2;
/** Dependent slices.
*
* Allows setting dependent_slice_segment_flag in slice headers.
*/
uint32_t dependent_slices : 2;
/** Sign data hiding.
*
* Allows setting sign_data_hiding_enable_flag in the PPS.
*/
uint32_t sign_data_hiding : 2;
/** Constrained intra prediction.
*
* Allows setting constrained_intra_pred_flag in the PPS.
*/
uint32_t constrained_intra_pred : 2;
/** Transform skipping.
*
* Allows setting transform_skip_enabled_flag in the PPS.
*/
uint32_t transform_skip : 2;
/** QP delta within coding units.
*
* Allows setting cu_qp_delta_enabled_flag in the PPS. When
* enabled, diff_cu_qp_delta_depth must be set to zero.
*/
uint32_t cu_qp_delta : 2;
/** Weighted prediction.
*
* Allows setting weighted_pred_flag and weighted_bipred_flag in
* the PPS. The pred_weight_table() data must be supplied with
* every slice header when weighted prediction is enabled.
*/
uint32_t weighted_prediction : 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with SAO. Driver also allows weighted_pred_flag and weighted_bipred_flag to be disabled/enabled respectively. How to set this field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the same case but for hardware which only has partial weighted prediction support? Again, I was imagining that no such hardware would exist, but we could separate them if you do have such hardware. (Hardware which lacks support for encoding P or B frames wouldn't care about the value of the other flag, because it would never be used.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question about weighted_prediction, media-driver support two kind of weighted-prediction: 1. explicit weighted prediction, application should provide pred_weight_table, and media-driver do weighted prediction basing on the pred_weight_table from applicaiton, so a pre-process needed (such as, fade in/out detection) before encoding 2. media driver based weighted prediction (or implicit weight prediction), media-driver will analyze the statistic datas and will provide a pred_weigt_table internally, to help the video quality. it happens inside media-driver during encoding process.
my question is: how to report this kind of capability?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@XinfengZhang I think the setting for driver-produced prediction weights should be signalled by its own attribute rather than embedded here, since it's not actually related to the codec implementation - it would exist in H.264/H.266 as well.

(There are other similar cases where either a driver-internal process or some kind of preprocessing step could be used to produce values for codec processes - e.g. the segmentation map in VP8/VP9/AV1, scaling lists in H.264/H.265/H.266, global motion in AV1. It would be sensible for these to all be treated in a consistent way.)

/** Transform and quantisation bypass.
*
* Allows setting transquant_bypass_enabled_flag in the PPS.
*/
uint32_t transquant_bypass : 2;
/** Deblocking filter disable.
*
* Allows setting slice_deblocking_filter_disabled_flag.
*/
uint32_t deblocking_filter_disable : 2;
/* Reserved for future use. */
uint32_t reserved : 2;
} bits;
uint32_t value;
} VAConfigAttribValEncHEVCFeatures;

/** Attribute value for VAConfigAttribEncHEVCBlockSizes.
*
* This attribute describes the supported coding tree and transform block
* sizes of an HEVC/H.265 encoder configuration
*/
typedef union VAConfigAttribValEncHEVCBlockSizes {
struct {
/** Largest supported size of coding tree blocks.
*
* CtbLog2SizeY must not be larger than this.
*/
uint32_t log2_max_coding_tree_block_size_minus3 : 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ask a question: if some device support LTU = 64, but not support LTU=32. how to report this attributes?
how to distinguish it from : support LTU=64 , also support LTU=32. both ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only 64x64 luma CTBs supported:
log2_max_coding_tree_block_size_minus3 = 3
log2_min_coding_tree_block_size_minus3 = 3
Both 64x64 and 32x32 luma CTBs supported:
log2_max_coding_tree_block_size_minus3 = 3
log2_min_coding_tree_block_size_minus3 = 2

/** Smallest supported size of coding tree blocks.
*
* CtbLog2SizeY must not be smaller than this.
*
* This may be the same as the maximum size, indicating that only
* one CTB size is supported.
*/
uint32_t log2_min_coding_tree_block_size_minus3 : 2;

/** Smallest supported size of luma coding blocks.
*
* MinCbLog2SizeY must not be smaller than this.
*/
uint32_t log2_min_luma_coding_block_size_minus3 : 2;

/** Largest supported size of luma transform blocks.
*
* MaxTbLog2SizeY must not be larger than this.
*/
uint32_t log2_max_luma_transform_block_size_minus2 : 2;
/** Smallest supported size of luma transform blocks.
*
* MinTbLog2SizeY must not be smaller than this.
*/
uint32_t log2_min_luma_transform_block_size_minus2 : 2;

/** Largest supported transform hierarchy depth in inter
* coding units.
*
* max_transform_hierarchy_depth_inter must not be larger
* than this.
*/
uint32_t max_max_transform_hierarchy_depth_inter : 2;
/** Smallest supported transform hierarchy depth in inter
* coding units.
*
* max_transform_hierarchy_depth_inter must not be smaller
* than this.
*/
uint32_t min_max_transform_hierarchy_depth_inter : 2;

/** Largest supported transform hierarchy depth in intra
* coding units.
*
* max_transform_hierarchy_depth_intra must not be larger
* than this.
*/
uint32_t max_max_transform_hierarchy_depth_intra : 2;
/** Smallest supported transform hierarchy depth in intra
* coding units.
*
* max_transform_hierarchy_depth_intra must not be smaller
* than this.
*/
uint32_t min_max_transform_hierarchy_depth_intra : 2;

/** Largest supported size of PCM coding blocks.
*
* Log2MaxIpcmCbSizeY must not be larger than this.
*/
uint32_t log2_max_pcm_coding_block_size_minus3 : 2;
/** Smallest supported size of PCM coding blocks.
*
* Log2MinIpcmCbSizeY must not be smaller than this.
*/
uint32_t log2_min_pcm_coding_block_size_minus3 : 2;

/** Reserved for future use. */
uint32_t reserved : 10;
} bits;
uint32_t value;
} VAConfigAttribValEncHEVCBlockSizes;

/**
* @name Picture flags
*
Expand Down
2 changes: 2 additions & 0 deletions va/va_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ const char *vaConfigAttribTypeStr(VAConfigAttribType configAttribType)
TOSTR(VAConfigAttribProtectedContentCipherMode);
TOSTR(VAConfigAttribProtectedContentCipherSampleType);
TOSTR(VAConfigAttribProtectedContentUsage);
TOSTR(VAConfigAttribEncHEVCFeatures);
TOSTR(VAConfigAttribEncHEVCBlockSizes);
case VAConfigAttribTypeMax: break;
}
return "<unknown config attribute type>";
Expand Down