ImBuf: optimize IMB_transform #115653
|
@ -15,22 +15,14 @@ extern "C" {
|
|||
void BLI_bicubic_interpolation_fl(
|
||||
const float *buffer, float *output, int width, int height, int components, float u, float v);
|
||||
|
||||
void BLI_bicubic_interpolation_char(const unsigned char *buffer,
|
||||
unsigned char *output,
|
||||
int width,
|
||||
int height,
|
||||
float u,
|
||||
float v);
|
||||
void BLI_bicubic_interpolation_char(
|
||||
const unsigned char *buffer, unsigned char *output, int width, int height, float u, float v);
|
||||
|
||||
void BLI_bilinear_interpolation_fl(
|
||||
const float *buffer, float *output, int width, int height, int components, float u, float v);
|
||||
|
||||
void BLI_bilinear_interpolation_char(const unsigned char *buffer,
|
||||
unsigned char *output,
|
||||
int width,
|
||||
int height,
|
||||
float u,
|
||||
float v);
|
||||
void BLI_bilinear_interpolation_char(
|
||||
const unsigned char *buffer, unsigned char *output, int width, int height, float u, float v);
|
||||
|
||||
void BLI_bilinear_interpolation_wrap_fl(const float *buffer,
|
||||
float *output,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_math_interp.h"
|
||||
|
@ -18,7 +19,6 @@
|
|||
# include <intrin.h>
|
||||
#endif
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* INTERPOLATIONS
|
||||
*
|
||||
|
@ -389,7 +389,7 @@ static void simd_to_rgba_uchar(__m128 rgba, uchar dst[4])
|
|||
/* Pack to 8 bit values. */
|
||||
__m128i rgba8 = _mm_packus_epi16(rgba16, _mm_setzero_si128());
|
||||
/* Store the packed bits into destination. */
|
||||
_mm_store_ss((float*)dst, _mm_castsi128_ps(rgba8));
|
||||
_mm_store_ss((float *)dst, _mm_castsi128_ps(rgba8));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -483,8 +483,7 @@ void BLI_bilinear_interpolation_char(
|
|||
void BLI_bilinear_interpolation_fl(
|
||||
const float *buffer, float *output, int width, int height, int components, float u, float v)
|
||||
{
|
||||
bilinear_interpolation_fl(
|
||||
buffer, output, width, height, components, u, v, false, false);
|
||||
bilinear_interpolation_fl(buffer, output, width, height, components, u, v, false, false);
|
||||
}
|
||||
|
||||
void BLI_bilinear_interpolation_wrap_fl(const float *buffer,
|
||||
|
@ -497,8 +496,7 @@ void BLI_bilinear_interpolation_wrap_fl(const float *buffer,
|
|||
bool wrap_x,
|
||||
bool wrap_y)
|
||||
{
|
||||
bilinear_interpolation_fl(
|
||||
buffer, output, width, height, components, u, v, wrap_x, wrap_y);
|
||||
bilinear_interpolation_fl(buffer, output, width, height, components, u, v, wrap_x, wrap_y);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
|
|
@ -684,10 +684,11 @@ void nearest_interpolation_color_wrap(
|
|||
const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v);
|
||||
void bilinear_interpolation_color(
|
||||
const struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v);
|
||||
void bilinear_interpolation_color_char(
|
||||
const struct ImBuf *in, unsigned char outI[4], float u, float v);
|
||||
void bilinear_interpolation_color_fl(
|
||||
const struct ImBuf *in, float outF[4], float u, float v);
|
||||
void bilinear_interpolation_color_char(const struct ImBuf *in,
|
||||
unsigned char outI[4],
|
||||
float u,
|
||||
float v);
|
||||
void bilinear_interpolation_color_fl(const struct ImBuf *in, float outF[4], float u, float v);
|
||||
/**
|
||||
* Note about wrapping, the u/v still needs to be within the image bounds,
|
||||
* just the interpolation is wrapped.
|
||||
|
|
|
@ -108,16 +108,14 @@ void bicubic_interpolation(const ImBuf *in, ImBuf *out, float u, float v, int xo
|
|||
/** \name Bi-Linear Interpolation
|
||||
* \{ */
|
||||
|
||||
void bilinear_interpolation_color_fl(
|
||||
const ImBuf *in, float outF[4], float u, float v)
|
||||
void bilinear_interpolation_color_fl(const ImBuf *in, float outF[4], float u, float v)
|
||||
{
|
||||
BLI_assert(outF);
|
||||
BLI_assert(in->float_buffer.data);
|
||||
BLI_bilinear_interpolation_fl(in->float_buffer.data, outF, in->x, in->y, 4, u, v);
|
||||
}
|
||||
|
||||
void bilinear_interpolation_color_char(
|
||||
const ImBuf *in, uchar outI[4], float u, float v)
|
||||
void bilinear_interpolation_color_char(const ImBuf *in, uchar outI[4], float u, float v)
|
||||
{
|
||||
BLI_assert(outI);
|
||||
BLI_assert(in->byte_buffer.data);
|
||||
|
|
|
@ -340,12 +340,8 @@ class Sampler {
|
|||
true);
|
||||
}
|
||||
else {
|
||||
BLI_bilinear_interpolation_fl(source->float_buffer.data,
|
||||
r_sample.data(),
|
||||
source->x,
|
||||
source->y,
|
||||
NumChannels,
|
||||
u, v);
|
||||
BLI_bilinear_interpolation_fl(
|
||||
source->float_buffer.data, r_sample.data(), source->x, source->y, NumChannels, u, v);
|
||||
}
|
||||
}
|
||||
else if constexpr (Filter == IMB_FILTER_NEAREST && std::is_same_v<StorageType, float>) {
|
||||
|
@ -358,7 +354,10 @@ class Sampler {
|
|||
}
|
||||
|
||||
private:
|
||||
void sample_nearest_float(const ImBuf *source, const float u, const float v, SampleType &r_sample)
|
||||
void sample_nearest_float(const ImBuf *source,
|
||||
const float u,
|
||||
const float v,
|
||||
SampleType &r_sample)
|
||||
{
|
||||
BLI_STATIC_ASSERT(std::is_same_v<StorageType, float>);
|
||||
|
||||
|
|
Loading…
Reference in New Issue