mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-16 13:59:51 +02:00
only apply color-mapping for alpha on the cropped area
This is only possible if the filtering is not VERTICAL or GRADIENT. Otherwise, we need the spatial predictors and hence need the un-visible part above crop_top row. COLOR_INDEX transform is the only transform that is not predicted from previous row. Applying the same for other transform (spatial predict, ...) is going to be more involve and use an extra temporary row. + remove ApplyInverseTransformsAlpha() (work is done directly within ExtractPalettedAlphaRows()) + change back to using filter_ instead of unfilter_func_ Change-Id: I09e57efae4a4af00bde35f21ca6e3d73b35d7d43
This commit is contained in:
@ -52,11 +52,12 @@ static int ALPHInit(ALPHDecoder* const dec, const uint8_t* data,
|
||||
const uint8_t* const alpha_data = data + ALPHA_HEADER_LEN;
|
||||
const size_t alpha_data_size = data_size - ALPHA_HEADER_LEN;
|
||||
int rsrv;
|
||||
int filter;
|
||||
VP8Io* const io = &dec->io_;
|
||||
|
||||
assert(data != NULL && output != NULL && src_io != NULL);
|
||||
|
||||
VP8FiltersInit();
|
||||
dec->output_ = output;
|
||||
dec->width_ = src_io->width;
|
||||
dec->height_ = src_io->height;
|
||||
assert(dec->width_ > 0 && dec->height_ > 0);
|
||||
@ -66,21 +67,17 @@ static int ALPHInit(ALPHDecoder* const dec, const uint8_t* data,
|
||||
}
|
||||
|
||||
dec->method_ = (data[0] >> 0) & 0x03;
|
||||
filter = (data[0] >> 2) & 0x03;
|
||||
dec->filter_ = (data[0] >> 2) & 0x03;
|
||||
dec->pre_processing_ = (data[0] >> 4) & 0x03;
|
||||
rsrv = (data[0] >> 6) & 0x03;
|
||||
if (dec->method_ < ALPHA_NO_COMPRESSION ||
|
||||
dec->method_ > ALPHA_LOSSLESS_COMPRESSION ||
|
||||
filter >= WEBP_FILTER_LAST ||
|
||||
dec->filter_ >= WEBP_FILTER_LAST ||
|
||||
dec->pre_processing_ > ALPHA_PREPROCESSED_LEVELS ||
|
||||
rsrv != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
VP8FiltersInit();
|
||||
dec->unfilter_func_ = WebPUnfilters[filter];
|
||||
dec->output_ = output;
|
||||
|
||||
// Copy the necessary parameters from src_io to io
|
||||
VP8InitIo(io);
|
||||
WebPInitCustomIo(NULL, io);
|
||||
@ -121,8 +118,9 @@ static int ALPHDecode(VP8Decoder* const dec, int row, int num_rows) {
|
||||
assert(dec->alpha_data_size_ >= ALPHA_HEADER_LEN + offset + num_pixels);
|
||||
memcpy(dec->alpha_plane_ + offset,
|
||||
dec->alpha_data_ + ALPHA_HEADER_LEN + offset, num_pixels);
|
||||
if (alph_dec->unfilter_func_ != NULL) {
|
||||
alph_dec->unfilter_func_(width, height, width, row, num_rows, output);
|
||||
if (WebPUnfilters[alph_dec->filter_] != NULL) {
|
||||
WebPUnfilters[alph_dec->filter_](width, height, width,
|
||||
row, num_rows, output);
|
||||
}
|
||||
} else { // alph_dec->method_ == ALPHA_LOSSLESS_COMPRESSION
|
||||
assert(alph_dec->vp8l_dec_ != NULL);
|
||||
|
Reference in New Issue
Block a user