summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgunsch <gunsch@chromium.org>2014-11-04 17:53:33 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-05 01:54:54 +0000
commit357d1f8cc2c53eebafa512b258acd6b18d0c44ab (patch)
tree9911301d7282b2b3d50690530df76f910f173c83
parent62bb47df51eac10a618b9ad5e4b15d2bae8ab6d6 (diff)
downloadchromium_src-357d1f8cc2c53eebafa512b258acd6b18d0c44ab.zip
chromium_src-357d1f8cc2c53eebafa512b258acd6b18d0c44ab.tar.gz
chromium_src-357d1f8cc2c53eebafa512b258acd6b18d0c44ab.tar.bz2
Use MediaFormat's crop rectangle when available instead of width/height.
Per Android media team, width/height is not always reliable. See: https://github.com/google/ExoPlayer/blob/a7b88cd6a9bac4de5ef47b23e0d7fb50c570b3a6/library/src/main/java/com/google/android/exoplayer/MediaCodecVideoTrackRenderer.java#L319 R=qinmin@chromium.org BUG=internal b/18224769 Review URL: https://codereview.chromium.org/698273003 Cr-Commit-Position: refs/heads/master@{#302739}
-rw-r--r--media/base/android/java/src/org/chromium/media/MediaCodecBridge.java24
1 files changed, 20 insertions, 4 deletions
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 28d20ff..399f355 100644
--- a/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java
+++ b/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java
@@ -62,6 +62,12 @@ class MediaCodecBridge {
// non-decreasing for the remaining frames.
private static final long MAX_PRESENTATION_TIMESTAMP_SHIFT_US = 100000;
+ // TODO(qinmin): Use MediaFormat constants when part of the public API.
+ private static final String KEY_CROP_LEFT = "crop-left";
+ private static final String KEY_CROP_RIGHT = "crop-right";
+ private static final String KEY_CROP_BOTTOM = "crop-bottom";
+ private static final String KEY_CROP_TOP = "crop-top";
+
private ByteBuffer[] mInputBuffers;
private ByteBuffer[] mOutputBuffers;
@@ -244,8 +250,7 @@ class MediaCodecBridge {
if (!supportedTypes[j].equalsIgnoreCase(mime))
continue;
- MediaCodecInfo.CodecCapabilities capabilities =
- info.getCapabilitiesForType(mime);
+ MediaCodecInfo.CodecCapabilities capabilities = info.getCapabilitiesForType(mime);
return capabilities.colorFormats;
}
}
@@ -401,14 +406,25 @@ class MediaCodecBridge {
}
}
+ private boolean outputFormatHasCropValues(MediaFormat format) {
+ return format.containsKey(KEY_CROP_RIGHT) && format.containsKey(KEY_CROP_LEFT)
+ && format.containsKey(KEY_CROP_BOTTOM) && format.containsKey(KEY_CROP_TOP);
+ }
+
@CalledByNative
private int getOutputHeight() {
- return mMediaCodec.getOutputFormat().getInteger(MediaFormat.KEY_HEIGHT);
+ MediaFormat format = mMediaCodec.getOutputFormat();
+ return outputFormatHasCropValues(format)
+ ? format.getInteger(KEY_CROP_BOTTOM) - format.getInteger(KEY_CROP_TOP) + 1
+ : format.getInteger(MediaFormat.KEY_HEIGHT);
}
@CalledByNative
private int getOutputWidth() {
- return mMediaCodec.getOutputFormat().getInteger(MediaFormat.KEY_WIDTH);
+ MediaFormat format = mMediaCodec.getOutputFormat();
+ return outputFormatHasCropValues(format)
+ ? format.getInteger(KEY_CROP_RIGHT) - format.getInteger(KEY_CROP_LEFT) + 1
+ : format.getInteger(MediaFormat.KEY_WIDTH);
}
@CalledByNative