FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
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 "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  RotContext
 
struct  ThreadData
 

Macros

#define OFFSET(x)   offsetof(RotContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define SET_SIZE_EXPR(name, opt_name)
 
#define FIXP   (1<<16)
 
#define INT_PI   205887
 
#define TS2T(ts, tb)   ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
 

Enumerations

enum  var_name {
  VAR_CH, VAR_N, VAR_NB_IN_CHANNELS, VAR_NB_OUT_CHANNELS,
  VAR_T, VAR_S, VAR_VARS_NB, VAR_B1,
  VAR_B2, VAR_S1, VAR_S2, VAR_T1,
  VAR_T2, VAR_NB, VAR_TB, VAR_PTS,
  VAR_START_PTS, VAR_PREV_PTS, VAR_PREV_SELECTED_PTS, VAR_T,
  VAR_START_T, VAR_PREV_T, VAR_PREV_SELECTED_T, VAR_PICT_TYPE,
  VAR_I, VAR_P, VAR_B, VAR_S,
  VAR_SI, VAR_SP, VAR_BI, VAR_PICT_TYPE_I,
  VAR_PICT_TYPE_P, VAR_PICT_TYPE_B, VAR_PICT_TYPE_S, VAR_PICT_TYPE_SI,
  VAR_PICT_TYPE_SP, VAR_PICT_TYPE_BI, VAR_INTERLACE_TYPE, VAR_INTERLACE_TYPE_P,
  VAR_INTERLACE_TYPE_T, VAR_INTERLACE_TYPE_B, VAR_CONSUMED_SAMPLES_N, VAR_SAMPLES_N,
  VAR_SAMPLE_RATE, VAR_N, VAR_SELECTED_N, VAR_PREV_SELECTED_N,
  VAR_KEY, VAR_POS, VAR_SCENE, VAR_VARS_NB,
  VAR_AVTB, VAR_INTB, VAR_SR, VAR_VARS_NB,
  VAR_FRAME_RATE, VAR_INTERLACED, VAR_N, VAR_NB_CONSUMED_SAMPLES,
  VAR_NB_SAMPLES, VAR_POS, VAR_PREV_INPTS, VAR_PREV_INT,
  VAR_PREV_OUTPTS, VAR_PREV_OUTT, VAR_PTS, VAR_SAMPLE_RATE,
  VAR_STARTPTS, VAR_STARTT, VAR_T, VAR_TB,
  VAR_RTCTIME, VAR_RTCSTART, VAR_S, VAR_SR,
  VAR_VARS_NB, VAR_W, VAR_H, VAR_A,
  VAR_DAR, VAR_SAR, VAR_HSUB, VAR_VSUB,
  VARS_NB, VAR_W, VAR_H, VAR_CW,
  VAR_CH, VAR_HSUB, VAR_VSUB, VARS_NB,
  VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH,
  VAR_OUT_W, VAR_OW, VAR_OUT_H, VAR_OH,
  VAR_A, VAR_SAR, VAR_DAR, VAR_HSUB,
  VAR_VSUB, VAR_X, VAR_Y, VAR_N,
  VAR_POS, VAR_T, VAR_VARS_NB, VAR_DAR,
  VAR_HSUB, VAR_VSUB, VAR_IN_H, VAR_IH,
  VAR_IN_W, VAR_IW, VAR_SAR, VAR_X,
  VAR_Y, VAR_H, VAR_W, VAR_T,
  VARS_NB, VAR_DAR, VAR_HSUB, VAR_VSUB,
  VAR_LINE_H, VAR_LH, VAR_MAIN_H, VAR_h,
  VAR_H, VAR_MAIN_W, VAR_w, VAR_W,
  VAR_MAX_GLYPH_A, VAR_ASCENT, VAR_MAX_GLYPH_D, VAR_DESCENT,
  VAR_MAX_GLYPH_H, VAR_MAX_GLYPH_W, VAR_N, VAR_SAR,
  VAR_T, VAR_TEXT_H, VAR_TH, VAR_TEXT_W,
  VAR_TW, VAR_X, VAR_Y, VAR_PICT_TYPE,
  VAR_VARS_NB, VAR_N, VAR_PTS, VAR_R,
  VAR_T, VAR_TB, VAR_NB, VAR_W,
  VAR_H, VAR_VAL, VAR_MAXVAL, VAR_MINVAL,
  VAR_NEGVAL, VAR_CLIPVAL, VAR_VARS_NB, VAR_MAIN_W,
  VAR_MW, VAR_MAIN_H, VAR_MH, VAR_OVERLAY_W,
  VAR_OW, VAR_OVERLAY_H, VAR_OH, VAR_HSUB,
  VAR_VSUB, VAR_X, VAR_Y, VAR_N,
  VAR_POS, VAR_T, VAR_VARS_NB, VAR_IN_W,
  VAR_IW, VAR_IN_H, VAR_IH, VAR_OUT_W,
  VAR_OW, VAR_OUT_H, VAR_OH, VAR_X,
  VAR_Y, VAR_A, VAR_SAR, VAR_DAR,
  VAR_HSUB, VAR_VSUB, VARS_NB, 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,
  VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH,
  VAR_OUT_W, VAR_OW, VAR_OUT_H, VAR_OH,
  VAR_A, VAR_SAR, VAR_DAR, VAR_HSUB,
  VAR_VSUB, VAR_OHSUB, VAR_OVSUB, VARS_NB,
  VAR_W, VAR_H, VAR_N, VAR_PTS,
  VAR_R, VAR_T, VAR_TB, VAR_NB,
  VAR_X, VAR_Y, VAR_W, VAR_H,
  VAR_TIME, VAR_SPEED, VAR_TEMPO, VAR_ORDER,
  VAR_PATTERN, VAR_ROW, VAR_VARS_NB
}
 

