@@ -54,6 +54,11 @@ enum { kCVPixelFormatType_420YpCbCr10BiPlanarFullRange = 'xf20' };
54
54
enum { kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange = 'x420' };
55
55
#endif
56
56
57
+ #if !HAVE_KVTQPMODULATIONLEVEL_DEFAULT
58
+ enum { kVTQPModulationLevel_Default = -1 };
59
+ enum { kVTQPModulationLevel_Disable = 0 };
60
+ #endif
61
+
57
62
#ifndef TARGET_CPU_ARM64
58
63
# define TARGET_CPU_ARM64 0
59
64
#endif
@@ -121,6 +126,7 @@ static struct{
121
126
CFStringRef kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality ;
122
127
CFStringRef kVTCompressionPropertyKey_ConstantBitRate ;
123
128
CFStringRef kVTCompressionPropertyKey_EncoderID ;
129
+ CFStringRef kVTCompressionPropertyKey_SpatialAdaptiveQPLevel ;
124
130
125
131
CFStringRef kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder ;
126
132
CFStringRef kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder ;
@@ -208,6 +214,7 @@ static void loadVTEncSymbols(void){
208
214
"ReferenceBufferCount" );
209
215
GET_SYM (kVTCompressionPropertyKey_MaxAllowedFrameQP , "MaxAllowedFrameQP" );
210
216
GET_SYM (kVTCompressionPropertyKey_MinAllowedFrameQP , "MinAllowedFrameQP" );
217
+ GET_SYM (kVTCompressionPropertyKey_SpatialAdaptiveQPLevel , "SpatialAdaptiveQPLevel" );
211
218
}
212
219
213
220
#define H264_PROFILE_CONSTRAINED_HIGH (AV_PROFILE_H264_HIGH | AV_PROFILE_H264_CONSTRAINED)
@@ -279,6 +286,7 @@ typedef struct VTEncContext {
279
286
int max_slice_bytes ;
280
287
int power_efficient ;
281
288
int max_ref_frames ;
289
+ int spatialaq ;
282
290
} VTEncContext ;
283
291
284
292
static void vtenc_free_buf_node (BufNode * info )
@@ -1599,6 +1607,13 @@ static int vtenc_create_encoder(AVCodecContext *avctx,
1599
1607
}
1600
1608
}
1601
1609
1610
+ if (vtctx -> spatialaq >= 0 ) {
1611
+ set_encoder_int_property_or_log (avctx ,
1612
+ compat_keys .kVTCompressionPropertyKey_SpatialAdaptiveQPLevel ,
1613
+ "spatialaq" ,
1614
+ vtctx -> spatialaq ? kVTQPModulationLevel_Default : kVTQPModulationLevel_Disable );
1615
+ }
1616
+
1602
1617
status = VTCompressionSessionPrepareToEncodeFrames (vtctx -> session );
1603
1618
if (status ) {
1604
1619
av_log (avctx , AV_LOG_ERROR , "Error: cannot prepare encoder: %d\n" , status );
@@ -2891,6 +2906,8 @@ static const enum AVPixelFormat prores_pix_fmts[] = {
2891
2906
{ .i64 = -1 }, -1, 1, VE }, \
2892
2907
{ "power_efficient", "Set to 1 to enable more power-efficient encoding if supported.", \
2893
2908
OFFSET(power_efficient), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
2909
+ { "spatial_aq", "Set to 1 to enable spatial AQ if supported.", \
2910
+ OFFSET(spatialaq), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE }, \
2894
2911
{ "max_ref_frames", \
2895
2912
"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.", \
2896
2913
OFFSET(max_ref_frames), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
0 commit comments