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 "internal.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 524 of file vf_colormap.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 530 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, "type" },
{ "relative", "the target colors are relative", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 1, FLAGS, "type" },
{ "absolute", "the target colors are absolute", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 1, FLAGS, "type" },
{ "kernel", "set the kernel used for measuring color difference", OFFSET(kernel_type), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_KERNELS-1, FLAGS, "kernel" },
{ "euclidean", "square root of sum of squared differences", 0, AV_OPT_TYPE_CONST, {.i64=EUCLIDEAN}, 0, 0, FLAGS, "kernel" },
{ "weuclidean", "weighted square root of sum of squared differences",0, AV_OPT_TYPE_CONST, {.i64=WEUCLIDEAN}, 0, 0, FLAGS, "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 537 of file vf_colormap.c.

◆ outputs

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

Definition at line 552 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 562 of file vf_colormap.c.

WEUCLIDEAN
@ WEUCLIDEAN
Definition: vf_colormap.c:39
w
uint8_t w
Definition: llviddspenc.c:38
EUCLIDEAN
@ EUCLIDEAN
Definition: vf_colormap.c:38
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:192
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
offset must point to two consecutive integers
Definition: opt.h:235
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:106
FILTER_PIXFMTS
#define FILTER_PIXFMTS(...)
Definition: internal.h:178
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:498
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:851
outputs
static const AVFilterPad outputs[]
Definition: vf_colormap.c:552
MAX_SIZE
#define MAX_SIZE
Definition: vf_colormap.c:35
inputs
static const AVFilterPad inputs[]
Definition: vf_colormap.c:537
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_colormap.c:483
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:499
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_colormap.c:530
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:117
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:193
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:155
NB_KERNELS
@ NB_KERNELS
Definition: vf_colormap.c:40
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
activate
static int activate(AVFilterContext *ctx)
Definition: vf_colormap.c:524