FFmpeg
Loading...
Searching...
No Matches
vf_coreimage.m File Reference

Video processing based on Apple's CoreImage API. More...

import <CoreImage/CoreImage.h>
import <AppKit/AppKit.h>
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "video.h"
#include "libavutil/internal.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"

Go to the source code of this file.

Data Structures

struct  CoreImageContext
 

Macros

#define CLAMP_WARNING
 
#define SafeCFRelease(ptr)
 
#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define GENERATOR_OPTIONS
 
#define FILTER_OPTIONS
 

Functions

static int config_output (AVFilterLink *link)
 
static int config_input (AVFilterLink *link)
 Determine image properties from input link of filter chain.
 
static void list_filters (CoreImageContext *ctx)
 Print a list of all available filters including options and respective value ranges and defaults.
 
static int apply_filter (CoreImageContext *ctx, AVFilterLink *link, AVFrame *frame)
 
static int filter_frame (AVFilterLink *link, AVFrame *frame)
 Apply all valid filters successively to the input image.
 
static int request_frame (AVFilterLink *link)
 
static void set_option (CoreImageContext *ctx, CIFilter *filter, const char *key, const char *value)
 Set an option of the given filter to the provided key-value pair.
 
static CIFilter * create_filter (CoreImageContext *ctx, const char *filter_name, AVDictionary *filter_options)
 Create a filter object by a given name and set all options to defaults.
 
static av_cold int init (AVFilterContext *fctx)
 
static av_cold int init_src (AVFilterContext *fctx)
 
static av_cold void uninit (AVFilterContext *fctx)
 
 AVFILTER_DEFINE_CLASS (coreimage)
 
 AVFILTER_DEFINE_CLASS (coreimagesrc)
 

Variables

static const AVFilterPad vf_coreimage_inputs []
 
static const AVFilterPad vf_coreimage_outputs []
 
static const AVFilterPad vsrc_coreimagesrc_outputs []
 
static const AVOption coreimage_options []
 
const FFFilter ff_vf_coreimage
 
static const AVOption coreimagesrc_options []
 
const FFFilter ff_vsrc_coreimagesrc
 

Detailed Description

Video processing based on Apple's CoreImage API.

Definition in file vf_coreimage.m.

Macro Definition Documentation

◆ CLAMP_WARNING

#define CLAMP_WARNING
Value:
do { \
av_log(ctx, AV_LOG_WARNING, "Value of \"%f\" for option \"%s\" is out of range [%f %f], clamping to \"%f\".\n", \
input, \
[input_key UTF8String], \
min_value.floatValue, \
max_value.floatValue, \
used_value.floatValue); \
} while(0)
static AVFormatContext * ctx
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216

Referenced by set_option().

◆ SafeCFRelease

#define SafeCFRelease ( ptr)
Value:
do { \
if (ptr) { \
CFRelease(ptr); \
ptr = NULL; \
} \
} while (0)
#define NULL
Definition coverity.c:32

Referenced by uninit().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 583 of file vf_coreimage.m.

◆ FLAGS

Definition at line 584 of file vf_coreimage.m.

◆ GENERATOR_OPTIONS

