Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mac-videotoolbox: Add Spatial AQ option (macOS 15) #11442

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dsaedtler
Copy link
Contributor

Description

Adds support for the new spatial aq property introduced in macOS 15: https://developer.apple.com/documentation/videotoolbox/kvtcompressionpropertykey_spatialadaptiveqplevel?language=objc

Motivation and Context

Disabling spatial aq seems to improve video quality of screen content (such as games) by a decent bit.

How Has This Been Tested?

M1 Pro with FFmpeg patch applied for direct frame-accurate comparison of AOM video game compression test corpus.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@dsaedtler dsaedtler marked this pull request as draft October 23, 2024 15:29
@dsaedtler
Copy link
Contributor Author

Apparently we need Xcdoe 16 for this to work, which is getting removed from the macos-14 images soon (actions/runner-images#10703) so we'd have to update to macos-15. Let's see what breaks?

@dsaedtler dsaedtler force-pushed the rodney/vt-spatial-aq branch from 1eb6fd5 to 0983707 Compare October 23, 2024 15:31
@dsaedtler dsaedtler marked this pull request as ready for review October 23, 2024 16:56
@dsaedtler dsaedtler force-pushed the rodney/vt-spatial-aq branch from 0983707 to 479ba15 Compare October 23, 2024 16:56
@Lain-B
Copy link
Collaborator

Lain-B commented Oct 26, 2024

I'm not a macOS specialist so might want @PatTheMav to give this a look just as a double-check, but seems trivial/simple enough so I threw an approval on it.

@dsaedtler dsaedtler force-pushed the rodney/vt-spatial-aq branch from 479ba15 to 3eb273a Compare October 26, 2024 20:46
@WizardCM WizardCM added macOS Affects macOS New Feature New feature or plugin labels Oct 26, 2024
Copy link
Member

@PatTheMav PatTheMav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this does indeed add a requirement to use Xcode 16 (which is fine in my book), then the lower version boundaries should be changed here as well:

set(_obs_macos_minimum_sdk 14.2) # Keep in sync with Xcode
set(_obs_macos_minimum_xcode 15.1) # Keep in sync with SDK

@dsaedtler dsaedtler force-pushed the rodney/vt-spatial-aq branch from 3eb273a to 9a1534a Compare October 27, 2024 00:20
@dsaedtler dsaedtler force-pushed the rodney/vt-spatial-aq branch from 9a1534a to 08df8d1 Compare December 14, 2024 23:02
@dsaedtler
Copy link
Contributor Author

Updated the PR with the following changes:

  • Checkbox was replaced by combobox with "Auto", "Enabled", and "Disabled" settings
  • Auto will disable spatial AQ for CBR/ABR, but keep it enabled for CRF

The choice to disable it by default for ABR/CBR was made based on an extensive analysis involving VMAF scoring and subjective checks on a large number of test clips1. In all cases the encoder produced significantly better results if spatial AQ was disabled.
In addition, having spatial AQ enabled would also result in bitrate overshoot in complex scenes, whereas keeping it disabled would result in the encoder sticking closer to the target bitrate.

One of the most noticeable issues when spatial AQ is enabled is that text often gets mangled:
image


The choice to keep it enabled for CRF was made in order to not change anything for users using target quality modes, as having spatial AQ enabled bumps the output bitrate by 50-100%, which provides a corresponding quality increase. If we were to disable it by default for CRF we would also have to bump the target quality values a bit (7-8 points) to make up for it.

Footnotes

  1. The test clips included both game footage as well as live action/"IRL" video filmed on a variety of devices.

@dsaedtler dsaedtler force-pushed the rodney/vt-spatial-aq branch from 08df8d1 to d305634 Compare December 15, 2024 00:41
plugins/mac-videotoolbox/encoder.c Outdated Show resolved Hide resolved
plugins/mac-videotoolbox/encoder.c Outdated Show resolved Hide resolved
plugins/mac-videotoolbox/encoder.c Outdated Show resolved Hide resolved
@dsaedtler dsaedtler force-pushed the rodney/vt-spatial-aq branch from d305634 to f618813 Compare December 16, 2024 15:39
@MysticalOS
Copy link

I wonder if this is what made apples H264 utterly wreck wow content all the time (so much text). i basically am forced to use software encoder cause apples mangles it to hell and back. nice find either way :o

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macOS Affects macOS New Feature New feature or plugin
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

6 participants