[FFmpeg-cvslog] lavc/videotoolboxenc: Add spatial_aq option
Dennis Sädtler
git at videolan.org
Tue Feb 11 11:33:39 EET 2025
ffmpeg | branch: master | Dennis Sädtler <dennis at obsproject.com> | Mon Dec 16 10:28:29 2024 +0100| [78ff3782af08a1b8d762b13492a1c1dd0f2c729c] | committer: Martin Storsjö
lavc/videotoolboxenc: Add spatial_aq option
Added in macOS 15 "Sequoia".
Signed-off-by: Dennis Sädtler <dennis at obsproject.com>
Signed-off-by: Martin Storsjö <martin at martin.st>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=78ff3782af08a1b8d762b13492a1c1dd0f2c729c
---
configure | 2 ++
libavcodec/version.h | 2 +-
libavcodec/videotoolboxenc.c | 17 +++++++++++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 6e46e59b6f..ed6cd97f6f 100755
--- a/configure
+++ b/configure
@@ -2490,6 +2490,7 @@ TYPES_LIST="
kCVImageBufferColorPrimaries_ITU_R_2020
kCVImageBufferTransferFunction_ITU_R_2020
kCVImageBufferTransferFunction_SMPTE_ST_428_1
+ kVTQPModulationLevel_Default
socklen_t
struct_addrinfo
struct_group_source_req
@@ -6749,6 +6750,7 @@ enabled videotoolbox && {
check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferColorPrimaries_ITU_R_2020 "-framework CoreVideo"
check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_ITU_R_2020 "-framework CoreVideo"
check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_SMPTE_ST_428_1 "-framework CoreVideo"
+ check_func_headers VideoToolbox/VTCompressionProperties.h kVTQPModulationLevel_Default "-framework CoreVideo"
}
enabled metal && test_cmd $metalcc -v || disable metal
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 2a08e42d7e..e6f3c4aa5b 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
#include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 33
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index da7b291b03..950a29d9fa 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -54,6 +54,11 @@ enum { kCVPixelFormatType_420YpCbCr10BiPlanarFullRange = 'xf20' };
enum { kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange = 'x420' };
#endif
+#if !HAVE_KVTQPMODULATIONLEVEL_DEFAULT
+enum { kVTQPModulationLevel_Default = -1 };
+enum { kVTQPModulationLevel_Disable = 0 };
+#endif
+
#ifndef TARGET_CPU_ARM64
# define TARGET_CPU_ARM64 0
#endif
@@ -121,6 +126,7 @@ static struct{
CFStringRef kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality;
CFStringRef kVTCompressionPropertyKey_ConstantBitRate;
CFStringRef kVTCompressionPropertyKey_EncoderID;
+ CFStringRef kVTCompressionPropertyKey_SpatialAdaptiveQPLevel;
CFStringRef kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder;
CFStringRef kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder;
@@ -208,6 +214,7 @@ static void loadVTEncSymbols(void){
"ReferenceBufferCount");
GET_SYM(kVTCompressionPropertyKey_MaxAllowedFrameQP, "MaxAllowedFrameQP");
GET_SYM(kVTCompressionPropertyKey_MinAllowedFrameQP, "MinAllowedFrameQP");
+ GET_SYM(kVTCompressionPropertyKey_SpatialAdaptiveQPLevel, "SpatialAdaptiveQPLevel");
}
#define H264_PROFILE_CONSTRAINED_HIGH (AV_PROFILE_H264_HIGH | AV_PROFILE_H264_CONSTRAINED)
@@ -279,6 +286,7 @@ typedef struct VTEncContext {
int max_slice_bytes;
int power_efficient;
int max_ref_frames;
+ int spatialaq;
} VTEncContext;
static void vtenc_free_buf_node(BufNode *info)
@@ -1599,6 +1607,13 @@ static int vtenc_create_encoder(AVCodecContext *avctx,
}
}
+ if (vtctx->spatialaq >= 0) {
+ set_encoder_int_property_or_log(avctx,
+ compat_keys.kVTCompressionPropertyKey_SpatialAdaptiveQPLevel,
+ "spatialaq",
+ vtctx->spatialaq ? kVTQPModulationLevel_Default : kVTQPModulationLevel_Disable);
+ }
+
status = VTCompressionSessionPrepareToEncodeFrames(vtctx->session);
if (status) {
av_log(avctx, AV_LOG_ERROR, "Error: cannot prepare encoder: %d\n", status);
@@ -2891,6 +2906,8 @@ static const enum AVPixelFormat prores_pix_fmts[] = {
{ .i64 = -1 }, -1, 1, VE }, \
{ "power_efficient", "Set to 1 to enable more power-efficient encoding if supported.", \
OFFSET(power_efficient), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
+ { "spatial_aq", "Set to 1 to enable spatial AQ if supported.", \
+ OFFSET(spatialaq), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
{ "max_ref_frames", \
"Sets the maximum number of reference frames. This only has an effect when the value is less than the maximum allowed by the profile/level.", \
OFFSET(max_ref_frames), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
More information about the ffmpeg-cvslog
mailing list