FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
vf_selectivecolor.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/file.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  process_range
 
struct  ThreadData
 
struct  SelectiveColorContext
 

Macros

#define OFFSET(x)   offsetof(SelectiveColorContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define RANGE_OPTION(color_name, range)   { color_name"s", "adjust "color_name" regions", OFFSET(opt_cmyk_adjust[range]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }
 
#define READ16(dst)
 
#define DEF_SELECTIVE_COLOR_FUNC(name, direct, correction_method)
 

Typedefs

typedef int(* get_adjust_range_func )(int r, int g, int b, int min_val, int max_val)
 
typedef int(* selective_color_func_type )(AVFilterContext *ctx, void *td, int jobnr, int nb_jobs)
 

Enumerations

enum  color_range {
  RANGE_REDS, RANGE_YELLOWS, RANGE_GREENS, RANGE_CYANS,
  RANGE_BLUES, RANGE_MAGENTAS, RANGE_WHITES, RANGE_NEUTRALS,
  RANGE_BLACKS, NB_RANGES
}
 
enum  correction_method { CORRECTION_METHOD_ABSOLUTE, CORRECTION_METHOD_RELATIVE, NB_CORRECTION_METHODS }
 

Functions

 AVFILTER_DEFINE_CLASS (selectivecolor)
 
static int get_mid_val (int r, int g, int b)
 
static int get_rgb_adjust_range (int r, int g, int b, int min_val, int max_val)
 
static int get_cmy_adjust_range (int r, int g, int b, int min_val, int max_val)
 
static int get_neutrals_adjust_range (int r, int g, int b, int min_val, int max_val)
 
static int get_whites_adjust_range (int r, int g, int b, int min_val, int max_val)
 
static int get_blacks_adjust_range (int r, int g, int b, int min_val, int max_val)
 
static int register_range (SelectiveColorContext *s, int range_id)
 
static int parse_psfile (AVFilterContext *ctx, const char *fname)
 
static av_cold int init (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int comp_adjust (int adjust_range, float value, float adjust, float k, int correction_method)
 
static int selective_color (AVFilterContext *ctx, ThreadData *td, int jobnr, int nb_jobs, int direct, int correction_method)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 

Variables

static const char * color_names [NB_RANGES]
 
static const AVOption selectivecolor_options []
 
static const AVFilterPad selectivecolor_inputs []
 
static const AVFilterPad selectivecolor_outputs []
 
AVFilter ff_vf_selectivecolor
 

Macro Definition Documentation

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

Definition at line 82 of file vf_selectivecolor.c.

Definition at line 83 of file vf_selectivecolor.c.

#define RANGE_OPTION (   color_name,
  range 
)    { color_name"s", "adjust "color_name" regions", OFFSET(opt_cmyk_adjust[range]), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }

Definition at line 84 of file vf_selectivecolor.c.

#define READ16 (   dst)
Value:
do { \
if (size < 2) { \
goto end; \
} \
dst = AV_RB16(buf); \
buf += 2; \
size -= 2; \
} while (0)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
Definition: bytestream.h:87
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
ptrdiff_t size
Definition: opengl_enc.c:101
void * buf
Definition: avisynth_c.h:553
if(ret< 0)
Definition: vf_mcdeint.c:282

Referenced by parse_psfile().

#define DEF_SELECTIVE_COLOR_FUNC (   name,
  direct,
  correction_method 
)
Value:
static int selective_color_##name(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) \
{ \
return selective_color(ctx, arg, jobnr, nb_jobs, direct, correction_method); \
}
correction_method
AVFormatContext * ctx
Definition: movenc-test.c:48
static int selective_color(AVFilterContext *ctx, ThreadData *td, int jobnr, int nb_jobs, int direct, int correction_method)
const char * arg
Definition: jacosubdec.c:66
return
An instance of a filter.
Definition: avfilter.h:304
const char * name
Definition: opengl_enc.c:103

Definition at line 382 of file vf_selectivecolor.c.

Typedef Documentation

typedef int(* get_adjust_range_func)(int r, int g, int b, int min_val, int max_val)

Definition at line 60 of file vf_selectivecolor.c.

typedef int(* selective_color_func_type)(AVFilterContext *ctx, void *td, int jobnr, int nb_jobs)

Definition at line 393 of file vf_selectivecolor.c.

Enumeration Type Documentation

Todo:
  • use integers so it can be made bitexact and a FATE test can be added
  • >8 bit support
Enumerator
RANGE_REDS 
RANGE_YELLOWS 
RANGE_GREENS 
RANGE_CYANS 
RANGE_BLUES 
RANGE_MAGENTAS 
RANGE_WHITES 
RANGE_NEUTRALS 
RANGE_BLACKS 
NB_RANGES 

