mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-25 13:18:22 +01:00
RGBA4444: harmonize lossless/lossy alpha values
lossy was rounding with a bias toward opaque: [232+, 8] -> [15, 1] now both paths use the range: [240+, 16] -> [15, 1] Change-Id: I3da2063b4959b9e9f45bae09e640acc1f43470c5
This commit is contained in:
parent
681cb30ad2
commit
fe1958f17d
@ -261,7 +261,7 @@ static int EmitAlphaRGBA4444(const VP8Io* const io, WebPDecParams* const p) {
|
||||
for (j = 0; j < num_rows; ++j) {
|
||||
for (i = 0; i < mb_w; ++i) {
|
||||
// Fill in the alpha value (converted to 4 bits).
|
||||
const uint32_t alpha_value = VP8Clip4Bits(alpha[i]);
|
||||
const uint32_t alpha_value = alpha[i] >> 4;
|
||||
alpha_dst[2 * i] = (alpha_dst[2 * i] & 0xf0) | alpha_value;
|
||||
alpha_mask &= alpha_value;
|
||||
}
|
||||
@ -453,7 +453,7 @@ static int ExportAlphaRGBA4444(WebPDecParams* const p, int y_pos) {
|
||||
WebPRescalerExportRow(&p->scaler_a);
|
||||
for (i = 0; i < width; ++i) {
|
||||
// Fill in the alpha value (converted to 4 bits).
|
||||
const uint32_t alpha_value = VP8Clip4Bits(p->scaler_a.dst[i]);
|
||||
const uint32_t alpha_value = p->scaler_a.dst[i] >> 4;
|
||||
alpha_dst[2 * i] = (alpha_dst[2 * i] & 0xf0) | alpha_value;
|
||||
alpha_mask &= alpha_value;
|
||||
}
|
||||
|
@ -90,11 +90,6 @@ static WEBP_INLINE void VP8YuvToRgba(uint8_t y, uint8_t u, uint8_t v,
|
||||
rgba[3] = 0xff;
|
||||
}
|
||||
|
||||
static WEBP_INLINE uint32_t VP8Clip4Bits(uint8_t c) {
|
||||
const uint32_t v = (c + 8) >> 4;
|
||||
return (v > 15) ? 15 : v;
|
||||
}
|
||||
|
||||
// Must be called before everything, to initialize the tables.
|
||||
void VP8YUVInit(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user