FFmpeg
Loading...
Searching...
No Matches
vf_perspective.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/eval.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "filters.h"
#include "video.h"

Go to the source code of this file.

Data Structures

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

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)
 
#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_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 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 enum AVPixelFormat pix_fmts []
 
static const char *const var_names [] = { "W", "H", "in", "on", NULL }
 
static const AVFilterPad perspective_inputs []
 
const FFFilter ff_vf_perspective
 

Macro Definition Documentation

◆ SUB_PIXEL_BITS

#define SUB_PIXEL_BITS   8

Definition at line 32 of file vf_perspective.c.

Referenced by resample_cubic(), and resample_linear().

◆ SUB_PIXELS

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

◆ COEFF_BITS

#define COEFF_BITS   11

Definition at line 34 of file vf_perspective.c.

◆ LINEAR

◆ CUBIC

#define CUBIC   1

Definition at line 37 of file vf_perspective.c.

Referenced by init().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 57 of file vf_perspective.c.

◆ FLAGS

Definition at line 58 of file vf_perspective.c.

Enumeration Type Documentation

◆ PERSPECTIVESense

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.

◆ EvalMode

enum EvalMode
Enumerator
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 

Definition at line 65 of file vf_perspective.c.

◆ anonymous enum

anonymous enum
Enumerator
VAR_W 
VAR_H 
VAR_IN 
VAR_ON 
VAR_VARS_NB 

Definition at line 121 of file vf_perspective.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( perspective )

◆ get_coeff()

static double get_coeff ( double d)
inlinestatic

Definition at line 104 of file vf_perspective.c.

Referenced by config_input().

◆ calc_persp_luts()

static int calc_persp_luts ( AVFilterContext * ctx,
AVFilterLink * inlink )
static

Definition at line 123 of file vf_perspective.c.

Referenced by config_input(), and filter_frame().

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 222 of file vf_perspective.c.

◆ resample_cubic()

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

Definition at line 276 of file vf_perspective.c.

Referenced by init().

◆ resample_linear()

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

Definition at line 355 of file vf_perspective.c.

Referenced by init(), and resample_linear_TMPL().

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 430 of file vf_perspective.c.

◆ filter_frame()

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

Definition at line 442 of file vf_perspective.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 484 of file vf_perspective.c.

Variable Documentation

◆ perspective_options

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, .unit = "interpolation" },
{ "linear", "", 0, AV_OPT_TYPE_CONST, {.i64=LINEAR}, 0, 0, FLAGS, .unit = "interpolation" },
{ "cubic", "", 0, AV_OPT_TYPE_CONST, {.i64=CUBIC}, 0, 0, FLAGS, .unit = "interpolation" },
{ "sense", "specify the sense of the coordinates", OFFSET(sense), AV_OPT_TYPE_INT, {.i64=PERSPECTIVE_SENSE_SOURCE}, 0, 1, FLAGS, .unit = "sense"},
{ "source", "specify locations in source to send to corners in destination",
0, AV_OPT_TYPE_CONST, {.i64=PERSPECTIVE_SENSE_SOURCE}, 0, 0, FLAGS, .unit = "sense"},
{ "destination", "specify locations in destination to send corners of source",
0, AV_OPT_TYPE_CONST, {.i64=PERSPECTIVE_SENSE_DESTINATION}, 0, 0, FLAGS, .unit = "sense"},
{ "eval", "specify when to evaluate expressions", OFFSET(eval_mode), AV_OPT_TYPE_INT, {.i64 = EVAL_MODE_INIT}, 0, EVAL_MODE_NB-1, FLAGS, .unit = "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 }
}
static int interpolation(DeclickChannel *c, const double *src, int ar_order, double *acoefficients, int *index, int nb_errors, double *auxiliary, double *interpolated)
@ EVAL_MODE_NB
Definition af_volume.h:42
@ EVAL_MODE_FRAME
Definition af_volume.h:41
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ 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
@ EVAL_MODE_INIT
Definition vf_fftfilt.c:41
#define CUBIC
#define LINEAR
@ PERSPECTIVE_SENSE_DESTINATION
coordinates give locations in destination of corners of source.
@ PERSPECTIVE_SENSE_SOURCE
coordinates give locations in source of corners of destination.

Definition at line 71 of file vf_perspective.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static
Initial value:
= {
}
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ 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_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ 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_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition pixfmt.h:107
@ 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_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ 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_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition pixfmt.h:174
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition pixfmt.h:283
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition pixfmt.h:212
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition pixfmt.h:86
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition pixfmt.h:173
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition pixfmt.h:165
@ 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_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

Definition at line 97 of file vf_perspective.c.

◆ var_names

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

Definition at line 120 of file vf_perspective.c.

◆ perspective_inputs

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

Definition at line 491 of file vf_perspective.c.

◆ ff_vf_perspective

const FFFilter ff_vf_perspective
Initial value:
= {
.p.name = "perspective",
.p.description = NULL_IF_CONFIG_SMALL("Correct the perspective of video."),
.p.priv_class = &perspective_class,
.priv_size = sizeof(PerspectiveContext),
.init = init,
}
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 perspective_inputs[]
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition video.c:37

Definition at line 500 of file vf_perspective.c.