* Re: [FFmpeg-devel] [PATCH v2] lavc/videotoolboxenc: Add spatial_aq option [not found] <20241216092829.1237-1-dennis@obsproject.com> @ 2025-02-04 21:51 ` Martin Storsjö 2025-02-11 9:28 ` Martin Storsjö 0 siblings, 1 reply; 2+ messages in thread From: Martin Storsjö @ 2025-02-04 21:51 UTC (permalink / raw) To: Dennis Sädtler via ffmpeg-devel; +Cc: dennis On Mon, 16 Dec 2024, Dennis Sädtler via ffmpeg-devel wrote: > From: Dennis Sädtler <dennis@obsproject.com> > > Added in macOS 15 "Sequoia". > > Signed-off-by: Dennis Sädtler <dennis@obsproject.com> > --- > Fixed line-endings, otherwise identical to v1. > > libavcodec/videotoolboxenc.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c > index da7b291b03..fb2de7b960 100644 > --- a/libavcodec/videotoolboxenc.c > +++ b/libavcodec/videotoolboxenc.c > @@ -121,6 +121,7 @@ static struct{ > CFStringRef kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality; > CFStringRef kVTCompressionPropertyKey_ConstantBitRate; > CFStringRef kVTCompressionPropertyKey_EncoderID; > + CFStringRef kVTCompressionPropertyKey_SpatialAdaptiveQPLevel; > > CFStringRef kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder; > CFStringRef kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder; > @@ -208,6 +209,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 +281,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 +1602,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); These constants aren't available if building with an older SDK, so this would break building in such cases. For other similar cases of compile time constants that may or may not be available, we have configure checks and provide the constants ourselves - that seems to be reasonable here too. With the following changes on top, it seems to build successfully even for older versions: diff --git a/configure b/configure index 32fbe58126..020c2af843 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 @@ -6748,6 +6749,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/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index fb2de7b960..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 If you don't mind these changes, I could push the patch with these changes squashed in. // Martin _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2] lavc/videotoolboxenc: Add spatial_aq option 2025-02-04 21:51 ` [FFmpeg-devel] [PATCH v2] lavc/videotoolboxenc: Add spatial_aq option Martin Storsjö @ 2025-02-11 9:28 ` Martin Storsjö 0 siblings, 0 replies; 2+ messages in thread From: Martin Storsjö @ 2025-02-11 9:28 UTC (permalink / raw) To: Dennis Sädtler via ffmpeg-devel; +Cc: dennis On Tue, 4 Feb 2025, Martin Storsjö wrote: > On Mon, 16 Dec 2024, Dennis Sädtler via ffmpeg-devel wrote: > >> From: Dennis Sädtler <dennis@obsproject.com> >> >> Added in macOS 15 "Sequoia". >> >> Signed-off-by: Dennis Sädtler <dennis@obsproject.com> >> --- >> Fixed line-endings, otherwise identical to v1. >> >> libavcodec/videotoolboxenc.c | 12 ++++++++++++ >> 1 file changed, 12 insertions(+) >> >> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c >> index da7b291b03..fb2de7b960 100644 >> --- a/libavcodec/videotoolboxenc.c >> +++ b/libavcodec/videotoolboxenc.c >> @@ -121,6 +121,7 @@ static struct{ >> CFStringRef >> kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality; >> CFStringRef kVTCompressionPropertyKey_ConstantBitRate; >> CFStringRef kVTCompressionPropertyKey_EncoderID; >> + CFStringRef kVTCompressionPropertyKey_SpatialAdaptiveQPLevel; >> >> CFStringRef >> kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder; >> CFStringRef >> kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder; >> @@ -208,6 +209,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 +281,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 +1602,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); > > These constants aren't available if building with an older SDK, so this would > break building in such cases. > > For other similar cases of compile time constants that may or may not be > available, we have configure checks and provide the constants ourselves - > that seems to be reasonable here too. > > With the following changes on top, it seems to build successfully even for > older versions: > > > diff --git a/configure b/configure > index 32fbe58126..020c2af843 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 > @@ -6748,6 +6749,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/videotoolboxenc.c b/libavcodec/videotoolboxenc.c > index fb2de7b960..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 > > > If you don't mind these changes, I could push the patch with these changes > squashed in. Will push with these changes. // Martin _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-11 9:29 UTC | newest] Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20241216092829.1237-1-dennis@obsproject.com> 2025-02-04 21:51 ` [FFmpeg-devel] [PATCH v2] lavc/videotoolboxenc: Add spatial_aq option Martin Storsjö 2025-02-11 9:28 ` Martin Storsjö
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git