MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / piz_uncompress

Function piz_uncompress

libavcodec/exr.c:603–690  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601}
602
603static int piz_uncompress(const EXRContext *s, const uint8_t *src, int ssize,
604 int dsize, EXRThreadData *td)
605{
606 GetByteContext gb;
607 uint16_t maxval, min_non_zero, max_non_zero;
608 uint16_t *ptr;
609 uint16_t *tmp = (uint16_t *)td->tmp;
610 uint16_t *out;
611 uint16_t *in;
612 int ret, i, j;
613 int pixel_half_size;/* 1 for half, 2 for float and uint32 */
614 EXRChannel *channel;
615 int tmp_offset;
616
617 if (!td->bitmap)
618 td->bitmap = av_malloc(BITMAP_SIZE);
619 if (!td->lut)
620 td->lut = av_malloc(1 << 17);
621 if (!td->bitmap || !td->lut) {
622 av_freep(&td->bitmap);
623 av_freep(&td->lut);
624 return AVERROR(ENOMEM);
625 }
626
627 bytestream2_init(&gb, src, ssize);
628 min_non_zero = bytestream2_get_le16(&gb);
629 max_non_zero = bytestream2_get_le16(&gb);
630
631 if (max_non_zero >= BITMAP_SIZE)
632 return AVERROR_INVALIDDATA;
633
634 memset(td->bitmap, 0, FFMIN(min_non_zero, BITMAP_SIZE));
635 if (min_non_zero <= max_non_zero)
636 bytestream2_get_buffer(&gb, td->bitmap + min_non_zero,
637 max_non_zero - min_non_zero + 1);
638 memset(td->bitmap + max_non_zero + 1, 0, BITMAP_SIZE - max_non_zero - 1);
639
640 if (bytestream2_get_bytes_left(&gb) < 4)
641 return AVERROR_INVALIDDATA;
642
643 maxval = reverse_lut(td->bitmap, td->lut);
644
645 bytestream2_skip(&gb, 4);
646 ret = huf_uncompress(s, td, &gb, tmp, dsize / sizeof(uint16_t));
647 if (ret)
648 return ret;
649
650 ptr = tmp;
651 for (i = 0; i < s->nb_channels; i++) {
652 channel = &s->channels[i];
653
654 if (channel->pixel_type == EXR_HALF)
655 pixel_half_size = 1;
656 else
657 pixel_half_size = 2;
658
659 for (j = 0; j < pixel_half_size; j++)
660 wav_decode(ptr + j, td->xsize, pixel_half_size, td->ysize,

Callers 1

decode_blockFunction · 0.85

Calls 10

av_freepFunction · 0.85
bytestream2_initFunction · 0.85
bytestream2_get_bufferFunction · 0.85
reverse_lutFunction · 0.85
bytestream2_skipFunction · 0.85
huf_uncompressFunction · 0.85
wav_decodeFunction · 0.85
apply_lutFunction · 0.70
av_mallocFunction · 0.50

Tested by

no test coverage detected