39 #define SAT_MIN_VAL -10
40 #define SAT_MAX_VAL 10
85 #define OFFSET(x) offsetof(HueContext, x)
86 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
91 { .str =
"1" }, .flags =
FLAGS },
95 { .str =
"0" }, .flags =
FLAGS },
117 for (i = 0; i < 256; i++) {
118 h->
lut_l[i] = av_clip_uint8(i + b * 25.5);
131 for (i = 0; i < 256; i++) {
132 for (j = 0; j < 256; j++) {
143 new_u = ((c *
u) - (s * v) + (1 << 15) + (128 << 16)) >> 16;
144 new_v = ((s *
u) + (c * v) + (1 << 15) + (128 << 16)) >> 16;
147 h->
lut_u[i][j] = av_clip_uint8(new_u);
148 h->
lut_v[i][j] = av_clip_uint8(new_v);
154 const char *expr,
const char *
option,
void *log_ctx)
167 "Error when evaluating the expression '%s' for %s\n",
175 *pexpr_ptr = new_pexpr;
177 *expr_ptr = new_expr;
189 "H and h options are incompatible and cannot be specified "
190 "at the same time\n");
194 #define SET_EXPR(expr, option) \
195 if (hue->expr##_expr) do { \
196 ret = set_expr(&hue->expr##_pexpr, &hue->expr##_expr, \
197 hue->expr##_expr, option, ctx); \
208 "H_expr:%s h_deg_expr:%s s_expr:%s b_expr:%s\n",
259 uint8_t *ldst,
const int dst_linesize,
260 uint8_t *lsrc,
const int src_linesize,
266 for (i = 0; i < w; i++)
267 ldst[i] = s->
lut_l[lsrc[i]];
269 lsrc += src_linesize;
270 ldst += dst_linesize;
282 for (i = 0; i < w; i++) {
283 const int u = usrc[i];
284 const int v = vsrc[i];
290 usrc += src_linesize;
291 vsrc += src_linesize;
292 udst += dst_linesize;
293 vdst += dst_linesize;
297 #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
298 #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
331 "Saturation value not in range [%d,%d]: clipping value to %0.1f\n",
342 "Brightness value not in range [%d,%d]: clipping value to %0.1f\n",
356 "H:%0.1f*PI h:%0.1f s:%0.1f b:%0.f t:%0.1f n:%d\n",
371 inlink->
w, inlink->
h);
375 inlink->
w, inlink->
h);
394 char *res,
int res_len,
int flags)
399 #define SET_EXPR(expr, option) \
401 ret = set_expr(&hue->expr##_pexpr, &hue->expr##_expr, \
402 args, option, ctx); \
407 if (!strcmp(cmd,
"h")) {
410 }
else if (!strcmp(cmd,
"H")) {
413 }
else if (!strcmp(cmd,
"s")) {
415 }
else if (!strcmp(cmd,
"b")) {
451 .priv_class = &hue_class,
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
double var_values[VAR_NB]
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
int h
agreed upon image height
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[]
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.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
#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.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
static void compute_sin_and_cos(HueContext *hue)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define AV_LOG_VERBOSE
Detailed information.
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)
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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 or variable; if left to 0/0, will be automatically copied from the first input of the source filter if it exists.
static av_cold int init(AVFilterContext *ctx)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVExpr * saturation_pexpr
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
AVExpr * brightness_pexpr
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
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)
static const AVFilterPad outputs[]
AVFILTER_DEFINE_CLASS(hue)
int format
agreed upon media format
static const AVFilterPad inputs[]
char * av_strdup(const char *s)
Duplicate a string.
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
static av_cold void uninit(AVFilterContext *ctx)
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Describe the class of an AVClass context structure.
static int set_expr(AVExpr **pexpr_ptr, char **expr_ptr, const char *expr, const char *option, void *log_ctx)
const char * name
Filter name.
static const AVOption hue_options[]
static const AVFilterPad hue_outputs[]
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 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)
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
AVFilterContext * dst
dest filter
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
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)
AVPixelFormat
Pixel format.
static const char *const var_names[]
int64_t frame_count
Number of past frames sent through the link.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
simple arithmetic expression evaluator
#define AV_CEIL_RSHIFT(a, b)