2 * Copyright (C) 2010 Georg Martius <georg.martius@web.de>
3 * Copyright (C) 2010 Daniel G. Taylor <dan@programmer-art.org>
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef AVFILTER_TRANSFORM_H
23 #define AVFILTER_TRANSFORM_H
29 * transform input video
31 * All matrices are defined as a single 9-item block of contiguous memory. For
32 * example, the identity matrix would be:
34 * float *matrix = {1, 0, 0,
39 enum InterpolateMethod {
40 INTERPOLATE_NEAREST, //< Nearest-neighbor (fast)
41 INTERPOLATE_BILINEAR, //< Bilinear
42 INTERPOLATE_BIQUADRATIC, //< Biquadratic (best)
43 INTERPOLATE_COUNT, //< Number of interpolation methods
46 // Shortcuts for the fastest and best interpolation methods
47 #define INTERPOLATE_DEFAULT INTERPOLATE_BILINEAR
48 #define INTERPOLATE_FAST INTERPOLATE_NEAREST
49 #define INTERPOLATE_BEST INTERPOLATE_BIQUADRATIC
52 FILL_BLANK, //< Fill zeroes at blank locations
53 FILL_ORIGINAL, //< Original image at blank locations
54 FILL_CLAMP, //< Extruded edge value at blank locations
55 FILL_MIRROR, //< Mirrored edge at blank locations
56 FILL_COUNT, //< Number of edge fill methods
59 // Shortcuts for fill methods
60 #define FILL_DEFAULT FILL_ORIGINAL
63 * Get an affine transformation matrix from given translation, rotation, and
64 * zoom factors. The matrix will look like:
66 * [ scale_x * cos(angle), -sin(angle), x_shift,
67 * sin(angle), scale_y * cos(angle), y_shift,
70 * @param x_shift horizontal translation
71 * @param y_shift vertical translation
72 * @param angle rotation in radians
73 * @param scale_x x scale percent (1.0 = 100%)
74 * @param scale_y y scale percent (1.0 = 100%)
75 * @param matrix 9-item affine transformation matrix
87 * Add two matrices together. result = m1 + m2.
89 * @param m1 9-item transformation matrix
90 * @param m2 9-item transformation matrix
91 * @param result 9-item transformation matrix
93 void avfilter_add_matrix(const float *m1, const float *m2, float *result);
96 * Subtract one matrix from another. result = m1 - m2.
98 * @param m1 9-item transformation matrix
99 * @param m2 9-item transformation matrix
100 * @param result 9-item transformation matrix
102 void avfilter_sub_matrix(const float *m1, const float *m2, float *result);
105 * Multiply a matrix by a scalar value. result = m1 * scalar.
107 * @param m1 9-item transformation matrix
108 * @param scalar a number
109 * @param result 9-item transformation matrix
111 void avfilter_mul_matrix(const float *m1, float scalar, float *result);
114 * Do an affine transformation with the given interpolation method. This
115 * multiplies each vector [x,y,1] by the matrix and then interpolates to
116 * get the final value.
118 * @param src source image
119 * @param dst destination image
120 * @param src_stride source image line size in bytes
121 * @param dst_stride destination image line size in bytes
122 * @param width image width in pixels
123 * @param height image height in pixels
124 * @param matrix 9-item affine transformation matrix
125 * @param interpolate pixel interpolation method
126 * @param fill edge fill method
127 * @return negative on error
129 int avfilter_transform(const uint8_t *src, uint8_t *dst,
130 int src_stride, int dst_stride,
131 int width, int height, const float *matrix,
132 enum InterpolateMethod interpolate,
133 enum FillMethod fill);
135 #endif /* AVFILTER_TRANSFORM_H */