FFmpeg
Loading...
Searching...
No Matches
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/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "filters.h"
#include "video.h"

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)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
#define SET_EXPR(expr, option)
 
#define SET_EXPR(expr, option)
 

Enumerations

enum  var_name {
  VAR_N , VAR_PTS , VAR_R , VAR_T ,
  VAR_TB , VAR_NB
}
 

Functions

 AVFILTER_DEFINE_CLASS (hue)
 
static void compute_sin_and_cos (HueContext *hue)
 
static void create_luma_lut (HueContext *h)
 
static void create_chrominance_lut (HueContext *h, const int32_t c, const int32_t s)
 
static int set_expr (AVExpr **pexpr_ptr, char **expr_ptr, 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 config_props (AVFilterLink *inlink)
 
static void apply_luma_lut (HueContext *s, uint8_t *ldst, const int dst_linesize, uint8_t *lsrc, const int src_linesize, int w, int h)
 
static void apply_luma_lut10 (HueContext *s, uint16_t *ldst, const int dst_linesize, uint16_t *lsrc, const int src_linesize, int w, int h)
 
static void apply_lut (HueContext *s, uint8_t *udst, uint8_t *vdst, const int dst_linesize, uint8_t *usrc, uint8_t *vsrc, const int src_linesize, int w, int h)
 
static void apply_lut10 (HueContext *s, uint16_t *udst, uint16_t *vdst, const int dst_linesize, uint16_t *usrc, uint16_t *vsrc, const int src_linesize, int w, int h)
 
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 enum AVPixelFormat pix_fmts []
 
static const AVFilterPad hue_inputs []
 
const FFFilter ff_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

◆ SAT_MIN_VAL

#define SAT_MIN_VAL   -10

Definition at line 39 of file vf_hue.c.

Referenced by filter_frame().

◆ SAT_MAX_VAL

#define SAT_MAX_VAL   10

Definition at line 40 of file vf_hue.c.

Referenced by filter_frame().

◆ OFFSET

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

Definition at line 88 of file vf_hue.c.

◆ FLAGS

◆ SET_EXPR [1/2]

#define SET_EXPR ( expr,
option )
Value:
if (hue->expr##_expr) do { \
ret = set_expr(&hue->expr##_pexpr, &hue->expr##_expr, \
hue->expr##_expr, option, ctx); \
if (ret < 0) \
return ret; \
} while (0)
static int set_expr(AVExpr **pexpr, const char *expr, void *log_ctx)
Definition af_volume.c:92
static AVFormatContext * ctx
option
Definition libkvazaar.c:312

Referenced by init(), and process_command().

◆ SET_EXPR [2/2]

#define SET_EXPR ( expr,
option )
Value:
do { \
ret = set_expr(&hue->expr##_pexpr, &hue->expr##_expr, \
args, option, ctx); \
if (ret < 0) \
return ret; \
} while (0)

Enumeration Type Documentation

◆ var_name

enum var_name
Enumerator
VAR_N 
VAR_PTS 
VAR_R 
VAR_T 
VAR_TB 
VAR_NB 

Definition at line 51 of file vf_hue.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( hue )

◆ compute_sin_and_cos()

static void compute_sin_and_cos ( HueContext * hue)
inlinestatic

Definition at line 104 of file vf_hue.c.

Referenced by filter_frame(), and init().

◆ create_luma_lut()

static void create_luma_lut ( HueContext * h)
inlinestatic

Definition at line 115 of file vf_hue.c.

Referenced by filter_frame().

◆ create_chrominance_lut()

static void create_chrominance_lut ( HueContext * h,
const int32_t c,
const int32_t s )
inlinestatic

Definition at line 128 of file vf_hue.c.

Referenced by filter_frame().

◆ set_expr()

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

Definition at line 178 of file vf_hue.c.

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 207 of file vf_hue.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 241 of file vf_hue.c.

◆ config_props()

static int config_props ( AVFilterLink * inlink)
static

Definition at line 265 of file vf_hue.c.

◆ apply_luma_lut()

static void apply_luma_lut ( HueContext * s,
uint8_t * ldst,
const int dst_linesize,
uint8_t * lsrc,
const int src_linesize,
int w,
int h )
static

Definition at line 282 of file vf_hue.c.

Referenced by filter_frame().

◆ apply_luma_lut10()

static void apply_luma_lut10 ( HueContext * s,
uint16_t * ldst,
const int dst_linesize,
uint16_t * lsrc,
const int src_linesize,
int w,
int h )
static

Definition at line 298 of file vf_hue.c.

Referenced by filter_frame().

◆ apply_lut()

static void apply_lut ( HueContext * s,
uint8_t * udst,
uint8_t * vdst,
const int dst_linesize,
uint8_t * usrc,
uint8_t * vsrc,
const int src_linesize,
int w,
int h )
static

Definition at line 314 of file vf_hue.c.

Referenced by filter_frame().

◆ apply_lut10()

static void apply_lut10 ( HueContext * s,
uint16_t * udst,
uint16_t * vdst,
const int dst_linesize,
uint16_t * usrc,
uint16_t * vsrc,
const int src_linesize,
int w,
int h )
static

Definition at line 337 of file vf_hue.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink * inlink,
AVFrame * inpic )
static

Definition at line 360 of file vf_hue.c.

◆ process_command()

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

Definition at line 466 of file vf_hue.c.

Variable Documentation

◆ var_names

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

Definition at line 42 of file vf_hue.c.

◆ hue_options

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 },
{ "b", "set the brightness expression", OFFSET(brightness_expr), AV_OPT_TYPE_STRING,
{ .str = "0" }, .flags = FLAGS },
{ NULL }
}
#define FLAGS
Definition cmdutils.c:598
#define OFFSET(x)
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275

Definition at line 90 of file vf_hue.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static
Initial value:
= {
}
#define AV_PIX_FMT_YUV420P10
Definition pixfmt.h:545
#define AV_PIX_FMT_YUVA444P10
Definition pixfmt.h:598
#define AV_PIX_FMT_YUVA420P10
Definition pixfmt.h:596
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:546
#define AV_PIX_FMT_YUVA422P10
Definition pixfmt.h:597
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition pixfmt.h:108
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition pixfmt.h:174
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition pixfmt.h:173
#define AV_PIX_FMT_YUV440P10
Definition pixfmt.h:547
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:548

Definition at line 251 of file vf_hue.c.

◆ hue_inputs

const AVFilterPad hue_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_props,
},
}
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static int config_props(AVBitStreamFilterLink *link)
Definition source.c:181

Definition at line 496 of file vf_hue.c.

◆ ff_vf_hue

const FFFilter ff_vf_hue
Initial value:
= {
.p.name = "hue",
.p.description = NULL_IF_CONFIG_SMALL("Adjust the hue and saturation of the input video."),
.p.priv_class = &hue_class,
.priv_size = sizeof(HueContext),
.init = init,
}
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#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:196
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:244
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
static const AVFilterPad hue_inputs[]
Definition vf_hue.c:496
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition video.c:37

Definition at line 505 of file vf_hue.c.