diff --git a/core/api/current.txt b/core/api/current.txt index b5493a3fa8c75..0652ec0afd6bd 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -22195,6 +22195,10 @@ package android.media { field public static final String KEY_COLOR_TRANSFER_REQUEST = "color-transfer-request"; field public static final String KEY_COMPLEXITY = "complexity"; field public static final String KEY_CREATE_INPUT_SURFACE_SUSPENDED = "create-input-buffers-suspended"; + field public static final String KEY_CROP_BOTTOM = "crop-bottom"; + field public static final String KEY_CROP_LEFT = "crop-left"; + field public static final String KEY_CROP_RIGHT = "crop-right"; + field public static final String KEY_CROP_TOP = "crop-top"; field public static final String KEY_DURATION = "durationUs"; field public static final String KEY_ENCODER_DELAY = "encoder-delay"; field public static final String KEY_ENCODER_PADDING = "encoder-padding"; diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java index 4563259c31f28..e39914db4d0ff 100644 --- a/media/java/android/media/MediaCodec.java +++ b/media/java/android/media/MediaCodec.java @@ -223,19 +223,19 @@ import java.util.concurrent.locks.ReentrantLock;
MediaFormat format = decoder.getOutputFormat(…);
int width = format.getInteger(MediaFormat.KEY_WIDTH);
- if (format.containsKey("crop-left") && format.containsKey("crop-right")) {
- width = format.getInteger("crop-right") + 1 - format.getInteger("crop-left");
+ if (format.containsKey(MediaFormat.KEY_CROP_LEFT)
+ && format.containsKey(MediaFormat.KEY_CROP_RIGHT)) {
+ width = format.getInteger(MediaFormat.KEY_CROP_RIGHT) + 1
+ - format.getInteger(MediaFormat.KEY_CROP_LEFT);
}
int height = format.getInteger(MediaFormat.KEY_HEIGHT);
- if (format.containsKey("crop-top") && format.containsKey("crop-bottom")) {
- height = format.getInteger("crop-bottom") + 1 - format.getInteger("crop-top");
+ if (format.containsKey(MediaFormat.KEY_CROP_TOP)
+ && format.containsKey(MediaFormat.KEY_CROP_BOTTOM)) {
+ height = format.getInteger(MediaFormat.KEY_CROP_BOTTOM) + 1
+ - format.getInteger(MediaFormat.KEY_CROP_TOP);
}
diff --git a/media/java/android/media/MediaFormat.java b/media/java/android/media/MediaFormat.java index 4956dbefa240b..de193f5f05787 100644 --- a/media/java/android/media/MediaFormat.java +++ b/media/java/android/media/MediaFormat.java @@ -358,6 +358,42 @@ public final class MediaFormat { */ public static final String KEY_HEIGHT = "height"; + /** + * A key describing the bottom-coordinate (y) of the crop rectangle. + * This is the bottom-most row included in the crop frame, + * where row indices start at 0. + * Additional information on the crop rectangle semantics can be found at + * {@link android.media.MediaCodec}. + */ + public static final String KEY_CROP_BOTTOM = "crop-bottom"; + + /** + * A key describing the left-coordinate (x) of the crop rectangle. + * This is the left-most column included in the crop frame, + * where column indices start at 0. + * Additional information on the crop rectangle semantics can be found at + * {@link android.media.MediaCodec}. + */ + public static final String KEY_CROP_LEFT = "crop-left"; + + /** + * A key describing the right-coordinate (x) of the crop rectangle. + * This is the right-most column included in the crop frame, + * where column indices start at 0. + * Additional information on the crop rectangle semantics can be found at + * {@link android.media.MediaCodec}. + */ + public static final String KEY_CROP_RIGHT = "crop-right"; + + /** + * A key describing the top-coordinate (y) of the crop rectangle. + * This is the top-most row included in the crop frame, + * where row indices start at 0. + * Additional information on the crop rectangle semantics can be found at + * {@link android.media.MediaCodec}. + */ + public static final String KEY_CROP_TOP = "crop-top"; + /** * A key describing the maximum expected width of the content in a video * decoder format, in case there are resolution changes in the video content.