• Home
  • Raw
  • Download

Lines Matching refs:dec

106                              VP8LDecoder* const dec,
249 VP8LDecoder* const dec, const int* const code_length_code_lengths, in ReadHuffmanCodeLengths() argument
252 VP8LBitReader* const br = &dec->br_; in ReadHuffmanCodeLengths()
303 if (!ok) dec->status_ = VP8_STATUS_BITSTREAM_ERROR; in ReadHuffmanCodeLengths()
309 static int ReadHuffmanCode(int alphabet_size, VP8LDecoder* const dec, in ReadHuffmanCode() argument
313 VP8LBitReader* const br = &dec->br_; in ReadHuffmanCode()
335 dec->status_ = VP8_STATUS_BITSTREAM_ERROR; in ReadHuffmanCode()
342 ok = ReadHuffmanCodeLengths(dec, code_length_code_lengths, alphabet_size, in ReadHuffmanCode()
352 dec->status_ = VP8_STATUS_BITSTREAM_ERROR; in ReadHuffmanCode()
358 static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize, in ReadHuffmanCodes() argument
361 VP8LBitReader* const br = &dec->br_; in ReadHuffmanCodes()
362 VP8LMetadata* const hdr = &dec->hdr_; in ReadHuffmanCodes()
378 if (!DecodeImageStream(huffman_xsize, huffman_ysize, 0, dec, in ReadHuffmanCodes()
413 dec->status_ = VP8_STATUS_OUT_OF_MEMORY; in ReadHuffmanCodes()
431 size = ReadHuffmanCode(alphabet_size, dec, code_lengths, next); in ReadHuffmanCodes()
488 static int AllocateAndInitRescaler(VP8LDecoder* const dec, VP8Io* const io) { in AllocateAndInitRescaler() argument
498 const uint64_t memory_size = sizeof(*dec->rescaler) + in AllocateAndInitRescaler()
503 dec->status_ = VP8_STATUS_OUT_OF_MEMORY; in AllocateAndInitRescaler()
506 assert(dec->rescaler_memory == NULL); in AllocateAndInitRescaler()
507 dec->rescaler_memory = memory; in AllocateAndInitRescaler()
509 dec->rescaler = (WebPRescaler*)memory; in AllocateAndInitRescaler()
510 memory += sizeof(*dec->rescaler); in AllocateAndInitRescaler()
515 WebPRescalerInit(dec->rescaler, in_width, in_height, (uint8_t*)scaled_data, in AllocateAndInitRescaler()
540 static int EmitRescaledRowsRGBA(const VP8LDecoder* const dec, in EmitRescaledRowsRGBA() argument
543 const WEBP_CSP_MODE colorspace = dec->output_->colorspace; in EmitRescaledRowsRGBA()
550 const int needed_lines = WebPRescaleNeededLines(dec->rescaler, lines_left); in EmitRescaledRowsRGBA()
554 dec->rescaler->src_width, needed_lines, 0); in EmitRescaledRowsRGBA()
556 WebPRescalerImport(dec->rescaler, lines_left, row_in, in_stride); in EmitRescaledRowsRGBA()
559 num_lines_out += Export(dec->rescaler, colorspace, out_stride, row_out); in EmitRescaledRowsRGBA()
608 static int ExportYUVA(const VP8LDecoder* const dec, int y_pos) { in ExportYUVA() argument
609 WebPRescaler* const rescaler = dec->rescaler; in ExportYUVA()
616 ConvertToYUVA(src, dst_width, y_pos, dec->output_); in ExportYUVA()
623 static int EmitRescaledRowsYUVA(const VP8LDecoder* const dec, in EmitRescaledRowsYUVA() argument
626 int y_pos = dec->last_out_row_; in EmitRescaledRowsYUVA()
629 const int needed_lines = WebPRescaleNeededLines(dec->rescaler, lines_left); in EmitRescaledRowsYUVA()
631 WebPMultARGBRows(in, in_stride, dec->rescaler->src_width, needed_lines, 0); in EmitRescaledRowsYUVA()
633 WebPRescalerImport(dec->rescaler, lines_left, in, in_stride); in EmitRescaledRowsYUVA()
637 y_pos += ExportYUVA(dec, y_pos); in EmitRescaledRowsYUVA()
642 static int EmitRowsYUVA(const VP8LDecoder* const dec, in EmitRowsYUVA() argument
645 int y_pos = dec->last_out_row_; in EmitRowsYUVA()
647 ConvertToYUVA((const uint32_t*)in, mb_w, y_pos, dec->output_); in EmitRowsYUVA()
703 typedef void (*ProcessRowsFunc)(VP8LDecoder* const dec, int row);
705 static void ApplyInverseTransforms(VP8LDecoder* const dec, int num_rows, in ApplyInverseTransforms() argument
707 int n = dec->next_transform_; in ApplyInverseTransforms()
708 const int cache_pixs = dec->width_ * num_rows; in ApplyInverseTransforms()
709 const int start_row = dec->last_row_; in ApplyInverseTransforms()
712 uint32_t* const rows_out = dec->argb_cache_; in ApplyInverseTransforms()
716 VP8LTransform* const transform = &dec->transforms_[n]; in ApplyInverseTransforms()
728 static void ProcessRows(VP8LDecoder* const dec, int row) { in ProcessRows() argument
729 const uint32_t* const rows = dec->pixels_ + dec->width_ * dec->last_row_; in ProcessRows()
730 const int num_rows = row - dec->last_row_; in ProcessRows()
732 assert(row <= dec->io_->crop_bottom); in ProcessRows()
737 VP8Io* const io = dec->io_; in ProcessRows()
738 uint8_t* rows_data = (uint8_t*)dec->argb_cache_; in ProcessRows()
741 ApplyInverseTransforms(dec, num_rows, rows); in ProcessRows()
742 if (!SetCropWindow(io, dec->last_row_, row, &rows_data, in_stride)) { in ProcessRows()
745 const WebPDecBuffer* const output = dec->output_; in ProcessRows()
748 uint8_t* const rgba = buf->rgba + dec->last_out_row_ * buf->stride; in ProcessRows()
750 EmitRescaledRowsRGBA(dec, rows_data, in_stride, io->mb_h, in ProcessRows()
755 dec->last_out_row_ += num_rows_out; in ProcessRows()
757 dec->last_out_row_ = io->use_scaling ? in ProcessRows()
758 EmitRescaledRowsYUVA(dec, rows_data, in_stride, io->mb_h) : in ProcessRows()
759 EmitRowsYUVA(dec, rows_data, in_stride, io->mb_w, io->mb_h); in ProcessRows()
761 assert(dec->last_out_row_ <= output->height); in ProcessRows()
766 dec->last_row_ = row; in ProcessRows()
767 assert(dec->last_row_ <= dec->height_); in ProcessRows()
802 static void ExtractPalettedAlphaRows(VP8LDecoder* const dec, int last_row) { in ExtractPalettedAlphaRows() argument
805 ALPHDecoder* const alph_dec = (ALPHDecoder*)dec->io_->opaque; in ExtractPalettedAlphaRows()
808 alph_dec->filter_ == WEBP_FILTER_HORIZONTAL) ? dec->io_->crop_top in ExtractPalettedAlphaRows()
809 : dec->last_row_; in ExtractPalettedAlphaRows()
810 const int first_row = (dec->last_row_ < top_row) ? top_row : dec->last_row_; in ExtractPalettedAlphaRows()
811 assert(last_row <= dec->io_->crop_bottom); in ExtractPalettedAlphaRows()
814 const int width = dec->io_->width; in ExtractPalettedAlphaRows()
817 (uint8_t*)dec->pixels_ + dec->width_ * first_row; in ExtractPalettedAlphaRows()
818 VP8LTransform* const transform = &dec->transforms_[0]; in ExtractPalettedAlphaRows()
819 assert(dec->next_transform_ == 1); in ExtractPalettedAlphaRows()
825 dec->last_row_ = dec->last_out_row_ = last_row; in ExtractPalettedAlphaRows()
947 static int DecodeAlphaData(VP8LDecoder* const dec, uint8_t* const data, in DecodeAlphaData() argument
950 int row = dec->last_pixel_ / width; in DecodeAlphaData()
951 int col = dec->last_pixel_ % width; in DecodeAlphaData()
952 VP8LBitReader* const br = &dec->br_; in DecodeAlphaData()
953 VP8LMetadata* const hdr = &dec->hdr_; in DecodeAlphaData()
954 int pos = dec->last_pixel_; // current position in DecodeAlphaData()
982 ExtractPalettedAlphaRows(dec, row); in DecodeAlphaData()
1005 ExtractPalettedAlphaRows(dec, row); in DecodeAlphaData()
1018 ExtractPalettedAlphaRows(dec, row > last_row ? last_row : row); in DecodeAlphaData()
1023 dec->status_ = br->eos_ ? VP8_STATUS_SUSPENDED in DecodeAlphaData()
1026 dec->last_pixel_ = pos; in DecodeAlphaData()
1031 static void SaveState(VP8LDecoder* const dec, int last_pixel) { in SaveState() argument
1032 assert(dec->incremental_); in SaveState()
1033 dec->saved_br_ = dec->br_; in SaveState()
1034 dec->saved_last_pixel_ = last_pixel; in SaveState()
1035 if (dec->hdr_.color_cache_size_ > 0) { in SaveState()
1036 VP8LColorCacheCopy(&dec->hdr_.color_cache_, &dec->hdr_.saved_color_cache_); in SaveState()
1040 static void RestoreState(VP8LDecoder* const dec) { in RestoreState() argument
1041 assert(dec->br_.eos_); in RestoreState()
1042 dec->status_ = VP8_STATUS_SUSPENDED; in RestoreState()
1043 dec->br_ = dec->saved_br_; in RestoreState()
1044 dec->last_pixel_ = dec->saved_last_pixel_; in RestoreState()
1045 if (dec->hdr_.color_cache_size_ > 0) { in RestoreState()
1046 VP8LColorCacheCopy(&dec->hdr_.saved_color_cache_, &dec->hdr_.color_cache_); in RestoreState()
1051 static int DecodeImageData(VP8LDecoder* const dec, uint32_t* const data, in DecodeImageData() argument
1054 int row = dec->last_pixel_ / width; in DecodeImageData()
1055 int col = dec->last_pixel_ % width; in DecodeImageData()
1056 VP8LBitReader* const br = &dec->br_; in DecodeImageData()
1057 VP8LMetadata* const hdr = &dec->hdr_; in DecodeImageData()
1058 uint32_t* src = data + dec->last_pixel_; in DecodeImageData()
1064 int next_sync_row = dec->incremental_ ? row : 1 << 24; in DecodeImageData()
1070 assert(dec->last_row_ < last_row); in DecodeImageData()
1076 SaveState(dec, (int)(src - data)); in DecodeImageData()
1118 process_func(dec, row); in DecodeImageData()
1148 process_func(dec, row); in DecodeImageData()
1175 if (dec->incremental_ && br->eos_ && src < src_end) { in DecodeImageData()
1176 RestoreState(dec); in DecodeImageData()
1180 process_func(dec, row > last_row ? last_row : row); in DecodeImageData()
1182 dec->status_ = VP8_STATUS_OK; in DecodeImageData()
1183 dec->last_pixel_ = (int)(src - data); // end-of-scan marker in DecodeImageData()
1192 dec->status_ = VP8_STATUS_BITSTREAM_ERROR; in DecodeImageData()
1232 VP8LDecoder* const dec) { in ReadTransform() argument
1234 VP8LBitReader* const br = &dec->br_; in ReadTransform()
1235 VP8LTransform* transform = &dec->transforms_[dec->next_transform_]; in ReadTransform()
1240 if (dec->transforms_seen_ & (1U << type)) { in ReadTransform()
1243 dec->transforms_seen_ |= (1U << type); in ReadTransform()
1249 ++dec->next_transform_; in ReadTransform()
1250 assert(dec->next_transform_ <= NUM_TRANSFORMS); in ReadTransform()
1260 0, dec, &transform->data_); in ReadTransform()
1270 ok = DecodeImageStream(num_colors, 1, 0, dec, &transform->data_); in ReadTransform()
1307 VP8LDecoder* const dec = (VP8LDecoder*)WebPSafeCalloc(1ULL, sizeof(*dec)); in VP8LNew() local
1308 if (dec == NULL) return NULL; in VP8LNew()
1309 dec->status_ = VP8_STATUS_OK; in VP8LNew()
1310 dec->state_ = READ_DIM; in VP8LNew()
1314 return dec; in VP8LNew()
1317 void VP8LClear(VP8LDecoder* const dec) { in VP8LClear() argument
1319 if (dec == NULL) return; in VP8LClear()
1320 ClearMetadata(&dec->hdr_); in VP8LClear()
1322 WebPSafeFree(dec->pixels_); in VP8LClear()
1323 dec->pixels_ = NULL; in VP8LClear()
1324 for (i = 0; i < dec->next_transform_; ++i) { in VP8LClear()
1325 ClearTransform(&dec->transforms_[i]); in VP8LClear()
1327 dec->next_transform_ = 0; in VP8LClear()
1328 dec->transforms_seen_ = 0; in VP8LClear()
1330 WebPSafeFree(dec->rescaler_memory); in VP8LClear()
1331 dec->rescaler_memory = NULL; in VP8LClear()
1333 dec->output_ = NULL; // leave no trace behind in VP8LClear()
1336 void VP8LDelete(VP8LDecoder* const dec) { in VP8LDelete() argument
1337 if (dec != NULL) { in VP8LDelete()
1338 VP8LClear(dec); in VP8LDelete()
1339 WebPSafeFree(dec); in VP8LDelete()
1343 static void UpdateDecoder(VP8LDecoder* const dec, int width, int height) { in UpdateDecoder() argument
1344 VP8LMetadata* const hdr = &dec->hdr_; in UpdateDecoder()
1346 dec->width_ = width; in UpdateDecoder()
1347 dec->height_ = height; in UpdateDecoder()
1355 VP8LDecoder* const dec, in DecodeImageStream() argument
1360 VP8LBitReader* const br = &dec->br_; in DecodeImageStream()
1361 VP8LMetadata* const hdr = &dec->hdr_; in DecodeImageStream()
1368 ok = ReadTransform(&transform_xsize, &transform_ysize, dec); in DecodeImageStream()
1377 dec->status_ = VP8_STATUS_BITSTREAM_ERROR; in DecodeImageStream()
1383 ok = ok && ReadHuffmanCodes(dec, transform_xsize, transform_ysize, in DecodeImageStream()
1386 dec->status_ = VP8_STATUS_BITSTREAM_ERROR; in DecodeImageStream()
1394 dec->status_ = VP8_STATUS_OUT_OF_MEMORY; in DecodeImageStream()
1401 UpdateDecoder(dec, transform_xsize, transform_ysize); in DecodeImageStream()
1404 dec->state_ = READ_HDR; in DecodeImageStream()
1412 dec->status_ = VP8_STATUS_OUT_OF_MEMORY; in DecodeImageStream()
1419 ok = DecodeImageData(dec, data, transform_xsize, transform_ysize, in DecodeImageStream()
1436 dec->last_pixel_ = 0; // Reset for future DECODE_DATA_FUNC() calls. in DecodeImageStream()
1444 static int AllocateInternalBuffers32b(VP8LDecoder* const dec, int final_width) { in AllocateInternalBuffers32b() argument
1445 const uint64_t num_pixels = (uint64_t)dec->width_ * dec->height_; in AllocateInternalBuffers32b()
1454 assert(dec->width_ <= final_width); in AllocateInternalBuffers32b()
1455 dec->pixels_ = (uint32_t*)WebPSafeMalloc(total_num_pixels, sizeof(uint32_t)); in AllocateInternalBuffers32b()
1456 if (dec->pixels_ == NULL) { in AllocateInternalBuffers32b()
1457 dec->argb_cache_ = NULL; // for sanity check in AllocateInternalBuffers32b()
1458 dec->status_ = VP8_STATUS_OUT_OF_MEMORY; in AllocateInternalBuffers32b()
1461 dec->argb_cache_ = dec->pixels_ + num_pixels + cache_top_pixels; in AllocateInternalBuffers32b()
1465 static int AllocateInternalBuffers8b(VP8LDecoder* const dec) { in AllocateInternalBuffers8b() argument
1466 const uint64_t total_num_pixels = (uint64_t)dec->width_ * dec->height_; in AllocateInternalBuffers8b()
1467 dec->argb_cache_ = NULL; // for sanity check in AllocateInternalBuffers8b()
1468 dec->pixels_ = (uint32_t*)WebPSafeMalloc(total_num_pixels, sizeof(uint8_t)); in AllocateInternalBuffers8b()
1469 if (dec->pixels_ == NULL) { in AllocateInternalBuffers8b()
1470 dec->status_ = VP8_STATUS_OUT_OF_MEMORY; in AllocateInternalBuffers8b()
1479 static void ExtractAlphaRows(VP8LDecoder* const dec, int last_row) { in ExtractAlphaRows() argument
1480 int cur_row = dec->last_row_; in ExtractAlphaRows()
1482 const uint32_t* in = dec->pixels_ + dec->width_ * cur_row; in ExtractAlphaRows()
1484 assert(last_row <= dec->io_->crop_bottom); in ExtractAlphaRows()
1489 ALPHDecoder* const alph_dec = (ALPHDecoder*)dec->io_->opaque; in ExtractAlphaRows()
1491 const int width = dec->io_->width; // the final width (!= dec->width_) in ExtractAlphaRows()
1494 const uint32_t* const src = dec->argb_cache_; in ExtractAlphaRows()
1495 ApplyInverseTransforms(dec, num_rows_to_process, in); in ExtractAlphaRows()
1500 in += num_rows_to_process * dec->width_; in ExtractAlphaRows()
1504 dec->last_row_ = dec->last_out_row_ = last_row; in ExtractAlphaRows()
1510 VP8LDecoder* dec = VP8LNew(); in VP8LDecodeAlphaHeader() local
1512 if (dec == NULL) return 0; in VP8LDecodeAlphaHeader()
1515 alph_dec->vp8l_dec_ = dec; in VP8LDecodeAlphaHeader()
1517 dec->width_ = alph_dec->width_; in VP8LDecodeAlphaHeader()
1518 dec->height_ = alph_dec->height_; in VP8LDecodeAlphaHeader()
1519 dec->io_ = &alph_dec->io_; in VP8LDecodeAlphaHeader()
1520 dec->io_->opaque = alph_dec; in VP8LDecodeAlphaHeader()
1521 dec->io_->width = alph_dec->width_; in VP8LDecodeAlphaHeader()
1522 dec->io_->height = alph_dec->height_; in VP8LDecodeAlphaHeader()
1524 dec->status_ = VP8_STATUS_OK; in VP8LDecodeAlphaHeader()
1525 VP8LInitBitReader(&dec->br_, data, data_size); in VP8LDecodeAlphaHeader()
1527 if (!DecodeImageStream(alph_dec->width_, alph_dec->height_, 1, dec, NULL)) { in VP8LDecodeAlphaHeader()
1534 if (dec->next_transform_ == 1 && in VP8LDecodeAlphaHeader()
1535 dec->transforms_[0].type_ == COLOR_INDEXING_TRANSFORM && in VP8LDecodeAlphaHeader()
1536 Is8bOptimizable(&dec->hdr_)) { in VP8LDecodeAlphaHeader()
1538 ok = AllocateInternalBuffers8b(dec); in VP8LDecodeAlphaHeader()
1542 ok = AllocateInternalBuffers32b(dec, alph_dec->width_); in VP8LDecodeAlphaHeader()
1556 VP8LDecoder* const dec = alph_dec->vp8l_dec_; in VP8LDecodeAlphaImageStream() local
1557 assert(dec != NULL); in VP8LDecodeAlphaImageStream()
1558 assert(last_row <= dec->height_); in VP8LDecodeAlphaImageStream()
1560 if (dec->last_row_ >= last_row) { in VP8LDecodeAlphaImageStream()
1568 DecodeAlphaData(dec, (uint8_t*)dec->pixels_, dec->width_, dec->height_, in VP8LDecodeAlphaImageStream()
1570 DecodeImageData(dec, dec->pixels_, dec->width_, dec->height_, in VP8LDecodeAlphaImageStream()
1576 int VP8LDecodeHeader(VP8LDecoder* const dec, VP8Io* const io) { in VP8LDecodeHeader() argument
1579 if (dec == NULL) return 0; in VP8LDecodeHeader()
1581 dec->status_ = VP8_STATUS_INVALID_PARAM; in VP8LDecodeHeader()
1585 dec->io_ = io; in VP8LDecodeHeader()
1586 dec->status_ = VP8_STATUS_OK; in VP8LDecodeHeader()
1587 VP8LInitBitReader(&dec->br_, io->data, io->data_size); in VP8LDecodeHeader()
1588 if (!ReadImageInfo(&dec->br_, &width, &height, &has_alpha)) { in VP8LDecodeHeader()
1589 dec->status_ = VP8_STATUS_BITSTREAM_ERROR; in VP8LDecodeHeader()
1592 dec->state_ = READ_DIM; in VP8LDecodeHeader()
1596 if (!DecodeImageStream(width, height, 1, dec, NULL)) goto Error; in VP8LDecodeHeader()
1600 VP8LClear(dec); in VP8LDecodeHeader()
1601 assert(dec->status_ != VP8_STATUS_OK); in VP8LDecodeHeader()
1605 int VP8LDecodeImage(VP8LDecoder* const dec) { in VP8LDecodeImage() argument
1610 if (dec == NULL) return 0; in VP8LDecodeImage()
1612 assert(dec->hdr_.huffman_tables_ != NULL); in VP8LDecodeImage()
1613 assert(dec->hdr_.htree_groups_ != NULL); in VP8LDecodeImage()
1614 assert(dec->hdr_.num_htree_groups_ > 0); in VP8LDecodeImage()
1616 io = dec->io_; in VP8LDecodeImage()
1622 if (dec->state_ != READ_DATA) { in VP8LDecodeImage()
1623 dec->output_ = params->output; in VP8LDecodeImage()
1624 assert(dec->output_ != NULL); in VP8LDecodeImage()
1627 dec->status_ = VP8_STATUS_INVALID_PARAM; in VP8LDecodeImage()
1631 if (!AllocateInternalBuffers32b(dec, io->width)) goto Err; in VP8LDecodeImage()
1633 if (io->use_scaling && !AllocateAndInitRescaler(dec, io)) goto Err; in VP8LDecodeImage()
1635 if (io->use_scaling || WebPIsPremultipliedMode(dec->output_->colorspace)) { in VP8LDecodeImage()
1639 if (!WebPIsRGBMode(dec->output_->colorspace)) { in VP8LDecodeImage()
1641 if (dec->output_->u.YUVA.a != NULL) WebPInitAlphaProcessing(); in VP8LDecodeImage()
1643 if (dec->incremental_) { in VP8LDecodeImage()
1644 if (dec->hdr_.color_cache_size_ > 0 && in VP8LDecodeImage()
1645 dec->hdr_.saved_color_cache_.colors_ == NULL) { in VP8LDecodeImage()
1646 if (!VP8LColorCacheInit(&dec->hdr_.saved_color_cache_, in VP8LDecodeImage()
1647 dec->hdr_.color_cache_.hash_bits_)) { in VP8LDecodeImage()
1648 dec->status_ = VP8_STATUS_OUT_OF_MEMORY; in VP8LDecodeImage()
1653 dec->state_ = READ_DATA; in VP8LDecodeImage()
1657 if (!DecodeImageData(dec, dec->pixels_, dec->width_, dec->height_, in VP8LDecodeImage()
1662 params->last_y = dec->last_out_row_; in VP8LDecodeImage()
1666 VP8LClear(dec); in VP8LDecodeImage()
1667 assert(dec->status_ != VP8_STATUS_OK); in VP8LDecodeImage()