/*
* Copyright (c) 2015 Arwa Arif <arwaarif1994@gmail.com>
+ * Copyright (c) 2017 Paul B Mahol
*
* This file is part of FFmpeg.
*
AVExpr *weight_expr[MAX_PLANES];
double *weight[MAX_PLANES];
+ void (*rdft_horizontal)(struct FFTFILTContext *s, AVFrame *in, int w, int h, int plane);
+ void (*irdft_horizontal)(struct FFTFILTContext *s, AVFrame *out, int w, int h, int plane);
} FFTFILTContext;
static const char *const var_names[] = { "X", "Y", "W", "H", "N", NULL };
{ "dc_Y", "adjust gain in Y plane", OFFSET(dc[Y]), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1000, FLAGS },
{ "dc_U", "adjust gain in U plane", OFFSET(dc[U]), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1000, FLAGS },
{ "dc_V", "adjust gain in V plane", OFFSET(dc[V]), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1000, FLAGS },
- { "weight_Y", "set luminance expression in Y plane", OFFSET(weight_str[Y]), AV_OPT_TYPE_STRING, {.str = "1"}, CHAR_MIN, CHAR_MAX, FLAGS },
- { "weight_U", "set chrominance expression in U plane", OFFSET(weight_str[U]), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS },
- { "weight_V", "set chrominance expression in V plane", OFFSET(weight_str[V]), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS },
+ { "weight_Y", "set luminance expression in Y plane", OFFSET(weight_str[Y]), AV_OPT_TYPE_STRING, {.str = "1"}, 0, 0, FLAGS },
+ { "weight_U", "set chrominance expression in U plane", OFFSET(weight_str[U]), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
+ { "weight_V", "set chrominance expression in V plane", OFFSET(weight_str[V]), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
{ "eval", "specify when to evaluate expressions", OFFSET(eval_mode), AV_OPT_TYPE_INT, {.i64 = EVAL_MODE_INIT}, 0, EVAL_MODE_NB-1, FLAGS, "eval" },
{ "init", "eval expressions once during initialization", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_INIT}, .flags = FLAGS, .unit = "eval" },
{ "frame", "eval expressions per-frame", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_FRAME}, .flags = FLAGS, .unit = "eval" },
}
/*Horizontal pass - RDFT*/
-static void rdft_horizontal(FFTFILTContext *s, AVFrame *in, int w, int h, int plane)
+static void rdft_horizontal8(FFTFILTContext *s, AVFrame *in, int w, int h, int plane)
{
int i, j;
av_rdft_calc(s->hrdft[plane], s->rdft_hdata[plane] + i * s->rdft_hlen[plane]);
}
+static void rdft_horizontal16(FFTFILTContext *s, AVFrame *in, int w, int h, int plane)
+{
+ const uint16_t *src = (const uint16_t *)in->data[plane];
+ int linesize = in->linesize[plane] / 2;
+ int i, j;
+
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++)
+ s->rdft_hdata[plane][i * s->rdft_hlen[plane] + j] = *(src + linesize * i + j);
+
+ copy_rev(s->rdft_hdata[plane] + i * s->rdft_hlen[plane], w, s->rdft_hlen[plane]);
+ }
+
+ for (i = 0; i < h; i++)
+ av_rdft_calc(s->hrdft[plane], s->rdft_hdata[plane] + i * s->rdft_hlen[plane]);
+}
+
/*Vertical pass - RDFT*/
static void rdft_vertical(FFTFILTContext *s, int h, int plane)
{
}
/*Horizontal pass - IRDFT*/
-static void irdft_horizontal(FFTFILTContext *s, AVFrame *out, int w, int h, int plane)
+static void irdft_horizontal8(FFTFILTContext *s, AVFrame *out, int w, int h, int plane)
{
int i, j;
s->rdft_vlen[plane]), 0, 255);
}
+static void irdft_horizontal16(FFTFILTContext *s, AVFrame *out, int w, int h, int plane)
+{
+ uint16_t *dst = (uint16_t *)out->data[plane];
+ int linesize = out->linesize[plane] / 2;
+ int max = (1 << s->depth) - 1;
+ int i, j;
+
+ for (i = 0; i < h; i++)
+ av_rdft_calc(s->ihrdft[plane], s->rdft_hdata[plane] + i * s->rdft_hlen[plane]);
+
+ for (i = 0; i < h; i++)
+ for (j = 0; j < w; j++)
+ *(dst + linesize * i + j) = av_clip(s->rdft_hdata[plane][i
+ *s->rdft_hlen[plane] + j] * 4 /
+ (s->rdft_hlen[plane] *
+ s->rdft_vlen[plane]), 0, max);
+}
+
static av_cold int initialize(AVFilterContext *ctx)
{
FFTFILTContext *s = ctx->priv;
if (s->eval_mode == EVAL_MODE_INIT)
do_eval(s, inlink, plane);
}
+
+ if (s->depth <= 8) {
+ s->rdft_horizontal = rdft_horizontal8;
+ s->irdft_horizontal = irdft_horizontal8;
+ } else if (s->depth > 8) {
+ s->rdft_horizontal = rdft_horizontal16;
+ s->irdft_horizontal = irdft_horizontal16;
+ } else {
+ return AVERROR_BUG;
+ }
return 0;
}
if (s->eval_mode == EVAL_MODE_FRAME)
do_eval(s, inlink, plane);
- rdft_horizontal(s, in, w, h, plane);
+ s->rdft_horizontal(s, in, w, h, plane);
rdft_vertical(s, h, plane);
/*Change user defined parameters*/
s->rdft_vdata[plane][0] += s->rdft_hlen[plane] * s->rdft_vlen[plane] * s->dc[plane];
irdft_vertical(s, h, plane);
- irdft_horizontal(s, out, w, h, plane);
+ s->irdft_horizontal(s, out, w, h, plane);
}
av_frame_free(&in);
AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P,
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVJ420P,
AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVJ422P,
+ AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV420P10,
+ AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV420P14,
+ AV_PIX_FMT_YUV420P16,
+ AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV422P10,
+ AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV422P14,
+ AV_PIX_FMT_YUV422P16,
+ AV_PIX_FMT_YUV444P9, AV_PIX_FMT_YUV444P10,
+ AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV444P14,
+ AV_PIX_FMT_YUV444P16,
AV_PIX_FMT_NONE
};