mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Use getAchievableFrameRatesFor to find approximate SW codec limits
We currently assume SW codecs are capable of playing all resolutions and frame rates up to their declared supported maximum values, even though the are likely not able to keep up playback smoothly for higher resolutions. For HW codecs we can check PerformancePoints to declare them as EXCEEDS_CAPABILITIES if they technically support a format but are not performant enough. We can do the same for SW codecs by checking getAchievableFrameRatesFor. PiperOrigin-RevId: 739253653
This commit is contained in:
parent
1230573dfb
commit
a472300c7a
@ -20,6 +20,8 @@
|
||||
buffers. This flag will signal the decoder to skip the decode-only
|
||||
buffers thereby resulting in faster seeking. Enable it with
|
||||
`DefaultRenderersFactory.experimentalSetEnableMediaCodecBufferDecodeOnlyFlag`.
|
||||
* Improve codec performance checks for software video codecs. This may
|
||||
lead to some additional tracks being marked as `EXCEEDS_CAPABILITIES`.
|
||||
* Text:
|
||||
* Metadata:
|
||||
* Image:
|
||||
|
@ -40,6 +40,7 @@ import android.media.MediaCodecInfo.CodecProfileLevel;
|
||||
import android.media.MediaCodecInfo.VideoCapabilities;
|
||||
import android.os.Build;
|
||||
import android.util.Pair;
|
||||
import android.util.Range;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@ -731,7 +732,18 @@ public final class MediaCodecInfo {
|
||||
// floor to avoid situations where a range check in areSizeAndRateSupported fails due to
|
||||
// slightly exceeding the limits for a standard format (e.g., 1080p at 30 fps).
|
||||
double floorFrameRate = Math.floor(frameRate);
|
||||
return capabilities.areSizeAndRateSupported(width, height, floorFrameRate);
|
||||
if (!capabilities.areSizeAndRateSupported(width, height, floorFrameRate)) {
|
||||
return false;
|
||||
}
|
||||
if (Util.SDK_INT < 24) {
|
||||
return true;
|
||||
}
|
||||
@Nullable
|
||||
Range<Double> achievableFrameRates = capabilities.getAchievableFrameRatesFor(width, height);
|
||||
if (achievableFrameRates == null) {
|
||||
return true;
|
||||
}
|
||||
return floorFrameRate <= achievableFrameRates.getUpper();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user