FFmpeg
Loading...
Searching...
No Matches
vf_rotate.c File Reference

rotation filter, partially based on the tests/rotozoom.c program More...

#include "libavutil/avstring.h"
#include "libavutil/eval.h"
#include "libavutil/opt.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/parseutils.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "drawutils.h"
#include "filters.h"
#include "video.h"
#include <float.h>

Go to the source code of this file.

Data Structures

struct  RotContext
 
struct  ThreadData
 Used for passing data between threads. More...
 

Macros

#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define TFLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
#define FIXP   (1<<16)
 
#define FIXP2   (1<<20)
 
#define INT_PI   3294199
 
#define SET_SIZE_EXPR(name, opt_name)
 

Enumerations

enum  var_name {
  VAR_IN_W , VAR_IW , VAR_IN_H , VAR_IH ,
  VAR_OUT_W , VAR_OW , VAR_OUT_H , VAR_OH ,
  VAR_HSUB , VAR_VSUB , VAR_N , VAR_T ,
  VAR_VARS_NB
}
 

Functions

 AVFILTER_DEFINE_CLASS (rotate)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static double get_rotated_w (void *opaque, double angle)
 
static double get_rotated_h (void *opaque, double angle)
 
static int64_t int_sin (int64_t a)
 Compute the sin of a using integer values.
 
static uint8_t * interpolate_bilinear8 (uint8_t *dst_color, const uint8_t *src, int src_linesize, int src_linestep, int x, int y, int max_x, int max_y)
 Interpolate the color in src at position x and y using bilinear interpolation.
 
static uint8_t * interpolate_bilinear16 (uint8_t *dst_color, const uint8_t *src, int src_linesize, int src_linestep, int x, int y, int max_x, int max_y)
 Interpolate the color in src at position x and y using bilinear interpolation.
 
static int config_props (AVFilterLink *outlink)
 
static av_always_inline void copy_elem (uint8_t *pout, const uint8_t *pin, int elem_size)
 
static av_always_inline void simple_rotate_internal (uint8_t *dst, const uint8_t *src, int src_linesize, int angle, int elem_size, int len)
 
static av_always_inline void simple_rotate (uint8_t *dst, const uint8_t *src, int src_linesize, int angle, int elem_size, int len)
 
static int filter_slice (AVFilterContext *ctx, void *arg, int job, int nb_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 

Variables

static const char *const var_names []
 
static const AVOption rotate_options []
 
static enum AVPixelFormat pix_fmts []
 
static double(*const func1 [])(void *, double)
 
static const char *const func1_names []
 
static const AVFilterPad rotate_inputs []
 
static const AVFilterPad rotate_outputs []
 
const FFFilter ff_vf_rotate
 

Detailed Description

rotation filter, partially based on the tests/rotozoom.c program

Definition in file vf_rotate.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET ( x)
Value:
offsetof(RotContext, x)

Definition at line 95 of file vf_rotate.c.

◆ FLAGS

Definition at line 96 of file vf_rotate.c.

◆ TFLAGS

◆ FIXP

#define FIXP   (1<<16)

Definition at line 194 of file vf_rotate.c.

Referenced by filter_frame(), filter_slice(), gen_image(), init_demo(), and int_pow().

◆ FIXP2

#define FIXP2   (1<<20)

Definition at line 195 of file vf_rotate.c.

Referenced by int_sin().

◆ INT_PI

#define INT_PI   3294199

Definition at line 196 of file vf_rotate.c.

Referenced by filter_frame(), and int_sin().

◆ SET_SIZE_EXPR

#define SET_SIZE_EXPR ( name,
opt_name )
Value:
do { \
ret = av_expr_parse_and_eval(&res, expr = rot->name##_expr_str, \
var_names, rot->var_values, \
func1_names, func1, NULL, NULL, rot, 0, ctx); \
if (ret < 0 || isnan(res) || isinf(res) || res <= 0) { \
av_log(ctx, AV_LOG_ERROR, \
"Error parsing or evaluating expression for option %s: " \
"invalid expression '%s' or non-positive or indefinite value %f\n", \
opt_name, expr, res); \
return ret; \
} \
} while (0)
static AVFormatContext * ctx
#define NULL
Definition coverity.c:32
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
Definition eval.c:839
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
#define isinf(x)
Definition libm.h:319
#define isnan(x)
Definition libm.h:342
static const char *const var_names[]
Definition noise.c:30
static double(*const func1[])(void *, double)
Definition vf_rotate.c:182
static const char *const func1_names[]
Definition vf_rotate.c:188

