2011-10-04 02:10:18 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Georg Martius <georg.martius@web.de>
|
|
|
|
* Copyright (C) 2010 Daniel G. Taylor <dan@programmer-art.org>
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2011-10-20 15:56:56 +02:00
|
|
|
#ifndef AVFILTER_TRANSFORM_H
|
|
|
|
#define AVFILTER_TRANSFORM_H
|
|
|
|
|
2012-05-09 08:15:27 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2011-10-04 02:10:18 +02:00
|
|
|
/**
|
2011-10-04 08:04:17 +02:00
|
|
|
* @file
|
2011-10-04 02:10:18 +02:00
|
|
|
* transform input video
|
|
|
|
*
|
|
|
|
* All matrices are defined as a single 9-item block of contiguous memory. For
|
|
|
|
* example, the identity matrix would be:
|
|
|
|
*
|
|
|
|
* float *matrix = {1, 0, 0,
|
|
|
|
* 0, 1, 0,
|
|
|
|
* 0, 0, 1};
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum InterpolateMethod {
|
|
|
|
INTERPOLATE_NEAREST, //< Nearest-neighbor (fast)
|
|
|
|
INTERPOLATE_BILINEAR, //< Bilinear
|
|
|
|
INTERPOLATE_BIQUADRATIC, //< Biquadratic (best)
|
|
|
|
INTERPOLATE_COUNT, //< Number of interpolation methods
|
|
|
|
};
|
|
|
|
|
|
|
|
// Shortcuts for the fastest and best interpolation methods
|
|
|
|
#define INTERPOLATE_DEFAULT INTERPOLATE_BILINEAR
|
|
|
|
#define INTERPOLATE_FAST INTERPOLATE_NEAREST
|
|
|
|
#define INTERPOLATE_BEST INTERPOLATE_BIQUADRATIC
|
|
|
|
|
|
|
|
enum FillMethod {
|
|
|
|
FILL_BLANK, //< Fill zeroes at blank locations
|
|
|
|
FILL_ORIGINAL, //< Original image at blank locations
|
|
|
|
FILL_CLAMP, //< Extruded edge value at blank locations
|
|
|
|
FILL_MIRROR, //< Mirrored edge at blank locations
|
|
|
|
FILL_COUNT, //< Number of edge fill methods
|
|
|
|
};
|
|
|
|
|
|
|
|
// Shortcuts for fill methods
|
|
|
|
#define FILL_DEFAULT FILL_ORIGINAL
|
|
|
|
|
|
|
|
/**
|
2019-08-08 15:24:31 +02:00
|
|
|
* Get an affine transformation matrix from given translation, rotation, and
|
|
|
|
* zoom factors. The matrix will look like:
|
2011-10-04 02:10:18 +02:00
|
|
|
*
|
2019-08-08 15:24:31 +02:00
|
|
|
* [ scale_x * cos(angle), -sin(angle), x_shift,
|
|
|
|
* sin(angle), scale_y * cos(angle), y_shift,
|
|
|
|
* 0, 0, 1 ]
|
2011-10-04 02:10:18 +02:00
|
|
|
*
|
2019-08-08 15:24:31 +02:00
|
|
|
* @param x_shift horizontal translation
|
|
|
|
* @param y_shift vertical translation
|
|
|
|
* @param angle rotation in radians
|
|
|
|
* @param scale_x x scale percent (1.0 = 100%)
|
|
|
|
* @param scale_y y scale percent (1.0 = 100%)
|
|
|
|
* @param matrix 9-item affine transformation matrix
|
2011-10-04 02:10:18 +02:00
|
|
|
*/
|
2019-08-08 15:24:31 +02:00
|
|
|
void ff_get_matrix(
|
|
|
|
float x_shift,
|
|
|
|
float y_shift,
|
|
|
|
float angle,
|
|
|
|
float scale_x,
|
|
|
|
float scale_y,
|
|
|
|
float *matrix
|
|
|
|
);
|
2011-10-04 02:10:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add two matrices together. result = m1 + m2.
|
|
|
|
*
|
2011-10-20 15:49:54 +02:00
|
|
|
* @param m1 9-item transformation matrix
|
|
|
|
* @param m2 9-item transformation matrix
|
|
|
|
* @param result 9-item transformation matrix
|
2011-10-04 02:10:18 +02:00
|
|
|
*/
|
|
|
|
void avfilter_add_matrix(const float *m1, const float *m2, float *result);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Subtract one matrix from another. result = m1 - m2.
|
|
|
|
*
|
2011-10-20 15:49:54 +02:00
|
|
|
* @param m1 9-item transformation matrix
|
|
|
|
* @param m2 9-item transformation matrix
|
|
|
|
* @param result 9-item transformation matrix
|
2011-10-04 02:10:18 +02:00
|
|
|
*/
|
|
|
|
void avfilter_sub_matrix(const float *m1, const float *m2, float *result);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Multiply a matrix by a scalar value. result = m1 * scalar.
|
|
|
|
*
|
2011-10-20 15:49:54 +02:00
|
|
|
* @param m1 9-item transformation matrix
|
|
|
|
* @param scalar a number
|
|
|
|
* @param result 9-item transformation matrix
|
2011-10-04 02:10:18 +02:00
|
|
|
*/
|
|
|
|
void avfilter_mul_matrix(const float *m1, float scalar, float *result);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do an affine transformation with the given interpolation method. This
|
|
|
|
* multiplies each vector [x,y,1] by the matrix and then interpolates to
|
|
|
|
* get the final value.
|
|
|
|
*
|
2011-10-20 15:49:54 +02:00
|
|
|
* @param src source image
|
|
|
|
* @param dst destination image
|
|
|
|
* @param src_stride source image line size in bytes
|
|
|
|
* @param dst_stride destination image line size in bytes
|
|
|
|
* @param width image width in pixels
|
|
|
|
* @param height image height in pixels
|
|
|
|
* @param matrix 9-item affine transformation matrix
|
|
|
|
* @param interpolate pixel interpolation method
|
|
|
|
* @param fill edge fill method
|
2012-11-01 00:41:46 +01:00
|
|
|
* @return negative on error
|
2011-10-04 02:10:18 +02:00
|
|
|
*/
|
2012-11-01 00:41:46 +01:00
|
|
|
int avfilter_transform(const uint8_t *src, uint8_t *dst,
|
2011-10-04 02:10:18 +02:00
|
|
|
int src_stride, int dst_stride,
|
|
|
|
int width, int height, const float *matrix,
|
|
|
|
enum InterpolateMethod interpolate,
|
|
|
|
enum FillMethod fill);
|
|
|
|
|
2011-10-20 15:56:56 +02:00
|
|
|
#endif /* AVFILTER_TRANSFORM_H */
|