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:
authorManuel Castilla <manzanillawork@gmail.com>2021-08-23 16:30:56 +0300
committerManuel Castilla <manzanillawork@gmail.com>2021-08-23 18:09:59 +0300
commit42f89b9212d31fbfdf387a29835b957d758e473e (patch)
treee8d50a1f4fe363572df3b5e28d086108368d355c /source/blender/compositor
parent153b45037f5d27cf125d56ebb9aa77aca53d0981 (diff)
Compositor: Fix incorrect copying of uchar buffers
Row stride and the area x coordinate offset were not taken into account.
Diffstat (limited to 'source/blender/compositor')
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.cc33
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h2
2 files changed, 28 insertions, 7 deletions
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cc b/source/blender/compositor/intern/COM_MemoryBuffer.cc
index 16274d720cd..1fbf502fea6 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cc
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cc
@@ -245,7 +245,9 @@ void MemoryBuffer::copy_from(const MemoryBuffer *src,
void MemoryBuffer::copy_from(const uchar *src, const rcti &area)
{
- copy_from(src, area, 0, this->get_num_channels(), this->get_num_channels(), 0);
+ const int elem_stride = this->get_num_channels();
+ const int row_stride = elem_stride * getWidth();
+ copy_from(src, area, 0, this->get_num_channels(), elem_stride, row_stride, 0);
}
void MemoryBuffer::copy_from(const uchar *src,
@@ -253,10 +255,18 @@ void MemoryBuffer::copy_from(const uchar *src,
const int channel_offset,
const int elem_size,
const int elem_stride,
+ const int row_stride,
const int to_channel_offset)
{
- copy_from(
- src, area, channel_offset, elem_size, elem_stride, area.xmin, area.ymin, to_channel_offset);
+ copy_from(src,
+ area,
+ channel_offset,
+ elem_size,
+ elem_stride,
+ row_stride,
+ area.xmin,
+ area.ymin,
+ to_channel_offset);
}
void MemoryBuffer::copy_from(const uchar *src,
@@ -264,6 +274,7 @@ void MemoryBuffer::copy_from(const uchar *src,
const int channel_offset,
const int elem_size,
const int elem_stride,
+ const int row_stride,
const int to_x,
const int to_y,
const int to_channel_offset)
@@ -273,10 +284,9 @@ void MemoryBuffer::copy_from(const uchar *src,
const int width = BLI_rcti_size_x(&area);
const int height = BLI_rcti_size_y(&area);
- const int src_row_stride = width * elem_stride;
- const uchar *const src_start = src + area.ymin * src_row_stride + channel_offset;
+ const uchar *const src_start = src + area.ymin * row_stride + channel_offset;
for (int y = 0; y < height; y++) {
- const uchar *from_elem = src_start + y * src_row_stride;
+ const uchar *from_elem = src_start + y * row_stride + area.xmin * elem_stride;
float *to_elem = &this->get_value(to_x, to_y + y, to_channel_offset);
const float *row_end = to_elem + width * this->elem_stride;
while (to_elem < row_end) {
@@ -346,7 +356,16 @@ void MemoryBuffer::copy_from(const ImBuf *src,
else if (src->rect) {
const uchar *uc_buf = (uchar *)src->rect;
const int elem_stride = src->channels;
- copy_from(uc_buf, area, channel_offset, elem_size, elem_stride, to_x, to_y, to_channel_offset);
+ const int row_stride = elem_stride * src->x;
+ copy_from(uc_buf,
+ area,
+ channel_offset,
+ elem_size,
+ elem_stride,
+ row_stride,
+ to_x,
+ to_y,
+ to_channel_offset);
if (ensure_linear_space) {
colorspace_to_scene_linear(this, area, src->rect_colorspace);
}
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index d3c7566d246..f3e15c2a495 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -583,12 +583,14 @@ class MemoryBuffer {
int channel_offset,
int elem_size,
int elem_stride,
+ int row_stride,
int to_channel_offset);
void copy_from(const uchar *src,
const rcti &area,
int channel_offset,
int elem_size,
int elem_stride,
+ int row_stride,
int to_x,
int to_y,
int to_channel_offset);