Merge "Fix how ExifInterface creates VP8X chunks for WebP files" am: 7bd2520d4a

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2303892

Change-Id: Ib1901b38dc8f9b91b41f6841608b945d92404b47
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2022-11-22 11:42:00 +00:00
committed by Automerger Merge Worker

View File

@@ -3829,7 +3829,7 @@ public class ExifInterface {
int widthAndHeight = 0;
int width = 0;
int height = 0;
int alpha = 0;
boolean alpha = false;
// Save VP8 frame data for later
byte[] vp8Frame = new byte[3];
@@ -3864,7 +3864,7 @@ public class ExifInterface {
width = ((widthAndHeight << 18) >> 18) + 1;
height = ((widthAndHeight << 4) >> 18) + 1;
// Retrieve alpha bit
alpha = widthAndHeight & (1 << 3);
alpha = (widthAndHeight & (1 << 28)) != 0;
bytesToRead -= (1 /* VP8L signature */ + 4);
}
@@ -3872,10 +3872,12 @@ public class ExifInterface {
nonHeaderOutputStream.write(WEBP_CHUNK_TYPE_VP8X);
nonHeaderOutputStream.writeInt(WEBP_CHUNK_TYPE_VP8X_DEFAULT_LENGTH);
byte[] data = new byte[WEBP_CHUNK_TYPE_VP8X_DEFAULT_LENGTH];
// ALPHA flag
if (alpha) {
data[0] = (byte) (data[0] | (1 << 4));
}
// EXIF flag
data[0] = (byte) (data[0] | (1 << 3));
// ALPHA flag
data[0] = (byte) (data[0] | (alpha << 4));
// VP8X stores Width - 1 and Height - 1 values
width -= 1;
height -= 1;