FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vf_colormap.c File Reference
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "filters.h"
#include "framesync.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  ColorMapContext
 
struct  ThreadData
 Used for passing data between threads. More...
 

Macros

#define MAX_SIZE   64
 
#define OFFSET(x)   offsetof(ColorMapContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
#define P2(x)   ((x)*(x))
 

Enumerations

enum  KernelType { EUCLIDEAN, WEUCLIDEAN, NB_KERNELS }
 

Functions

static int gauss_make_triangular (double *A, int *p, int n)
 
static void gauss_solve_triangular (const double *A, const int *p, double *b, int n)
 
static int gauss_solve (double *A, double *b, int n)
 
static float euclidean_kernel (const float *x, const float *y)
 
static float weuclidean_kernel (const float *x, const float *y)
 
static void build_map (AVFilterContext *ctx)
 
static int colormap_slice (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int import_map (AVFilterLink *inlink, AVFrame *in)
 
static int process_frame (FFFrameSync *fs)
 
static int config_output (AVFilterLink *outlink)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
 AVFILTER_DEFINE_CLASS (colormap)
 

Variables

static const AVOption colormap_options []
 
static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
const AVFilter ff_vf_colormap
 

Detailed Description

Compute a look-up table from map of colors.

Definition in file vf_colormap.c.

Macro Definition Documentation

◆ MAX_SIZE

#define MAX_SIZE   64

Definition at line 35 of file vf_colormap.c.

◆ OFFSET

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

Definition at line 67 of file vf_colormap.c.

◆ FLAGS

Definition at line 68 of file vf_colormap.c.

◆ P2

#define P2 (   x)    ((x)*(x))

Definition at line 150 of file vf_colormap.c.

Enumeration Type Documentation

◆ KernelType

enum KernelType
Enumerator
EUCLIDEAN 
WEUCLIDEAN 
NB_KERNELS 

Definition at line 37 of file vf_colormap.c.

Function Documentation

◆ gauss_make_triangular()

static int gauss_make_triangular ( double A,
int *  p,
int  n 
)
static

Definition at line 82 of file vf_colormap.c.

Referenced by build_map(), and gauss_solve().

◆ gauss_solve_triangular()

static void gauss_solve_triangular ( const double A,
const int *  p,
double b,
int  n 
)
static

Definition at line 116 of file vf_colormap.c.

Referenced by build_map(), and gauss_solve().

◆ gauss_solve()

static int gauss_solve ( double A,
double b,
int  n 
)
static

Definition at line 136 of file vf_colormap.c.

Referenced by build_map().

◆ euclidean_kernel()

static float euclidean_kernel ( const float x,
const float y 
)
static

Definition at line 152 of file vf_colormap.c.

Referenced by process_frame().

◆ weuclidean_kernel()

static float weuclidean_kernel ( const float x,
const float y 
)
static

Definition at line 160 of file vf_colormap.c.

Referenced by process_frame().

◆ build_map()

static void build_map ( AVFilterContext ctx)
static

Definition at line 169 of file vf_colormap.c.

Referenced by process_frame().

◆ colormap_slice()

static int colormap_slice ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 303 of file vf_colormap.c.

Referenced by process_frame().

◆ import_map()

static int import_map ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 375 of file vf_colormap.c.

Referenced by process_frame().

◆ process_frame()

static int process_frame ( FFFrameSync fs)
static

Definition at line 422 of file vf_colormap.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 483 of file vf_colormap.c.

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 526 of file vf_colormap.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 532 of file vf_colormap.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( colormap  )

Variable Documentation

◆ colormap_options

const AVOption colormap_options[]
static
Initial value:
= {
{ "patch_size", "set patch size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "64x64"}, 0, 0, FLAGS },
{ "nb_patches", "set number of patches", OFFSET(size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, MAX_SIZE, FLAGS },
{ "type", "set the target type used", OFFSET(target_type), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS, .unit = "type" },
{ "relative", "the target colors are relative", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 1, FLAGS, .unit = "type" },
{ "absolute", "the target colors are absolute", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 1, FLAGS, .unit = "type" },
{ "kernel", "set the kernel used for measuring color difference", OFFSET(kernel_type), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_KERNELS-1, FLAGS, .unit = "kernel" },
{ "euclidean", "square root of sum of squared differences", 0, AV_OPT_TYPE_CONST, {.i64=EUCLIDEAN}, 0, 0, FLAGS, .unit = "kernel" },
{ "weuclidean", "weighted square root of sum of squared differences",0, AV_OPT_TYPE_CONST, {.i64=WEUCLIDEAN}, 0, 0, FLAGS, .unit = "kernel" },
{ NULL }
}

Definition at line 70 of file vf_colormap.c.

◆ inputs

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

Definition at line 539 of file vf_colormap.c.

◆ outputs

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

Definition at line 554 of file vf_colormap.c.

◆ ff_vf_colormap

const AVFilter ff_vf_colormap
Initial value:
= {
.name = "colormap",
.description = NULL_IF_CONFIG_SMALL("Apply custom Color Maps to video stream."),
.priv_class = &colormap_class,
.priv_size = sizeof(ColorMapContext),
.process_command = ff_filter_process_command,
.uninit = uninit,
}

Definition at line 564 of file vf_colormap.c.

WEUCLIDEAN
@ WEUCLIDEAN
Definition: vf_colormap.c:39
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
w
uint8_t w
Definition: llviddspenc.c:38
EUCLIDEAN
@ EUCLIDEAN
Definition: vf_colormap.c:38
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
NULL
#define NULL
Definition: coverity.c:32
FLAGS
#define FLAGS
Definition: vf_colormap.c:68
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition: opt.h:303
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:94
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:532
size
int size
Definition: twinvq_data.h:10344
OFFSET
#define OFFSET(x)
Definition: vf_colormap.c:67
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:900
outputs
static const AVFilterPad outputs[]
Definition: vf_colormap.c:554
MAX_SIZE
#define MAX_SIZE
Definition: vf_colormap.c:35
FILTER_PIXFMTS
#define FILTER_PIXFMTS(...)
Definition: filters.h:248
inputs
static const AVFilterPad inputs[]
Definition: vf_colormap.c:539
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_colormap.c:483
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:533
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_colormap.c:532
ColorMapContext
Definition: vf_colormap.c:43
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:152
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:190
NB_KERNELS
@ NB_KERNELS
Definition: vf_colormap.c:40
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
activate
static int activate(AVFilterContext *ctx)
Definition: vf_colormap.c:526