vf_hue.c File Reference

Apply a hue/saturation filter to the input video Ported from MPlayer libmpcodecs/vf_hue.c. More...

#include <float.h>
#include "libavutil/eval.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
Include dependency graph for vf_hue.c:

Go to the source code of this file.

Data Structures

struct  HueContext
 

Macros

#define SAT_MIN_VAL   -10
 
#define SAT_MAX_VAL   10
 
#define OFFSET(x)   offsetof(HueContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define SET_EXPR(expr, option)
 
#define TS2D(ts)   ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
 
#define TS2T(ts, tb)   ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
 
#define SET_CMD(expr, option)
 

Enumerations

enum  var_name {
  VAR_B1, VAR_B2, VAR_S1, VAR_S2,
  VAR_T1, VAR_T2, VAR_NB, VAR_N,
  VAR_T, VAR_S, VAR_VARS_NB, VAR_TB,
  VAR_PTS, VAR_START_PTS, VAR_PREV_PTS, VAR_PREV_SELECTED_PTS,
  VAR_T, VAR_START_T, VAR_PREV_T, VAR_PREV_SELECTED_T,
  VAR_PICT_TYPE, VAR_PICT_TYPE_I, VAR_PICT_TYPE_P, VAR_PICT_TYPE_B,
  VAR_PICT_TYPE_S, VAR_PICT_TYPE_SI, VAR_PICT_TYPE_SP, VAR_PICT_TYPE_BI,
  VAR_INTERLACE_TYPE, VAR_INTERLACE_TYPE_P, VAR_INTERLACE_TYPE_T, VAR_INTERLACE_TYPE_B,
  VAR_CONSUMED_SAMPLES_N, VAR_SAMPLES_N, VAR_SAMPLE_RATE, VAR_N,
  VAR_SELECTED_N, VAR_PREV_SELECTED_N, VAR_KEY, VAR_POS,
  VAR_SCENE, VAR_VARS_NB, VAR_FRAME_RATE, VAR_INTERLACED,
  VAR_N, VAR_NB_CONSUMED_SAMPLES, VAR_NB_SAMPLES, VAR_POS,
  VAR_PREV_INPTS, VAR_PREV_INT, VAR_PREV_OUTPTS, VAR_PREV_OUTT,
  VAR_PTS, VAR_SAMPLE_RATE, VAR_STARTPTS, VAR_STARTT,
  VAR_T, VAR_TB, VAR_RTCTIME, VAR_RTCSTART,
  VAR_VARS_NB, VAR_AVTB, VAR_INTB, VAR_SR,
  VAR_VARS_NB, VAR_W, VAR_H, VAR_CW,
  VAR_CH, VAR_HSUB, VAR_VSUB, VARS_NB,
  VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH,
  VAR_OUT_W, VAR_OW, VAR_OUT_H, VAR_OH,
  VAR_A, VAR_SAR, VAR_DAR, VAR_HSUB,
  VAR_VSUB, VAR_X, VAR_Y, VAR_N,
  VAR_POS, VAR_T, VAR_VARS_NB, VAR_DAR,
  VAR_HSUB, VAR_VSUB, VAR_LINE_H, VAR_LH,
  VAR_MAIN_H, VAR_h, VAR_H, VAR_MAIN_W,
  VAR_w, VAR_W, VAR_MAX_GLYPH_A, VAR_ASCENT,
  VAR_MAX_GLYPH_D, VAR_DESCENT, VAR_MAX_GLYPH_H, VAR_MAX_GLYPH_W,
  VAR_N, VAR_SAR, VAR_T, VAR_TEXT_H,
  VAR_TH, VAR_TEXT_W, VAR_TW, VAR_X,
  VAR_Y, VAR_VARS_NB, VAR_N, VAR_PTS,
  VAR_R, VAR_T, VAR_TB, VAR_NB,
  VAR_W, VAR_H, VAR_VAL, VAR_MAXVAL,
  VAR_MINVAL, VAR_NEGVAL, VAR_CLIPVAL, VAR_VARS_NB,
  VAR_MAIN_W, VAR_MW, VAR_MAIN_H, VAR_MH,
  VAR_OVERLAY_W, VAR_OW, VAR_OVERLAY_H, VAR_OH,
  VAR_HSUB, VAR_VSUB, VAR_X, VAR_Y,
  VAR_N, VAR_POS, VAR_T, VAR_VARS_NB,
  VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH,
  VAR_OUT_W, VAR_OW, VAR_OUT_H, VAR_OH,
  VAR_X, VAR_Y, VAR_A, VAR_SAR,
  VAR_DAR, VAR_HSUB, VAR_VSUB, VARS_NB,
  VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH,
  VAR_OUT_W, VAR_OW, VAR_OUT_H, VAR_OH,
  VAR_A, VAR_SAR, VAR_DAR, VAR_HSUB,
  VAR_VSUB, VARS_NB, VAR_X, VAR_Y,
  VAR_W, VAR_H, VAR_TIME, VAR_SPEED,
  VAR_TEMPO, VAR_ORDER, VAR_PATTERN, VAR_ROW,
  VAR_VARS_NB
}
 

