From 1f72c82acbf689e507d3b696d3671950eb443370 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 9 Jul 2023 15:04:26 -0500 Subject: [PATCH] Consolidate AV1 and HEVC options into a single preference --- app/src/main/java/com/limelight/Game.java | 4 +- .../video/MediaCodecDecoderRenderer.java | 12 ++--- .../preferences/PreferenceConfiguration.java | 50 ++++++------------- app/src/main/res/values/arrays.xml | 17 ++----- app/src/main/res/values/strings.xml | 15 ++---- app/src/main/res/xml/preferences.xml | 7 --- 6 files changed, 32 insertions(+), 73 deletions(-) diff --git a/app/src/main/java/com/limelight/Game.java b/app/src/main/java/com/limelight/Game.java index fad3f66c..33a26088 100644 --- a/app/src/main/java/com/limelight/Game.java +++ b/app/src/main/java/com/limelight/Game.java @@ -411,12 +411,12 @@ public class Game extends Activity implements SurfaceHolder.Callback, } // Display a message to the user if HEVC was forced on but we still didn't find a decoder - if (prefConfig.hevcFormat == PreferenceConfiguration.FormatOption.FORCE_ON && !decoderRenderer.isHevcSupported()) { + if (prefConfig.videoFormat == PreferenceConfiguration.FormatOption.FORCE_HEVC && !decoderRenderer.isHevcSupported()) { Toast.makeText(this, "No HEVC decoder found", Toast.LENGTH_LONG).show(); } // Display a message to the user if AV1 was forced on but we still didn't find a decoder - if (prefConfig.av1Format == PreferenceConfiguration.FormatOption.FORCE_ON && !decoderRenderer.isAv1Supported()) { + if (prefConfig.videoFormat == PreferenceConfiguration.FormatOption.FORCE_AV1 && !decoderRenderer.isAv1Supported()) { Toast.makeText(this, "No AV1 decoder found", Toast.LENGTH_LONG).show(); } diff --git a/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java b/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java index 9bb3f1c6..063e8f9e 100644 --- a/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java +++ b/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java @@ -218,8 +218,8 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C } private MediaCodecInfo findHevcDecoder(PreferenceConfiguration prefs, boolean meteredNetwork, boolean requestedHdr) { - // Don't return anything if HEVC is forced off - if (prefs.hevcFormat == PreferenceConfiguration.FormatOption.FORCE_OFF) { + // Don't return anything if H.264 is forced + if (prefs.videoFormat == PreferenceConfiguration.FormatOption.FORCE_H264) { return null; } @@ -234,7 +234,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C LimeLog.info("Found HEVC decoder, but it's not whitelisted - "+hevcDecoderInfo.getName()); // Force HEVC enabled if the user asked for it - if (prefs.hevcFormat == PreferenceConfiguration.FormatOption.FORCE_ON) { + if (prefs.videoFormat == PreferenceConfiguration.FormatOption.FORCE_HEVC) { LimeLog.info("Forcing HEVC enabled despite non-whitelisted decoder"); } // HDR implies HEVC forced on, since HEVCMain10HDR10 is required for HDR. @@ -259,8 +259,8 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C } private MediaCodecInfo findAv1Decoder(PreferenceConfiguration prefs) { - // Don't return anything if AV1 is forced off - if (prefs.av1Format == PreferenceConfiguration.FormatOption.FORCE_OFF) { + // For now, don't use AV1 unless explicitly requested + if (prefs.videoFormat != PreferenceConfiguration.FormatOption.FORCE_AV1) { return null; } @@ -270,7 +270,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C LimeLog.info("Found AV1 decoder, but it's not whitelisted - "+decoderInfo.getName()); // Force HEVC enabled if the user asked for it - if (prefs.av1Format == PreferenceConfiguration.FormatOption.FORCE_ON) { + if (prefs.videoFormat == PreferenceConfiguration.FormatOption.FORCE_AV1) { LimeLog.info("Forcing AV1 enabled despite non-whitelisted decoder"); } // Use AV1 if the HEVC decoder is unable to meet the performance point diff --git a/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java b/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java index 16a1cffa..9ca173ce 100644 --- a/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java +++ b/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java @@ -12,8 +12,9 @@ import com.limelight.nvstream.jni.MoonBridge; public class PreferenceConfiguration { public enum FormatOption { AUTO, - FORCE_ON, - FORCE_OFF + FORCE_AV1, + FORCE_HEVC, + FORCE_H264, }; private static final String LEGACY_RES_FPS_PREF_STRING = "list_resolution_fps"; @@ -34,8 +35,7 @@ public class PreferenceConfiguration { private static final String MULTI_CONTROLLER_PREF_STRING = "checkbox_multi_controller"; static final String AUDIO_CONFIG_PREF_STRING = "list_audio_config"; private static final String USB_DRIVER_PREF_SRING = "checkbox_usb_driver"; - private static final String HEVC_FORMAT_PREF_STRING = "video_format"; - private static final String AV1_FORMAT_PREF_STRING = "av1_format"; + private static final String VIDEO_FORMAT_PREF_STRING = "video_format"; private static final String ONSCREEN_CONTROLLER_PREF_STRING = "checkbox_show_onscreen_controls"; private static final String ONLY_L3_R3_PREF_STRING = "checkbox_only_show_L3R3"; private static final String LEGACY_DISABLE_FRAME_DROP_PREF_STRING = "checkbox_disable_frame_drop"; @@ -70,8 +70,7 @@ public class PreferenceConfiguration { public static final String DEFAULT_LANGUAGE = "default"; private static final boolean DEFAULT_MULTI_CONTROLLER = true; private static final boolean DEFAULT_USB_DRIVER = true; - private static final String DEFAULT_HEVC_FORMAT = "auto"; - private static final String DEFAULT_AV1_FORMAT = "never"; + private static final String DEFAULT_VIDEO_FORMAT = "auto"; private static final boolean ONSCREEN_CONTROLLER_DEFAULT = false; private static final boolean ONLY_L3_R3_DEFAULT = false; @@ -111,8 +110,7 @@ public class PreferenceConfiguration { public int width, height, fps; public int bitrate; - public FormatOption hevcFormat; - public FormatOption av1Format; + public FormatOption videoFormat; public int deadzonePercentage; public int oscOpacity; public boolean stretchVideo, enableSops, playHostAudio, disableWarnings; @@ -301,37 +299,21 @@ public class PreferenceConfiguration { prefs.getString(FPS_PREF_STRING, DEFAULT_FPS)); } - private static FormatOption getHevcFormatValue(Context context) { + private static FormatOption getVideoFormatValue(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - String str = prefs.getString(HEVC_FORMAT_PREF_STRING, DEFAULT_HEVC_FORMAT); + String str = prefs.getString(VIDEO_FORMAT_PREF_STRING, DEFAULT_VIDEO_FORMAT); if (str.equals("auto")) { return FormatOption.AUTO; } + else if (str.equals("forceav1")) { + return FormatOption.FORCE_AV1; + } else if (str.equals("forceh265")) { - return FormatOption.FORCE_ON; + return FormatOption.FORCE_HEVC; } else if (str.equals("neverh265")) { - return FormatOption.FORCE_OFF; - } - else { - // Should never get here - return FormatOption.AUTO; - } - } - - private static FormatOption getAV1FormatValue(Context context) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - - String str = prefs.getString(AV1_FORMAT_PREF_STRING, DEFAULT_AV1_FORMAT); - if (str.equals("auto")) { - return FormatOption.AUTO; - } - else if (str.equals("force")) { - return FormatOption.FORCE_ON; - } - else if (str.equals("never")) { - return FormatOption.FORCE_OFF; + return FormatOption.FORCE_H264; } else { // Should never get here @@ -379,8 +361,7 @@ public class PreferenceConfiguration { .remove(LEGACY_RES_FPS_PREF_STRING) .remove(RESOLUTION_PREF_STRING) .remove(FPS_PREF_STRING) - .remove(HEVC_FORMAT_PREF_STRING) - .remove(AV1_FORMAT_PREF_STRING) + .remove(VIDEO_FORMAT_PREF_STRING) .remove(ENABLE_HDR_PREF_STRING) .remove(UNLOCK_FPS_STRING) .remove(FULL_RANGE_PREF_STRING) @@ -507,8 +488,7 @@ public class PreferenceConfiguration { config.audioConfiguration = MoonBridge.AUDIO_CONFIGURATION_STEREO; } - config.hevcFormat = getHevcFormatValue(context); - config.av1Format = getAV1FormatValue(context); + config.videoFormat = getVideoFormatValue(context); config.framePacing = getFramePacingValue(context); config.deadzonePercentage = prefs.getInt(DEADZONE_PREF_STRING, DEFAULT_DEADZONE); diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 3c473700..2fb29bfe 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -96,27 +96,18 @@ - @string/videoformat_hevcauto + @string/videoformat_auto + @string/videoformat_av1always @string/videoformat_hevcalways - @string/videoformat_hevcnever + @string/videoformat_h264always auto + forceav1 forceh265 neverh265 - - @string/av1_format_auto - @string/av1_format_always - @string/av1_format_never - - - auto - force - never - - @string/pacing_latency @string/pacing_balanced diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 73afb81d..307c0076 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -236,10 +236,8 @@ Disable on-screen connection warning messages while streaming Never drop frames May reduce micro-stuttering on some devices, but can increase latency - Change HEVC settings - HEVC lowers video bandwidth requirements but requires a newer device - Change AV1 settings (Experimental) - AV1 lowers video bandwidth requirements more than HEVC, but is currently experimental. + Change codec settings + Newer codecs can lower video bandwidth requirements if your device supports them. Codec selections may be ignored if not supported by the host software or GPU. Enable HDR (Experimental) Stream HDR when the game and PC GPU support it. HDR requires a GPU with HEVC Main 10 encoding support. Force full range video (Experimental) @@ -274,13 +272,10 @@ 5.1 Surround Sound 7.1 Surround Sound - Automatic (Recommended) + Automatic (Recommended) + Prefer AV1 (Experimental) Prefer HEVC - Never use HEVC - - Automatic (Recommended) - Prefer AV1 - Never use AV1 + Prefer H.264 Video frame pacing Specify how to balance video latency and smoothness diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 65ed8a60..f52b6827 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -220,13 +220,6 @@ android:entryValues="@array/video_format_values" android:summary="@string/summary_video_format" android:defaultValue="auto" /> -