Commit Graph

35 Commits

Author SHA1 Message Date
PatTheMav
63a131ce22 mac-videotoolbox: Fix handling of unsuccessful encoder creation
When an encoder was not created in create_encoder, the appropriate
OSStatus value is returned but the calling code expects a boolean
return value.

The negative OSStatus code sent on error is thus interpreted as a
truthy value and the error is not detected. Changing the call signature
to correctly return an OSStatus (and change the caller to detect
error situations) fixes this.
2023-12-02 17:49:24 -06:00
gxalpha
6ed2e13974 mac-videotoolbox: Remove CRF 0 second keyint override
The previous commit sets the default configuration to 2 seconds, meaning
that the 0 second default interval no longer happens per default. If
someone explicitly sets the interval to 0 seconds ("auto"), we should
allow them to do that.
2023-11-04 18:47:52 -05:00
gxalpha
5cd30d6a86 mac-videotoolbox: Set default keyframe interval to 2 seconds
0 seconds means "auto" according to the documentation, but this appears
to be broken in many configurations (more than just CRF mode on Apple
Silicon). With some encoders it means that the encoder sets a keyframes
every 31st frame, other times it just doesn't set any keyframes at all
after the first one, only rarely does the "auto" interval actually
appear to work.
Lets just set the default to 2 seconds and be happy. In theory this is
the maximum keyframe interval and encoders are allowed to set more if
they so wish, but they never appear to do so.
2023-11-04 18:47:52 -05:00
gxalpha
ba4467199c plugins: Remove old macOS version ifdefs
8dd20dfd33 introduced an explicit check
for the available macOS SDK, meaning that we can be sure that the macOS
13.1 SDK is available. As such, we do not require ifdef guards for the
availability of functions that are older than 13.1.
2023-10-27 16:00:42 -04:00
PatTheMav
53cfe5cb7f mac-videotoolbox: Remove unreachable code to fix clang warning 2023-06-16 14:12:58 -04:00
gxalpha
ded9aba106 mac-videotoolbox: Remove encoder sorting 2023-06-03 13:48:47 -07:00
gxalpha
0cc7ea7a2a mac-videotoolbox: Fix incorrect keyframe interval calculation 2023-05-18 18:28:53 -04:00
gxalpha
1c15066cc4 mac-videotoolbox: Differentiate unsupported format and range errors 2023-04-29 16:15:42 -07:00
derrod
3fed2e081e mac-videotoolbox: Enforce non-zero keyframe interval in CRF mode 2023-04-05 17:03:21 -07:00
PatTheMav
43f12d1fbd mac-videotoolbox: Fix compile issue if HEVC is disabled
The format is only checked for 10-bit capable formats, which in this
case applies to HEVC only. When HEVC is disabled, then `format` is
not checked and becomes an unused variable otherwise.
2023-04-04 23:14:27 +02:00
PatTheMav
8061652051 mac-videotoolbox: Refactor implementation
Existing code made use of macros which broke parsing in Xcode and
complicated debugging as crucial code was executed within macros and
not actual source code.

Use of mutable CoreFramework data structures (which were never mutated)
is replaced by use of faster non-mutable variants.

When an allocator needs to be used, `kCFAllocatorDefault` is specified
explicitly.

VideoToolbox session properties are also set in bulk instead of
multiple consecutive calls.

