vf_curves.c File Reference
#include "libavutil/opt.h"
#include "libavutil/bprint.h"
#include "libavutil/eval.h"
#include "libavutil/file.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/avassert.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
Include dependency graph for vf_curves.c:

Go to the source code of this file.

Data Structures

struct  keypoint
 
struct  CurvesContext
 

Macros

#define NB_COMP   3
 
#define OFFSET(x)   offsetof(CurvesContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define B   0 /* sub diagonal (below main) */
 
#define M   1 /* main diagonal (center) */
 
#define A   2 /* sup diagonal (above main) */
 
#define READ16(dst)
 
#define SET_COMP_IF_NOT_SET(n, name)
 

Enumerations

enum  preset {
  PRESET_NONE, PRESET_COLOR_NEGATIVE, PRESET_CROSS_PROCESS, PRESET_DARKER,
  PRESET_INCREASE_CONTRAST, PRESET_LIGHTER, PRESET_LINEAR_CONTRAST, PRESET_MEDIUM_CONTRAST,
  PRESET_NEGATIVE, PRESET_STRONG_CONTRAST, PRESET_VINTAGE, NB_PRESETS
}
 

Functions

 AVFILTER_DEFINE_CLASS (curves)
 
static struct keypointmake_point (double x, double y, struct keypoint *next)
 
static int parse_points_str (AVFilterContext *ctx, struct keypoint **points, const char *s)
 
static int get_nb_points (const struct keypoint *d)
 
static int interpolate (AVFilterContext *ctx, uint8_t *y, const struct keypoint *points)
 Natural cubic spline interpolation Finding curves using Cubic Splines notes by Steven Rauch and John Stockie. More...
 
static int parse_psfile (AVFilterContext *ctx, const char *fname)
 
static av_cold int init (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 

Variables

static const AVOption curves_options []
 
struct {
   const char *   r
 
   const char *   g
 
   const char *   b
 
   const char *   master
 
curves_presets []
 
static const AVFilterPad curves_inputs []
 
static const AVFilterPad curves_outputs []
 
AVFilter avfilter_vf_curves
 

Macro Definition Documentation

#define A   2 /* sup diagonal (above main) */

Referenced by interpolate().

#define B   0 /* sub diagonal (below main) */

Referenced by interpolate().

Definition at line 64 of file vf_curves.c.

#define M   1 /* main diagonal (center) */

Referenced by interpolate().

#define NB_COMP   3

Definition at line 37 of file vf_curves.c.

Referenced by filter_frame(), and init().

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

Definition at line 63 of file vf_curves.c.

#define READ16 (   dst)
Value:
do { \
if (size < 2) \
buf += 2; \
size -= 2; \
} while (0)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
#define AV_RB16
int size
void * buf
Definition: avisynth_c.h:594
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160
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 the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame This method is called when a frame is wanted on an output For an it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return it should return

Referenced by parse_psfile().

#define SET_COMP_IF_NOT_SET (   n,
  name 
)
Value:
do { \
if (!pts[n] && curves_presets[curves->preset].name) { \
pts[n] = av_strdup(curves_presets[curves->preset].name); \
if (!pts[n]) \
return AVERROR(ENOMEM); \
} \
} while (0)
static const struct @117 curves_presets[]
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
char * av_strdup(const char *s)
Duplicate the string s.
Definition: mem.c:220
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Buffer references ownership and permissions
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 the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame This method is called when a frame is wanted on an output For an it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return it should return

Referenced by init().

Enumeration Type Documentation

enum preset
Enumerator
PRESET_NONE 
PRESET_COLOR_NEGATIVE 
PRESET_CROSS_PROCESS 
PRESET_DARKER 
PRESET_INCREASE_CONTRAST 
PRESET_LIGHTER 
PRESET_LINEAR_CONTRAST 
PRESET_MEDIUM_CONTRAST 
PRESET_NEGATIVE 
PRESET_STRONG_CONTRAST 
PRESET_VINTAGE 
NB_PRESETS 

Definition at line 39 of file vf_curves.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( curves  )
static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 449 of file vf_curves.c.

static int get_nb_points ( const struct keypoint d)
static

Definition at line 194 of file vf_curves.c.

Referenced by interpolate().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 359 of file vf_curves.c.

static int interpolate ( AVFilterContext ctx,
uint8_t y,
const struct keypoint points 
)
static

Natural cubic spline interpolation Finding curves using Cubic Splines notes by Steven Rauch and John Stockie.

See also
http://people.math.sfu.ca/~stockie/teaching/macm316/notes/splines.pdf

Definition at line 209 of file vf_curves.c.

Referenced by init().

static struct keypoint* make_point ( double  x,
double  y,
struct keypoint next 
)
static

Definition at line 123 of file vf_curves.c.

Referenced by parse_points_str().

static int parse_points_str ( AVFilterContext ctx,
struct keypoint **  points,
const char *  s 
)
static

Definition at line 135 of file vf_curves.c.

Referenced by init().

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

Definition at line 305 of file vf_curves.c.

Referenced by init().

static int query_formats ( AVFilterContext ctx)
static

Definition at line 442 of file vf_curves.c.

Variable Documentation

AVFilter avfilter_vf_curves
Initial value:
= {
.name = "curves",
.description = NULL_IF_CONFIG_SMALL("Adjust components curves."),
.priv_size = sizeof(CurvesContext),
.init = init,
.priv_class = &curves_class,
}
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_cold int init(AVFilterContext *ctx)
Definition: vf_curves.c:359
static const AVFilterPad curves_inputs[]
Definition: vf_curves.c:491
static int query_formats(AVFilterContext *ctx)
Definition: vf_curves.c:442
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
static const AVFilterPad curves_outputs[]
Definition: vf_curves.c:500

Definition at line 508 of file vf_curves.c.

const char* b

Definition at line 96 of file vf_curves.c.

Referenced by init(), and interpolate().

const AVFilterPad curves_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
{ NULL }
}
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_curves.c:449
NULL
Definition: eval.c:55

