Fix kvz_get_extended_block functions.

The buffers allocated in functions kvz_get_extended_block_avx2 and
kvz_get_extended_block_generic were too small when the width of the
block was less than its height. Fixed to allocate correctly sized
buffers.
This commit is contained in:
Arttu Ylä-Outinen 2015-11-03 11:27:50 +02:00
parent bdd8b1c0aa
commit 4402e251ae
2 changed files with 6 additions and 6 deletions

View file

@ -502,7 +502,7 @@ void kvz_get_extended_block_avx2(int xpos, int ypos, int mv_x, int mv_y, int off
int sample_out_of_bounds = out_of_bounds_y || out_of_bounds_x; int sample_out_of_bounds = out_of_bounds_y || out_of_bounds_x;
if (sample_out_of_bounds){ if (sample_out_of_bounds){
out->buffer = MALLOC(kvz_pixel, (width + filter_size) * (width + filter_size)); out->buffer = MALLOC(kvz_pixel, (width + filter_size) * (height + filter_size));
if (!out->buffer){ if (!out->buffer){
fprintf(stderr, "Memory allocation failed!\n"); fprintf(stderr, "Memory allocation failed!\n");
assert(0); assert(0);
@ -521,7 +521,7 @@ void kvz_get_extended_block_avx2(int xpos, int ypos, int mv_x, int mv_y, int off
coord_y *= ref_width; coord_y *= ref_width;
if (!out_of_bounds_x){ if (!out_of_bounds_x){
memcpy(&out->buffer[dst_y*(width + filter_size) + 0], &ref[coord_y + min_x], (width + filter_size) * sizeof(kvz_pixel)); memcpy(&out->buffer[dst_y * out->stride + 0], &ref[coord_y + min_x], out->stride * sizeof(kvz_pixel));
} else { } else {
for (dst_x = 0, x = (xpos)-half_filter_size; x < ((xpos + width)) + half_filter_size; dst_x++, x++) { for (dst_x = 0, x = (xpos)-half_filter_size; x < ((xpos + width)) + half_filter_size; dst_x++, x++) {
@ -529,7 +529,7 @@ void kvz_get_extended_block_avx2(int xpos, int ypos, int mv_x, int mv_y, int off
coord_x = CLIP(0, (ref_width)-1, coord_x); coord_x = CLIP(0, (ref_width)-1, coord_x);
// Store source block data (with extended borders) // Store source block data (with extended borders)
out->buffer[dst_y*(width + filter_size) + dst_x] = ref[coord_y + coord_x]; out->buffer[dst_y * out->stride + dst_x] = ref[coord_y + coord_x];
} }
} }
} }

View file

@ -503,7 +503,7 @@ void kvz_get_extended_block_generic(int xpos, int ypos, int mv_x, int mv_y, int
int sample_out_of_bounds = out_of_bounds_y || out_of_bounds_x; int sample_out_of_bounds = out_of_bounds_y || out_of_bounds_x;
if (sample_out_of_bounds){ if (sample_out_of_bounds){
out->buffer = MALLOC(kvz_pixel, (width + filter_size) * (width + filter_size)); out->buffer = MALLOC(kvz_pixel, (width + filter_size) * (height + filter_size));
if (!out->buffer){ if (!out->buffer){
fprintf(stderr, "Memory allocation failed!\n"); fprintf(stderr, "Memory allocation failed!\n");
assert(0); assert(0);
@ -522,7 +522,7 @@ void kvz_get_extended_block_generic(int xpos, int ypos, int mv_x, int mv_y, int
coord_y *= ref_width; coord_y *= ref_width;
if (!out_of_bounds_x){ if (!out_of_bounds_x){
memcpy(&out->buffer[dst_y*(width + filter_size) + 0], &ref[coord_y + min_x], (width + filter_size) * sizeof(kvz_pixel)); memcpy(&out->buffer[dst_y * out->stride + 0], &ref[coord_y + min_x], out->stride * sizeof(kvz_pixel));
} else { } else {
for (dst_x = 0, x = (xpos)-half_filter_size; x < ((xpos + width)) + half_filter_size; dst_x++, x++) { for (dst_x = 0, x = (xpos)-half_filter_size; x < ((xpos + width)) + half_filter_size; dst_x++, x++) {
@ -530,7 +530,7 @@ void kvz_get_extended_block_generic(int xpos, int ypos, int mv_x, int mv_y, int
coord_x = CLIP(0, (ref_width)-1, coord_x); coord_x = CLIP(0, (ref_width)-1, coord_x);
// Store source block data (with extended borders) // Store source block data (with extended borders)
out->buffer[dst_y*(width + filter_size) + dst_x] = ref[coord_y + coord_x]; out->buffer[dst_y * out->stride + dst_x] = ref[coord_y + coord_x];
} }
} }
} }