From 68b2eab7df55ab6cc8a84559538edfaf1b3ea24f Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 18 Oct 2017 12:33:30 -0700 Subject: [PATCH] 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 --- examples/cwebp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/cwebp.c b/examples/cwebp.c index 61350b9d..ff8d3ea2 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -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);