FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
vf_perspective.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/eval.h"
#include "libavutil/imgutils.h"
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  PerspectiveContext
 
struct  ThreadData
 

Macros

#define SUB_PIXEL_BITS   8
 
#define SUB_PIXELS   (1 << SUB_PIXEL_BITS)
 
#define COEFF_BITS   11
 
#define LINEAR   0
 
#define CUBIC   1
 
#define OFFSET(x)   offsetof(PerspectiveContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 

Enumerations

enum  PERSPECTIVESense { PERSPECTIVE_SENSE_SOURCE = 0, PERSPECTIVE_SENSE_DESTINATION = 1 }
 
enum  EvalMode {
  EVAL_MODE_ONCE, EVAL_MODE_FRAME, EVAL_MODE_NB, EVAL_MODE_INIT,
  EVAL_MODE_FRAME, EVAL_MODE_NB, EVAL_MODE_INIT, EVAL_MODE_FRAME,
  EVAL_MODE_NB, EVAL_MODE_INIT, EVAL_MODE_FRAME, EVAL_MODE_NB,
  EVAL_MODE_INIT, EVAL_MODE_FRAME, EVAL_MODE_NB, EVAL_MODE_INIT,
  EVAL_MODE_FRAME, EVAL_MODE_NB, EVAL_MODE_INIT, EVAL_MODE_FRAME,
  EVAL_MODE_NB
}
 
enum  {
  VAR_W, VAR_H, VAR_IN, VAR_ON,
  VAR_VARS_NB
}
 

Functions

 AVFILTER_DEFINE_CLASS (perspective)
 
static int query_formats (AVFilterContext *ctx)
 
static double get_coeff (double d)
 
static int calc_persp_luts (AVFilterContext *ctx, AVFilterLink *inlink)
 
static int config_input (AVFilterLink *inlink)
 
static int resample_cubic (AVFilterContext *ctx, void *arg, int job, int nb_jobs)
 
static int resample_linear (AVFilterContext *ctx, void *arg, int job, int nb_jobs)
 
static av_cold int init (AVFilterContext *ctx)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption perspective_options []
 
static const char *const var_names [] = { "W", "H", "in", "on", NULL }
 
static const AVFilterPad perspective_inputs []
 
static const AVFilterPad perspective_outputs []
 
AVFilter ff_vf_perspective
 

Macro Definition Documentation

#define SUB_PIXEL_BITS   8

Definition at line 32 of file vf_perspective.c.

Referenced by resample_cubic(), and resample_linear().

#define SUB_PIXELS   (1 << SUB_PIXEL_BITS)

Definition at line 33 of file vf_perspective.c.

Referenced by calc_persp_luts(), config_input(), resample_cubic(), and resample_linear().

#define COEFF_BITS   11

Definition at line 34 of file vf_perspective.c.

Referenced by config_input(), and resample_cubic().

#define LINEAR   0

Definition at line 36 of file vf_perspective.c.

Referenced by init().

#define CUBIC   1

Definition at line 37 of file vf_perspective.c.

Referenced by init().

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

Definition at line 57 of file vf_perspective.c.

Definition at line 58 of file vf_perspective.c.

Enumeration Type Documentation

Enumerator
PERSPECTIVE_SENSE_SOURCE 

coordinates give locations in source of corners of destination.

PERSPECTIVE_SENSE_DESTINATION 

coordinates give locations in destination of corners of source.

Definition at line 60 of file vf_perspective.c.

enum EvalMode
Enumerator
EVAL_MODE_ONCE 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 

Definition at line 65 of file vf_perspective.c.

anonymous enum
Enumerator
VAR_W 
VAR_H 
VAR_IN 
VAR_ON 
VAR_VARS_NB 

Definition at line 129 of file vf_perspective.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( perspective  )
static int query_formats ( AVFilterContext ctx)
static

Definition at line 97 of file vf_perspective.c.

static double get_coeff ( double  d)
inlinestatic

Definition at line 112 of file vf_perspective.c.

Referenced by config_input().

static int calc_persp_luts ( AVFilterContext ctx,
AVFilterLink inlink 
)
static

Definition at line 131 of file vf_perspective.c.

Referenced by config_input(), and filter_frame().

static int config_input ( AVFilterLink inlink)
static

