2011-05-28 22:51:03 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011 Stefano Sabatini
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Compute a look-up table for binding the input value to the output
|
|
|
|
* value, and apply it to input video.
|
|
|
|
*/
|
|
|
|
|
2013-04-30 19:30:02 +03:00
|
|
|
#include "libavutil/attributes.h"
|
2012-08-06 16:49:32 +03:00
|
|
|
#include "libavutil/common.h"
|
2011-05-28 22:51:03 +03:00
|
|
|
#include "libavutil/eval.h"
|
|
|
|
#include "libavutil/opt.h"
|
|
|
|
#include "libavutil/pixdesc.h"
|
|
|
|
#include "avfilter.h"
|
2013-01-01 19:38:54 +03:00
|
|
|
#include "drawutils.h"
|
2012-05-30 11:12:55 +03:00
|
|
|
#include "formats.h"
|
2011-06-30 10:51:17 +03:00
|
|
|
#include "internal.h"
|
2012-05-30 12:20:32 +03:00
|
|
|
#include "video.h"
|
2011-05-28 22:51:03 +03:00
|
|
|
|
2012-02-20 11:42:33 +03:00
|
|
|
static const char *const var_names[] = {
|
2011-05-28 22:51:03 +03:00
|
|
|
"w", ///< width of the input video
|
|
|
|
"h", ///< height of the input video
|
|
|
|
"val", ///< input value for the pixel
|
|
|
|
"maxval", ///< max value for the pixel
|
|
|
|
"minval", ///< min value for the pixel
|
|
|
|
"negval", ///< negated value
|
|
|
|
"clipval",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum var_name {
|
|
|
|
VAR_W,
|
|
|
|
VAR_H,
|
|
|
|
VAR_VAL,
|
|
|
|
VAR_MAXVAL,
|
|
|
|
VAR_MINVAL,
|
|
|
|
VAR_NEGVAL,
|
|
|
|
VAR_CLIPVAL,
|
|
|
|
VAR_VARS_NB
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const AVClass *class;
|
|
|
|
uint8_t lut[4][256]; ///< lookup table for each component
|
|
|
|
char *comp_expr_str[4];
|
|
|
|
AVExpr *comp_expr[4];
|
|
|
|
int hsub, vsub;
|
|
|
|
double var_values[VAR_VARS_NB];
|
|
|
|
int is_rgb, is_yuv;
|
|
|
|
int step;
|
2011-05-28 23:00:26 +03:00
|
|
|
int negate_alpha; /* only used by negate */
|
2011-05-28 22:51:03 +03:00
|
|
|
} LutContext;
|
|
|
|
|
|
|
|
#define Y 0
|
|
|
|
#define U 1
|
|
|
|
#define V 2
|
|
|
|
#define R 0
|
|
|
|
#define G 1
|
|
|
|
#define B 2
|
|
|
|
#define A 3
|
|
|
|
|
|
|
|
#define OFFSET(x) offsetof(LutContext, x)
|
2012-08-13 14:40:01 +03:00
|
|
|
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
|
2011-05-28 22:51:03 +03:00
|
|
|
|
2012-08-09 18:48:03 +03:00
|
|
|
static const AVOption options[] = {
|
2013-02-25 23:21:29 +03:00
|
|
|
{ "c0", "set component #0 expression", OFFSET(comp_expr_str[0]), AV_OPT_TYPE_STRING, { .str = "val" }, .flags = FLAGS },
|
|
|
|
{ "c1", "set component #1 expression", OFFSET(comp_expr_str[1]), AV_OPT_TYPE_STRING, { .str = "val" }, .flags = FLAGS },
|
|
|
|
{ "c2", "set component #2 expression", OFFSET(comp_expr_str[2]), AV_OPT_TYPE_STRING, { .str = "val" }, .flags = FLAGS },
|
|
|
|
{ "c3", "set component #3 expression", OFFSET(comp_expr_str[3]), AV_OPT_TYPE_STRING, { .str = "val" }, .flags = FLAGS },
|
|
|
|
{ "y", "set Y expression", OFFSET(comp_expr_str[Y]), AV_OPT_TYPE_STRING, { .str = "val" }, .flags = FLAGS },
|
|
|
|
{ "u", "set U expression", OFFSET(comp_expr_str[U]), AV_OPT_TYPE_STRING, { .str = "val" }, .flags = FLAGS },
|
|
|
|
{ "v", "set V expression", OFFSET(comp_expr_str[V]), AV_OPT_TYPE_STRING, { .str = "val" }, .flags = FLAGS },
|
|
|
|
{ "r", "set R expression", OFFSET(comp_expr_str[R]), AV_OPT_TYPE_STRING, { .str = "val" }, .flags = FLAGS },
|
|
|
|
{ "g", "set G expression", OFFSET(comp_expr_str[G]), AV_OPT_TYPE_STRING, { .str = "val" }, .flags = FLAGS },
|
|
|
|
{ "b", "set B expression", OFFSET(comp_expr_str[B]), AV_OPT_TYPE_STRING, { .str = "val" }, .flags = FLAGS },
|
|
|
|
{ "a", "set A expression", OFFSET(comp_expr_str[A]), AV_OPT_TYPE_STRING, { .str = "val" }, .flags = FLAGS },
|
|
|
|
{ NULL },
|
2011-05-28 22:51:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static av_cold void uninit(AVFilterContext *ctx)
|
|
|
|
{
|
|
|
|
LutContext *lut = ctx->priv;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
av_expr_free(lut->comp_expr[i]);
|
|
|
|
lut->comp_expr[i] = NULL;
|
|
|
|
av_freep(&lut->comp_expr_str[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define YUV_FORMATS \
|
2012-10-06 13:10:34 +03:00
|
|
|
AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, \
|
|
|
|
AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV440P, \
|
2013-05-07 15:44:46 +03:00
|
|
|
AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P, \
|
2012-10-06 13:10:34 +03:00
|
|
|
AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P, \
|
|
|
|
AV_PIX_FMT_YUVJ440P
|
2011-05-28 22:51:03 +03:00
|
|
|
|
|
|
|
#define RGB_FORMATS \
|
2012-10-06 13:10:34 +03:00
|
|
|
AV_PIX_FMT_ARGB, AV_PIX_FMT_RGBA, \
|
|
|
|
AV_PIX_FMT_ABGR, AV_PIX_FMT_BGRA, \
|
|
|
|
AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24
|
2011-05-28 22:51:03 +03:00
|
|
|
|
2012-10-08 21:54:00 +03:00
|
|
|
static const enum AVPixelFormat yuv_pix_fmts[] = { YUV_FORMATS, AV_PIX_FMT_NONE };
|
|
|
|
static const enum AVPixelFormat rgb_pix_fmts[] = { RGB_FORMATS, AV_PIX_FMT_NONE };
|
|
|
|
static const enum AVPixelFormat all_pix_fmts[] = { RGB_FORMATS, YUV_FORMATS, AV_PIX_FMT_NONE };
|
2011-05-28 22:51:03 +03:00
|
|
|
|
|
|
|
static int query_formats(AVFilterContext *ctx)
|
|
|
|
{
|
|
|
|
LutContext *lut = ctx->priv;
|
|
|
|
|
2012-10-08 21:54:00 +03:00
|
|
|
const enum AVPixelFormat *pix_fmts = lut->is_rgb ? rgb_pix_fmts :
|
2011-11-05 17:20:18 +03:00
|
|
|
lut->is_yuv ? yuv_pix_fmts : all_pix_fmts;
|
2011-05-28 22:51:03 +03:00
|
|
|
|
2012-05-30 11:12:55 +03:00
|
|
|
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
|
2011-05-28 22:51:03 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clip value val in the minval - maxval range.
|
|
|
|
*/
|
|
|
|
static double clip(void *opaque, double val)
|
|
|
|
{
|
|
|
|
LutContext *lut = opaque;
|
|
|
|
double minval = lut->var_values[VAR_MINVAL];
|
|
|
|
double maxval = lut->var_values[VAR_MAXVAL];
|
|
|
|
|
|
|
|
return av_clip(val, minval, maxval);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute gamma correction for value val, assuming the minval-maxval
|
|
|
|
* range, val is clipped to a value contained in the same interval.
|
|
|
|
*/
|
|
|
|
static double compute_gammaval(void *opaque, double gamma)
|
|
|
|
{
|
|
|
|
LutContext *lut = opaque;
|
|
|
|
double val = lut->var_values[VAR_CLIPVAL];
|
|
|
|
double minval = lut->var_values[VAR_MINVAL];
|
|
|
|
double maxval = lut->var_values[VAR_MAXVAL];
|
|
|
|
|
|
|
|
return pow((val-minval)/(maxval-minval), gamma) * (maxval-minval)+minval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static double (* const funcs1[])(void *, double) = {
|
|
|
|
(void *)clip,
|
|
|
|
(void *)compute_gammaval,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char * const funcs1_names[] = {
|
|
|
|
"clip",
|
|
|
|
"gammaval",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static int config_props(AVFilterLink *inlink)
|
|
|
|
{
|
|
|
|
AVFilterContext *ctx = inlink->dst;
|
|
|
|
LutContext *lut = ctx->priv;
|
2012-10-06 14:29:37 +03:00
|
|
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
|
2013-01-01 19:38:54 +03:00
|
|
|
uint8_t rgba_map[4]; /* component index -> RGBA color index map */
|
2011-05-28 22:51:03 +03:00
|
|
|
int min[4], max[4];
|
2013-02-27 19:08:50 +03:00
|
|
|
int val, color, ret;
|
2011-05-28 22:51:03 +03:00
|
|
|
|
|
|
|
lut->hsub = desc->log2_chroma_w;
|
|
|
|
lut->vsub = desc->log2_chroma_h;
|
|
|
|
|
|
|
|
lut->var_values[VAR_W] = inlink->w;
|
|
|
|
lut->var_values[VAR_H] = inlink->h;
|
|
|
|
|
|
|
|
switch (inlink->format) {
|
2012-10-06 13:10:34 +03:00
|
|
|
case AV_PIX_FMT_YUV410P:
|
|
|
|
case AV_PIX_FMT_YUV411P:
|
|
|
|
case AV_PIX_FMT_YUV420P:
|
|
|
|
case AV_PIX_FMT_YUV422P:
|
|
|
|
case AV_PIX_FMT_YUV440P:
|
|
|
|
case AV_PIX_FMT_YUV444P:
|
|
|
|
case AV_PIX_FMT_YUVA420P:
|
2013-05-07 15:44:46 +03:00
|
|
|
case AV_PIX_FMT_YUVA422P:
|
|
|
|
case AV_PIX_FMT_YUVA444P:
|
2011-05-28 22:51:03 +03:00
|
|
|
min[Y] = min[U] = min[V] = 16;
|
|
|
|
max[Y] = 235;
|
|
|
|
max[U] = max[V] = 240;
|
2011-07-02 16:23:56 +03:00
|
|
|
min[A] = 0; max[A] = 255;
|
2011-05-28 22:51:03 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
min[0] = min[1] = min[2] = min[3] = 0;
|
|
|
|
max[0] = max[1] = max[2] = max[3] = 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
lut->is_yuv = lut->is_rgb = 0;
|
2011-06-30 10:51:17 +03:00
|
|
|
if (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1;
|
|
|
|
else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1;
|
2011-05-28 22:51:03 +03:00
|
|
|
|
|
|
|
if (lut->is_rgb) {
|
2013-01-01 19:38:54 +03:00
|
|
|
ff_fill_rgba_map(rgba_map, inlink->format);
|
2011-05-28 22:51:03 +03:00
|
|
|
lut->step = av_get_bits_per_pixel(desc) >> 3;
|
|
|
|
}
|
|
|
|
|
2013-02-27 19:08:50 +03:00
|
|
|
for (color = 0; color < desc->nb_components; color++) {
|
2011-05-28 22:51:03 +03:00
|
|
|
double res;
|
2013-02-27 19:08:50 +03:00
|
|
|
int comp = lut->is_rgb ? rgba_map[color] : color;
|
2012-05-31 11:11:09 +03:00
|
|
|
|
2011-05-28 22:51:03 +03:00
|
|
|
/* create the parsed expression */
|
2012-05-31 11:11:09 +03:00
|
|
|
ret = av_expr_parse(&lut->comp_expr[color], lut->comp_expr_str[color],
|
2011-05-28 22:51:03 +03:00
|
|
|
var_names, funcs1_names, funcs1, NULL, NULL, 0, ctx);
|
|
|
|
if (ret < 0) {
|
|
|
|
av_log(ctx, AV_LOG_ERROR,
|
2012-05-31 11:11:09 +03:00
|
|
|
"Error when parsing the expression '%s' for the component %d and color %d.\n",
|
|
|
|
lut->comp_expr_str[comp], comp, color);
|
2011-05-28 22:51:03 +03:00
|
|
|
return AVERROR(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compute the lut */
|
2012-05-31 11:11:09 +03:00
|
|
|
lut->var_values[VAR_MAXVAL] = max[color];
|
|
|
|
lut->var_values[VAR_MINVAL] = min[color];
|
2011-05-28 22:51:03 +03:00
|
|
|
|
|
|
|
for (val = 0; val < 256; val++) {
|
|
|
|
lut->var_values[VAR_VAL] = val;
|
2012-05-31 11:11:09 +03:00
|
|
|
lut->var_values[VAR_CLIPVAL] = av_clip(val, min[color], max[color]);
|
2011-05-28 22:51:03 +03:00
|
|
|
lut->var_values[VAR_NEGVAL] =
|
2012-05-31 11:11:09 +03:00
|
|
|
av_clip(min[color] + max[color] - lut->var_values[VAR_VAL],
|
|
|
|
min[color], max[color]);
|
2011-05-28 22:51:03 +03:00
|
|
|
|
2012-05-31 11:11:09 +03:00
|
|
|
res = av_expr_eval(lut->comp_expr[color], lut->var_values, lut);
|
2011-05-28 22:51:03 +03:00
|
|
|
if (isnan(res)) {
|
|
|
|
av_log(ctx, AV_LOG_ERROR,
|
2012-05-31 11:11:09 +03:00
|
|
|
"Error when evaluating the expression '%s' for the value %d for the component %d.\n",
|
|
|
|
lut->comp_expr_str[color], val, comp);
|
2011-05-28 22:51:03 +03:00
|
|
|
return AVERROR(EINVAL);
|
|
|
|
}
|
2012-05-31 11:11:09 +03:00
|
|
|
lut->lut[comp][val] = av_clip((int)res, min[color], max[color]);
|
|
|
|
av_log(ctx, AV_LOG_DEBUG, "val[%d][%d] = %d\n", comp, val, lut->lut[comp][val]);
|
2011-05-28 22:51:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-11-28 10:41:07 +03:00
|
|
|
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
2011-05-28 22:51:03 +03:00
|
|
|
{
|
|
|
|
AVFilterContext *ctx = inlink->dst;
|
|
|
|
LutContext *lut = ctx->priv;
|
|
|
|
AVFilterLink *outlink = ctx->outputs[0];
|
2012-11-28 10:41:07 +03:00
|
|
|
AVFrame *out;
|
2011-06-26 19:49:00 +03:00
|
|
|
uint8_t *inrow, *outrow, *inrow0, *outrow0;
|
2013-04-17 13:07:46 +03:00
|
|
|
int i, j, plane, direct = 0;
|
2011-05-28 22:51:03 +03:00
|
|
|
|
2013-04-17 13:07:46 +03:00
|
|
|
if (av_frame_is_writable(in)) {
|
|
|
|
direct = 1;
|
|
|
|
out = in;
|
|
|
|
} else {
|
2013-04-17 13:16:16 +03:00
|
|
|
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
|
|
|
|
if (!out) {
|
|
|
|
av_frame_free(&in);
|
|
|
|
return AVERROR(ENOMEM);
|
|
|
|
}
|
|
|
|
av_frame_copy_props(out, in);
|
2013-04-17 13:07:46 +03:00
|
|
|
}
|
2012-11-29 00:39:35 +03:00
|
|
|
|
2011-05-28 22:51:03 +03:00
|
|
|
if (lut->is_rgb) {
|
|
|
|
/* packed */
|
2012-11-29 00:39:35 +03:00
|
|
|
inrow0 = in ->data[0];
|
|
|
|
outrow0 = out->data[0];
|
2011-05-28 22:51:03 +03:00
|
|
|
|
2012-11-28 10:41:07 +03:00
|
|
|
for (i = 0; i < in->height; i ++) {
|
2012-04-03 19:13:33 +03:00
|
|
|
int w = inlink->w;
|
2012-05-10 21:09:37 +03:00
|
|
|
const uint8_t (*tab)[256] = (const uint8_t (*)[256])lut->lut;
|
2011-06-26 19:49:00 +03:00
|
|
|
inrow = inrow0;
|
|
|
|
outrow = outrow0;
|
2012-04-03 19:13:33 +03:00
|
|
|
for (j = 0; j < w; j++) {
|
2013-04-17 13:08:13 +03:00
|
|
|
switch (lut->step) {
|
2013-04-17 22:18:24 +03:00
|
|
|
case 4: outrow[3] = tab[3][inrow[3]]; // Fall-through
|
|
|
|
case 3: outrow[2] = tab[2][inrow[2]]; // Fall-through
|
|
|
|
case 2: outrow[1] = tab[1][inrow[1]]; // Fall-through
|
2013-04-17 13:08:13 +03:00
|
|
|
default: outrow[0] = tab[0][inrow[0]];
|
2012-04-03 19:13:33 +03:00
|
|
|
}
|
2011-05-28 22:51:03 +03:00
|
|
|
outrow += lut->step;
|
|
|
|
inrow += lut->step;
|
|
|
|
}
|
2012-11-29 00:39:35 +03:00
|
|
|
inrow0 += in ->linesize[0];
|
|
|
|
outrow0 += out->linesize[0];
|
2011-05-28 22:51:03 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* planar */
|
2012-11-29 00:39:35 +03:00
|
|
|
for (plane = 0; plane < 4 && in->data[plane]; plane++) {
|
2011-05-28 22:51:03 +03:00
|
|
|
int vsub = plane == 1 || plane == 2 ? lut->vsub : 0;
|
|
|
|
int hsub = plane == 1 || plane == 2 ? lut->hsub : 0;
|
|
|
|
|
2012-11-29 00:39:35 +03:00
|
|
|
inrow = in ->data[plane];
|
|
|
|
outrow = out->data[plane];
|
2011-05-28 22:51:03 +03:00
|
|
|
|
2013-03-10 03:30:30 +03:00
|
|
|
for (i = 0; i < (in->height + (1<<vsub) - 1)>>vsub; i ++) {
|
2012-04-03 18:49:04 +03:00
|
|
|
const uint8_t *tab = lut->lut[plane];
|
2012-06-20 21:13:43 +03:00
|
|
|
int w = (inlink->w + (1<<hsub) - 1)>>hsub;
|
2012-04-03 18:49:04 +03:00
|
|
|
for (j = 0; j < w; j++)
|
|
|
|
outrow[j] = tab[inrow[j]];
|
2012-11-29 00:39:35 +03:00
|
|
|
inrow += in ->linesize[plane];
|
|
|
|
outrow += out->linesize[plane];
|
2011-05-28 22:51:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-17 13:07:46 +03:00
|
|
|
if (!direct)
|
|
|
|
av_frame_free(&in);
|
|
|
|
|
2012-11-29 00:39:35 +03:00
|
|
|
return ff_filter_frame(outlink, out);
|
2011-05-28 22:51:03 +03:00
|
|
|
}
|
|
|
|
|
2012-07-21 19:45:52 +03:00
|
|
|
static const AVFilterPad inputs[] = {
|
|
|
|
{ .name = "default",
|
|
|
|
.type = AVMEDIA_TYPE_VIDEO,
|
2012-11-29 00:39:35 +03:00
|
|
|
.filter_frame = filter_frame,
|
2012-07-21 19:45:52 +03:00
|
|
|
.config_props = config_props,
|
2012-11-28 10:41:07 +03:00
|
|
|
},
|
2012-07-21 19:45:52 +03:00
|
|
|
{ .name = NULL}
|
|
|
|
};
|
|
|
|
static const AVFilterPad outputs[] = {
|
|
|
|
{ .name = "default",
|
|
|
|
.type = AVMEDIA_TYPE_VIDEO, },
|
|
|
|
{ .name = NULL}
|
|
|
|
};
|
2013-04-10 22:54:13 +03:00
|
|
|
|
2012-08-09 18:48:03 +03:00
|
|
|
#define DEFINE_LUT_FILTER(name_, description_) \
|
2011-05-28 22:51:03 +03:00
|
|
|
AVFilter avfilter_vf_##name_ = { \
|
2011-07-21 12:00:47 +03:00
|
|
|
.name = #name_, \
|
|
|
|
.description = NULL_IF_CONFIG_SMALL(description_), \
|
2011-05-28 22:51:03 +03:00
|
|
|
.priv_size = sizeof(LutContext), \
|
2013-02-25 23:21:29 +03:00
|
|
|
.priv_class = &name_ ## _class, \
|
2011-05-28 22:51:03 +03:00
|
|
|
\
|
2012-08-09 18:48:03 +03:00
|
|
|
.init = name_##_init, \
|
2011-05-28 22:51:03 +03:00
|
|
|
.uninit = uninit, \
|
|
|
|
.query_formats = query_formats, \
|
|
|
|
\
|
2012-07-21 19:45:52 +03:00
|
|
|
.inputs = inputs, \
|
|
|
|
.outputs = outputs, \
|
2013-04-08 21:35:02 +03:00
|
|
|
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE, \
|
2011-05-28 22:51:03 +03:00
|
|
|
}
|
|
|
|
|
2011-05-28 22:51:03 +03:00
|
|
|
#if CONFIG_LUT_FILTER
|
2012-08-09 18:48:03 +03:00
|
|
|
|
|
|
|
#define lut_options options
|
|
|
|
AVFILTER_DEFINE_CLASS(lut);
|
|
|
|
|
2013-03-13 10:26:39 +03:00
|
|
|
static int lut_init(AVFilterContext *ctx)
|
2012-08-09 18:48:03 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_LUT_FILTER(lut, "Compute and apply a lookup table to the RGB/YUV input video.");
|
2011-05-28 22:51:03 +03:00
|
|
|
#endif
|
2012-08-09 18:48:03 +03:00
|
|
|
|
2011-05-28 22:51:03 +03:00
|
|
|
#if CONFIG_LUTYUV_FILTER
|
2012-08-09 18:48:03 +03:00
|
|
|
|
|
|
|
#define lutyuv_options options
|
|
|
|
AVFILTER_DEFINE_CLASS(lutyuv);
|
|
|
|
|
2013-05-05 12:42:18 +03:00
|
|
|
static av_cold int lutyuv_init(AVFilterContext *ctx)
|
2012-08-09 18:48:03 +03:00
|
|
|
{
|
|
|
|
LutContext *lut = ctx->priv;
|
|
|
|
|
|
|
|
lut->is_yuv = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_LUT_FILTER(lutyuv, "Compute and apply a lookup table to the YUV input video.");
|
2011-05-28 22:51:03 +03:00
|
|
|
#endif
|
2012-08-09 18:48:03 +03:00
|
|
|
|
2011-05-28 22:51:03 +03:00
|
|
|
#if CONFIG_LUTRGB_FILTER
|
2012-08-09 18:48:03 +03:00
|
|
|
|
|
|
|
#define lutrgb_options options
|
|
|
|
AVFILTER_DEFINE_CLASS(lutrgb);
|
|
|
|
|
2013-05-05 12:42:18 +03:00
|
|
|
static av_cold int lutrgb_init(AVFilterContext *ctx)
|
2012-08-09 18:48:03 +03:00
|
|
|
{
|
|
|
|
LutContext *lut = ctx->priv;
|
|
|
|
|
|
|
|
lut->is_rgb = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_LUT_FILTER(lutrgb, "Compute and apply a lookup table to the RGB input video.");
|
2011-05-28 22:51:03 +03:00
|
|
|
#endif
|
2011-05-28 23:00:26 +03:00
|
|
|
|
|
|
|
#if CONFIG_NEGATE_FILTER
|
|
|
|
|
2013-02-25 23:21:29 +03:00
|
|
|
static const AVOption negate_options[] = {
|
2013-04-27 02:45:24 +03:00
|
|
|
{ "negate_alpha", NULL, OFFSET(negate_alpha), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
|
2013-02-25 23:21:29 +03:00
|
|
|
{ NULL },
|
|
|
|
};
|
|
|
|
|
2012-08-09 18:48:03 +03:00
|
|
|
AVFILTER_DEFINE_CLASS(negate);
|
|
|
|
|
2013-04-30 19:30:02 +03:00
|
|
|
static av_cold int negate_init(AVFilterContext *ctx)
|
2011-05-28 23:00:26 +03:00
|
|
|
{
|
|
|
|
LutContext *lut = ctx->priv;
|
2013-02-25 23:21:29 +03:00
|
|
|
int i;
|
2011-05-28 23:00:26 +03:00
|
|
|
|
2011-05-28 23:00:26 +03:00
|
|
|
av_log(ctx, AV_LOG_DEBUG, "negate_alpha:%d\n", lut->negate_alpha);
|
2011-05-28 23:00:26 +03:00
|
|
|
|
2013-02-25 23:21:29 +03:00
|
|
|
for (i = 0; i < 4; i++) {
|
2013-04-10 22:54:13 +03:00
|
|
|
lut->comp_expr_str[i] = av_strdup((i == 3 && !lut->negate_alpha) ?
|
2013-02-25 23:21:29 +03:00
|
|
|
"val" : "negval");
|
|
|
|
if (!lut->comp_expr_str[i]) {
|
|
|
|
uninit(ctx);
|
|
|
|
return AVERROR(ENOMEM);
|
|
|
|
}
|
|
|
|
}
|
2012-08-09 18:48:03 +03:00
|
|
|
|
2013-04-15 01:22:16 +03:00
|
|
|
return 0;
|
2011-05-28 23:00:26 +03:00
|
|
|
}
|
|
|
|
|
2012-08-09 18:48:03 +03:00
|
|
|
DEFINE_LUT_FILTER(negate, "Negate input video.");
|
2011-05-28 23:00:26 +03:00
|
|
|
|
2011-11-05 16:49:52 +03:00
|
|
|
#endif
|