Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2015-04-30 13:10:58 +0300
committerAntony Riakiotakis <kalast@gmail.com>2015-04-30 13:11:20 +0300
commit290997538590d54387602a37879ad4cffbc311da (patch)
tree58887bf967bd42e36b9609006304d9683461d6ac /source/blender/imbuf/intern/colormanagement.c
parent4bcc7a2ec6bf6937778a2227c7f938c50a0fafe5 (diff)
Fix T44541 aka gigapixel image render support in blender.
Moral of the story: Make sure that size_t is used whenever pointer arithmetic is involved. For images, that basically means whenever any squared dimensions are involved. Casting an operand to size_t early in the operation is usually sufficient to force the entire operation to size_t. There might still be places lurking where we don't support this correctly. This has been tested with render pipeline, quite a few image functions (meaning we can paint on such images now, albeit somewhat slowly ;) ) and export to jpeg. Too many places in code to check so I guess we'll be handling cases as they come. Don't try this at home unless you have an immense ammount of RAM. First GPixel render of suzanne in the multiverse can be found here: http://download.blender.org/demo/test/suzanne-billion-pixel.jpg Can be viewed from blender (takes about 3.3 GB after loading but may take more during loading so 8GB might be more safe to try this).
Diffstat (limited to 'source/blender/imbuf/intern/colormanagement.c')
-rw-r--r--source/blender/imbuf/intern/colormanagement.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index 20baa1614c9..d6fdcad0819 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -1306,8 +1306,8 @@ static void display_buffer_init_handle(void *handle_v, int start_line, int tot_l
float dither = ibuf->dither;
bool is_data = (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) != 0;
- int offset = channels * start_line * ibuf->x;
- int display_buffer_byte_offset = DISPLAY_BUFFER_CHANNELS * start_line * ibuf->x;
+ size_t offset = ((size_t)channels) * start_line * ibuf->x;
+ size_t display_buffer_byte_offset = ((size_t)DISPLAY_BUFFER_CHANNELS) * start_line * ibuf->x;
memset(handle, 0, sizeof(DisplayBufferThread));
@@ -1344,7 +1344,7 @@ static void display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle,
int channels = handle->channels;
int width = handle->width;
- int buffer_size = channels * width * height;
+ size_t buffer_size = ((size_t)channels) * width * height;
bool is_data = handle->is_data;
bool is_data_display = handle->cm_processor->is_data_result;
@@ -1357,11 +1357,11 @@ static void display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle,
float *fp;
unsigned char *cp;
- int i;
+ size_t i;
/* first convert byte buffer to float, keep in image space */
for (i = 0, fp = linear_buffer, cp = byte_buffer;
- i < width * height;
+ i < ((size_t)width) * height;
i++, fp += channels, cp += channels)
{
if (channels == 3) {
@@ -1440,7 +1440,7 @@ static void *do_display_buffer_apply_thread(void *handle_v)
}
else {
bool is_straight_alpha, predivide;
- float *linear_buffer = MEM_mallocN(channels * width * height * sizeof(float),
+ float *linear_buffer = MEM_mallocN(((size_t)channels) * width * height * sizeof(float),
"color conversion linear buffer");
display_buffer_apply_get_linear_buffer(handle, height, linear_buffer, &is_straight_alpha);
@@ -1467,14 +1467,14 @@ static void *do_display_buffer_apply_thread(void *handle_v)
}
if (display_buffer) {
- memcpy(display_buffer, linear_buffer, width * height * channels * sizeof(float));
+ memcpy(display_buffer, linear_buffer, ((size_t)width) * height * channels * sizeof(float));
if (is_straight_alpha && channels == 4) {
- int i;
+ size_t i;
float *fp;
for (i = 0, fp = display_buffer;
- i < width * height;
+ i < ((size_t)width) * height;
i++, fp += channels)
{
straight_to_premul_v4(fp);
@@ -2959,7 +2959,7 @@ void IMB_colormanagement_processor_apply(ColormanageProcessor *cm_processor, flo
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
- float *pixel = buffer + channels * (y * width + x);
+ float *pixel = buffer + channels * (((size_t)y) * width + x);
curve_mapping_apply_pixel(cm_processor->curve_mapping, pixel, channels);
}