Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Enables or disables spatial adaptive quantization (AQ) in an encoder MFT.
Data type
BOOL (VT_BOOL)
Property GUID
CODECAPI_AVEncVideoEnableSpatialAdaptiveQuantization
Property value
If the value is TRUE, AQ is enabled. If the value is FALSE, AQ is disabled. The default value is implementation-dependent.
Remarks
When AQ is enabled, if the implementation of AQ supports multiple AQ strengths, the default AQ strength will be used.
When AQ is enabled, the CODECAPI_AVEncVideoEncodeQP value is not strictly followed, as AQ dynamically adjusts Quantization Parameter (QP) values. When AQ is enabled, the CODECAPI_AVEncVideoMaxQP and CODECAPI_AVEncVideoMinQP values are still used as the upper and lower bounds for QP by the AQ algorithm.
Use ICodecAPI::IsSupported to check if the encoder supports this property. Use ICodecAPI::GetValue to query the value of this property. Use ICodecAPI::SetValue to configure this property.
Note that while the variant type of the CODECAPI_AVEncVideoEnableSpatialAdaptiveQuantization property is VT_BOOL, IMFAttributes does not support Boolean attributes. Therefore, you should use SetUINT32 instead. Any non-zero value is interpreted as TRUE. The attribute value will be automatically converted to a VT_BOOL property value when it is transferred to the encoder MFT.
Examples
The following example demonstrates how to use the CODECAPI_AVEncVideoEnableSpatialAdaptiveQuantization property to configure an encoder MFT to enable or disable the spatial adaptive quantization feature.
#include <codecapi.h>
#include <mfapi.h>
#include <wil.com.h>
#include <wil/result_macros.h>
// Inform an encoder MFT to enable or disable the spatial adaptive quantization feature.
// This function assumes that the encoder MFT supports ICodecAPI interface.
// It checks whether the new property CODECAPI_AVEncVideoEnableSpatialAdaptiveQuantization is supported.
// If not supported, it returns E_NOTIMPL.
HRESULT ConfigureEncoderForSpatialAdaptiveQuantization(_In_ IMFTransform* encoder)
{
wil::com_ptr_nothrow<ICodecAPI> codecAPI;
RETURN_IF_FAILED(wil::com_query_to_nothrow(encoder, &codecAPI));
// Check if the encoder supports the property for controlling the usage of spatial adaptive quantization
if (!codecAPI->IsSupported(&CODECAPI_AVEncVideoEnableSpatialAdaptiveQuantization))
{
return E_NOTIMPL;
}
// Configure the encoder to enable spatial adaptive quantization
VARIANT value{};
value.vt = VT_BOOL;
value.boolVal = VARIANT_TRUE; // VARIANT_FALSE: disable; VARIANT_TRUE: enable
return codecAPI->SetValue(&CODECAPI_AVEncVideoEnableSpatialAdaptiveQuantization, &value);
}
Requirements
| Requirement | Value |
|---|---|
| Minimum supported client | Windows 11, build 26100 |
| Minimum supported server | Windows Server 2025 |
| Header | Codecapi.h |