Functions

 AVFILTER_DEFINE_CLASS (hue)
 
static void compute_sin_and_cos (HueContext *hue)
 
static int set_expr (AVExpr **pexpr, const char *expr, const char *option, void *log_ctx)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_props (AVFilterLink *inlink)
 
static void process_chrominance (uint8_t *udst, uint8_t *vdst, const int dst_linesize, uint8_t *usrc, uint8_t *vsrc, const int src_linesize, int w, int h, const int32_t c, const int32_t s)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *inpic)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 

Variables

static const char *const var_names []
 
static const AVOption hue_options []
 
static const AVFilterPad hue_inputs []
 
static const AVFilterPad hue_outputs []
 
AVFilter avfilter_vf_hue
 

Detailed Description

Apply a hue/saturation filter to the input video Ported from MPlayer libmpcodecs/vf_hue.c.

Definition in file vf_hue.c.

Macro Definition Documentation

Definition at line 79 of file vf_hue.c.

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

Definition at line 78 of file vf_hue.c.

#define SAT_MAX_VAL   10

Definition at line 40 of file vf_hue.c.

Referenced by filter_frame().

#define SAT_MIN_VAL   -10

Definition at line 39 of file vf_hue.c.

Referenced by filter_frame().

#define SET_CMD (   expr,
  option 
)
Value:
do { \
if (!strcmp(cmd, option)) \
return set_expr(&hue->expr##_pexpr, args, cmd, ctx); \
} while (0)
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
static int set_expr(AVExpr **pexpr, const char *expr, const char *option, void *log_ctx)
Definition: vf_hue.c:103
option
Definition: dnxhdenc.c:49
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 process_command().

#define SET_EXPR (   expr,
  option 
)
Value:
if (hue->expr##_expr) do { \
ret = set_expr(&hue->expr##_pexpr, hue->expr##_expr, option, ctx); \
if (ret < 0) \
} while (0)
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
ret
Definition: avfilter.c:821
static int set_expr(AVExpr **pexpr, const char *expr, const char *option, void *log_ctx)
Definition: vf_hue.c:103
option
Definition: dnxhdenc.c:49
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().

#define TS2D (   ts)    ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))

Definition at line 233 of file vf_hue.c.

Referenced by filter_frame().

#define TS2T (   ts,
  tb 
)    ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))

Definition at line 234 of file vf_hue.c.

Referenced by filter_frame().

Enumeration Type Documentation

enum var_name
Enumerator
VAR_B1 
VAR_B2 
VAR_S1 
VAR_S2 
VAR_T1 
VAR_T2 
VAR_NB 
VAR_N 
VAR_T 
VAR_S 
VAR_VARS_NB 
VAR_TB 
VAR_PTS 
VAR_START_PTS 
VAR_PREV_PTS 
VAR_PREV_SELECTED_PTS 
VAR_T 
VAR_START_T 
VAR_PREV_T 
VAR_PREV_SELECTED_T 
VAR_PICT_TYPE 
VAR_PICT_TYPE_I 
VAR_PICT_TYPE_P 
VAR_PICT_TYPE_B 
VAR_PICT_TYPE_S 
VAR_PICT_TYPE_SI 
VAR_PICT_TYPE_SP 
VAR_PICT_TYPE_BI 
VAR_INTERLACE_TYPE 
VAR_INTERLACE_TYPE_P 
VAR_INTERLACE_TYPE_T 
VAR_INTERLACE_TYPE_B 
VAR_CONSUMED_SAMPLES_N 
VAR_SAMPLES_N 
VAR_SAMPLE_RATE 
VAR_N 
VAR_SELECTED_N 
VAR_PREV_SELECTED_N 
VAR_KEY 
VAR_POS 
VAR_SCENE 
VAR_VARS_NB 
VAR_FRAME_RATE 
VAR_INTERLACED 
VAR_N 
VAR_NB_CONSUMED_SAMPLES 
VAR_NB_SAMPLES 
VAR_POS 
VAR_PREV_INPTS 
VAR_PREV_INT 
VAR_PREV_OUTPTS 
VAR_PREV_OUTT 
VAR_PTS 
VAR_SAMPLE_RATE 
VAR_STARTPTS 
VAR_STARTT 
VAR_T 
VAR_TB 
VAR_RTCTIME 
VAR_RTCSTART 
VAR_VARS_NB 
VAR_AVTB 
VAR_INTB 
VAR_SR 
VAR_VARS_NB 
VAR_W 
VAR_H 
VAR_CW 
VAR_CH 
VAR_HSUB 
VAR_VSUB 
VARS_NB 
VAR_IN_W 
VAR_IW 
VAR_IN_H 
VAR_IH 
VAR_OUT_W 
VAR_OW 
VAR_OUT_H 
VAR_OH 
VAR_A 
VAR_SAR 
VAR_DAR 
VAR_HSUB 
VAR_VSUB 
VAR_X 
VAR_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_sin_and_cos ( HueContext hue)
inlinestatic

