cwebp: fix alpha reporting w/lossless & metadata

the incorrect bit was being extracted from the lossless bitstream header
causing the alpha flag in VP8X to be misreported. previously the
signature byte was ignored in the calculation of the offset.

since:
8ba1bf61 Stricter check for presence of alpha when writing lossless
images

BUG=webp:361

Change-Id: I7c618b5f01a37f5e4b799dee11a7949efaf88046
This commit is contained in:
James Zern 2017-10-18 12:33:30 -07:00
parent 30042faa9a
commit 68b2eab7df

View File

@ -463,8 +463,9 @@ static int WriteWebPWithMetadata(FILE* const out,
} else {
const int is_lossless = !memcmp(webp, "VP8L", kTagSize);
if (is_lossless) {
// Presence of alpha is stored in the 29th bit of VP8L data.
if (webp[kChunkHeaderSize + 3] & (1 << 5)) flags |= kAlphaFlag;
// Presence of alpha is stored in the 37th bit (29th after the
// signature) of VP8L data.
if (webp[kChunkHeaderSize + 4] & (1 << 4)) flags |= kAlphaFlag;
}
ok = ok && (fwrite(kVP8XHeader, kChunkHeaderSize, 1, out) == 1);
ok = ok && WriteLE32(out, flags);