Definition at line 228 of file vf_perspective.c.

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

Definition at line 282 of file vf_perspective.c.

Referenced by init().

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

Definition at line 361 of file vf_perspective.c.

Referenced by init().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 436 of file vf_perspective.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 448 of file vf_perspective.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 489 of file vf_perspective.c.

Variable Documentation

const AVOption perspective_options[]
static
Initial value:
= {
{ "x0", "set top left x coordinate", OFFSET(expr_str[0][0]), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS },
{ "y0", "set top left y coordinate", OFFSET(expr_str[0][1]), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS },
{ "x1", "set top right x coordinate", OFFSET(expr_str[1][0]), AV_OPT_TYPE_STRING, {.str="W"}, 0, 0, FLAGS },
{ "y1", "set top right y coordinate", OFFSET(expr_str[1][1]), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS },
{ "x2", "set bottom left x coordinate", OFFSET(expr_str[2][0]), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS },
{ "y2", "set bottom left y coordinate", OFFSET(expr_str[2][1]), AV_OPT_TYPE_STRING, {.str="H"}, 0, 0, FLAGS },
{ "x3", "set bottom right x coordinate", OFFSET(expr_str[3][0]), AV_OPT_TYPE_STRING, {.str="W"}, 0, 0, FLAGS },
{ "y3", "set bottom right y coordinate", OFFSET(expr_str[3][1]), AV_OPT_TYPE_STRING, {.str="H"}, 0, 0, FLAGS },
{ "interpolation", "set interpolation", OFFSET(interpolation), AV_OPT_TYPE_INT, {.i64=LINEAR}, 0, 1, FLAGS, "interpolation" },
{ "linear", "", 0, AV_OPT_TYPE_CONST, {.i64=LINEAR}, 0, 0, FLAGS, "interpolation" },
{ "cubic", "", 0, AV_OPT_TYPE_CONST, {.i64=CUBIC}, 0, 0, FLAGS, "interpolation" },
{ "sense", "specify the sense of the coordinates", OFFSET(sense), AV_OPT_TYPE_INT, {.i64=PERSPECTIVE_SENSE_SOURCE}, 0, 1, FLAGS, "sense"},
{ "source", "specify locations in source to send to corners in destination",
0, AV_OPT_TYPE_CONST, {.i64=PERSPECTIVE_SENSE_SOURCE}, 0, 0, FLAGS, "sense"},
{ "destination", "specify locations in destination to send corners of source",
{ "eval", "specify when to evaluate expressions", OFFSET(eval_mode), AV_OPT_TYPE_INT, {.i64 = EVAL_MODE_INIT}, 0, EVAL_MODE_NB-1, FLAGS, "eval" },
{ "init", "eval expressions once during initialization", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_INIT}, .flags = FLAGS, .unit = "eval" },
{ "frame", "eval expressions per-frame", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_FRAME}, .flags = FLAGS, .unit = "eval" },
{ NULL }
}
#define NULL
Definition: coverity.c:32
coordinates give locations in destination of corners of source.
#define FLAGS
coordinates give locations in source of corners of destination.
#define CUBIC
#define LINEAR
#define OFFSET(x)

Definition at line 71 of file vf_perspective.c.

const char* const var_names[] = { "W", "H", "in", "on", NULL }
static

Definition at line 128 of file vf_perspective.c.

Referenced by calc_persp_luts().

const AVFilterPad perspective_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_input,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_input(AVFilterLink *inlink)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)

Definition at line 496 of file vf_perspective.c.

const AVFilterPad perspective_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
#define NULL
Definition: coverity.c:32

Definition at line 506 of file vf_perspective.c.

AVFilter ff_vf_perspective
Initial value:
= {
.name = "perspective",
.description = NULL_IF_CONFIG_SMALL("Correct the perspective of video."),
.priv_size = sizeof(PerspectiveContext),
.init = init,
.priv_class = &perspective_class,
}
static int query_formats(AVFilterContext *ctx)
#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:125
static av_cold void uninit(AVFilterContext *ctx)
static int flags
Definition: log.c:55
static const AVFilterPad perspective_inputs[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
static av_cold int init(AVFilterContext *ctx)
static const AVFilterPad perspective_outputs[]

Definition at line 514 of file vf_perspective.c.