Also simplifies detection of Apple Silicon hosts to make code more
readable.
2023-02-21 21:29:12 +01:00
jpark37
09c2a321ce mac-videotoolbox: Add ProRes 4444 (XQ) support
Also leverage P216/P416 pixel formats to retain precision.
2023-02-21 18:48:44 +01:00
gxalpha
67e6b8649a mac-videotoolbox: Load encoders from system asynchronously
Copying the encoder list takes a while which blocks the main thread.
Doing the copying asynchronously removes instead of blocking the main
thread improves startup performance by about 60ms.
2023-02-12 17:38:21 +01:00
jpark37
0fc3cb1962 mac-videotoolbox: Add HDR metadata 2022-12-10 21:43:50 -08:00
jpark37
6c8028a849 mac-videotoolbox: Don't parse HEVC as AVC 2022-12-03 15:31:41 -08:00
gxalpha
838446082e mac-videotoolbox: Default to High profile 2022-11-19 15:05:05 -08:00
gxalpha
8e8148a2d5 mac-videotoolbox: Support P010 and HDR color spaces 2022-11-12 12:24:10 +01:00
PatTheMav
097e9ccecf mac-videtoolbox: Use correct size for system representation CFStrings 2022-11-02 22:44:20 +01:00
gxalpha
a352f0fdd8 mac-videotoolbox: Make unsupported color format text codec agnostic 2022-11-02 22:44:20 +01:00
Developer-Ecosystem-Engineering
44c824985c mac-videotoolbox: Remove HW_ACCEL flags
The hw/sw encoder selection is enforced by the encoder IDs, so these flags are
not explicitly needed.
2022-11-02 22:44:20 +01:00
Developer-Ecosystem-Engineering
761530d34b mac-videotoolbox: Add support platform hardware and software ProRes 422
Utilize the systems ProRes software and hardware encoders on supported configurations
2022-11-02 22:44:20 +01:00
Developer-Ecosystem-Engineering
e461ec4be1 mac-videotoolbox: Add support for platform hardware and software HEVC
Adds support for the system provided HEVC encoders
2022-11-02 22:44:20 +01:00
gxalpha
dd06fe44ad mac-videotoolbox: Remove "None" profile
Selecting this would actually fall back to "main", so we should just use
main as the default.
2022-10-09 16:58:30 -07:00
gxalpha
ff0f5ca681 mac-videotoolbox: Remove unused defines 2022-10-01 16:25:05 -07:00
gxalpha
ad57af4c0a mac-videotoolbox: Reject color formats other than NV12 and I420 2022-08-09 16:19:30 +02:00
PatTheMav
a001f97e3c mac-videotoolbox: Remove guard for hardware acceleration check 2022-07-31 12:21:35 +02:00
Vainock
eb06594381 Use property suffixes for units everywhere 2022-07-22 08:24:51 -04:00
tytan652
5ff07c63b6 mac-videotoolbox: Guard hardware_accelerated check behind macOS 10.14 2022-07-19 12:46:42 +02:00
PatTheMav
566ce79b0f mac-videotoolbox: Enable CBR and CRF on hardware encoders only
Both rate control methods only work on hardware encoders and will error
out when selected for software encoders, so we shouldn't show them there

Co-Authored-By: Sebastian Beckmann <beckmann.sebastian@outlook.de>
2022-07-11 23:45:43 +02:00
AuroraWright
84c7d87a7f mac-videotoolbox: Add CRF support on Apple silicon
Co-Authored-By: Sebastian Beckmann <beckmann.sebastian@outlook.de>
2022-07-11 23:45:43 +02:00
Developer-Ecosystem-Engineering
9e0d7b3123 mac-videotoolbox: Add CBR support on Apple silicon / macOS 13
Implementation adjusted by the OBS Project.

Co-Authored-By: Sebastian Beckmann <beckmann.sebastian@outlook.de>
2022-07-11 23:45:43 +02:00
gxalpha
8c987a86ac mac-videotoolbox: Use type_data as it was intended 2022-07-11 23:45:43 +02:00
gxalpha
fffb320225 mac-videotoolbox: Remove redundant bitrate check
The session_set_bitrate method already returns an OSStatus to confirm
that everything has been successful. As such, a second check to make
sure that the bitrate has indeed changed is redundant and only adds
unnecessary code.
2022-07-11 23:45:43 +02:00
gxalpha
182906d412 mac-videotoolbox: Rename functions to remove "h264" 2022-07-11 23:45:43 +02:00
gxalpha
737f0ab08a mac-videotoolbox: Rename mac-vth264 plugin to mac-videotoolbox 2022-07-11 23:45:43 +02:00