FFmpeg
Data Structures | Macros | Functions | Variables
vf_format.c File Reference
#include "config_components.h"
#include <string.h>
#include "libavutil/internal.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  FormatContext
 

Macros

#define DEFINE_PARSE(name, Type, get, descr, extra_test)
 
#define PARSE_LIST(strfield, fmtfield, tvar, parse)
 
#define OFFSET(x)   offsetof(FormatContext, x)
 

Functions

static av_cold void uninit (AVFilterContext *ctx)
 
static av_cold int invert_formats (AVFilterFormats **fmts, AVFilterFormats *allfmts)
 
static av_cold int init (AVFilterContext *ctx)
 
static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
 AVFILTER_DEFINE_CLASS_EXT (format, "(no)format", options)
 

Variables

static const AVOption options []
 
static const AVFilterPad inputs []
 

Detailed Description

format and noformat video filters

Definition in file vf_format.c.

Macro Definition Documentation

◆ DEFINE_PARSE

#define DEFINE_PARSE (   name,
  Type,
  get,
  descr,
  extra_test 
)
Value:
static int parse_##name(enum Type *ret, const char *arg, void *log_ctx) \
{ \
char *tail; \
int val = get(arg); \
if (val < 0) { \
val = strtol(arg, &tail, 0); \
if (*tail || extra_test) { \
av_log(log_ctx, AV_LOG_ERROR, "Invalid " descr " '%s'\n", arg); \
return AVERROR(EINVAL); \
} \
} \
*ret = val; \
return 0; \
}

Definition at line 91 of file vf_format.c.

◆ PARSE_LIST

#define PARSE_LIST (   strfield,
  fmtfield,
  tvar,
  parse 
)
Value:
for (char *sep, *cur = s->strfield; cur; cur = sep) { \
sep = strchr(cur, '|'); \
if (sep && *sep) \
*sep++ = 0; \
if ((ret = parse(&tvar, cur, ctx)) < 0 || \
(ret = ff_add_format(&s->fmtfield, tvar)) < 0) \
return ret; \
}

◆ OFFSET

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

Definition at line 171 of file vf_format.c.

Function Documentation

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 53 of file vf_format.c.

◆ invert_formats()

static av_cold int invert_formats ( AVFilterFormats **  fmts,
AVFilterFormats allfmts 
)
static

Definition at line 62 of file vf_format.c.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 112 of file vf_format.c.

◆ query_formats()

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

Definition at line 154 of file vf_format.c.

◆ AVFILTER_DEFINE_CLASS_EXT()

AVFILTER_DEFINE_CLASS_EXT ( format  ,
"(no)format ,
options   
)

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "pix_fmts", "A '|'-separated list of pixel formats", OFFSET(pix_fmts), AV_OPT_TYPE_STRING, .flags = AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM },
{ "color_spaces", "A '|'-separated list of color spaces", OFFSET(csps), AV_OPT_TYPE_STRING, .flags = AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM },
{ "color_ranges", "A '|'-separated list of color ranges", OFFSET(ranges), AV_OPT_TYPE_STRING, .flags = AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM },
{ "alpha_modes", "A '|'-separated list of alpha modes", OFFSET(alphamodes), AV_OPT_TYPE_STRING, .flags = AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM },
{ NULL }
}

Definition at line 172 of file vf_format.c.

◆ inputs

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
.get_buffer.video = ff_null_get_video_buffer,
},
}

Definition at line 182 of file vf_format.c.

name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
val
static double val(void *priv, double ch)
Definition: aeval.c:77
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:296
ctx
static AVFormatContext * ctx
Definition: movenc.c:49
arg
const char * arg
Definition: jacosubdec.c:65
NULL
#define NULL
Definition: coverity.c:32
ff_add_format
int ff_add_format(AVFilterFormats **avff, int64_t fmt)
Add fmt to the list of media formats contained in *avff.
Definition: formats.c:571
parse
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
Definition: apv_parser.c:92
AV_OPT_FLAG_FILTERING_PARAM
#define AV_OPT_FLAG_FILTERING_PARAM
A generic parameter which can be set by the user for filtering.
Definition: opt.h:380
OFFSET
#define OFFSET(x)
Definition: vf_format.c:171
ff_null_get_video_buffer
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:44
Type
Type
Definition: vf_idet.c:30
s
uint8_t s
Definition: llvidencdsp.c:39
AV_OPT_FLAG_VIDEO_PARAM
#define AV_OPT_FLAG_VIDEO_PARAM
Definition: opt.h:357
ret
ret
Definition: filter_design.txt:187
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
AV_OPT_TYPE_STRING
@ 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