Commit f2b08a07 authored by Martin Vignali's avatar Martin Vignali Committed by Michael Niedermayer

libavcodec/exr : cosmetics, rename variable in b44_uncompress func

Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent acca56d9
...@@ -944,74 +944,74 @@ static void unpack_3(const uint8_t b[3], uint16_t s[16]) ...@@ -944,74 +944,74 @@ static void unpack_3(const uint8_t b[3], uint16_t s[16])
static int b44_uncompress(EXRContext *s, const uint8_t *src, int compressed_size, static int b44_uncompress(EXRContext *s, const uint8_t *src, int compressed_size,
int uncompressed_size, EXRThreadData *td) { int uncompressed_size, EXRThreadData *td) {
const int8_t *sr = src; const int8_t *sr = src;
int stayToUncompress = compressed_size; int stay_to_uncompress = compressed_size;
int nbB44BlockW, nbB44BlockH; int nb_b44_block_w, nb_b44_block_h;
int indexHgX, indexHgY, indexOut, indexTmp; int index_tl_x, index_tl_y, index_out, index_tmp;
uint16_t tmpBuffer[16]; /* B44 use 4x4 half float pixel */ uint16_t tmp_buffer[16]; /* B44 use 4x4 half float pixel */
int c, iY, iX, y, x; int c, iY, iX, y, x;
int target_channel_offset = 0; int target_channel_offset = 0;
/* calc B44 block count */ /* calc B44 block count */
nbB44BlockW = td->xsize / 4; nb_b44_block_w = td->xsize / 4;
if ((td->xsize % 4) != 0) if ((td->xsize % 4) != 0)
nbB44BlockW++; nb_b44_block_w++;
nbB44BlockH = td->ysize / 4; nb_b44_block_h = td->ysize / 4;
if ((td->ysize % 4) != 0) if ((td->ysize % 4) != 0)
nbB44BlockH++; nb_b44_block_h++;
for (c = 0; c < s->nb_channels; c++) { for (c = 0; c < s->nb_channels; c++) {
if (s->channels[c].pixel_type == EXR_HALF) {/* B44 only compress half float data */ if (s->channels[c].pixel_type == EXR_HALF) {/* B44 only compress half float data */
for (iY = 0; iY < nbB44BlockH; iY++) { for (iY = 0; iY < nb_b44_block_h; iY++) {
for (iX = 0; iX < nbB44BlockW; iX++) {/* For each B44 block */ for (iX = 0; iX < nb_b44_block_w; iX++) {/* For each B44 block */
if (stayToUncompress < 3) { if (stay_to_uncompress < 3) {
av_log(s, AV_LOG_ERROR, "Not enough data for B44A block: %d", stayToUncompress); av_log(s, AV_LOG_ERROR, "Not enough data for B44A block: %d", stay_to_uncompress);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if (src[compressed_size - stayToUncompress + 2] == 0xfc) { /* B44A block */ if (src[compressed_size - stay_to_uncompress + 2] == 0xfc) { /* B44A block */
unpack_3(sr, tmpBuffer); unpack_3(sr, tmp_buffer);
sr += 3; sr += 3;
stayToUncompress -= 3; stay_to_uncompress -= 3;
} else {/* B44 Block */ } else {/* B44 Block */
if (stayToUncompress < 14) { if (stay_to_uncompress < 14) {
av_log(s, AV_LOG_ERROR, "Not enough data for B44 block: %d", stayToUncompress); av_log(s, AV_LOG_ERROR, "Not enough data for B44 block: %d", stay_to_uncompress);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
unpack_14(sr, tmpBuffer); unpack_14(sr, tmp_buffer);
sr += 14; sr += 14;
stayToUncompress -= 14; stay_to_uncompress -= 14;
} }
/* copy data to uncompress buffer (B44 block can exceed target resolution)*/ /* copy data to uncompress buffer (B44 block can exceed target resolution)*/
indexHgX = iX * 4; index_tl_x = iX * 4;
indexHgY = iY * 4; index_tl_y = iY * 4;
for (y = indexHgY; y < FFMIN(indexHgY + 4, td->ysize); y++) { for (y = index_tl_y; y < FFMIN(index_tl_y + 4, td->ysize); y++) {
for (x = indexHgX; x < FFMIN(indexHgX + 4, td->xsize); x++) { for (x = index_tl_x; x < FFMIN(index_tl_x + 4, td->xsize); x++) {
indexOut = target_channel_offset * td->xsize + y * td->channel_line_size + 2 * x; index_out = target_channel_offset * td->xsize + y * td->channel_line_size + 2 * x;
indexTmp = (y-indexHgY) * 4 + (x-indexHgX); index_tmp = (y-index_tl_y) * 4 + (x-index_tl_x);
td->uncompressed_data[indexOut] = tmpBuffer[indexTmp] & 0xff; td->uncompressed_data[index_out] = tmp_buffer[index_tmp] & 0xff;
td->uncompressed_data[indexOut + 1] = tmpBuffer[indexTmp] >> 8; td->uncompressed_data[index_out + 1] = tmp_buffer[index_tmp] >> 8;
} }
} }
} }
} }
target_channel_offset += 2; target_channel_offset += 2;
} else {/* Float or UINT 32 channel */ } else {/* Float or UINT 32 channel */
if (stayToUncompress < td->ysize * td->xsize * 4) { if (stay_to_uncompress < td->ysize * td->xsize * 4) {
av_log(s, AV_LOG_ERROR, "Not enough data for uncompress channel: %d", stayToUncompress); av_log(s, AV_LOG_ERROR, "Not enough data for uncompress channel: %d", stay_to_uncompress);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
for (y = 0; y < td->ysize; y++) { for (y = 0; y < td->ysize; y++) {
indexOut = target_channel_offset * td->xsize + y * td->channel_line_size; index_out = target_channel_offset * td->xsize + y * td->channel_line_size;
memcpy(&td->uncompressed_data[indexOut], sr, td->xsize * 4); memcpy(&td->uncompressed_data[index_out], sr, td->xsize * 4);
sr += td->xsize * 4; sr += td->xsize * 4;
} }
target_channel_offset += 4; target_channel_offset += 4;
stayToUncompress -= td->ysize * td->xsize * 4; stay_to_uncompress -= td->ysize * td->xsize * 4;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment