Fix integer truncation when calculating int64_t values
Large int64_t values were calculated and assigned int however the calculation was performed on integer types which would truncate the result before casting to an in64_t.
This commit is contained in:
@@ -287,5 +287,5 @@ int64_t BKE_lightprobe_grid_cache_frame_sample_count(const LightProbeGridCacheFr
|
||||
return cache->block_len * cube_i(cache->block_size);
|
||||
}
|
||||
/* LIGHTPROBE_CACHE_UNIFORM_GRID */
|
||||
return cache->size[0] * cache->size[1] * cache->size[2];
|
||||
return int64_t(cache->size[0]) * cache->size[1] * cache->size[2];
|
||||
}
|
||||
|
||||
@@ -1226,7 +1226,7 @@ LightProbeGridCacheFrame *IrradianceBake::read_result_packed()
|
||||
cache_frame->baking.L1_c = (float(*)[4])irradiance_L1_c_tx_.read<float4>(GPU_DATA_FLOAT);
|
||||
cache_frame->baking.validity = (float *)validity_tx_.read<float>(GPU_DATA_FLOAT);
|
||||
|
||||
int64_t sample_count = irradiance_L0_tx_.width() * irradiance_L0_tx_.height() *
|
||||
int64_t sample_count = int64_t(irradiance_L0_tx_.width()) * irradiance_L0_tx_.height() *
|
||||
irradiance_L0_tx_.depth();
|
||||
size_t coefficient_texture_size = sizeof(*cache_frame->irradiance.L0) * sample_count;
|
||||
size_t validity_texture_size = sizeof(*cache_frame->connectivity.validity) * sample_count;
|
||||
|
||||
@@ -429,7 +429,7 @@ static ImBuf *imb_load_jp2_stream(opj_stream_t *stream,
|
||||
}
|
||||
|
||||
if (image->comps[i].sgnd) {
|
||||
signed_offsets[i] = 1 << (image->comps[i].prec - 1);
|
||||
signed_offsets[i] = long(1) << (image->comps[i].prec - 1);
|
||||
}
|
||||
|
||||
/* only needed for float images but doesn't hurt to calc this */
|
||||
|
||||
@@ -519,11 +519,11 @@ static int seq_disk_cache_add_header_entry(SeqCacheKey *key, ImBuf *ibuf, DiskCa
|
||||
/* Store colorspace name of ibuf. */
|
||||
const char *colorspace_name;
|
||||
if (ibuf->byte_buffer.data) {
|
||||
header->entry[i].size_raw = ibuf->x * ibuf->y * ibuf->channels;
|
||||
header->entry[i].size_raw = int64_t(ibuf->x) * ibuf->y * ibuf->channels;
|
||||
colorspace_name = IMB_colormanagement_get_rect_colorspace(ibuf);
|
||||
}
|
||||
else {
|
||||
header->entry[i].size_raw = ibuf->x * ibuf->y * ibuf->channels * 4;
|
||||
header->entry[i].size_raw = int64_t(ibuf->x) * ibuf->y * ibuf->channels * 4;
|
||||
colorspace_name = IMB_colormanagement_get_float_colorspace(ibuf);
|
||||
}
|
||||
STRNCPY(header->entry[i].colorspace_name, colorspace_name);
|
||||
|
||||
Reference in New Issue
Block a user