32 #define INTERPOLATE_METHOD(name) \
33 static uint8_t name(float x, float y, const uint8_t *src, \
34 int width, int height, int stride, uint8_t def)
36 #define PIXEL(img, x, y, w, h, stride, def) \
37 ((x) < 0 || (y) < 0) ? (def) : \
38 (((x) >= (w) || (y) >= (h)) ? (def) : \
39 img[(x) + (y) * (stride)])
54 int x_c, x_f, y_c, y_f;
71 return (v1*(x - x_f)*(y - y_f) + v2*((x - x_f)*(y_c - y)) +
72 v3*(x_c - x)*(y - y_f) + v4*((x_c - x)*(y_c - y)));
81 int x_c, x_f, y_c, y_f;
98 f1 = 1 - sqrt((x_c - x) * (y_c - y));
99 f2 = 1 - sqrt((x_c - x) * (y - y_f));
100 f3 = 1 - sqrt((x - x_f) * (y_c - y));
101 f4 = 1 - sqrt((x - x_f) * (y - y_f));
102 return (v1 * f1 + v2 * f2 + v3 * f3 + v4 * f4) / (f1 + f2 + f3 + f4);
107 matrix[0] = zoom * cos(angle);
108 matrix[1] = -sin(angle);
110 matrix[3] = -matrix[1];
111 matrix[4] = matrix[0];
121 for (i = 0; i < 9; i++)
122 result[i] = m1[i] + m2[i];
128 for (i = 0; i < 9; i++)
129 result[i] = m1[i] - m2[i];
135 for (i = 0; i < 9; i++)
136 result[i] = m1[i] * scalar;
140 int src_stride,
int dst_stride,
150 switch(interpolate) {
152 func = interpolate_nearest;
155 func = interpolate_bilinear;
158 func = interpolate_biquadratic;
164 for (y = 0; y <
height; y++) {
165 for(x = 0; x <
width; x++) {
166 x_s = x * matrix[0] + y * matrix[1] + matrix[2];
167 y_s = x * matrix[3] + y * matrix[4] + matrix[5];
171 def = src[y * src_stride + x];
174 y_s = av_clipf(y_s, 0, height - 1);
175 x_s = av_clipf(x_s, 0, width - 1);
176 def = src[(int)y_s * src_stride + (
int)x_s];
184 def = src[(int)y_s * src_stride + (
int)x_s];
187 dst[y * dst_stride + x] =
func(x_s, y_s, src, width, height, src_stride, def);
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static void interpolate(float *out, float v1, float v2, int size)
simple assert() macros that are a bit more flexible than ISO C assert().
static av_always_inline av_const int avpriv_mirror(int x, int w)
int(* func)(AVBPrint *dst, const char *in, const char *arg)
GLint GLenum GLboolean GLsizei stride
common internal and external API header