Go to the documentation of this file.
39 #define SAT_MIN_VAL -10
40 #define SAT_MAX_VAL 10
88 #define OFFSET(x) offsetof(HueContext, x)
89 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
94 { .str =
"1" }, .flags =
FLAGS },
98 { .str =
"0" }, .flags =
FLAGS },
117 const float b =
h->brightness;
120 for (
i = 0;
i < 256;
i++) {
123 for (
i = 0;
i < 65536;
i++) {
137 for (
i = 0;
i < 256;
i++) {
138 for (j = 0; j < 256; j++) {
149 new_u = ((
c *
u) - (
s * v) + (1 << 15) + (128 << 16)) >> 16;
150 new_v = ((
s *
u) + (
c * v) + (1 << 15) + (128 << 16)) >> 16;
157 for (
i = 0;
i < 1024;
i++) {
158 for (j = 0; j < 1024; j++) {
168 new_u = ((
c *
u) - (
s * v) + (1 << 15) + (512 << 16)) >> 16;
169 new_v = ((
s *
u) + (
c * v) + (1 << 15) + (512 << 16)) >> 16;
179 const char *expr,
const char *
option,
void *log_ctx)
192 "Error when evaluating the expression '%s' for %s\n",
200 *pexpr_ptr = new_pexpr;
202 *expr_ptr = new_expr;
214 "H and h options are incompatible and cannot be specified "
215 "at the same time\n");
219 #define SET_EXPR(expr, option) \
220 if (hue->expr##_expr) do { \
221 ret = set_expr(&hue->expr##_pexpr, &hue->expr##_expr, \
222 hue->expr##_expr, option, ctx); \
233 "H_expr:%s h_deg_expr:%s s_expr:%s b_expr:%s\n",
282 uint8_t *ldst,
const int dst_linesize,
283 uint8_t *lsrc,
const int src_linesize,
289 for (
i = 0;
i <
w;
i++)
290 ldst[
i] =
s->lut_l[lsrc[
i]];
292 lsrc += src_linesize;
293 ldst += dst_linesize;
298 uint16_t *ldst,
const int dst_linesize,
299 uint16_t *lsrc,
const int src_linesize,
305 for (
i = 0;
i <
w;
i++)
306 ldst[
i] =
s->lut_l16[lsrc[
i]];
308 lsrc += src_linesize;
309 ldst += dst_linesize;
314 uint8_t *udst, uint8_t *vdst,
const int dst_linesize,
315 uint8_t *usrc, uint8_t *vsrc,
const int src_linesize,
321 for (
i = 0;
i <
w;
i++) {
322 const int u = usrc[
i];
323 const int v = vsrc[
i];
325 udst[
i] =
s->lut_u[
u][v];
326 vdst[
i] =
s->lut_v[
u][v];
329 usrc += src_linesize;
330 vsrc += src_linesize;
331 udst += dst_linesize;
332 vdst += dst_linesize;
337 uint16_t *udst, uint16_t *vdst,
const int dst_linesize,
338 uint16_t *usrc, uint16_t *vsrc,
const int src_linesize,
344 for (
i = 0;
i <
w;
i++) {
348 udst[
i] =
s->lut_u10[
u][v];
349 vdst[
i] =
s->lut_v10[
u][v];
352 usrc += src_linesize;
353 vsrc += src_linesize;
354 udst += dst_linesize;
355 vdst += dst_linesize;
368 const int bps =
desc->comp[0].depth > 8 ? 2 : 1;
392 "Saturation value not in range [%d,%d]: clipping value to %0.1f\n",
403 "Brightness value not in range [%d,%d]: clipping value to %0.1f\n",
417 "H:%0.1f*PI h:%0.1f s:%0.1f b:%0.f t:%0.1f n:%d\n",
441 (uint16_t*)
inpic->data[1], (uint16_t*)
inpic->data[2],
inpic->linesize[1]/2,
465 char *res,
int res_len,
int flags)
470 #define SET_EXPR(expr, option) \
472 ret = set_expr(&hue->expr##_pexpr, &hue->expr##_expr, \
473 args, option, ctx); \
478 if (!strcmp(cmd,
"h")) {
481 }
else if (!strcmp(cmd,
"H")) {
484 }
else if (!strcmp(cmd,
"s")) {
486 }
else if (!strcmp(cmd,
"b")) {
520 .priv_class = &hue_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define AV_LOG_WARNING
Something somehow does not look correct.
AVPixelFormat
Pixel format.
double var_values[VAR_NB]
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame 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. Frame references ownership and permissions
#define u(width, name, range_min, range_max)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define FILTER_PIXFMTS_ARRAY(array)
static void compute_sin_and_cos(HueContext *hue)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV420P10
#define AV_LOG_VERBOSE
Detailed information.
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
const char * name
Filter name.
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)
A link between two filters.
#define AV_PIX_FMT_YUVA422P10
static const AVFilterPad hue_inputs[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
AVExpr * saturation_pexpr
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
static void create_chrominance_lut(HueContext *h, const int32_t c, const int32_t s)
#define SET_EXPR(expr, option)
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
A filter pad used for either input or output.
#define AV_PIX_FMT_YUV444P10
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_cold int init(AVFilterContext *ctx)
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
#define AV_CEIL_RSHIFT(a, b)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
static void create_luma_lut(HueContext *h)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_INPUTS(array)
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
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 enum AVPixelFormat pix_fmts[]
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)
uint16_t lut_v10[1024][1024]
#define AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV422P10
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
static av_cold void uninit(AVFilterContext *ctx)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
#define AV_PIX_FMT_YUVA444P10
AVFILTER_DEFINE_CLASS(hue)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
#define i(width, name, range_min, range_max)
int w
agreed upon image width
uint16_t lut_u10[1024][1024]
const char * name
Pad name.
static const AVOption hue_options[]
static int set_expr(AVExpr **pexpr_ptr, char **expr_ptr, const char *expr, const char *option, void *log_ctx)
static const char *const var_names[]
int h
agreed upon image height
AVExpr * brightness_pexpr
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
char * av_strdup(const char *s)
Duplicate a string.
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static int config_props(AVFilterLink *inlink)
#define FILTER_OUTPUTS(array)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static const AVFilterPad hue_outputs[]
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
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)
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)