You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avfilter/vf_fftfilt: use the name 's' for the pointer to the private context
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
@@ -73,8 +73,8 @@ AVFILTER_DEFINE_CLASS(fftfilt);
|
|||||||
|
|
||||||
static inline double lum(void *priv, double x, double y, int plane)
|
static inline double lum(void *priv, double x, double y, int plane)
|
||||||
{
|
{
|
||||||
FFTFILTContext *fftfilt = priv;
|
FFTFILTContext *s = priv;
|
||||||
return fftfilt->rdft_vdata[plane][(int)x * fftfilt->rdft_vlen[plane] + (int)y];
|
return s->rdft_vdata[plane][(int)x * s->rdft_vlen[plane] + (int)y];
|
||||||
}
|
}
|
||||||
|
|
||||||
static double weight_Y(void *priv, double x, double y) { return lum(priv, x, y, Y); }
|
static double weight_Y(void *priv, double x, double y) { return lum(priv, x, y, Y); }
|
||||||
@@ -93,95 +93,95 @@ static void copy_rev (FFTSample *dest, int w, int w2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*Horizontal pass - RDFT*/
|
/*Horizontal pass - RDFT*/
|
||||||
static void rdft_horizontal(FFTFILTContext *fftfilt, AVFrame *in, int w, int h, int plane)
|
static void rdft_horizontal(FFTFILTContext *s, AVFrame *in, int w, int h, int plane)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
fftfilt->rdft = av_rdft_init(fftfilt->rdft_hbits[plane], DFT_R2C);
|
s->rdft = av_rdft_init(s->rdft_hbits[plane], DFT_R2C);
|
||||||
|
|
||||||
for (i = 0; i < h; i++) {
|
for (i = 0; i < h; i++) {
|
||||||
for (j = 0; j < w; j++)
|
for (j = 0; j < w; j++)
|
||||||
fftfilt->rdft_hdata[plane][i * fftfilt->rdft_hlen[plane] + j] = *(in->data[plane] + in->linesize[plane] * i + j);
|
s->rdft_hdata[plane][i * s->rdft_hlen[plane] + j] = *(in->data[plane] + in->linesize[plane] * i + j);
|
||||||
|
|
||||||
copy_rev(fftfilt->rdft_hdata[plane] + i * fftfilt->rdft_hlen[plane], w, fftfilt->rdft_hlen[plane]);
|
copy_rev(s->rdft_hdata[plane] + i * s->rdft_hlen[plane], w, s->rdft_hlen[plane]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < h; i++)
|
for (i = 0; i < h; i++)
|
||||||
av_rdft_calc(fftfilt->rdft, fftfilt->rdft_hdata[plane] + i * fftfilt->rdft_hlen[plane]);
|
av_rdft_calc(s->rdft, s->rdft_hdata[plane] + i * s->rdft_hlen[plane]);
|
||||||
|
|
||||||
av_rdft_end(fftfilt->rdft);
|
av_rdft_end(s->rdft);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Vertical pass - RDFT*/
|
/*Vertical pass - RDFT*/
|
||||||
static void rdft_vertical(FFTFILTContext *fftfilt, int h, int plane)
|
static void rdft_vertical(FFTFILTContext *s, int h, int plane)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
fftfilt->rdft = av_rdft_init(fftfilt->rdft_vbits[plane], DFT_R2C);
|
s->rdft = av_rdft_init(s->rdft_vbits[plane], DFT_R2C);
|
||||||
|
|
||||||
for (i = 0; i < fftfilt->rdft_hlen[plane]; i++) {
|
for (i = 0; i < s->rdft_hlen[plane]; i++) {
|
||||||
for (j = 0; j < h; j++)
|
for (j = 0; j < h; j++)
|
||||||
fftfilt->rdft_vdata[plane][i * fftfilt->rdft_vlen[plane] + j] =
|
s->rdft_vdata[plane][i * s->rdft_vlen[plane] + j] =
|
||||||
fftfilt->rdft_hdata[plane][j * fftfilt->rdft_hlen[plane] + i];
|
s->rdft_hdata[plane][j * s->rdft_hlen[plane] + i];
|
||||||
copy_rev(fftfilt->rdft_vdata[plane] + i * fftfilt->rdft_vlen[plane], h, fftfilt->rdft_vlen[plane]);
|
copy_rev(s->rdft_vdata[plane] + i * s->rdft_vlen[plane], h, s->rdft_vlen[plane]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < fftfilt->rdft_hlen[plane]; i++)
|
for (i = 0; i < s->rdft_hlen[plane]; i++)
|
||||||
av_rdft_calc(fftfilt->rdft, fftfilt->rdft_vdata[plane] + i * fftfilt->rdft_vlen[plane]);
|
av_rdft_calc(s->rdft, s->rdft_vdata[plane] + i * s->rdft_vlen[plane]);
|
||||||
|
|
||||||
av_rdft_end(fftfilt->rdft);
|
av_rdft_end(s->rdft);
|
||||||
}
|
}
|
||||||
/*Vertical pass - IRDFT*/
|
/*Vertical pass - IRDFT*/
|
||||||
static void irdft_vertical(FFTFILTContext *fftfilt, int h, int plane)
|
static void irdft_vertical(FFTFILTContext *s, int h, int plane)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
fftfilt->rdft = av_rdft_init(fftfilt->rdft_vbits[plane], IDFT_C2R);
|
s->rdft = av_rdft_init(s->rdft_vbits[plane], IDFT_C2R);
|
||||||
for (i = 0; i < fftfilt->rdft_hlen[plane]; i++)
|
for (i = 0; i < s->rdft_hlen[plane]; i++)
|
||||||
av_rdft_calc(fftfilt->rdft, fftfilt->rdft_vdata[plane] + i * fftfilt->rdft_vlen[plane]);
|
av_rdft_calc(s->rdft, s->rdft_vdata[plane] + i * s->rdft_vlen[plane]);
|
||||||
|
|
||||||
for (i = 0; i < fftfilt->rdft_hlen[plane]; i++)
|
for (i = 0; i < s->rdft_hlen[plane]; i++)
|
||||||
for (j = 0; j < h; j++)
|
for (j = 0; j < h; j++)
|
||||||
fftfilt->rdft_hdata[plane][j * fftfilt->rdft_hlen[plane] + i] =
|
s->rdft_hdata[plane][j * s->rdft_hlen[plane] + i] =
|
||||||
fftfilt->rdft_vdata[plane][i * fftfilt->rdft_vlen[plane] + j];
|
s->rdft_vdata[plane][i * s->rdft_vlen[plane] + j];
|
||||||
|
|
||||||
av_rdft_end(fftfilt->rdft);
|
av_rdft_end(s->rdft);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Horizontal pass - IRDFT*/
|
/*Horizontal pass - IRDFT*/
|
||||||
static void irdft_horizontal(FFTFILTContext *fftfilt, AVFrame *out, int w, int h, int plane)
|
static void irdft_horizontal(FFTFILTContext *s, AVFrame *out, int w, int h, int plane)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
fftfilt->rdft = av_rdft_init(fftfilt->rdft_hbits[plane], IDFT_C2R);
|
s->rdft = av_rdft_init(s->rdft_hbits[plane], IDFT_C2R);
|
||||||
for (i = 0; i < h; i++)
|
for (i = 0; i < h; i++)
|
||||||
av_rdft_calc(fftfilt->rdft, fftfilt->rdft_hdata[plane] + i * fftfilt->rdft_hlen[plane]);
|
av_rdft_calc(s->rdft, s->rdft_hdata[plane] + i * s->rdft_hlen[plane]);
|
||||||
|
|
||||||
for (i = 0; i < h; i++)
|
for (i = 0; i < h; i++)
|
||||||
for (j = 0; j < w; j++)
|
for (j = 0; j < w; j++)
|
||||||
*(out->data[plane] + out->linesize[plane] * i + j) = av_clip(fftfilt->rdft_hdata[plane][i
|
*(out->data[plane] + out->linesize[plane] * i + j) = av_clip(s->rdft_hdata[plane][i
|
||||||
*fftfilt->rdft_hlen[plane] + j] * 4 /
|
*s->rdft_hlen[plane] + j] * 4 /
|
||||||
(fftfilt->rdft_hlen[plane] *
|
(s->rdft_hlen[plane] *
|
||||||
fftfilt->rdft_vlen[plane]), 0, 255);
|
s->rdft_vlen[plane]), 0, 255);
|
||||||
|
|
||||||
av_rdft_end(fftfilt->rdft);
|
av_rdft_end(s->rdft);
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold int initialize(AVFilterContext *ctx)
|
static av_cold int initialize(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
FFTFILTContext *fftfilt = ctx->priv;
|
FFTFILTContext *s = ctx->priv;
|
||||||
int ret = 0, plane;
|
int ret = 0, plane;
|
||||||
|
|
||||||
if (!fftfilt->dc[U] && !fftfilt->dc[V]) {
|
if (!s->dc[U] && !s->dc[V]) {
|
||||||
fftfilt->dc[U] = fftfilt->dc[Y];
|
s->dc[U] = s->dc[Y];
|
||||||
fftfilt->dc[V] = fftfilt->dc[Y];
|
s->dc[V] = s->dc[Y];
|
||||||
} else {
|
} else {
|
||||||
if (!fftfilt->dc[U]) fftfilt->dc[U] = fftfilt->dc[V];
|
if (!s->dc[U]) s->dc[U] = s->dc[V];
|
||||||
if (!fftfilt->dc[V]) fftfilt->dc[V] = fftfilt->dc[U];
|
if (!s->dc[V]) s->dc[V] = s->dc[U];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fftfilt->weight_str[U] && !fftfilt->weight_str[V]) {
|
if (!s->weight_str[U] && !s->weight_str[V]) {
|
||||||
fftfilt->weight_str[U] = av_strdup(fftfilt->weight_str[Y]);
|
s->weight_str[U] = av_strdup(s->weight_str[Y]);
|
||||||
fftfilt->weight_str[V] = av_strdup(fftfilt->weight_str[Y]);
|
s->weight_str[V] = av_strdup(s->weight_str[Y]);
|
||||||
} else {
|
} else {
|
||||||
if (!fftfilt->weight_str[U]) fftfilt->weight_str[U] = av_strdup(fftfilt->weight_str[V]);
|
if (!s->weight_str[U]) s->weight_str[U] = av_strdup(s->weight_str[V]);
|
||||||
if (!fftfilt->weight_str[V]) fftfilt->weight_str[V] = av_strdup(fftfilt->weight_str[U]);
|
if (!s->weight_str[V]) s->weight_str[V] = av_strdup(s->weight_str[U]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (plane = 0; plane < 3; plane++) {
|
for (plane = 0; plane < 3; plane++) {
|
||||||
@@ -189,7 +189,7 @@ static av_cold int initialize(AVFilterContext *ctx)
|
|||||||
const char *const func2_names[] = {"weight_Y", "weight_U", "weight_V", NULL };
|
const char *const func2_names[] = {"weight_Y", "weight_U", "weight_V", NULL };
|
||||||
double (*func2[])(void *, double, double) = { weight_Y, weight_U, weight_V, p[plane], NULL };
|
double (*func2[])(void *, double, double) = { weight_Y, weight_U, weight_V, p[plane], NULL };
|
||||||
|
|
||||||
ret = av_expr_parse(&fftfilt->weight_expr[plane], fftfilt->weight_str[plane], var_names,
|
ret = av_expr_parse(&s->weight_expr[plane], s->weight_str[plane], var_names,
|
||||||
NULL, NULL, func2_names, func2, 0, ctx);
|
NULL, NULL, func2_names, func2, 0, ctx);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
break;
|
break;
|
||||||
@@ -199,7 +199,7 @@ static av_cold int initialize(AVFilterContext *ctx)
|
|||||||
|
|
||||||
static int config_props(AVFilterLink *inlink)
|
static int config_props(AVFilterLink *inlink)
|
||||||
{
|
{
|
||||||
FFTFILTContext *fftfilt = inlink->dst->priv;
|
FFTFILTContext *s = inlink->dst->priv;
|
||||||
const AVPixFmtDescriptor *desc;
|
const AVPixFmtDescriptor *desc;
|
||||||
int rdft_hbits, rdft_vbits, i, j, plane;
|
int rdft_hbits, rdft_vbits, i, j, plane;
|
||||||
double values[VAR_VARS_NB];
|
double values[VAR_VARS_NB];
|
||||||
@@ -211,16 +211,16 @@ static int config_props(AVFilterLink *inlink)
|
|||||||
|
|
||||||
/* RDFT - Array initialization for Horizontal pass*/
|
/* RDFT - Array initialization for Horizontal pass*/
|
||||||
for (rdft_hbits = 1; 1 << rdft_hbits < w*10/9; rdft_hbits++);
|
for (rdft_hbits = 1; 1 << rdft_hbits < w*10/9; rdft_hbits++);
|
||||||
fftfilt->rdft_hbits[i] = rdft_hbits;
|
s->rdft_hbits[i] = rdft_hbits;
|
||||||
fftfilt->rdft_hlen[i] = 1 << rdft_hbits;
|
s->rdft_hlen[i] = 1 << rdft_hbits;
|
||||||
if (!(fftfilt->rdft_hdata[i] = av_malloc_array(h, fftfilt->rdft_hlen[i] * sizeof(FFTSample))))
|
if (!(s->rdft_hdata[i] = av_malloc_array(h, s->rdft_hlen[i] * sizeof(FFTSample))))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
/* RDFT - Array initialization for Vertical pass*/
|
/* RDFT - Array initialization for Vertical pass*/
|
||||||
for (rdft_vbits = 1; 1 << rdft_vbits < h*10/9; rdft_vbits++);
|
for (rdft_vbits = 1; 1 << rdft_vbits < h*10/9; rdft_vbits++);
|
||||||
fftfilt->rdft_vbits[i] = rdft_vbits;
|
s->rdft_vbits[i] = rdft_vbits;
|
||||||
fftfilt->rdft_vlen[i] = 1 << rdft_vbits;
|
s->rdft_vlen[i] = 1 << rdft_vbits;
|
||||||
if (!(fftfilt->rdft_vdata[i] = av_malloc_array(fftfilt->rdft_hlen[i], fftfilt->rdft_vlen[i] * sizeof(FFTSample))))
|
if (!(s->rdft_vdata[i] = av_malloc_array(s->rdft_hlen[i], s->rdft_vlen[i] * sizeof(FFTSample))))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,16 +229,16 @@ static int config_props(AVFilterLink *inlink)
|
|||||||
values[VAR_H] = inlink->h;
|
values[VAR_H] = inlink->h;
|
||||||
for (plane = 0; plane < 3; plane++)
|
for (plane = 0; plane < 3; plane++)
|
||||||
{
|
{
|
||||||
if(!(fftfilt->weight[plane] = av_malloc_array(fftfilt->rdft_hlen[plane], fftfilt->rdft_vlen[plane] * sizeof(double))))
|
if(!(s->weight[plane] = av_malloc_array(s->rdft_hlen[plane], s->rdft_vlen[plane] * sizeof(double))))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
for (i = 0; i < fftfilt->rdft_hlen[plane]; i++)
|
for (i = 0; i < s->rdft_hlen[plane]; i++)
|
||||||
{
|
{
|
||||||
values[VAR_X] = i;
|
values[VAR_X] = i;
|
||||||
for (j = 0; j < fftfilt->rdft_vlen[plane]; j++)
|
for (j = 0; j < s->rdft_vlen[plane]; j++)
|
||||||
{
|
{
|
||||||
values[VAR_Y] = j;
|
values[VAR_Y] = j;
|
||||||
fftfilt->weight[plane][i * fftfilt->rdft_vlen[plane] + j] =
|
s->weight[plane][i * s->rdft_vlen[plane] + j] =
|
||||||
av_expr_eval(fftfilt->weight_expr[plane], values, fftfilt);
|
av_expr_eval(s->weight_expr[plane], values, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,7 +250,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
AVFilterContext *ctx = inlink->dst;
|
AVFilterContext *ctx = inlink->dst;
|
||||||
AVFilterLink *outlink = inlink->dst->outputs[0];
|
AVFilterLink *outlink = inlink->dst->outputs[0];
|
||||||
const AVPixFmtDescriptor *desc;
|
const AVPixFmtDescriptor *desc;
|
||||||
FFTFILTContext *fftfilt = ctx->priv;
|
FFTFILTContext *s = ctx->priv;
|
||||||
AVFrame *out;
|
AVFrame *out;
|
||||||
int i, j, plane;
|
int i, j, plane;
|
||||||
|
|
||||||
@@ -270,19 +270,19 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
h = FF_CEIL_RSHIFT(h, desc->log2_chroma_h);
|
h = FF_CEIL_RSHIFT(h, desc->log2_chroma_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
rdft_horizontal(fftfilt, in, w, h, plane);
|
rdft_horizontal(s, in, w, h, plane);
|
||||||
rdft_vertical(fftfilt, h, plane);
|
rdft_vertical(s, h, plane);
|
||||||
|
|
||||||
/*Change user defined parameters*/
|
/*Change user defined parameters*/
|
||||||
for (i = 0; i < fftfilt->rdft_hlen[plane]; i++)
|
for (i = 0; i < s->rdft_hlen[plane]; i++)
|
||||||
for (j = 0; j < fftfilt->rdft_vlen[plane]; j++)
|
for (j = 0; j < s->rdft_vlen[plane]; j++)
|
||||||
fftfilt->rdft_vdata[plane][i * fftfilt->rdft_vlen[plane] + j] *=
|
s->rdft_vdata[plane][i * s->rdft_vlen[plane] + j] *=
|
||||||
fftfilt->weight[plane][i * fftfilt->rdft_vlen[plane] + j];
|
s->weight[plane][i * s->rdft_vlen[plane] + j];
|
||||||
|
|
||||||
fftfilt->rdft_vdata[plane][0] += fftfilt->rdft_hlen[plane] * fftfilt->rdft_vlen[plane] * fftfilt->dc[plane];
|
s->rdft_vdata[plane][0] += s->rdft_hlen[plane] * s->rdft_vlen[plane] * s->dc[plane];
|
||||||
|
|
||||||
irdft_vertical(fftfilt, h, plane);
|
irdft_vertical(s, h, plane);
|
||||||
irdft_horizontal(fftfilt, out, w, h, plane);
|
irdft_horizontal(s, out, w, h, plane);
|
||||||
}
|
}
|
||||||
|
|
||||||
av_frame_free(&in);
|
av_frame_free(&in);
|
||||||
@@ -291,13 +291,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
|
|
||||||
static av_cold void uninit(AVFilterContext *ctx)
|
static av_cold void uninit(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
FFTFILTContext *fftfilt = ctx->priv;
|
FFTFILTContext *s = ctx->priv;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < MAX_PLANES; i++) {
|
for (i = 0; i < MAX_PLANES; i++) {
|
||||||
av_free(fftfilt->rdft_hdata[i]);
|
av_free(s->rdft_hdata[i]);
|
||||||
av_free(fftfilt->rdft_vdata[i]);
|
av_free(s->rdft_vdata[i]);
|
||||||
av_expr_free(fftfilt->weight_expr[i]);
|
av_expr_free(s->weight_expr[i]);
|
||||||
av_free(fftfilt->weight[i]);
|
av_free(s->weight[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user