Merge "Fix how ExifInterface creates VP8X chunks for WebP files"

This commit is contained in:
Treehugger Robot
2022-11-22 11:38:23 +00:00
committed by Gerrit Code Review

View File

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