UI: Add Apple H.264 hardware encoder to simple mode

Adds the Apple Silicon hardware encoder as a simple mode option. For
recordings this only requires being on Apple Silicon (since we use the
Constant Quality setting), while for streaming it requires the user to
be on macOS 13 or newer (since we're using CBR).
This commit is contained in:
gxalpha
2022-06-23 02:46:03 +02:00
committed by Sebastian Beckmann
parent 566ce79b0f
commit 29ae00e4af
6 changed files with 68 additions and 1 deletions

View File

@@ -3542,6 +3542,11 @@ void OBSBasicSettings::SaveOutputSettings()
#endif
else if (encoder == SIMPLE_ENCODER_AMD)
presetType = "AMDPreset";
else if (encoder == SIMPLE_ENCODER_APPLE_H264)
/* The Apple encoders don't have presets like the other encoders
do. This only exists to make sure that the x264 preset doesn't
get overwritten with empty data. */
presetType = "ApplePreset";
else
presetType = "Preset";
@@ -4768,6 +4773,14 @@ void OBSBasicSettings::FillSimpleRecordingValues()
ui->simpleOutRecEncoder->addItem(
ENCODER_STR("Hardware.AMD.H264"),
QString(SIMPLE_ENCODER_AMD));
if (EncoderAvailable("com.apple.videotoolbox.videoencoder.ave.avc")
#ifndef __aarch64__
&& os_get_emulation_status() == true
#endif
)
ui->simpleOutRecEncoder->addItem(
ENCODER_STR("Hardware.Apple.H264"),
QString(SIMPLE_ENCODER_APPLE_H264));
#undef ADD_QUALITY
}
@@ -4793,6 +4806,18 @@ void OBSBasicSettings::FillSimpleStreamingValues()
ui->simpleOutStrEncoder->addItem(
ENCODER_STR("Hardware.AMD.H264"),
QString(SIMPLE_ENCODER_AMD));
/* Preprocessor guard required for the macOS version check */
#ifdef __APPLE__
if (EncoderAvailable("com.apple.videotoolbox.videoencoder.ave.avc")
#ifndef __aarch64__
&& os_get_emulation_status() == true
#endif
)
if (__builtin_available(macOS 13.0, *))
ui->simpleOutStrEncoder->addItem(
ENCODER_STR("Hardware.Apple.H264"),
QString(SIMPLE_ENCODER_APPLE_H264));
#endif
#undef ENCODER_STR
}
@@ -4835,6 +4860,9 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged()
QString preset;
const char *defaultPreset = nullptr;
ui->simpleOutAdvanced->setVisible(true);
ui->simpleOutPresetLabel->setVisible(true);
ui->simpleOutPreset->setVisible(true);
ui->simpleOutPreset->clear();
if (encoder == SIMPLE_ENCODER_QSV) {
@@ -4906,6 +4934,11 @@ void OBSBasicSettings::SimpleStreamingEncoderChanged()
defaultPreset = "balanced";
preset = curAMDPreset;
} else if (encoder == SIMPLE_ENCODER_APPLE_H264) {
ui->simpleOutAdvanced->setChecked(false);
ui->simpleOutAdvanced->setVisible(false);
ui->simpleOutPreset->setVisible(false);
ui->simpleOutPresetLabel->setVisible(false);
} else {
#define PRESET_STR(val) \