Lines Matching refs:dec

27   ALPHDecoder* const dec = (ALPHDecoder*)WebPSafeCalloc(1ULL, sizeof(*dec));
28 return dec;
31 void ALPHDelete(ALPHDecoder* const dec) {
32 if (dec != NULL) {
33 VP8LDelete(dec->vp8l_dec_);
34 dec->vp8l_dec_ = NULL;
35 WebPSafeFree(dec);
46 static int ALPHInit(ALPHDecoder* const dec, const uint8_t* data,
56 dec->width_ = width;
57 dec->height_ = height;
63 dec->method_ = (data[0] >> 0) & 0x03;
64 dec->filter_ = (data[0] >> 2) & 0x03;
65 dec->pre_processing_ = (data[0] >> 4) & 0x03;
67 if (dec->method_ < ALPHA_NO_COMPRESSION ||
68 dec->method_ > ALPHA_LOSSLESS_COMPRESSION ||
69 dec->filter_ >= WEBP_FILTER_LAST ||
70 dec->pre_processing_ > ALPHA_PREPROCESSED_LEVELS ||
75 if (dec->method_ == ALPHA_NO_COMPRESSION) {
76 const size_t alpha_decoded_size = dec->width_ * dec->height_;
79 assert(dec->method_ == ALPHA_LOSSLESS_COMPRESSION);
80 ok = VP8LDecodeAlphaHeader(dec, alpha_data, alpha_data_size, output);
90 static int ALPHDecode(VP8Decoder* const dec, int row, int num_rows) {
91 ALPHDecoder* const alph_dec = dec->alph_dec_;
95 uint8_t* const output = dec->alpha_plane_;
99 assert(dec->alpha_data_size_ >= ALPHA_HEADER_LEN + offset + num_pixels);
100 memcpy(dec->alpha_plane_ + offset,
101 dec->alpha_data_ + ALPHA_HEADER_LEN + offset, num_pixels);
113 if (row + num_rows == dec->pic_hdr_.height_) {
114 dec->is_alpha_decoded_ = 1;
122 const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec,
124 const int width = dec->pic_hdr_.width_;
125 const int height = dec->pic_hdr_.height_;
133 assert(dec->alpha_plane_ != NULL);
134 dec->alph_dec_ = ALPHNew();
135 if (dec->alph_dec_ == NULL) return NULL;
136 if (!ALPHInit(dec->alph_dec_, dec->alpha_data_, dec->alpha_data_size_,
137 width, height, dec->alpha_plane_)) {
138 ALPHDelete(dec->alph_dec_);
139 dec->alph_dec_ = NULL;
143 if (dec->alph_dec_->pre_processing_ != ALPHA_PREPROCESSED_LEVELS) {
144 dec->alpha_dithering_ = 0; // disable dithering
150 if (!dec->is_alpha_decoded_) {
152 assert(dec->alph_dec_ != NULL);
153 ok = ALPHDecode(dec, row, num_rows);
154 if (ok && dec->alpha_dithering_ > 0) {
155 ok = WebPDequantizeLevels(dec->alpha_plane_, width, height,
156 dec->alpha_dithering_);
158 if (!ok || dec->is_alpha_decoded_) {
159 ALPHDelete(dec->alph_dec_);
160 dec->alph_dec_ = NULL;
166 return dec->alpha_plane_ + row * width;