mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-07 16:36:27 +00:00
Enable RFI for HEVC on Qualcomm and Nvidia decoders
This commit is contained in:
@@ -198,7 +198,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
|
|||||||
// for even required levels of HEVC.
|
// for even required levels of HEVC.
|
||||||
MediaCodecInfo hevcDecoderInfo = MediaCodecHelper.findProbableSafeDecoder("video/hevc", -1);
|
MediaCodecInfo hevcDecoderInfo = MediaCodecHelper.findProbableSafeDecoder("video/hevc", -1);
|
||||||
if (hevcDecoderInfo != null) {
|
if (hevcDecoderInfo != null) {
|
||||||
if (!MediaCodecHelper.decoderIsWhitelistedForHevc(hevcDecoderInfo.getName(), meteredNetwork, prefs)) {
|
if (!MediaCodecHelper.decoderIsWhitelistedForHevc(hevcDecoderInfo.getName())) {
|
||||||
LimeLog.info("Found HEVC decoder, but it's not whitelisted - "+hevcDecoderInfo.getName());
|
LimeLog.info("Found HEVC decoder, but it's not whitelisted - "+hevcDecoderInfo.getName());
|
||||||
|
|
||||||
// Force HEVC enabled if the user asked for it
|
// Force HEVC enabled if the user asked for it
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ public class MediaCodecHelper {
|
|||||||
private static final List<String> blacklistedDecoderPrefixes;
|
private static final List<String> blacklistedDecoderPrefixes;
|
||||||
private static final List<String> spsFixupBitstreamFixupDecoderPrefixes;
|
private static final List<String> spsFixupBitstreamFixupDecoderPrefixes;
|
||||||
private static final List<String> blacklistedAdaptivePlaybackPrefixes;
|
private static final List<String> blacklistedAdaptivePlaybackPrefixes;
|
||||||
private static final List<String> deprioritizedHevcDecoders;
|
|
||||||
private static final List<String> baselineProfileHackPrefixes;
|
private static final List<String> baselineProfileHackPrefixes;
|
||||||
private static final List<String> directSubmitPrefixes;
|
private static final List<String> directSubmitPrefixes;
|
||||||
private static final List<String> constrainedHighProfilePrefixes;
|
private static final List<String> constrainedHighProfilePrefixes;
|
||||||
@@ -195,14 +194,6 @@ public class MediaCodecHelper {
|
|||||||
// during initialization to avoid SoCs with broken HEVC decoders.
|
// during initialization to avoid SoCs with broken HEVC decoders.
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
|
||||||
deprioritizedHevcDecoders = new LinkedList<>();
|
|
||||||
|
|
||||||
// These are decoders that work but aren't used by default for various reasons.
|
|
||||||
|
|
||||||
// Qualcomm is currently the only decoders in this group.
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
useFourSlicesPrefixes = new LinkedList<>();
|
useFourSlicesPrefixes = new LinkedList<>();
|
||||||
|
|
||||||
@@ -325,19 +316,15 @@ public class MediaCodecHelper {
|
|||||||
|
|
||||||
// Tegra K1 and later can do reference frame invalidation properly
|
// Tegra K1 and later can do reference frame invalidation properly
|
||||||
if (configInfo.reqGlEsVersion >= 0x30000) {
|
if (configInfo.reqGlEsVersion >= 0x30000) {
|
||||||
LimeLog.info("Added omx.nvidia to AVC reference frame invalidation support list");
|
LimeLog.info("Added omx.nvidia to reference frame invalidation support list");
|
||||||
refFrameInvalidationAvcPrefixes.add("omx.nvidia");
|
refFrameInvalidationAvcPrefixes.add("omx.nvidia");
|
||||||
|
refFrameInvalidationHevcPrefixes.add("omx.nvidia");
|
||||||
|
|
||||||
LimeLog.info("Added omx.qcom/c2.qti to AVC reference frame invalidation support list");
|
LimeLog.info("Added omx.qcom/c2.qti to reference frame invalidation support list");
|
||||||
refFrameInvalidationAvcPrefixes.add("omx.qcom");
|
refFrameInvalidationAvcPrefixes.add("omx.qcom");
|
||||||
|
refFrameInvalidationHevcPrefixes.add("omx.qcom");
|
||||||
refFrameInvalidationAvcPrefixes.add("c2.qti");
|
refFrameInvalidationAvcPrefixes.add("c2.qti");
|
||||||
|
refFrameInvalidationHevcPrefixes.add("c2.qti");
|
||||||
// Prior to M, we were tricking the decoder into using baseline profile, which
|
|
||||||
// won't support RFI properly.
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
LimeLog.info("Added omx.intel to AVC reference frame invalidation support list");
|
|
||||||
refFrameInvalidationAvcPrefixes.add("omx.intel");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Qualcomm's early HEVC decoders break hard on our HEVC stream. The best check to
|
// Qualcomm's early HEVC decoders break hard on our HEVC stream. The best check to
|
||||||
@@ -349,13 +336,9 @@ public class MediaCodecHelper {
|
|||||||
// (see comment on isGLES31SnapdragonRenderer).
|
// (see comment on isGLES31SnapdragonRenderer).
|
||||||
//
|
//
|
||||||
if (isGLES31SnapdragonRenderer(glRenderer)) {
|
if (isGLES31SnapdragonRenderer(glRenderer)) {
|
||||||
// We prefer reference frame invalidation support (which is only doable on AVC on
|
LimeLog.info("Added omx.qcom/c2.qti to HEVC decoders based on GLES 3.1+ support");
|
||||||
// older Qualcomm chips) vs. enabling HEVC by default. The user can override using the settings
|
whitelistedHevcDecoders.add("omx.qcom");
|
||||||
// to force HEVC on. If HDR or mobile data will be used, we'll override this and use
|
whitelistedHevcDecoders.add("c2.qti");
|
||||||
// HEVC anyway.
|
|
||||||
LimeLog.info("Added omx.qcom/c2.qti to deprioritized HEVC decoders based on GLES 3.1+ support");
|
|
||||||
deprioritizedHevcDecoders.add("omx.qcom");
|
|
||||||
deprioritizedHevcDecoders.add("c2.qti");
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
blacklistedDecoderPrefixes.add("OMX.qcom.video.decoder.hevc");
|
blacklistedDecoderPrefixes.add("OMX.qcom.video.decoder.hevc");
|
||||||
@@ -616,7 +599,7 @@ public class MediaCodecHelper {
|
|||||||
return isDecoderInList(refFrameInvalidationHevcPrefixes, decoderName);
|
return isDecoderInList(refFrameInvalidationHevcPrefixes, decoderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean decoderIsWhitelistedForHevc(String decoderName, boolean meteredData, PreferenceConfiguration prefs) {
|
public static boolean decoderIsWhitelistedForHevc(String decoderName) {
|
||||||
// Google didn't have official support for HEVC (or more importantly, a CTS test) until
|
// Google didn't have official support for HEVC (or more importantly, a CTS test) until
|
||||||
// Lollipop. I've seen some MediaTek devices on 4.4 crash when attempting to use HEVC,
|
// Lollipop. I've seen some MediaTek devices on 4.4 crash when attempting to use HEVC,
|
||||||
// so I'm restricting HEVC usage to Lollipop and higher.
|
// so I'm restricting HEVC usage to Lollipop and higher.
|
||||||
@@ -634,21 +617,6 @@ public class MediaCodecHelper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some devices have HEVC decoders that we prefer not to use
|
|
||||||
// typically because it can't support reference frame invalidation.
|
|
||||||
// However, we will use it for HDR and for streaming over mobile networks
|
|
||||||
// since it works fine otherwise. We will also use it for 4K because RFI
|
|
||||||
// is currently disabled due to issues with video corruption.
|
|
||||||
if (isDecoderInList(deprioritizedHevcDecoders, decoderName)) {
|
|
||||||
if (meteredData || (prefs.width == 3840 && prefs.height == 2160)) {
|
|
||||||
LimeLog.info("Selected deprioritized decoder");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return isDecoderInList(whitelistedHevcDecoders, decoderName);
|
return isDecoderInList(whitelistedHevcDecoders, decoderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user