• Home
  • Raw
  • Download

Lines Matching refs:dec

28   ALPHDecoder* const dec = (ALPHDecoder*)WebPSafeCalloc(1ULL, sizeof(*dec));  in ALPHNew()  local
29 return dec; in ALPHNew()
33 static void ALPHDelete(ALPHDecoder* const dec) { in ALPHDelete() argument
34 if (dec != NULL) { in ALPHDelete()
35 VP8LDelete(dec->vp8l_dec_); in ALPHDelete()
36 dec->vp8l_dec_ = NULL; in ALPHDelete()
37 WebPSafeFree(dec); in ALPHDelete()
48 static int ALPHInit(ALPHDecoder* const dec, const uint8_t* data, in ALPHInit() argument
55 VP8Io* const io = &dec->io_; in ALPHInit()
60 dec->output_ = output; in ALPHInit()
61 dec->width_ = src_io->width; in ALPHInit()
62 dec->height_ = src_io->height; in ALPHInit()
63 assert(dec->width_ > 0 && dec->height_ > 0); in ALPHInit()
69 dec->method_ = (data[0] >> 0) & 0x03; in ALPHInit()
70 dec->filter_ = (WEBP_FILTER_TYPE)((data[0] >> 2) & 0x03); in ALPHInit()
71 dec->pre_processing_ = (data[0] >> 4) & 0x03; in ALPHInit()
73 if (dec->method_ < ALPHA_NO_COMPRESSION || in ALPHInit()
74 dec->method_ > ALPHA_LOSSLESS_COMPRESSION || in ALPHInit()
75 dec->filter_ >= WEBP_FILTER_LAST || in ALPHInit()
76 dec->pre_processing_ > ALPHA_PREPROCESSED_LEVELS || in ALPHInit()
84 io->opaque = dec; in ALPHInit()
95 if (dec->method_ == ALPHA_NO_COMPRESSION) { in ALPHInit()
96 const size_t alpha_decoded_size = dec->width_ * dec->height_; in ALPHInit()
99 assert(dec->method_ == ALPHA_LOSSLESS_COMPRESSION); in ALPHInit()
100 ok = VP8LDecodeAlphaHeader(dec, alpha_data, alpha_data_size); in ALPHInit()
110 static int ALPHDecode(VP8Decoder* const dec, int row, int num_rows) { in ALPHDecode() argument
111 ALPHDecoder* const alph_dec = dec->alph_dec_; in ALPHDecode()
116 const uint8_t* prev_line = dec->alpha_prev_line_; in ALPHDecode()
117 const uint8_t* deltas = dec->alpha_data_ + ALPHA_HEADER_LEN + row * width; in ALPHDecode()
118 uint8_t* dst = dec->alpha_plane_ + row * width; in ALPHDecode()
119 assert(deltas <= &dec->alpha_data_[dec->alpha_data_size_]); in ALPHDecode()
136 dec->alpha_prev_line_ = prev_line; in ALPHDecode()
145 dec->is_alpha_decoded_ = 1; in ALPHDecode()
150 static int AllocateAlphaPlane(VP8Decoder* const dec, const VP8Io* const io) { in AllocateAlphaPlane() argument
154 assert(dec->alpha_plane_mem_ == NULL); in AllocateAlphaPlane()
155 dec->alpha_plane_mem_ = in AllocateAlphaPlane()
156 (uint8_t*)WebPSafeMalloc(alpha_size, sizeof(*dec->alpha_plane_)); in AllocateAlphaPlane()
157 if (dec->alpha_plane_mem_ == NULL) { in AllocateAlphaPlane()
160 dec->alpha_plane_ = dec->alpha_plane_mem_; in AllocateAlphaPlane()
161 dec->alpha_prev_line_ = NULL; in AllocateAlphaPlane()
165 void WebPDeallocateAlphaMemory(VP8Decoder* const dec) { in WebPDeallocateAlphaMemory() argument
166 assert(dec != NULL); in WebPDeallocateAlphaMemory()
167 WebPSafeFree(dec->alpha_plane_mem_); in WebPDeallocateAlphaMemory()
168 dec->alpha_plane_mem_ = NULL; in WebPDeallocateAlphaMemory()
169 dec->alpha_plane_ = NULL; in WebPDeallocateAlphaMemory()
170 ALPHDelete(dec->alph_dec_); in WebPDeallocateAlphaMemory()
171 dec->alph_dec_ = NULL; in WebPDeallocateAlphaMemory()
177 const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec, in VP8DecompressAlphaRows() argument
183 assert(dec != NULL && io != NULL); in VP8DecompressAlphaRows()
189 if (!dec->is_alpha_decoded_) { in VP8DecompressAlphaRows()
190 if (dec->alph_dec_ == NULL) { // Initialize decoder. in VP8DecompressAlphaRows()
191 dec->alph_dec_ = ALPHNew(); in VP8DecompressAlphaRows()
192 if (dec->alph_dec_ == NULL) return NULL; in VP8DecompressAlphaRows()
193 if (!AllocateAlphaPlane(dec, io)) goto Error; in VP8DecompressAlphaRows()
194 if (!ALPHInit(dec->alph_dec_, dec->alpha_data_, dec->alpha_data_size_, in VP8DecompressAlphaRows()
195 io, dec->alpha_plane_)) { in VP8DecompressAlphaRows()
199 if (dec->alph_dec_->pre_processing_ != ALPHA_PREPROCESSED_LEVELS) { in VP8DecompressAlphaRows()
200 dec->alpha_dithering_ = 0; // disable dithering in VP8DecompressAlphaRows()
206 assert(dec->alph_dec_ != NULL); in VP8DecompressAlphaRows()
208 if (!ALPHDecode(dec, row, num_rows)) goto Error; in VP8DecompressAlphaRows()
210 if (dec->is_alpha_decoded_) { // finished? in VP8DecompressAlphaRows()
211 ALPHDelete(dec->alph_dec_); in VP8DecompressAlphaRows()
212 dec->alph_dec_ = NULL; in VP8DecompressAlphaRows()
213 if (dec->alpha_dithering_ > 0) { in VP8DecompressAlphaRows()
214 uint8_t* const alpha = dec->alpha_plane_ + io->crop_top * width in VP8DecompressAlphaRows()
219 width, dec->alpha_dithering_)) { in VP8DecompressAlphaRows()
227 return dec->alpha_plane_ + row * width; in VP8DecompressAlphaRows()
230 WebPDeallocateAlphaMemory(dec); in VP8DecompressAlphaRows()