Commit 2170ca41 authored by Paul B Mahol's avatar Paul B Mahol

avfilter/vf_fftfilt: add support for more pixel formats

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 2726b2d7
...@@ -36,6 +36,11 @@ ...@@ -36,6 +36,11 @@
typedef struct FFTFILTContext { typedef struct FFTFILTContext {
const AVClass *class; const AVClass *class;
int depth;
int nb_planes;
int planewidth[MAX_PLANES];
int planeheight[MAX_PLANES];
RDFTContext *hrdft[MAX_PLANES]; RDFTContext *hrdft[MAX_PLANES];
RDFTContext *vrdft[MAX_PLANES]; RDFTContext *vrdft[MAX_PLANES];
RDFTContext *ihrdft[MAX_PLANES]; RDFTContext *ihrdft[MAX_PLANES];
...@@ -198,9 +203,17 @@ static int config_props(AVFilterLink *inlink) ...@@ -198,9 +203,17 @@ static int config_props(AVFilterLink *inlink)
double values[VAR_VARS_NB]; double values[VAR_VARS_NB];
desc = av_pix_fmt_desc_get(inlink->format); desc = av_pix_fmt_desc_get(inlink->format);
s->depth = desc->comp[0].depth;
s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
s->planewidth[0] = s->planewidth[3] = inlink->w;
s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
s->planeheight[0] = s->planeheight[3] = inlink->h;
s->nb_planes = av_pix_fmt_count_planes(inlink->format);
for (i = 0; i < desc->nb_components; i++) { for (i = 0; i < desc->nb_components; i++) {
int w = inlink->w; int w = s->planewidth[i];
int h = inlink->h; int h = s->planeheight[i];
/* 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++);
...@@ -228,10 +241,10 @@ static int config_props(AVFilterLink *inlink) ...@@ -228,10 +241,10 @@ static int config_props(AVFilterLink *inlink)
} }
/*Luminance value - Array initialization*/ /*Luminance value - Array initialization*/
values[VAR_W] = inlink->w; for (plane = 0; plane < 3; plane++) {
values[VAR_H] = inlink->h; values[VAR_W] = s->planewidth[plane];
for (plane = 0; plane < 3; plane++) values[VAR_H] = s->planeheight[plane];
{
if(!(s->weight[plane] = av_malloc_array(s->rdft_hlen[plane], s->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 < s->rdft_hlen[plane]; i++) for (i = 0; i < s->rdft_hlen[plane]; i++)
...@@ -252,7 +265,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) ...@@ -252,7 +265,6 @@ 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;
FFTFILTContext *s = ctx->priv; FFTFILTContext *s = ctx->priv;
AVFrame *out; AVFrame *out;
int i, j, plane; int i, j, plane;
...@@ -265,15 +277,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) ...@@ -265,15 +277,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
av_frame_copy_props(out, in); av_frame_copy_props(out, in);
desc = av_pix_fmt_desc_get(inlink->format); for (plane = 0; plane < s->nb_planes; plane++) {
for (plane = 0; plane < desc->nb_components; plane++) { int w = s->planewidth[plane];
int w = inlink->w; int h = s->planeheight[plane];
int h = inlink->h;
if (plane == 1 || plane == 2) {
w = AV_CEIL_RSHIFT(w, desc->log2_chroma_w);
h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
}
rdft_horizontal(s, in, w, h, plane); rdft_horizontal(s, in, w, h, plane);
rdft_vertical(s, h, plane); rdft_vertical(s, h, plane);
...@@ -314,7 +320,9 @@ static int query_formats(AVFilterContext *ctx) ...@@ -314,7 +320,9 @@ static int query_formats(AVFilterContext *ctx)
{ {
static const enum AVPixelFormat pixel_fmts_fftfilt[] = { static const enum AVPixelFormat pixel_fmts_fftfilt[] = {
AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY8,
AV_PIX_FMT_YUV444P, 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_NONE AV_PIX_FMT_NONE
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment