FFmpeg
Macros | Functions
transform.c File Reference
#include "libavutil/common.h"
#include "libavutil/avassert.h"
#include "transform.h"

Go to the source code of this file.

Macros

#define INTERPOLATE_METHOD(name)
 
#define PIXEL(img, x, y, w, h, stride, def)
 

Functions

 INTERPOLATE_METHOD (interpolate_nearest)
 Nearest neighbor interpolation. More...
 
 INTERPOLATE_METHOD (interpolate_bilinear)
 Bilinear interpolation. More...
 
 INTERPOLATE_METHOD (interpolate_biquadratic)
 Biquadratic interpolation. More...
 
void avfilter_get_matrix (float x_shift, float y_shift, float angle, float zoom, float *matrix)
 Get an affine transformation matrix from a given translation, rotation, and zoom factor. More...
 
void avfilter_add_matrix (const float *m1, const float *m2, float *result)
 Add two matrices together. More...
 
void avfilter_sub_matrix (const float *m1, const float *m2, float *result)
 Subtract one matrix from another. More...
 
void avfilter_mul_matrix (const float *m1, float scalar, float *result)
 Multiply a matrix by a scalar value. More...
 
int avfilter_transform (const uint8_t *src, uint8_t *dst, int src_stride, int dst_stride, int width, int height, const float *matrix, enum InterpolateMethod interpolate, enum FillMethod fill)
 Do an affine transformation with the given interpolation method. More...
 

Detailed Description

transform input video

Definition in file transform.c.

Macro Definition Documentation

◆ INTERPOLATE_METHOD

#define INTERPOLATE_METHOD (   name)
Value:
static uint8_t name(float x, float y, const uint8_t *src, \
int width, int height, int stride, uint8_t def)

Definition at line 32 of file transform.c.

◆ PIXEL

#define PIXEL (   img,
  x,
  y,
  w,
  h,
  stride,
  def 
)
Value:
((x) < 0 || (y) < 0) ? (def) : \
(((x) >= (w) || (y) >= (h)) ? (def) : \
img[(x) + (y) * (stride)])

Definition at line 36 of file transform.c.

Function Documentation

◆ INTERPOLATE_METHOD() [1/3]

INTERPOLATE_METHOD ( interpolate_nearest  )

Nearest neighbor interpolation.

Definition at line 44 of file transform.c.

◆ INTERPOLATE_METHOD() [2/3]

INTERPOLATE_METHOD ( interpolate_bilinear  )

Bilinear interpolation.

Definition at line 52 of file transform.c.

◆ INTERPOLATE_METHOD() [3/3]

INTERPOLATE_METHOD ( interpolate_biquadratic  )

Biquadratic interpolation.

Definition at line 79 of file transform.c.

◆ avfilter_get_matrix()

void avfilter_get_matrix ( float  x_shift,
float  y_shift,
float  angle,
float  zoom,
float *  matrix 
)

Get an affine transformation matrix from a given translation, rotation, and zoom factor.

The matrix will look like:

[ zoom * cos(angle), -sin(angle), x_shift, sin(angle), zoom * cos(angle), y_shift, 0, 0, 1 ]

Parameters
x_shifthorizontal translation
y_shiftvertical translation
anglerotation in radians
zoomscale percent (1.0 = 100%)
matrix9-item affine transformation matrix

Definition at line 106 of file transform.c.

Referenced by filter_frame().

◆ avfilter_add_matrix()

void avfilter_add_matrix ( const float *  m1,
const float *  m2,
float *  result 
)

Add two matrices together.

result = m1 + m2.

Parameters
m19-item transformation matrix
m29-item transformation matrix
result9-item transformation matrix

Definition at line 118 of file transform.c.

◆ avfilter_sub_matrix()

void avfilter_sub_matrix ( const float *  m1,
const float *  m2,
float *  result 
)

Subtract one matrix from another.

result = m1 - m2.

Parameters
m19-item transformation matrix
m29-item transformation matrix
result9-item transformation matrix

Definition at line 125 of file transform.c.

◆ avfilter_mul_matrix()

void avfilter_mul_matrix ( const float *  m1,
float  scalar,
float *  result 
)

Multiply a matrix by a scalar value.

result = m1 * scalar.

Parameters
m19-item transformation matrix
scalara number
result9-item transformation matrix

Definition at line 132 of file transform.c.

◆ avfilter_transform()

int avfilter_transform ( const uint8_t src,
uint8_t dst,
int  src_stride,
int  dst_stride,
int  width,
int  height,
const float *  matrix,
enum InterpolateMethod  interpolate,
enum FillMethod  fill 
)

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.

Parameters
srcsource image
dstdestination image
src_stridesource image line size in bytes
dst_stridedestination image line size in bytes
widthimage width in pixels
heightimage height in pixels
matrix9-item affine transformation matrix
interpolatepixel interpolation method
filledge fill method
Returns
negative on error

Definition at line 139 of file transform.c.

Referenced by deshake_transform_c().

stride
int stride
Definition: mace.c:144
w
uint8_t w
Definition: llviddspenc.c:38
name
const char * name
Definition: avisynth_c.h:867
src
#define src
Definition: vp8dsp.c:254
width
#define width
height
#define height
uint8_t
uint8_t
Definition: audio_convert.c:194
h
h
Definition: vp9dsp_template.c:2038