diff options
Diffstat (limited to 'media')
| -rw-r--r-- | media/java/android/media/Image.java | 6 | ||||
| -rw-r--r-- | media/java/android/media/MediaCodec.java | 18 |
2 files changed, 14 insertions, 10 deletions
diff --git a/media/java/android/media/Image.java b/media/java/android/media/Image.java index 522e45d..0d6b91a 100644 --- a/media/java/android/media/Image.java +++ b/media/java/android/media/Image.java @@ -146,8 +146,10 @@ public abstract class Image implements AutoCloseable { * using coordinates in the largest-resolution plane. */ public void setCropRect(Rect cropRect) { - cropRect = new Rect(cropRect); // make a copy - cropRect.intersect(0, 0, getWidth(), getHeight()); + if (cropRect != null) { + cropRect = new Rect(cropRect); // make a copy + cropRect.intersect(0, 0, getWidth(), getHeight()); + } mCropRect = cropRect; } diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java index 420510a..8985b52 100644 --- a/media/java/android/media/MediaCodec.java +++ b/media/java/android/media/MediaCodec.java @@ -1778,21 +1778,17 @@ final public class MediaCodec { mIsValid = true; mIsReadOnly = buffer.isReadOnly(); mBuffer = buffer.duplicate(); - if (cropRect != null) { - cropRect.offset(-xOffset, -yOffset); - } - super.setCropRect(cropRect); // save offsets and info mXOffset = xOffset; mYOffset = yOffset; mInfo = info; - // read media-info. the size of media info can be 80 or 156 depending on + // read media-info. the size of media info can be 80 or 156/160 depending on // whether it was created on a 32- or 64-bit process. See MediaImage - if (info.remaining() == 80 || info.remaining() == 156) { - boolean sizeIsLong = info.remaining() == 156; - int type = info.getInt(); + if (info.remaining() == 80 || info.remaining() == 156 || info.remaining() == 160) { + boolean sizeIsLong = info.remaining() != 80; + int type = readInt(info, info.remaining() == 160); if (type != TYPE_YUV) { throw new UnsupportedOperationException("unsupported type: " + type); } @@ -1833,6 +1829,12 @@ final public class MediaCodec { throw new UnsupportedOperationException( "unsupported info length: " + info.remaining()); } + + if (cropRect == null) { + cropRect = new Rect(0, 0, mWidth, mHeight); + } + cropRect.offset(-xOffset, -yOffset); + super.setCropRect(cropRect); } private class MediaPlane extends Plane { |
