29 #include "libavutil/eval.h"
30 #include "libavutil/imgutils.h"
31 #include "libavutil/opt.h"
32 #include "libavutil/pixdesc.h"
39 #define SAT_MIN_VAL -10
40 #define SAT_MAX_VAL 10
84 #define OFFSET(x) offsetof(HueContext, x)
85 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
88 { .str = NULL }, .flags =
FLAGS },
90 { .str =
"1" }, .flags =
FLAGS },
92 { .str = NULL }, .flags =
FLAGS },
94 { .str =
"0" }, .flags =
FLAGS },
116 for (i = 0; i < 256; i++) {
117 h->
lut_l[i] = av_clip_uint8(i + b * 25.5);
130 for (i = 0; i < 256; i++) {
131 for (j = 0; j < 256; j++) {
142 new_u = ((c *
u) - (s * v) + (1 << 15) + (128 << 16)) >> 16;
143 new_v = ((s *
u) + (c * v) + (1 << 15) + (128 << 16)) >> 16;
153 const char *expr,
const char *
option,
void *log_ctx)
163 NULL, NULL, NULL, NULL, 0, log_ctx);
166 "Error when evaluating the expression '%s' for %s\n",
174 *pexpr_ptr = new_pexpr;
176 *expr_ptr = new_expr;
188 "H and h options are incompatible and cannot be specified "
189 "at the same time\n");
193 #define SET_EXPR(expr, option) \
194 if (hue->expr##_expr) do { \
195 ret = set_expr(&hue->expr##_pexpr, &hue->expr##_expr, \
196 hue->expr##_expr, option, ctx); \
207 "H_expr:%s h_deg_expr:%s s_expr:%s b_expr:%s\n",
257 uint8_t *ldst,
const int dst_linesize,
258 uint8_t *lsrc,
const int src_linesize,
264 for (i = 0; i < w; i++)
265 ldst[i] = s->
lut_l[lsrc[i]];
267 lsrc += src_linesize;
268 ldst += dst_linesize;
280 for (i = 0; i < w; i++) {
281 const int u = usrc[i];
282 const int v = vsrc[i];
288 usrc += src_linesize;
289 vsrc += src_linesize;
290 udst += dst_linesize;
291 vdst += dst_linesize;
295 #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
296 #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
329 "Saturation value not in range [%d,%d]: clipping value to %0.1f\n",
340 "Brightness value not in range [%d,%d]: clipping value to %0.1f\n",
354 "H:%0.1f*PI h:%0.1f s:%0.f b:%0.f t:%0.1f n:%d\n",
369 inlink->
w, inlink->
h);
373 inlink->
w, inlink->
h);
395 #define SET_EXPR(expr, option) \
397 ret = set_expr(&hue->expr##_pexpr, &hue->expr##_expr, \
398 args, option, ctx); \
403 if (!strcmp(cmd,
"h")) {
406 }
else if (!strcmp(cmd,
"H")) {
409 }
else if (!strcmp(cmd,
"s")) {
411 }
else if (!strcmp(cmd,
"b")) {
447 .priv_class = &hue_class,
This structure describes decoded (raw) audio or video data.
static double rint(double x)
double var_values[VAR_NB]
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
const char * name
Filter name.
void * priv
private data for use by the filter
#define AV_LOG_WARNING
Something somehow does not look correct.
static const AVFilterPad outputs[]
char * av_strdup(const char *s) av_malloc_attrib
Duplicate the string s.
int h
agreed upon image height
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
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 int query_formats(AVFilterContext *ctx)
static void create_chrominance_lut(HueContext *h, const int32_t c, const int32_t s)
static const AVFilterPad hue_inputs[]
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
#define SET_EXPR(expr, option)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static void compute_sin_and_cos(HueContext *hue)
static av_always_inline av_const uint8_t av_clip_uint8_c(int a)
Clip a signed integer value into the 0-255 range.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define FF_CEIL_RSHIFT(a, b)
static double av_q2d(AVRational a)
Convert rational to double.
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_LOG_VERBOSE
Detailed information.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
static void create_luma_lut(HueContext *h)
A filter pad used for either input or output.
A link between two filters.
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown; if left to 0/0, will be automatically be cop...
static av_cold int init(AVFilterContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVExpr * saturation_pexpr
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVPixelFormat
Pixel format.
AVExpr * brightness_pexpr
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
int w
agreed upon image width
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)
int format
agreed upon media format
Main libavfilter public API header.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
AVFilterLink ** outputs
array of pointers to output links
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static av_cold void uninit(AVFilterContext *ctx)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
static int set_expr(AVExpr **pexpr_ptr, char **expr_ptr, const char *expr, const char *option, void *log_ctx)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static const AVOption hue_options[]
AVFilterContext * dst
dest filter
static const AVFilterPad hue_outputs[]
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)
#define AVFILTER_DEFINE_CLASS(fname)
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 int config_props(AVFilterLink *inlink)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static const char *const var_names[]
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
int64_t frame_count
Number of past frames sent through the link.