Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Unified Diff: media/base/android/java/src/org/chromium/media/MediaCodecBridge.java

Issue 1869103002: Enable adaptive playback for spitzer, use conservative size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cl feedback. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/android/java/src/org/chromium/media/MediaCodecBridge.java
diff --git a/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java b/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java
index 23167ac726dcc526e1057135c6b418a5949e5e4d..4befc19a379c4e5e8b0ed60a9f24854d9ecb0417 100644
--- a/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java
+++ b/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java
@@ -43,10 +43,6 @@ class MediaCodecBridge {
private static final int MEDIA_CODEC_ABORT = 8;
private static final int MEDIA_CODEC_ERROR = 9;
- // Max adaptive playback size to be supplied to the decoder.
- private static final int MAX_ADAPTIVE_PLAYBACK_WIDTH = 1920;
- private static final int MAX_ADAPTIVE_PLAYBACK_HEIGHT = 1080;
-
// After a flush(), dequeueOutputBuffer() can often produce empty presentation timestamps
// for several frames. As a result, the player may find that the time does not increase
// after decoding a frame. To detect this, we check whether the presentation timestamp from
@@ -455,9 +451,21 @@ class MediaCodecBridge {
private boolean configureVideo(MediaFormat format, Surface surface, MediaCrypto crypto,
int flags, boolean allowAdaptivePlayback) {
try {
- if (mAdaptivePlaybackSupported && allowAdaptivePlayback) {
- format.setInteger(MediaFormat.KEY_MAX_WIDTH, MAX_ADAPTIVE_PLAYBACK_WIDTH);
- format.setInteger(MediaFormat.KEY_MAX_HEIGHT, MAX_ADAPTIVE_PLAYBACK_HEIGHT);
+ // If adaptive playback is turned off by request, then treat it as
+ // not supported. Note that configureVideo is only called once
+ // during creation, else this would prevent re-enabling adaptive
+ // playback later.
+ if (!allowAdaptivePlayback) mAdaptivePlaybackSupported = false;
+
+ if (mAdaptivePlaybackSupported) {
+ // The max size is a hint to the codec, and causes it to
+ // allocate more memory up front. It still supports higher
+ // resolutions if they arrive. So, we try to ask only for
+ // the initial size.
+ format.setInteger(
DaleCurtis 2016/04/07 22:55:17 FWIW, since I had to go check, VideoDecoderConfig:
+ MediaFormat.KEY_MAX_WIDTH, format.getInteger(MediaFormat.KEY_WIDTH));
+ format.setInteger(
+ MediaFormat.KEY_MAX_HEIGHT, format.getInteger(MediaFormat.KEY_HEIGHT));
}
mMediaCodec.configure(format, surface, crypto, flags);
return true;
@@ -496,8 +504,9 @@ class MediaCodecBridge {
@CalledByNative
private boolean isAdaptivePlaybackSupported(int width, int height) {
- if (!mAdaptivePlaybackSupported) return false;
- return width <= MAX_ADAPTIVE_PLAYBACK_WIDTH && height <= MAX_ADAPTIVE_PLAYBACK_HEIGHT;
+ // If media codec has adaptive playback supported, then the max sizes
+ // used during creation are only hints.
+ return mAdaptivePlaybackSupported;
}
@CalledByNative

Powered by Google App Engine
This is Rietveld 408576698