39#define SAT_MIN_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",
283 uint8_t *ldst,
const int dst_linesize,
284 uint8_t *lsrc,
const int src_linesize,
290 for (
i = 0;
i <
w;
i++)
291 ldst[
i] =
s->lut_l[lsrc[
i]];
293 lsrc += src_linesize;
294 ldst += dst_linesize;
299 uint16_t *ldst,
const int dst_linesize,
300 uint16_t *lsrc,
const int src_linesize,
306 for (
i = 0;
i <
w;
i++)
307 ldst[
i] =
s->lut_l16[lsrc[
i]];
309 lsrc += src_linesize;
310 ldst += dst_linesize;
315 uint8_t *udst, uint8_t *vdst,
const int dst_linesize,
316 uint8_t *usrc, uint8_t *vsrc,
const int src_linesize,
322 for (
i = 0;
i <
w;
i++) {
323 const int u = usrc[
i];
324 const int v = vsrc[
i];
326 udst[
i] =
s->lut_u[
u][v];
327 vdst[
i] =
s->lut_v[
u][v];
330 usrc += src_linesize;
331 vsrc += src_linesize;
332 udst += dst_linesize;
333 vdst += dst_linesize;
338 uint16_t *udst, uint16_t *vdst,
const int dst_linesize,
339 uint16_t *usrc, uint16_t *vsrc,
const int src_linesize,
345 for (
i = 0;
i <
w;
i++) {
349 udst[
i] =
s->lut_u10[
u][v];
350 vdst[
i] =
s->lut_v10[
u][v];
353 usrc += src_linesize;
354 vsrc += src_linesize;
355 udst += dst_linesize;
356 vdst += dst_linesize;
370 const int bps =
desc->comp[0].depth > 8 ? 2 : 1;
394 "Saturation value not in range [%d,%d]: clipping value to %0.1f\n",
405 "Brightness value not in range [%d,%d]: clipping value to %0.1f\n",
419 "H:%0.1f*PI h:%0.1f s:%0.1f b:%0.f t:%0.1f n:%d\n",
434 inlink->
w *
bps, inlink->
h);
438 inlink->
w *
bps, inlink->
h);
443 (uint16_t*)
inpic->data[1], (uint16_t*)
inpic->data[2],
inpic->linesize[1]/2,
448 (uint16_t*)
inpic->data[0],
inpic->linesize[0]/2, inlink->
w, inlink->
h);
456 inpic->data[0],
inpic->linesize[0], inlink->
w, inlink->
h);
467 char *res,
int res_len,
int flags)
472#define SET_EXPR(expr, option) \
474 ret = set_expr(&hue->expr##_pexpr, &hue->expr##_expr, \
475 args, option, ctx); \
480 if (!strcmp(cmd,
"h")) {
483 }
else if (!strcmp(cmd,
"H")) {
486 }
else if (!strcmp(cmd,
"s")) {
488 }
else if (!strcmp(cmd,
"b")) {
508 .p.priv_class = &hue_class,
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static IPT saturation(const CmsCtx *ctx, IPT ipt)
#define AV_CEIL_RSHIFT(a, b)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
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.
simple arithmetic expression evaluator
@ 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...
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
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.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define u(width, name, range_min, range_max)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_PIXFMTS_ARRAY(array)
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
Memory handling functions.
static const char *const var_names[]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUVA422P10
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV444P10
static int config_props(AVBitStreamFilterLink *link)
Describe the class of an AVClass context structure.
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Link properties exposed to filter code, but not external callers.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
uint16_t lut_v10[1024][1024]
double var_values[VAR_NB]
AVExpr * brightness_pexpr
AVExpr * saturation_pexpr
uint16_t lut_u10[1024][1024]
static AVFormatContext * ctx
static void create_luma_lut(HueContext *h)
static const AVOption hue_options[]
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 void compute_sin_and_cos(HueContext *hue)
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 int set_expr(AVExpr **pexpr_ptr, char **expr_ptr, const char *expr, const char *option, void *log_ctx)
static const AVFilterPad hue_inputs[]
static int config_props(AVFilterLink *inlink)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static av_cold void uninit(AVFilterContext *ctx)
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 create_chrominance_lut(HueContext *h, const int32_t c, const int32_t s)
#define SET_EXPR(expr, option)
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.