|
|
|
@ -432,7 +432,7 @@ static float* stbr__add_empty_ring_buffer_entry(stbr__info* stbr_info, int n) |
|
|
|
|
return ring_buffer; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void stbr__resample_horizontal_upsample(stbr__info* stbr_info, int n) |
|
|
|
|
static void stbr__resample_horizontal_upsample(stbr__info* stbr_info, int n, float* output_buffer) |
|
|
|
|
{ |
|
|
|
|
STBR_UNIMPLEMENTED(stbr_info->output_w < stbr_info->input_w); |
|
|
|
|
int x, k, c; |
|
|
|
@ -443,8 +443,6 @@ static void stbr__resample_horizontal_upsample(stbr__info* stbr_info, int n) |
|
|
|
|
stbr__contributors* horizontal_contributors = stbr_info->horizontal_contributors; |
|
|
|
|
float* horizontal_coefficients = stbr_info->horizontal_coefficients; |
|
|
|
|
|
|
|
|
|
float* ring_buffer = stbr__add_empty_ring_buffer_entry(stbr_info, n); |
|
|
|
|
|
|
|
|
|
for (x = 0; x < output_w; x++) |
|
|
|
|
{ |
|
|
|
|
int n0 = horizontal_contributors[x].n0; |
|
|
|
@ -466,7 +464,11 @@ static void stbr__resample_horizontal_upsample(stbr__info* stbr_info, int n) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
for (c = 0; c < channels; c++) |
|
|
|
|
ring_buffer[out_texel_index + c] += decode_buffer[in_texel_index + c] * coefficient; |
|
|
|
|
{ |
|
|
|
|
output_buffer[out_texel_index + c] += decode_buffer[in_texel_index + c] * coefficient; |
|
|
|
|
|
|
|
|
|
STBR_DEBUG_ASSERT(output_buffer[out_texel_index + c] <= 1.0f); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -483,9 +485,7 @@ static void stbr__resample_horizontal_downsample(stbr__info* stbr_info, int n) |
|
|
|
|
|
|
|
|
|
float* horizontal_buffer = stbr_info->horizontal_buffer; |
|
|
|
|
|
|
|
|
|
STBR_DEBUG_ASSERT(stbr_info->output_h < stbr_info->input_h); |
|
|
|
|
|
|
|
|
|
memset(horizontal_buffer, 0, stbr_info->output_w * channels * sizeof(float)); |
|
|
|
|
STBR_DEBUG_ASSERT(stbr_info->output_w < stbr_info->input_w); |
|
|
|
|
|
|
|
|
|
for (x = 0; x < input_w; x++) |
|
|
|
|
{ |
|
|
|
@ -529,7 +529,7 @@ static void stbr__decode_and_resample_upsample(stbr__info* stbr_info, int n) |
|
|
|
|
stbr__decode_scanline(stbr_info, n); |
|
|
|
|
|
|
|
|
|
// Now resample it into the ring buffer.
|
|
|
|
|
stbr__resample_horizontal_upsample(stbr_info, n); |
|
|
|
|
stbr__resample_horizontal_upsample(stbr_info, n, stbr__add_empty_ring_buffer_entry(stbr_info, n)); |
|
|
|
|
|
|
|
|
|
// Now it's sitting in the ring buffer ready to be used as source for the vertical sampling.
|
|
|
|
|
} |
|
|
|
@ -545,8 +545,13 @@ static void stbr__decode_and_resample_downsample(stbr__info* stbr_info, int n) |
|
|
|
|
// Decode the nth scanline from the source image into the decode buffer.
|
|
|
|
|
stbr__decode_scanline(stbr_info, n); |
|
|
|
|
|
|
|
|
|
memset(stbr_info->horizontal_buffer, 0, stbr_info->output_w * stbr_info->channels * sizeof(float)); |
|
|
|
|
|
|
|
|
|
// Now resample it into the horizontal buffer.
|
|
|
|
|
stbr__resample_horizontal_downsample(stbr_info, n); |
|
|
|
|
if (stbr_info->output_w > stbr_info->input_w) |
|
|
|
|
stbr__resample_horizontal_upsample(stbr_info, n, stbr_info->horizontal_buffer); |
|
|
|
|
else |
|
|
|
|
stbr__resample_horizontal_downsample(stbr_info, n); |
|
|
|
|
|
|
|
|
|
// Now it's sitting in the horizontal buffer ready to be distributed into the ring buffers.
|
|
|
|
|
} |
|
|
|
@ -638,7 +643,7 @@ static void stbr__resample_vertical_downsample(stbr__info* stbr_info, int n, int |
|
|
|
|
int n0 = vertical_contributors->n0; |
|
|
|
|
int n1 = vertical_contributors->n1; |
|
|
|
|
|
|
|
|
|
STBR_DEBUG_ASSERT(stbr_info->output_w < stbr_info->input_w); |
|
|
|
|
STBR_DEBUG_ASSERT(stbr_info->output_h < stbr_info->input_h); |
|
|
|
|
STBR_DEBUG_ASSERT(n0 >= in_first_scanline); |
|
|
|
|
STBR_DEBUG_ASSERT(n1 <= in_last_scanline); |
|
|
|
|
|
|
|
|
|