Definition at line 92 of file vf_hue.c.

Referenced by filter_frame(), and init().

static int config_props ( AVFilterLink inlink)
static

Definition at line 178 of file vf_hue.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame inpic 
)
static

Definition at line 236 of file vf_hue.c.

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 123 of file vf_hue.c.

static void process_chrominance ( uint8_t udst,
uint8_t vdst,
const int  dst_linesize,
uint8_t usrc,
uint8_t vsrc,
const int  src_linesize,
int  w,
int  h,
const int32_t  c,
const int32_t  s 
)
static

Definition at line 194 of file vf_hue.c.

Referenced by filter_frame().

static int process_command ( AVFilterContext ctx,
const char *  cmd,
const char *  args,
char *  res,
int  res_len,
int  flags 
)
static

Definition at line 306 of file vf_hue.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 162 of file vf_hue.c.

static int set_expr ( AVExpr **  pexpr,
const char *  expr,
const char *  option,
void log_ctx 
)
static

Definition at line 103 of file vf_hue.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 153 of file vf_hue.c.

Variable Documentation

AVFilter avfilter_vf_hue
Initial value:
= {
.name = "hue",
.description = NULL_IF_CONFIG_SMALL("Adjust the hue and saturation of the input video."),
.priv_size = sizeof(HueContext),
.init = init,
.priv_class = &hue_class,
}
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
static int query_formats(AVFilterContext *ctx)
Definition: vf_hue.c:162
static const AVFilterPad hue_inputs[]
Definition: vf_hue.c:322
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_hue.c:306
static av_cold int init(AVFilterContext *ctx)
Definition: vf_hue.c:123
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_hue.c:153
static const AVFilterPad hue_outputs[]
Definition: vf_hue.c:332
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

Definition at line 340 of file vf_hue.c.

const AVFilterPad hue_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_props,
},
{ NULL }
}
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
Definition: vf_hue.c:236
NULL
Definition: eval.c:55
static int config_props(AVFilterLink *inlink)
Definition: vf_hue.c:178

Definition at line 322 of file vf_hue.c.

const AVOption hue_options[]
static
Initial value:
= {
{ "h", "set the hue angle degrees expression", OFFSET(hue_deg_expr), AV_OPT_TYPE_STRING,
{ .str = NULL }, .flags = FLAGS },
{ "s", "set the saturation expression", OFFSET(saturation_expr), AV_OPT_TYPE_STRING,
{ .str = "1" }, .flags = FLAGS },
{ "H", "set the hue angle radians expression", OFFSET(hue_expr), AV_OPT_TYPE_STRING,
{ .str = NULL }, .flags = FLAGS },
{ NULL }
}
#define FLAGS
Definition: vf_hue.c:79
NULL
Definition: eval.c:55
#define OFFSET(x)
Definition: vf_hue.c:78

Definition at line 80 of file vf_hue.c.

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

Definition at line 332 of file vf_hue.c.

const char* const var_names[]
static
Initial value:
= {
"n",
"pts",
"r",
"t",
"tb",
}
NULL
Definition: eval.c:55

Definition at line 42 of file vf_hue.c.

Referenced by set_expr().