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>
This commit is contained in:
parent
1df908f33f
commit
d9e1e08133
@ -749,6 +749,9 @@ static int piz_uncompress(EXRContext *s, const uint8_t *src, int ssize,
|
|||||||
uint16_t *tmp = (uint16_t *)td->tmp;
|
uint16_t *tmp = (uint16_t *)td->tmp;
|
||||||
uint8_t *out;
|
uint8_t *out;
|
||||||
int ret, i, j;
|
int ret, i, j;
|
||||||
|
int pixel_half_size;/* 1 for half, 2 for float and uint32 */
|
||||||
|
EXRChannel *channel;
|
||||||
|
int tmp_offset;
|
||||||
|
|
||||||
if (!td->bitmap)
|
if (!td->bitmap)
|
||||||
td->bitmap = av_malloc(BITMAP_SIZE);
|
td->bitmap = av_malloc(BITMAP_SIZE);
|
||||||
@ -781,24 +784,38 @@ static int piz_uncompress(EXRContext *s, const uint8_t *src, int ssize,
|
|||||||
|
|
||||||
ptr = tmp;
|
ptr = tmp;
|
||||||
for (i = 0; i < s->nb_channels; i++) {
|
for (i = 0; i < s->nb_channels; i++) {
|
||||||
EXRChannel *channel = &s->channels[i];
|
channel = &s->channels[i];
|
||||||
int size = channel->pixel_type;
|
|
||||||
|
|
||||||
for (j = 0; j < size; j++)
|
if (channel->pixel_type == EXR_HALF)
|
||||||
wav_decode(ptr + j, td->xsize, size, td->ysize,
|
pixel_half_size = 1;
|
||||||
td->xsize * size, maxval);
|
else
|
||||||
ptr += td->xsize * td->ysize * size;
|
pixel_half_size = 2;
|
||||||
|
|
||||||
|
for (j = 0; j < pixel_half_size; j++)
|
||||||
|
wav_decode(ptr + j, td->xsize, pixel_half_size, td->ysize,
|
||||||
|
td->xsize * pixel_half_size, maxval);
|
||||||
|
ptr += td->xsize * td->ysize * pixel_half_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_lut(td->lut, tmp, dsize / sizeof(uint16_t));
|
apply_lut(td->lut, tmp, dsize / sizeof(uint16_t));
|
||||||
|
|
||||||
out = td->uncompressed_data;
|
out = td->uncompressed_data;
|
||||||
for (i = 0; i < td->ysize; i++)
|
for (i = 0; i < td->ysize; i++) {
|
||||||
|
tmp_offset = 0;
|
||||||
for (j = 0; j < s->nb_channels; j++) {
|
for (j = 0; j < s->nb_channels; j++) {
|
||||||
uint16_t *in = tmp + j * td->xsize * td->ysize + i * td->xsize;
|
uint16_t *in;
|
||||||
memcpy(out, in, td->xsize * 2);
|
EXRChannel *channel = &s->channels[j];
|
||||||
out += td->xsize * 2;
|
if (channel->pixel_type == EXR_HALF)
|
||||||
|
pixel_half_size = 1;
|
||||||
|
else
|
||||||
|
pixel_half_size = 2;
|
||||||
|
|
||||||
|
in = tmp + tmp_offset * td->xsize * td->ysize + i * td->xsize * pixel_half_size;
|
||||||
|
tmp_offset += pixel_half_size;
|
||||||
|
memcpy(out, in, td->xsize * 2 * pixel_half_size);
|
||||||
|
out += td->xsize * 2 * pixel_half_size;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user