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
94 { .str =
"1" }, .flags =
FLAGS },
98 { .str =
"0" }, .flags =
FLAGS },
120 for (i = 0; i < 256; i++) {
121 h->
lut_l[i] = av_clip_uint8(i + b * 25.5);
123 for (i = 0; i < 65536; i++) {
124 h->
lut_l16[i] = av_clip_uintp2(i + b * 102.4, 10);
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;
153 h->
lut_u[i][j] = av_clip_uint8(new_u);
154 h->
lut_v[i][j] = av_clip_uint8(new_v);
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;
172 h->
lut_u10[i][j] = av_clip_uintp2(new_u, 10);
173 h->
lut_v10[i][j] = av_clip_uintp2(new_v, 10);
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",
289 uint8_t *ldst,
const int dst_linesize,
290 uint8_t *lsrc,
const int src_linesize,
296 for (i = 0; i <
w; i++)
297 ldst[i] = s->
lut_l[lsrc[i]];
299 lsrc += src_linesize;
300 ldst += dst_linesize;
305 uint16_t *ldst,
const int dst_linesize,
306 uint16_t *lsrc,
const int src_linesize,
312 for (i = 0; i <
w; i++)
315 lsrc += src_linesize;
316 ldst += dst_linesize;
328 for (i = 0; i <
w; i++) {
329 const int u = usrc[i];
330 const int v = vsrc[i];
336 usrc += src_linesize;
337 vsrc += src_linesize;
338 udst += dst_linesize;
339 vdst += dst_linesize;
344 uint16_t *udst, uint16_t *vdst,
const int dst_linesize,
345 uint16_t *usrc, uint16_t *vsrc,
const int src_linesize,
351 for (i = 0; i <
w; i++) {
352 const int u = av_clip_uintp2(usrc[i], 10);
353 const int v = av_clip_uintp2(vsrc[i], 10);
359 usrc += src_linesize;
360 vsrc += src_linesize;
361 udst += dst_linesize;
362 vdst += dst_linesize;
366 #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
367 #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
402 "Saturation value not in range [%d,%d]: clipping value to %0.1f\n",
413 "Brightness value not in range [%d,%d]: clipping value to %0.1f\n",
427 "H:%0.1f*PI h:%0.1f s:%0.1f b:%0.f t:%0.1f n:%d\n",
442 inlink->
w * bps, inlink->
h);
446 inlink->
w * bps, inlink->
h);
451 (uint16_t*) inpic->
data[1], (uint16_t*) inpic->
data[2], inpic->
linesize[1]/2,
456 (uint16_t*) inpic->
data[0], inpic->
linesize[0]/2, inlink->
w, inlink->
h);
475 char *res,
int res_len,
int flags)
480 #define SET_EXPR(expr, option) \
482 ret = set_expr(&hue->expr##_pexpr, &hue->expr##_expr, \
483 args, option, ctx); \
488 if (!strcmp(cmd,
"h")) {
491 }
else if (!strcmp(cmd,
"H")) {
494 }
else if (!strcmp(cmd,
"s")) {
496 }
else if (!strcmp(cmd,
"b")) {
532 .priv_class = &hue_class,
#define AV_PIX_FMT_YUV440P10
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]
#define AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA422P10
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)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
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).
#define u(width, name, range_min, range_max)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define AV_LOG_VERBOSE
Detailed information.
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 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...
#define AV_PIX_FMT_YUV444P10
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)
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)
#define AV_PIX_FMT_YUVA444P10
static const AVFilterPad inputs[]
AVFILTER_DEFINE_CLASS(hue)
static const AVFilterPad outputs[]
int format
agreed upon media format
uint16_t lut_v10[1024][1024]
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...
#define AV_PIX_FMT_YUV420P10
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[]
#define flags(name, subs,...)
#define AV_PIX_FMT_YUV422P10
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)
uint16_t lut_u10[1024][1024]
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)
int depth
Number of bits in the component.
AVPixelFormat
Pixel format.
static const char *const var_names[]
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)