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 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 []
 
const AVFilter ff_vf_coreimage
 
static const AVOption coreimagesrc_options []
 
const 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 586 of file vf_coreimage.m.

◆ FLAGS

Definition at line 587 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 589 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 598 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().

◆ apply_filter()

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

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

◆ request_frame()

static int request_frame ( AVFilterLink link)
static

Definition at line 280 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 315 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 408 of file vf_coreimage.m.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext fctx)
static

Definition at line 427 of file vf_coreimage.m.

Referenced by init_src().

◆ init_src()

static av_cold int init_src ( AVFilterContext fctx)
static

Definition at line 524 of file vf_coreimage.m.

◆ uninit()

static av_cold void uninit ( AVFilterContext fctx)
static

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

Definition at line 561 of file vf_coreimage.m.

◆ vf_coreimage_outputs

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

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

Definition at line 577 of file vf_coreimage.m.

◆ coreimage_options

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

Definition at line 606 of file vf_coreimage.m.

◆ ff_vf_coreimage

const 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 613 of file vf_coreimage.m.

◆ coreimagesrc_options

const AVOption coreimagesrc_options[]
static
Initial value:

Definition at line 626 of file vf_coreimage.m.

◆ ff_vsrc_coreimagesrc

const 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 634 of file vf_coreimage.m.

AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:237
w
uint8_t w
Definition: llviddspenc.c:38
OFFSET
#define OFFSET(x)
Definition: vf_coreimage.m:586
AV_OPT_TYPE_DURATION
@ AV_OPT_TYPE_DURATION
Definition: opt.h:238
vf_coreimage_outputs
static const AVFilterPad vf_coreimage_outputs[]
Definition: vf_coreimage.m:570
AV_OPT_TYPE_RATIONAL
@ AV_OPT_TYPE_RATIONAL
Definition: opt.h:229
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:275
vsrc_coreimagesrc_outputs
static const AVFilterPad vsrc_coreimagesrc_outputs[]
Definition: vf_coreimage.m:577
request_frame
static int request_frame(AVFilterLink *link)
Definition: vf_coreimage.m:280
init
static av_cold int init(AVFilterContext *fctx)
Definition: vf_coreimage.m:427
config_output
static int config_output(AVFilterLink *link)
Definition: vf_coreimage.m:65
duration
int64_t duration
Definition: movenc.c:64
FILTER_OPTIONS
#define FILTER_OPTIONS
Definition: vf_coreimage.m:598
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
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:234
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:117
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
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:92
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:181
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:587
init_src
static av_cold int init_src(AVFilterContext *fctx)
Definition: vf_coreimage.m:524
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
uninit
static av_cold void uninit(AVFilterContext *fctx)
Definition: vf_coreimage.m:535
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:241
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
vf_coreimage_inputs
static const AVFilterPad vf_coreimage_inputs[]
Definition: vf_coreimage.m:561
GENERATOR_OPTIONS
#define GENERATOR_OPTIONS
Definition: vf_coreimage.m:589
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228