#define GENERATOR_OPTIONS
Value:
{"size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS}, \
{"s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS}, \
{"rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS}, \
{"r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS}, \
{"duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS}, \
{"d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS}, \
{"sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl = 1}, 0, INT_MAX, FLAGS},
#define FLAGS
Definition cmdutils.c:597
#define OFFSET(x)
static int64_t duration
Definition ffplay.c:330
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition opt.h:302
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
Definition opt.h:318
@ AV_OPT_TYPE_RATIONAL
Underlying C type is AVRational.
Definition opt.h:279
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition opt.h:314
uint8_t w
Definition llvidencdsp.c:39

Definition at line 586 of file vf_coreimage.m.

◆ FILTER_OPTIONS

#define FILTER_OPTIONS
Value:
{"list_filters", "list available filters", OFFSET(list_filters), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, .flags = FLAGS}, \
{"list_generators", "list available generators", OFFSET(list_generators), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, .flags = FLAGS}, \
{"filter", "names and options of filters to apply", OFFSET(filter_string), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = FLAGS}, \
{"output_rect", "output rectangle within output image", OFFSET(output_rect), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = FLAGS},
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ 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
static void list_filters(CoreImageContext *ctx)
Print a list of all available filters including options and respective value ranges and defaults.

Definition at line 595 of file vf_coreimage.m.

Function Documentation

◆ config_output()

static int config_output ( AVFilterLink * link)
static

Definition at line 66 of file vf_coreimage.m.

◆ config_input()

static int config_input ( AVFilterLink * link)
static

Determine image properties from input link of filter chain.

Definition at line 85 of file vf_coreimage.m.

◆ list_filters()

static void list_filters ( CoreImageContext * ctx)
static

Print a list of all available filters including options and respective value ranges and defaults.

Definition at line 96 of file vf_coreimage.m.

Referenced by init().

◆ apply_filter()

static int apply_filter ( CoreImageContext * ctx,
AVFilterLink * link,
AVFrame * frame )
static

Definition at line 134 of file vf_coreimage.m.

Referenced by filter_frame(), and request_frame().

◆ filter_frame()

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

Apply all valid filters successively to the input image.

The final output image is copied from the GPU by "drawing" using a bitmap context.

Definition at line 271 of file vf_coreimage.m.

◆ request_frame()

static int request_frame ( AVFilterLink * link)
static

Definition at line 276 of file vf_coreimage.m.

◆ set_option()

static void set_option ( CoreImageContext * ctx,
CIFilter * filter,
const char * key,
const char * value )
static

Set an option of the given filter to the provided key-value pair.

Definition at line 312 of file vf_coreimage.m.

Referenced by create_filter().

◆ create_filter()

static CIFilter * create_filter ( CoreImageContext * ctx,
const char * filter_name,
AVDictionary * filter_options )
static

Create a filter object by a given name and set all options to defaults.

Overwrite any option given by the user to the provided value in filter_options.

Definition at line 405 of file vf_coreimage.m.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext * fctx)
static

Definition at line 424 of file vf_coreimage.m.

◆ init_src()

static av_cold int init_src ( AVFilterContext * fctx)
static

Definition at line 521 of file vf_coreimage.m.

◆ uninit()

static av_cold void uninit ( AVFilterContext * fctx)
static

Definition at line 532 of file vf_coreimage.m.

◆ AVFILTER_DEFINE_CLASS() [1/2]

AVFILTER_DEFINE_CLASS ( coreimage )

◆ AVFILTER_DEFINE_CLASS() [2/2]

AVFILTER_DEFINE_CLASS ( coreimagesrc )

Variable Documentation

◆ vf_coreimage_inputs

const AVFilterPad vf_coreimage_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 558 of file vf_coreimage.m.

◆ vf_coreimage_outputs

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

Definition at line 567 of file vf_coreimage.m.

◆ vsrc_coreimagesrc_outputs

const AVFilterPad vsrc_coreimagesrc_outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
.config_props = config_output,
},
}
static int request_frame(AVFilterLink *outlink)
Definition af_aecho.c:272
static int config_output(AVBitStreamFilterLink *outlink)

Definition at line 574 of file vf_coreimage.m.

◆ coreimage_options

const AVOption coreimage_options[]
static
Initial value:
= {
{ NULL }
}
#define FILTER_OPTIONS

Definition at line 603 of file vf_coreimage.m.

◆ ff_vf_coreimage

const FFFilter ff_vf_coreimage
Initial value:
= {
.p.name = "coreimage",
.p.description = NULL_IF_CONFIG_SMALL("Video filtering using CoreImage API."),
.p.priv_class = &coreimage_class,
.init = init,
.uninit = uninit,
.priv_size = sizeof(CoreImageContext),
}
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_SINGLE_PIXFMT(pix_fmt_)
Definition filters.h:254
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition pixfmt.h:99
static const AVFilterPad vf_coreimage_inputs[]
static const AVFilterPad vf_coreimage_outputs[]

Definition at line 610 of file vf_coreimage.m.

◆ coreimagesrc_options

const AVOption coreimagesrc_options[]
static
Initial value:
= {
{ NULL }
}
#define GENERATOR_OPTIONS

Definition at line 623 of file vf_coreimage.m.

◆ ff_vsrc_coreimagesrc

const FFFilter ff_vsrc_coreimagesrc
Initial value:
= {
.p.name = "coreimagesrc",
.p.description = NULL_IF_CONFIG_SMALL("Video source using image generators of CoreImage API."),
.p.priv_class = &coreimagesrc_class,
.p.inputs = NULL,
.init = init_src,
.uninit = uninit,
.priv_size = sizeof(CoreImageContext),
}
static av_cold int init_src(AVFilterContext *fctx)
static const AVFilterPad vsrc_coreimagesrc_outputs[]

Definition at line 631 of file vf_coreimage.m.