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

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

Issue 698273003: Use MediaFormat's crop rectangle when available instead of width/height. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 28d20ffd742ef10161237c8bfda1c52ed524a143..399f355f8735a097267929ea42eb81ddb41ffda6 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);
gunsch 2014/11/05 00:05:51 note: this change was due to a presubmit error, pr
qinmin 2014/11/05 00:28:00 this line is now more than 100 chars long, what is
gunsch 2014/11/05 00:31:44 Yes, indentation was the warning. This is only 98
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698