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

scale video filter More...

#include <float.h>
#include <stdio.h>
#include <string.h>
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "framesync.h"
#include "libavutil/pixfmt.h"
#include "scale_eval.h"
#include "video.h"
#include "libavutil/eval.h"
#include "libavutil/imgutils_internal.h"
#include "libavutil/internal.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/pixdesc.h"
#include "libswscale/swscale.h"

Go to the source code of this file.

Data Structures

struct  ScaleContext
 

Macros

#define IS_SCALE2REF(ctx)
 
#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define TFLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 

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_A , VAR_SAR , VAR_DAR , VAR_HSUB ,
  VAR_VSUB , VAR_OHSUB , VAR_OVSUB , VAR_N ,
  VAR_T , VAR_REF_W , VAR_RW , VAR_REF_H ,
  VAR_RH , VAR_REF_A , VAR_REF_SAR , VAR_REF_DAR ,
  VAR_RDAR , VAR_REF_HSUB , VAR_REF_VSUB , VAR_REF_N ,
  VAR_REF_T , VAR_REF_POS , VAR_S2R_MAIN_W , VAR_S2R_MAIN_H ,
  VAR_S2R_MAIN_A , VAR_S2R_MAIN_SAR , VAR_S2R_MAIN_DAR , VAR_S2R_MDAR ,
  VAR_S2R_MAIN_HSUB , VAR_S2R_MAIN_VSUB , VAR_S2R_MAIN_N , VAR_S2R_MAIN_T ,
  VAR_S2R_MAIN_POS , VARS_NB
}
 
enum  EvalMode { EVAL_MODE_INIT , EVAL_MODE_FRAME , EVAL_MODE_NB }
 

Functions

static int config_props (AVFilterLink *outlink)
 
static int check_exprs (AVFilterContext *ctx)
 
static int scale_parse_expr (AVFilterContext *ctx, char *str_expr, AVExpr **pexpr_ptr, const char *var, const char *args)
 
static av_cold int preinit (AVFilterContext *ctx)
 
static int do_scale (FFFrameSync *fs)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static int scale_eval_dimensions (AVFilterContext *ctx)
 
static int config_props_ref (AVFilterLink *outlink)
 
static int request_frame (AVFilterLink *outlink)
 
static int request_frame_ref (AVFilterLink *outlink)
 
static int scale_frame (AVFilterLink *link, AVFrame **frame_in, AVFrame **frame_out)
 
static int filter_frame (AVFilterLink *link, AVFrame *in)
 
static int filter_frame_ref (AVFilterLink *link, AVFrame *in)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 
static int activate (AVFilterContext *ctx)
 
static const AVClasschild_class_iterate (void **iter)
 
static void * child_next (void *obj, void *prev)
 
static const AVClassscale2ref_child_class_iterate (void **iter)
 
static void * scale2ref_child_next (void *obj, void *prev)
 

Variables

static const char *const var_names []
 
const FFFilter ff_vf_scale2ref
 
static const AVOption scale_options []
 
static const AVClass scale_class
 
static const AVFilterPad avfilter_vf_scale_inputs []
 
static const AVFilterPad avfilter_vf_scale_outputs []
 
const FFFilter ff_vf_scale
 
static const AVClass scale2ref_class
 
static const AVFilterPad avfilter_vf_scale2ref_inputs []
 
static const AVFilterPad avfilter_vf_scale2ref_outputs []
 

Detailed Description

scale video filter

Definition in file vf_scale.c.

Macro Definition Documentation

◆ IS_SCALE2REF

#define IS_SCALE2REF ( ctx)
Value:
((ctx)->filter == &ff_vf_scale2ref.p)
const FFFilter ff_vf_scale2ref
Definition vf_scale.c:1258
static AVFormatContext * ctx
Definition movenc.c:49

Definition at line 180 of file vf_scale.c.

Referenced by check_exprs(), config_props(), init(), nppscale_scale(), scale_eval_dimensions(), and scale_frame().

◆ OFFSET

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

Definition at line 1065 of file vf_scale.c.

◆ FLAGS

Definition at line 1066 of file vf_scale.c.