Referenced by config_props().

Enumeration Type Documentation

◆ var_name

enum var_name
Enumerator
VAR_IN_W 
VAR_IW 
VAR_IN_H 
VAR_IH 
VAR_OUT_W 
VAR_OW 
VAR_OUT_H 
VAR_OH 
VAR_HSUB 
VAR_VSUB 
VAR_N 
VAR_T 
VAR_VARS_NB 

Definition at line 52 of file vf_rotate.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( rotate )

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 114 of file vf_rotate.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 127 of file vf_rotate.c.

◆ get_rotated_w()

static double get_rotated_w ( void * opaque,
double angle )
static

Definition at line 158 of file vf_rotate.c.

◆ get_rotated_h()

static double get_rotated_h ( void * opaque,
double angle )
static

Definition at line 170 of file vf_rotate.c.

◆ int_sin()

static int64_t int_sin ( int64_t a)
static

Compute the sin of a using integer values.

Input is scaled by FIXP2 and output values are scaled by FIXP.

Definition at line 202 of file vf_rotate.c.

Referenced by filter_frame().

◆ interpolate_bilinear8()

static uint8_t * interpolate_bilinear8 ( uint8_t * dst_color,
const uint8_t * src,
int src_linesize,
int src_linestep,
int x,
int y,
int max_x,
int max_y )
static

Interpolate the color in src at position x and y using bilinear interpolation.

Definition at line 225 of file vf_rotate.c.

Referenced by config_props().

◆ interpolate_bilinear16()

static uint8_t * interpolate_bilinear16 ( uint8_t * dst_color,
const uint8_t * src,
int src_linesize,
int src_linestep,
int x,
int y,
int max_x,
int max_y )
static

Interpolate the color in src at position x and y using bilinear interpolation.

Definition at line 255 of file vf_rotate.c.

Referenced by config_props().

◆ config_props()

static int config_props ( AVFilterLink * outlink)
static

Definition at line 281 of file vf_rotate.c.

◆ copy_elem()

static av_always_inline void copy_elem ( uint8_t * pout,
const uint8_t * pin,
int elem_size )
static

Definition at line 356 of file vf_rotate.c.

Referenced by simple_rotate_internal().

◆ simple_rotate_internal()

static av_always_inline void simple_rotate_internal ( uint8_t * dst,
const uint8_t * src,
int src_linesize,
int angle,
int elem_size,
int len )
static

Definition at line 379 of file vf_rotate.c.

Referenced by simple_rotate().

◆ simple_rotate()

static av_always_inline void simple_rotate ( uint8_t * dst,
const uint8_t * src,
int src_linesize,
int angle,
int elem_size,
int len )
static

Definition at line 401 of file vf_rotate.c.

Referenced by filter_slice().

◆ filter_slice()

static int filter_slice ( AVFilterContext * ctx,
void * arg,
int job,
int nb_jobs )
static

Definition at line 412 of file vf_rotate.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink * inlink,
AVFrame * in )
static

Definition at line 502 of file vf_rotate.c.

◆ process_command()

static int process_command ( AVFilterContext * ctx,
const char * cmd,
const char * args,
char * res,
int res_len,
int flags )
static

Definition at line 557 of file vf_rotate.c.

Variable Documentation

◆ var_names

const char* const var_names[]
static
Initial value:
= {
"in_w" , "iw",
"in_h" , "ih",
"out_w", "ow",
"out_h", "oh",
"hsub", "vsub",
"n",
"t",
}

Definition at line 41 of file vf_rotate.c.

◆ rotate_options