Definition at line 491 of file vf_curves.c.

const AVOption curves_options[]
static
Initial value:
= {
{ "preset", "select a color curves preset", OFFSET(preset), AV_OPT_TYPE_INT, {.i64=PRESET_NONE}, PRESET_NONE, NB_PRESETS-1, FLAGS, "preset_name" },
{ "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_NONE}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
{ "color_negative", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_COLOR_NEGATIVE}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
{ "cross_process", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_CROSS_PROCESS}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
{ "darker", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_DARKER}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
{ "increase_contrast", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_INCREASE_CONTRAST}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
{ "lighter", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_LIGHTER}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
{ "linear_contrast", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_LINEAR_CONTRAST}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
{ "medium_contrast", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_MEDIUM_CONTRAST}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
{ "negative", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_NEGATIVE}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
{ "strong_contrast", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_STRONG_CONTRAST}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
{ "vintage", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_VINTAGE}, INT_MIN, INT_MAX, FLAGS, "preset_name" },
{ "master","set master points coordinates",OFFSET(comp_points_str[NB_COMP]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "m", "set master points coordinates",OFFSET(comp_points_str[NB_COMP]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "red", "set red points coordinates", OFFSET(comp_points_str[0]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "r", "set red points coordinates", OFFSET(comp_points_str[0]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "green", "set green points coordinates", OFFSET(comp_points_str[1]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "g", "set green points coordinates", OFFSET(comp_points_str[1]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "blue", "set blue points coordinates", OFFSET(comp_points_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "b", "set blue points coordinates", OFFSET(comp_points_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "all", "set points coordinates for all components", OFFSET(comp_points_str_all), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "psfile", "set Photoshop curves file name", OFFSET(psfile), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ NULL }
}
#define NB_COMP
Definition: vf_curves.c:37
#define FLAGS
Definition: vf_curves.c:64
NULL
Definition: eval.c:55
#define OFFSET(x)
Definition: vf_curves.c:63
preset
Definition: vf_curves.c:39

Definition at line 65 of file vf_curves.c.

const AVFilterPad curves_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
NULL
Definition: eval.c:55

Definition at line 500 of file vf_curves.c.

const { ... } curves_presets[]
Initial value:
= {
"0/1 0.129/1 0.466/0.498 0.725/0 1/0",
"0/1 0.109/1 0.301/0.498 0.517/0 1/0",
"0/1 0.098/1 0.235/0.498 0.423/0 1/0",
},
"0.25/0.156 0.501/0.501 0.686/0.745",
"0.25/0.188 0.38/0.501 0.745/0.815 1/0.815",
"0.231/0.094 0.709/0.874",
},
[PRESET_DARKER] = { .master = "0.5/0.4" },
[PRESET_INCREASE_CONTRAST] = { .master = "0.149/0.066 0.831/0.905 0.905/0.98" },
[PRESET_LIGHTER] = { .master = "0.4/0.5" },
[PRESET_LINEAR_CONTRAST] = { .master = "0.305/0.286 0.694/0.713" },
[PRESET_MEDIUM_CONTRAST] = { .master = "0.286/0.219 0.639/0.643" },
[PRESET_NEGATIVE] = { .master = "0/1 1/0" },
[PRESET_STRONG_CONTRAST] = { .master = "0.301/0.196 0.592/0.6 0.686/0.737" },
"0/0.11 0.42/0.51 1/0.95",
"0.50/0.48",
"0/0.22 0.49/0.44 1/0.8",
}
}
const char* g

Definition at line 95 of file vf_curves.c.

Referenced by init().

const char* master

Definition at line 97 of file vf_curves.c.

Referenced by init(), and revert_channel_correlation().

const char* r

Definition at line 94 of file vf_curves.c.

Referenced by add_bell(), add_hfyu_left_prediction_bgr32_c(), alloc_frame_buffer(), av_des_mac(), av_find_nearest_q_idx(), av_inv_q(), av_realloc_f(), av_rescale_rnd(), avcodec_default_execute(), avcodec_default_execute2(), avfilter_graph_request_oldest(), avfilter_graph_send_command(), avpriv_set_systematic_pal2(), avs_get_row_size_p(), cache_read(), cdg_load_palette(), cdxl_decode_ham6(), cdxl_decode_ham8(), cinepak_decode_codebook(), cng_decode_frame(), color_distance(), compute_lpc_coefs(), config_output(), config_props(), convert_timestamp(), crypt(), dca_downmix(), DECLARE_ALIGNED(), decode_block(), decode_block_coeffs_internal(), decode_frame(), decode_hybrid(), decode_mvc2(), decode_pal(), decode_rbsp_trailing(), decode_refpass(), decode_rgb_frame(), decode_rice(), dither_int_to_float_triangular_c(), dshow_cycle_devices(), dshow_cycle_pins(), dshow_list_device_options(), dshow_open_device(), dshow_read_close(), dshow_read_header(), dv_read_seek(), dvbsub_init_decoder(), dvbsub_parse_clut_segment(), encode_dvb_subtitles(), encode_frame(), encode_rgb_frame(), encode_scalar(), encode_thread(), eval_expr(), expand_script(), expand_tseq(), ff_alsa_extend_reorder_buf(), ff_draw_supported_pixel_formats(), ff_gmc_c(), ff_init_cabac_states(), ff_lag_rac_init(), ff_mov_read_stsd_entries(), ff_parse_time_base(), ff_rac_terminate(), ff_rgb24toyv12_c(), ff_rtp_send_h264(), ff_rtp_send_mpegvideo(), file_read(), file_write(), fill_picture_parameters(), fill_slice_long(), filter(), filter_frame(), flic_decode_frame_8BPP(), frac64(), generate_interval(), generate_intervals(), generate_joint_tables(), generate_plateau(), generate_transition(), get_bits_left(), get_high_utility_cell(), get_sr_golomb_shorten(), get_strl(), get_symbol2(), guess_palette(), h263_handle_packet(), hpel_motion_search(), idcin_read_packet(), idct_col2(), idct_row(), import_palette(), init(), interpolate(), iterative_me(), lag_decode_frame(), lex_char(), lex_time(), ls_decode_line(), main(), make_cdt15_entry(), make_cdt16_entry(), make_cdt24_entry(), matroska_parse_laces(), mc_block(), modplug_read_header(), mp_yuv_to_rgb(), mpeg4_decode_sprite_trajectory(), mpegts_push_data(), mss2_blit_wmv9_template(), mss2_decode_frame(), mul32(), MULH(), opt_list(), paf_vid_decode(), paint_mouse_pointer(), parse_block_def(), parse_options(), parse_palette_segment(), parse_script(), parse_synth_channel(), parse_synth_def(), parse_time_sequence(), parse_timestamp(), pix_abs16x16_x2_mvi(), png_filter_row(), pop_integer(), pow_poly(), process_ipmovie_chunk(), ps_stereo_interpolate_c(), ps_stereo_interpolate_ipdopd_c(), push_integer(), put_pixel(), put_symbol2(), qpel_motion_search(), qtrle_decode_24bpp(), read_var_block_data(), read_whole_file(), request_frame(), restore_rgb_planes(), rgb12to15(), rgb24_to_yuv420p(), rgb24to15(), rgb24to15_c(), rgb24to16(), rgb24to16_c(), rgb24tobgr15(), rgb24tobgr15_c(), rgb24tobgr16(), rgb24tobgr16_c(), ring2_test(), roundToInt16(), rtmp_close(), rtmp_get_file_handle(), rtmp_open(), rtmp_read(), rtmp_read_pause(), rtmp_read_seek(), rtmp_write(), rtsp_read_packet(), rv30_decode_init(), rv40_decode_init(), sad_hpel_motion_search(), sbg_read_header(), sbg_read_probe(), search_keyval(), set_palette(), smacker_decode_bigtree(), smacker_decode_tree(), stereo_processing(), sub_left_prediction_bgr32(), sub_left_prediction_rgb24(), subtitle_thread(), super2xsai(), swri_rematrix_init(), sws_scale(), tta_decode_frame(), update_palette_index(), vmd_decode(), vmdvideo_decode_init(), vqa_decode_chunk(), wavesynth_decode(), wavesynth_init(), xan_decode_frame(), xface_encode_frame(), yuv2rgb_1_c_template(), yuv2rgb_2_c_template(), yuv2rgb_write(), yuv2rgb_write_full(), yuv2rgb_X_c_template(), and yuv_a_to_rgba().