◆ TFLAGS

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_A 
VAR_SAR 
VAR_DAR 
VAR_HSUB 
VAR_VSUB 
VAR_OHSUB 
VAR_OVSUB 
VAR_N 
VAR_T 
VAR_REF_W 
VAR_RW 
VAR_REF_H 
VAR_RH 
VAR_REF_A 
VAR_REF_SAR 
VAR_REF_DAR 
VAR_RDAR 
VAR_REF_HSUB 
VAR_REF_VSUB 
VAR_REF_N 
VAR_REF_T 
VAR_REF_POS 
VAR_S2R_MAIN_W 
VAR_S2R_MAIN_H 
VAR_S2R_MAIN_A 
VAR_S2R_MAIN_SAR 
VAR_S2R_MAIN_DAR 
VAR_S2R_MDAR 
VAR_S2R_MAIN_HSUB 
VAR_S2R_MAIN_VSUB 
VAR_S2R_MAIN_N 
VAR_S2R_MAIN_T 
VAR_S2R_MAIN_POS 
VARS_NB 

Definition at line 84 of file vf_scale.c.

◆ EvalMode

enum EvalMode
Enumerator
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 

Definition at line 121 of file vf_scale.c.

Function Documentation

◆ config_props()

static int config_props ( AVFilterLink * outlink)
static

Definition at line 621 of file vf_scale.c.

Referenced by do_scale(), scale_frame(), and scale_parse_expr().

◆ check_exprs()

static int check_exprs ( AVFilterContext * ctx)
static

Definition at line 184 of file vf_scale.c.

Referenced by scale_parse_expr().

◆ scale_parse_expr()

static int scale_parse_expr ( AVFilterContext * ctx,
char * str_expr,
AVExpr ** pexpr_ptr,
const char * var,
const char * args )
static

Definition at line 257 of file vf_scale.c.

Referenced by init(), process_command(), and scale_frame().

◆ preinit()

static av_cold int preinit ( AVFilterContext * ctx)
static

Definition at line 310 of file vf_scale.c.

◆ do_scale()

static int do_scale ( FFFrameSync * fs)
static

Definition at line 898 of file vf_scale.c.

Referenced by config_props().

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 328 of file vf_scale.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 441 of file vf_scale.c.

◆ query_formats()

static int query_formats ( const AVFilterContext * ctx,
AVFilterFormatsConfig ** cfg_in,
AVFilterFormatsConfig ** cfg_out )
static

Definition at line 451 of file vf_scale.c.

◆ scale_eval_dimensions()

static int scale_eval_dimensions ( AVFilterContext * ctx)
static

Definition at line 532 of file vf_scale.c.

Referenced by config_props().

◆ config_props_ref()

static int config_props_ref ( AVFilterLink * outlink)
static

Definition at line 716 of file vf_scale.c.

Referenced by filter_frame_ref().

◆ request_frame()

static int request_frame ( AVFilterLink * outlink)
static

Definition at line 733 of file vf_scale.c.

◆ request_frame_ref()

static int request_frame_ref ( AVFilterLink * outlink)
static

Definition at line 738 of file vf_scale.c.

◆ scale_frame()

static int scale_frame ( AVFilterLink * link,
AVFrame ** frame_in,
AVFrame ** frame_out )
static

Definition at line 744 of file vf_scale.c.

Referenced by do_scale(), and filter_frame().

◆ filter_frame()

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

Definition at line 961 of file vf_scale.c.

◆ filter_frame_ref()

static int filter_frame_ref ( AVFilterLink * link,
AVFrame * in )
static

Definition at line 975 of file vf_scale.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 1010 of file vf_scale.c.

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 1035 of file vf_scale.c.

◆ child_class_iterate()

static const AVClass * child_class_iterate ( void ** iter)
static

Definition at line 1041 of file vf_scale.c.

◆ child_next()

static void * child_next ( void * obj,
void * prev )
static

Definition at line 1055 of file vf_scale.c.

◆ scale2ref_child_class_iterate()

static const AVClass * scale2ref_child_class_iterate ( void ** iter)
static

Definition at line 1205 of file vf_scale.c.

◆ scale2ref_child_next()

static void * scale2ref_child_next ( void * obj,
void * prev )
static

Definition at line 1212 of file vf_scale.c.

Variable Documentation

◆ var_names

const char* const var_names[]
static

Definition at line 46 of file vf_scale.c.