const AVOption rotate_options[]
static
Initial value:
= {
{ "angle", "set angle (in radians)", OFFSET(angle_expr_str), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, .flags=TFLAGS },
{ "a", "set angle (in radians)", OFFSET(angle_expr_str), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, .flags=TFLAGS },
{ "out_w", "set output width expression", OFFSET(outw_expr_str), AV_OPT_TYPE_STRING, {.str="iw"}, 0, 0, .flags=FLAGS },
{ "ow", "set output width expression", OFFSET(outw_expr_str), AV_OPT_TYPE_STRING, {.str="iw"}, 0, 0, .flags=FLAGS },
{ "out_h", "set output height expression", OFFSET(outh_expr_str), AV_OPT_TYPE_STRING, {.str="ih"}, 0, 0, .flags=FLAGS },
{ "oh", "set output height expression", OFFSET(outh_expr_str), AV_OPT_TYPE_STRING, {.str="ih"}, 0, 0, .flags=FLAGS },
{ "fillcolor", "set background fill color", OFFSET(fillcolor_str), AV_OPT_TYPE_STRING, {.str="black"}, 0, 0, .flags=FLAGS },
{ "c", "set background fill color", OFFSET(fillcolor_str), AV_OPT_TYPE_STRING, {.str="black"}, 0, 0, .flags=FLAGS },
{ "bilinear", "use bilinear interpolation", OFFSET(use_bilinear), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, .flags=FLAGS },
{ NULL }
}
#define TFLAGS
Definition af_afade.c:66
#define FLAGS
Definition cmdutils.c:598
#define OFFSET(x)
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275

Definition at line 99 of file vf_rotate.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static
Initial value:
= {
}
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition pixfmt.h:75
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUVA444P9LE
planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
Definition pixfmt.h:180
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition pixfmt.h:265
@ AV_PIX_FMT_YUVA444P10LE
planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition pixfmt.h:186
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition pixfmt.h:99
@ AV_PIX_FMT_YUV420P9LE
planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition pixfmt.h:154
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition pixfmt.h:102
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_YUVA420P10LE
planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition pixfmt.h:182
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition pixfmt.h:101
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition pixfmt.h:108
@ AV_PIX_FMT_YUV420P10LE
planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition pixfmt.h:156
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition pixfmt.h:264
@ AV_PIX_FMT_YUVA420P9LE
planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian
Definition pixfmt.h:176
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition pixfmt.h:100
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ AV_PIX_FMT_YUV444P9LE
planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition pixfmt.h:160
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition pixfmt.h:174
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition pixfmt.h:212
@ AV_PIX_FMT_YUVA444P16LE
planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
Definition pixfmt.h:192
@ AV_PIX_FMT_YUVA420P16LE
planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
Definition pixfmt.h:188
@ AV_PIX_FMT_YUV420P12LE
planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition pixfmt.h:268
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition pixfmt.h:263
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition pixfmt.h:76
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition pixfmt.h:165
@ AV_PIX_FMT_YUV444P16LE
planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition pixfmt.h:132
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition pixfmt.h:262
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition pixfmt.h:87
@ AV_PIX_FMT_YUV444P10LE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition pixfmt.h:162
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition pixfmt.h:85
@ AV_PIX_FMT_YUV420P16LE
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
Definition pixfmt.h:128
@ AV_PIX_FMT_YUV444P12LE
planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
Definition pixfmt.h:276

Definition at line 135 of file vf_rotate.c.

◆ func1

double(*const func1[])(void *, double) ( void * ,
double  )
static
Initial value:
= {
}
static double get_rotated_w(void *opaque, double angle)
Definition vf_rotate.c:158
static double get_rotated_h(void *opaque, double angle)
Definition vf_rotate.c:170

Definition at line 182 of file vf_rotate.c.

Referenced by config_props(), ff_rate_control_init(), and parse_channel_expressions().

◆ func1_names

const char* const func1_names[]
static
Initial value:
= {
"rotw",
"roth",
}

Definition at line 188 of file vf_rotate.c.

Referenced by av_expr_parse(), av_expr_parse_and_eval(), config_props(), ff_rate_control_init(), and parse_channel_expressions().

◆ rotate_inputs

const AVFilterPad rotate_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
}
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200

Definition at line 580 of file vf_rotate.c.

◆ rotate_outputs

const AVFilterPad rotate_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_props,
},
}
static int config_props(AVBitStreamFilterLink *link)
Definition source.c:181

Definition at line 588 of file vf_rotate.c.

◆ ff_vf_rotate

const FFFilter ff_vf_rotate
Initial value:
= {
.p.name = "rotate",
.p.description = NULL_IF_CONFIG_SMALL("Rotate the input image."),
.p.priv_class = &rotate_class,
.priv_size = sizeof(RotContext),
.init = init,
}
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition avfilter.h:196
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:244
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
static const AVFilterPad rotate_inputs[]
Definition vf_rotate.c:580
static const AVFilterPad rotate_outputs[]
Definition vf_rotate.c:588

Definition at line 596 of file vf_rotate.c.