mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-16 13:31:51 +00:00
Fix use of Android 11 low latency decoding feature
This commit is contained in:
@@ -706,43 +706,57 @@ public class MediaCodecHelper {
|
|||||||
// and we want to be sure all callers are handling this possibility
|
// and we want to be sure all callers are handling this possibility
|
||||||
@SuppressWarnings("RedundantThrows")
|
@SuppressWarnings("RedundantThrows")
|
||||||
private static MediaCodecInfo findKnownSafeDecoder(String mimeType, int requiredProfile) throws Exception {
|
private static MediaCodecInfo findKnownSafeDecoder(String mimeType, int requiredProfile) throws Exception {
|
||||||
for (MediaCodecInfo codecInfo : getMediaCodecList()) {
|
// Some devices (Exynos devces, at least) have two sets of decoders.
|
||||||
// Skip encoders
|
// The first set of decoders are C2 which do not support FEATURE_LowLatency,
|
||||||
if (codecInfo.isEncoder()) {
|
// but the second set of OMX decoders do support FEATURE_LowLatency. We want
|
||||||
continue;
|
// to pick the OMX decoders despite the fact that C2 is listed first.
|
||||||
}
|
// On some Qualcomm devices (like Pixel 4), there are separate low latency decoders
|
||||||
|
// (like c2.qti.hevc.decoder.low_latency) that advertise FEATURE_LowLatency while
|
||||||
// Skip compatibility aliases on Q+
|
// the standard ones (like c2.qti.hevc.decoder) do not. Like Exynos, the decoders
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
// with FEATURE_LowLatency support are listed after the standard ones.
|
||||||
if (codecInfo.isAlias()) {
|
for (int i = 0; i < 2; i++) {
|
||||||
|
for (MediaCodecInfo codecInfo : getMediaCodecList()) {
|
||||||
|
// Skip encoders
|
||||||
|
if (codecInfo.isEncoder()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Find a decoder that supports the requested video format
|
|
||||||
for (String mime : codecInfo.getSupportedTypes()) {
|
|
||||||
if (mime.equalsIgnoreCase(mimeType)) {
|
|
||||||
LimeLog.info("Examining decoder capabilities of "+codecInfo.getName());
|
|
||||||
|
|
||||||
// Skip blacklisted codecs
|
// Skip compatibility aliases on Q+
|
||||||
if (isCodecBlacklisted(codecInfo)) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
if (codecInfo.isAlias()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CodecCapabilities caps = codecInfo.getCapabilitiesForType(mime);
|
// Find a decoder that supports the requested video format
|
||||||
|
for (String mime : codecInfo.getSupportedTypes()) {
|
||||||
|
if (mime.equalsIgnoreCase(mimeType)) {
|
||||||
|
LimeLog.info("Examining decoder capabilities of " + codecInfo.getName() + " (round " + (i + 1) + ")");
|
||||||
|
|
||||||
if (requiredProfile != -1) {
|
// Skip blacklisted codecs
|
||||||
for (CodecProfileLevel profile : caps.profileLevels) {
|
if (isCodecBlacklisted(codecInfo)) {
|
||||||
if (profile.profile == requiredProfile) {
|
continue;
|
||||||
LimeLog.info("Decoder " + codecInfo.getName() + " supports required profile");
|
|
||||||
return codecInfo;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LimeLog.info("Decoder " + codecInfo.getName() + " does NOT support required profile");
|
CodecCapabilities caps = codecInfo.getCapabilitiesForType(mime);
|
||||||
}
|
|
||||||
else {
|
if (i == 0 && !decoderSupportsAndroidRLowLatency(codecInfo, mime)) {
|
||||||
return codecInfo;
|
LimeLog.info("Skipping decoder that lacks FEATURE_LowLatency for round 1");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requiredProfile != -1) {
|
||||||
|
for (CodecProfileLevel profile : caps.profileLevels) {
|
||||||
|
if (profile.profile == requiredProfile) {
|
||||||
|
LimeLog.info("Decoder " + codecInfo.getName() + " supports required profile");
|
||||||
|
return codecInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LimeLog.info("Decoder " + codecInfo.getName() + " does NOT support required profile");
|
||||||
|
} else {
|
||||||
|
return codecInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,3 +41,6 @@ This file serves to document some of the decoder errata when using MediaCodec ha
|
|||||||
|
|
||||||
14. Some HEVC decoders lag when receiving a stream with 16 reference frames
|
14. Some HEVC decoders lag when receiving a stream with 16 reference frames
|
||||||
- Affected decoders: Tegra X1 in Pixel C (but NOT in SHIELD TV darcy)
|
- Affected decoders: Tegra X1 in Pixel C (but NOT in SHIELD TV darcy)
|
||||||
|
|
||||||
|
15. Some devices that support Android 11's FEATURE_LowLatency don't support it on their first compatible H.264/HEVC decoder. It is important to examine *all* decoders for FEATURE_LowLatency before deciding on one.
|
||||||
|
- Affected devices: Pixel 4 (c2.qti.avc.decoder.low_latency vs c2.qti.avc.decoder) and Galaxy S21 Exynos (OMX.Exynos.avc.dec [FEATURE_LowLatency] vs C2.Exynos.avc.decoder [no FEATURE_LowLatency])
|
||||||
Reference in New Issue
Block a user