Skip to content

Commit d9e1e08

Browse files
mvjimichaelni
authored andcommitted
libavcodec/exr : fix decoding piz float file.
fix ticket #5674 the size of data to process in piz_uncompress, is now calc using the pixel type of each channel. the data reorganization, alos take care about the size of each channel Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
1 parent 1df908f commit d9e1e08

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

libavcodec/exr.c

+27-10
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,9 @@ static int piz_uncompress(EXRContext *s, const uint8_t *src, int ssize,
749749
uint16_t *tmp = (uint16_t *)td->tmp;
750750
uint8_t *out;
751751
int ret, i, j;
752+
int pixel_half_size;/* 1 for half, 2 for float and uint32 */
753+
EXRChannel *channel;
754+
int tmp_offset;
752755

753756
if (!td->bitmap)
754757
td->bitmap = av_malloc(BITMAP_SIZE);
@@ -781,24 +784,38 @@ static int piz_uncompress(EXRContext *s, const uint8_t *src, int ssize,
781784

782785
ptr = tmp;
783786
for (i = 0; i < s->nb_channels; i++) {
784-
EXRChannel *channel = &s->channels[i];
785-
int size = channel->pixel_type;
787+
channel = &s->channels[i];
786788

787-
for (j = 0; j < size; j++)
788-
wav_decode(ptr + j, td->xsize, size, td->ysize,
789-
td->xsize * size, maxval);
790-
ptr += td->xsize * td->ysize * size;
789+
if (channel->pixel_type == EXR_HALF)
790+
pixel_half_size = 1;
791+
else
792+
pixel_half_size = 2;
793+
794+
for (j = 0; j < pixel_half_size; j++)
795+
wav_decode(ptr + j, td->xsize, pixel_half_size, td->ysize,
796+
td->xsize * pixel_half_size, maxval);
797+
ptr += td->xsize * td->ysize * pixel_half_size;
791798
}
792799

793800
apply_lut(td->lut, tmp, dsize / sizeof(uint16_t));
794801

795802
out = td->uncompressed_data;
796-
for (i = 0; i < td->ysize; i++)
803+
for (i = 0; i < td->ysize; i++) {
804+
tmp_offset = 0;
797805
for (j = 0; j < s->nb_channels; j++) {
798-
uint16_t *in = tmp + j * td->xsize * td->ysize + i * td->xsize;
799-
memcpy(out, in, td->xsize * 2);
800-
out += td->xsize * 2;
806+
uint16_t *in;
807+
EXRChannel *channel = &s->channels[j];
808+
if (channel->pixel_type == EXR_HALF)
809+
pixel_half_size = 1;
810+
else
811+
pixel_half_size = 2;
812+
813+
in = tmp + tmp_offset * td->xsize * td->ysize + i * td->xsize * pixel_half_size;
814+
tmp_offset += pixel_half_size;
815+
memcpy(out, in, td->xsize * 2 * pixel_half_size);
816+
out += td->xsize * 2 * pixel_half_size;
801817
}
818+
}
802819

803820
return 0;
804821
}

0 commit comments

Comments
 (0)