◆ ff_vf_scale2ref

const FFFilter ff_vf_scale2ref
Initial value:
= {
.p.name = "scale2ref",
.p.description = NULL_IF_CONFIG_SMALL("Scale the input video size and/or convert the image format to the given reference."),
.p.priv_class = &scale2ref_class,
.preinit = preinit,
.init = init,
.uninit = uninit,
.priv_size = sizeof(ScaleContext),
.process_command = process_command,
}
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
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
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_QUERY_FUNC2(func)
Definition filters.h:241
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static av_cold int preinit(AVBitStreamFilterContext *ctx)
Definition source.c:137
static const AVClass scale2ref_class
Definition vf_scale.c:1220
static const AVFilterPad avfilter_vf_scale2ref_inputs[]
Definition vf_scale.c:1230
static const AVFilterPad avfilter_vf_scale2ref_outputs[]
Definition vf_scale.c:1243

Definition at line 179 of file vf_scale.c.

◆ scale_options

const AVOption scale_options[]
static

Definition at line 1069 of file vf_scale.c.

◆ scale_class

const AVClass scale_class
static
Initial value:
= {
.class_name = "scale",
.item_name = av_default_item_name,
.option = scale_options,
.child_class_iterate = child_class_iterate,
.child_next = child_next,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
@ AV_CLASS_CATEGORY_FILTER
Definition log.h:36
static void * child_next(void *obj, void *prev)
Definition vf_scale.c:1055
static const AVClass * child_class_iterate(void **iter)
Definition vf_scale.c:1041
static const AVOption scale_options[]
Definition vf_scale.c:1069

Definition at line 1164 of file vf_scale.c.

◆ avfilter_vf_scale_inputs

const AVFilterPad avfilter_vf_scale_inputs[]
static
Initial value:
= {
{
.name = "default",
},
}
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200

Definition at line 1174 of file vf_scale.c.

◆ avfilter_vf_scale_outputs

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

Definition at line 1181 of file vf_scale.c.

◆ ff_vf_scale

const FFFilter ff_vf_scale
Initial value:
= {
.p.name = "scale",
.p.description = NULL_IF_CONFIG_SMALL("Scale the input video size and/or convert the image format."),
.p.priv_class = &scale_class,
.preinit = preinit,
.init = init,
.uninit = uninit,
.priv_size = sizeof(ScaleContext),
.activate = activate,
.process_command = process_command,
}
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition avfilter.h:155
static int activate(AVBitStreamFilterContext *ctx)
static const AVClass scale_class
Definition vf_scale.c:1164
static const AVFilterPad avfilter_vf_scale_outputs[]
Definition vf_scale.c:1181
static const AVFilterPad avfilter_vf_scale_inputs[]
Definition vf_scale.c:1174

Definition at line 1189 of file vf_scale.c.

◆ scale2ref_class

const AVClass scale2ref_class
static
Initial value:
= {
.class_name = "scale(2ref)",
.item_name = av_default_item_name,
.option = scale_options,
.child_class_iterate = scale2ref_child_class_iterate,
.child_next = scale2ref_child_next,
}
static void * scale2ref_child_next(void *obj, void *prev)
Definition vf_scale.c:1212
static const AVClass * scale2ref_child_class_iterate(void **iter)
Definition vf_scale.c:1205

Definition at line 1220 of file vf_scale.c.

◆ avfilter_vf_scale2ref_inputs

const AVFilterPad avfilter_vf_scale2ref_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
{
.name = "ref",
.filter_frame = filter_frame_ref,
},
}
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
static int filter_frame_ref(AVFilterLink *link, AVFrame *in)
Definition vf_scale.c:975

Definition at line 1230 of file vf_scale.c.

◆ avfilter_vf_scale2ref_outputs

const AVFilterPad avfilter_vf_scale2ref_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_props,
.request_frame= request_frame,
},
{
.name = "ref",
.config_props = config_props_ref,
.request_frame= request_frame_ref,
},
}
static int request_frame(AVFilterLink *outlink)
Definition af_aecho.c:272
static int request_frame_ref(AVFilterLink *outlink)
Definition vf_scale.c:738
static int config_props_ref(AVFilterLink *outlink)
Definition vf_scale.c:716

Definition at line 1243 of file vf_scale.c.