FFmpeg
Loading...
Searching...
No Matches
vf_colormap.c File Reference

Compute a look-up table from map of colors. More...

#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)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
#define P2(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 FFFilter 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

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 67 of file vf_colormap.c.

◆ FLAGS

◆ P2

#define P2 ( x)
Value:
((x)*(x))

Definition at line 150 of file vf_colormap.c.

Referenced by euclidean_kernel(), and weuclidean_kernel().

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.

◆ 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 }
}
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition opt.h:302
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
uint8_t w
Definition llvidencdsp.c:39
int size
#define MAX_SIZE
Definition vf_colormap.c:35
@ NB_KERNELS
Definition vf_colormap.c:40
@ EUCLIDEAN
Definition vf_colormap.c:38
@ WEUCLIDEAN
Definition vf_colormap.c:39

Definition at line 70 of file vf_colormap.c.

◆ inputs

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
},
{
.name = "source",
},
{
.name = "target",
},
}
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200

Definition at line 539 of file vf_colormap.c.

◆ outputs

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}
static int config_output(AVBitStreamFilterLink *outlink)

Definition at line 554 of file vf_colormap.c.

◆ ff_vf_colormap

const FFFilter ff_vf_colormap
Initial value:
= {
.p.name = "colormap",
.p.description = NULL_IF_CONFIG_SMALL("Apply custom Color Maps to video stream."),
.p.priv_class = &colormap_class,
.priv_size = sizeof(ColorMapContext),
.process_command = ff_filter_process_command,
.uninit = uninit,
}
static const AVFilterPad inputs[]
Definition af_aap.c:299
static const AVFilterPad outputs[]
Definition af_aap.c:310
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:906
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
#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:204
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_PIXFMTS(...)
Definition filters.h:250
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
#define AV_PIX_FMT_GBRPF32
Definition pixfmt.h:584
#define AV_PIX_FMT_GBRAPF32
Definition pixfmt.h:585

Definition at line 564 of file vf_colormap.c.