Definition at line 36 of file vf_selectivecolor.c.

Enumerator
CORRECTION_METHOD_ABSOLUTE 
CORRECTION_METHOD_RELATIVE 
NB_CORRECTION_METHODS 

Definition at line 50 of file vf_selectivecolor.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( selectivecolor  )
static int get_mid_val ( int  r,
int  g,
int  b 
)
inlinestatic

Definition at line 106 of file vf_selectivecolor.c.

Referenced by get_cmy_adjust_range(), and get_rgb_adjust_range().

static int get_rgb_adjust_range ( int  r,
int  g,
int  b,
int  min_val,
int  max_val 
)
static

Definition at line 114 of file vf_selectivecolor.c.

Referenced by register_range().

static int get_cmy_adjust_range ( int  r,
int  g,
int  b,
int  min_val,
int  max_val 
)
static

Definition at line 129 of file vf_selectivecolor.c.

Referenced by register_range().

static int get_neutrals_adjust_range ( int  r,
int  g,
int  b,
int  min_val,
int  max_val 
)
static

Definition at line 144 of file vf_selectivecolor.c.

Referenced by register_range().

static int get_whites_adjust_range ( int  r,
int  g,
int  b,
int  min_val,
int  max_val 
)
static

Definition at line 150 of file vf_selectivecolor.c.

Referenced by register_range().

static int get_blacks_adjust_range ( int  r,
int  g,
int  b,
int  min_val,
int  max_val 
)
static

Definition at line 156 of file vf_selectivecolor.c.

Referenced by register_range().

static int register_range ( SelectiveColorContext s,
int  range_id 
)
static

Definition at line 162 of file vf_selectivecolor.c.

Referenced by init(), and parse_psfile().

static int parse_psfile ( AVFilterContext ctx,
const char *  fname 
)
static

Definition at line 194 of file vf_selectivecolor.c.

Referenced by init().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 247 of file vf_selectivecolor.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 288 of file vf_selectivecolor.c.

static int comp_adjust ( int  adjust_range,
float  value,
float  adjust,
float  k,
int  correction_method 
)
inlinestatic

Definition at line 297 of file vf_selectivecolor.c.

Referenced by selective_color().

static int selective_color ( AVFilterContext ctx,
ThreadData td,
int  jobnr,
int  nb_jobs,
int  direct,
int  correction_method 
)
inlinestatic

Definition at line 307 of file vf_selectivecolor.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 395 of file vf_selectivecolor.c.

Variable Documentation

const char* color_names[NB_RANGES]
static
Initial value:
= {
"red", "yellow", "green", "cyan", "blue", "magenta", "white", "neutral", "black"
}

Definition at line 56 of file vf_selectivecolor.c.

Referenced by init(), and register_range().

const AVOption selectivecolor_options[]
static
Initial value:
= {
{ "correction_method", "select correction method", OFFSET(correction_method), AV_OPT_TYPE_INT, {.i64 = CORRECTION_METHOD_ABSOLUTE}, 0, NB_CORRECTION_METHODS-1, FLAGS, "correction_method" },
{ "absolute", NULL, 0, AV_OPT_TYPE_CONST, {.i64=CORRECTION_METHOD_ABSOLUTE}, INT_MIN, INT_MAX, FLAGS, "correction_method" },
{ "relative", NULL, 0, AV_OPT_TYPE_CONST, {.i64=CORRECTION_METHOD_RELATIVE}, INT_MIN, INT_MAX, FLAGS, "correction_method" },
{ "psfile", "set Photoshop selectivecolor file name", OFFSET(psfile), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ NULL }
}
#define NULL
Definition: coverity.c:32
correction_method
#define OFFSET(x)
#define RANGE_OPTION(color_name, range)
#define FLAGS

Definition at line 87 of file vf_selectivecolor.c.

const AVFilterPad selectivecolor_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int filter_frame(AVFilterLink *inlink, AVFrame *in)

Definition at line 431 of file vf_selectivecolor.c.

const AVFilterPad selectivecolor_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
#define NULL
Definition: coverity.c:32

Definition at line 440 of file vf_selectivecolor.c.

AVFilter ff_vf_selectivecolor
Initial value:
= {
.name = "selectivecolor",
.description = NULL_IF_CONFIG_SMALL("Apply CMYK adjustments to specific color ranges."),
.priv_size = sizeof(SelectiveColorContext),
.init = init,
.priv_class = &selectivecolor_class,
}
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:122
static const AVFilterPad selectivecolor_inputs[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:113
static const AVFilterPad selectivecolor_outputs[]
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:385
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:375
static av_cold int init(AVFilterContext *ctx)
static int flags
Definition: cpu.c:47
static int query_formats(AVFilterContext *ctx)

Definition at line 448 of file vf_selectivecolor.c.