FFmpeg
Data Structures | Macros | Functions | Variables
vf_coreimage.m File Reference
#import <CoreImage/CoreImage.h>
#import <AppKit/AppKit.h>
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
#include "libavutil/internal.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)   offsetof(CoreImageContext, 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. More...
 
static void list_filters (CoreImageContext *ctx)
 Print a list of all available filters including options and respective value ranges and defaults. More...
 
static int query_formats (AVFilterContext *fctx)
 
static int query_formats_src (AVFilterContext *fctx)
 
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. More...
 
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. More...
 
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. More...
 
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 []
 
AVFilter ff_vf_coreimage
 
static const AVOption coreimagesrc_options []
 
AVFilter 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)

◆ SafeCFRelease

#define SafeCFRelease (   ptr)
Value:
do { \
if (ptr) { \
CFRelease(ptr); \
ptr = NULL; \
} \
} while (0)

◆ OFFSET

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

Definition at line 630 of file vf_coreimage.m.

◆ FLAGS

Definition at line 631 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},

Definition at line 633 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},

Definition at line 642 of file vf_coreimage.m.

Function Documentation

◆ config_output()

static int config_output ( AVFilterLink link)
static

Definition at line 65 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 83 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 94 of file vf_coreimage.m.

Referenced by init().

◆ query_formats()

static int query_formats ( AVFilterContext fctx)
static

Definition at line 138 of file vf_coreimage.m.

◆ query_formats_src()

static int query_formats_src ( AVFilterContext fctx)
static

Definition at line 160 of file vf_coreimage.m.

◆ apply_filter()

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

Definition at line 181 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 318 of file vf_coreimage.m.

◆ request_frame()

static int request_frame ( AVFilterLink link)
static

Definition at line 323 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 358 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 451 of file vf_coreimage.m.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext fctx)
static

Definition at line 470 of file vf_coreimage.m.

Referenced by init_src().

◆ init_src()

static av_cold int init_src ( AVFilterContext fctx)
static

Definition at line 565 of file vf_coreimage.m.

◆ uninit()

static av_cold void uninit ( AVFilterContext fctx)
static

Definition at line 576 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,
},
{ NULL }
}

Definition at line 602 of file vf_coreimage.m.

◆ vf_coreimage_outputs

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

Definition at line 612 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,
},
{ NULL }
}

Definition at line 620 of file vf_coreimage.m.

◆ coreimage_options

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

Definition at line 650 of file vf_coreimage.m.

◆ ff_vf_coreimage

AVFilter ff_vf_coreimage
Initial value:
= {
.name = "coreimage",
.description = NULL_IF_CONFIG_SMALL("Video filtering using CoreImage API."),
.init = init,
.uninit = uninit,
.priv_size = sizeof(CoreImageContext),
.priv_class = &coreimage_class,
}

Definition at line 657 of file vf_coreimage.m.

◆ coreimagesrc_options

const AVOption coreimagesrc_options[]
static
Initial value:

Definition at line 670 of file vf_coreimage.m.

◆ ff_vsrc_coreimagesrc

AVFilter ff_vsrc_coreimagesrc
Initial value:
= {
.name = "coreimagesrc",
.description = NULL_IF_CONFIG_SMALL("Video source using image generators of CoreImage API."),
.init = init_src,
.uninit = uninit,
.priv_size = sizeof(CoreImageContext),
.priv_class = &coreimagesrc_class,
}

Definition at line 678 of file vf_coreimage.m.

AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:236
w
uint8_t w
Definition: llviddspenc.c:38
OFFSET
#define OFFSET(x)
Definition: vf_coreimage.m:630
AV_OPT_TYPE_DURATION
@ AV_OPT_TYPE_DURATION
Definition: opt.h:237
vf_coreimage_outputs
static const AVFilterPad vf_coreimage_outputs[]
Definition: vf_coreimage.m:612
AV_OPT_TYPE_RATIONAL
@ AV_OPT_TYPE_RATIONAL
Definition: opt.h:228
CoreImageContext
Definition: vf_coreimage.m:37
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *frame)
Apply all valid filters successively to the input image.
Definition: vf_coreimage.m:318
vsrc_coreimagesrc_outputs
static const AVFilterPad vsrc_coreimagesrc_outputs[]
Definition: vf_coreimage.m:620
request_frame
static int request_frame(AVFilterLink *link)
Definition: vf_coreimage.m:323
init
static av_cold int init(AVFilterContext *fctx)
Definition: vf_coreimage.m:470
query_formats
static int query_formats(AVFilterContext *fctx)
Definition: vf_coreimage.m:138
config_output
static int config_output(AVFilterLink *link)
Definition: vf_coreimage.m:65
duration
int64_t duration
Definition: movenc.c:63
FILTER_OPTIONS
#define FILTER_OPTIONS
Definition: vf_coreimage.m:642
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
ctx
AVFormatContext * ctx
Definition: movenc.c:48
config_input
static int config_input(AVFilterLink *link)
Determine image properties from input link of filter chain.
Definition: vf_coreimage.m:83
NULL
#define NULL
Definition: coverity.c:32
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:233
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:188
input
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
Definition: filter_design.txt:172
list_filters
static void list_filters(CoreImageContext *ctx)
Print a list of all available filters including options and respective value ranges and defaults.
Definition: vf_coreimage.m:94
FLAGS
#define FLAGS
Definition: vf_coreimage.m:631
init_src
static av_cold int init_src(AVFilterContext *fctx)
Definition: vf_coreimage.m:565
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
query_formats_src
static int query_formats_src(AVFilterContext *fctx)
Definition: vf_coreimage.m:160
uninit
static av_cold void uninit(AVFilterContext *fctx)
Definition: vf_coreimage.m:576
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:240
vf_coreimage_inputs
static const AVFilterPad vf_coreimage_inputs[]
Definition: vf_coreimage.m:602
GENERATOR_OPTIONS
#define GENERATOR_OPTIONS
Definition: vf_coreimage.m:633
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:227