Functions

 AVFILTER_DEFINE_CLASS (rotate)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static double get_rotated_w (void *opaque, double angle)
 
static double get_rotated_h (void *opaque, double angle)
 
static int config_props (AVFilterLink *outlink)
 
static int64_t int_sin (int64_t a)
 Compute the sin of a using integer values.
 
static uint8_tinterpolate_bilinear (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 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 * var_names []
 
static const AVOption rotate_options []
 
static double(*const func1 [])(void *, double)
 
static const char *const func1_names []
 
static const AVFilterPad rotate_inputs []
 
static const AVFilterPad rotate_outputs []
 
AVFilter ff_vf_rotate
 

Detailed Description

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

Definition in file vf_rotate.c.

Macro Definition Documentation

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

Definition at line 90 of file vf_rotate.c.

Definition at line 91 of file vf_rotate.c.

#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)

Referenced by config_props().

#define FIXP   (1<<16)

Definition at line 254 of file vf_rotate.c.

Referenced by filter_frame(), filter_slice(), and int_sin().

#define INT_PI   205887

Definition at line 255 of file vf_rotate.c.

Referenced by filter_frame(), and int_sin().

#define TS2T (   ts,
  tb 
)    ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))

Definition at line 310 of file vf_rotate.c.

Referenced by filter_frame().

Enumeration Type Documentation

enum var_name
Enumerator:
VAR_CH 
VAR_N 
VAR_NB_IN_CHANNELS 
VAR_NB_OUT_CHANNELS 
VAR_T 
VAR_S 
VAR_VARS_NB 
VAR_B1 
VAR_B2 
VAR_S1 
VAR_S2 
VAR_T1 
V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R_IW 
VAR_IN_H 
VAR_IH 
VAR_OUT_W 
VAR_OW 
VAR_OUT_H 
VAR_OH 
VAR_A 
VAR_SAR 
VAR_DAR 
VAR_HSUB 
VAR_VSUB 
VAR_OHSUB 
VAR_OVSUB 
VARS_NB 
VAR_W 
VAR_H 
VAR_N 
VAR_PTS 
VAR_R 
VAR_T 
VAR_TB 
VAR_NB 
VAR_X 
VAR_Y 
VAR_W 
VAR_H 
VAR_TIME 
VAR_SPEED 
VAR_TEMPO 
VAR_ORDER 
VAR_PATTERN 
VAR_ROW 
VAR_VARS_NB 

Definition at line 50 of file vf_rotate.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( rotate  )
static av_cold int init ( AVFilterContext ctx)
static

Definition at line 108 of file vf_rotate.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 121 of file vf_rotate.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 129 of file vf_rotate.c.

static double get_rotated_w ( void opaque,
double  angle 
)
static

Definition at line 150 of file vf_rotate.c.

static double get_rotated_h ( void opaque,
double  angle 
)
static

Definition at line 162 of file vf_rotate.c.

static int config_props ( AVFilterLink outlink)
static

Definition at line 186 of file vf_rotate.c.

static int64_t int_sin ( int64_t  a)
static

Compute the sin of a using integer values.

Input and output values are scaled by FIXP.

Definition at line 261 of file vf_rotate.c.

Referenced by filter_frame().

static uint8_t* interpolate_bilinear ( 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 284 of file vf_rotate.c.

Referenced by avfilter_transform(), and filter_slice().

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

Definition at line 312 of file vf_rotate.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 382 of file vf_rotate.c.

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

Definition at line 436 of file vf_rotate.c.

Variable Documentation

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

Definition at line 39 of file vf_rotate.c.

Referenced by config_props(), and process_command().

const AVOption rotate_options[]
static
Initial value:
= {
{ "angle", "set angle (in radians)", OFFSET(angle_expr_str), AV_OPT_TYPE_STRING, {.str="0"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
{ "a", "set angle (in radians)", OFFSET(angle_expr_str), AV_OPT_TYPE_STRING, {.str="0"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
{ "out_w", "set output width expression", OFFSET(outw_expr_str), AV_OPT_TYPE_STRING, {.str="iw"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
{ "ow", "set output width expression", OFFSET(outw_expr_str), AV_OPT_TYPE_STRING, {.str="iw"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
{ "out_h", "set output height expression", OFFSET(outh_expr_str), AV_OPT_TYPE_STRING, {.str="ih"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
{ "oh", "set output height expression", OFFSET(outh_expr_str), AV_OPT_TYPE_STRING, {.str="ih"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
{ "fillcolor", "set background fill color", OFFSET(fillcolor_str), AV_OPT_TYPE_STRING, {.str="black"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
{ "c", "set background fill color", OFFSET(fillcolor_str), AV_OPT_TYPE_STRING, {.str="black"}, CHAR_MIN, CHAR_MAX, .flags=FLAGS },
{ "bilinear", "use bilinear interpolation", OFFSET(use_bilinear), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, .flags=FLAGS },
{ NULL }
}

Definition at line 93 of file vf_rotate.c.

double(* const func1[])(void *, double)
static
Initial value:

Definition at line 174 of file vf_rotate.c.

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

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

Definition at line 180 of file vf_rotate.c.

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

const AVFilterPad rotate_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
{ NULL }
}

Definition at line 459 of file vf_rotate.c.

const AVFilterPad rotate_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_props,
},
{ NULL }
}

Definition at line 468 of file vf_rotate.c.

AVFilter ff_vf_rotate
Initial value:
= {
.name = "rotate",
.description = NULL_IF_CONFIG_SMALL("Rotate the input image."),
.priv_size = sizeof(RotContext),
.init = init,
.priv_class = &rotate_class,
}

Definition at line 477 of file vf_rotate.c.