Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
I have attached the patch, changing the configuration file. From 82e64037476a6e7dd914fb9bb6faefcf4de2de8d Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Mon, 9 Mar 2015 09:05:35 +0530 Subject: [PATCH] Add dependencies to configure file for vf_fftfilt --- configure |3 +++ 1 file changed, 3 insertions(+) diff --git a/configure b/configure index 1ea2032..8e832c2 100755 --- a/configure +++ b/configure @@ -2595,6 +2595,8 @@ deshake_filter_select=pixelutils drawtext_filter_deps=libfreetype ebur128_filter_deps=gpl eq_filter_deps=gpl +fftfilt_filter_deps=avcodec +fftfilt_filter_select=rdft flite_filter_deps=libflite frei0r_filter_deps=frei0r dlopen frei0r_src_filter_deps=frei0r dlopen @@ -5455,6 +5457,7 @@ enabled asyncts_filter prepend avfilter_deps avresample enabled atempo_filterprepend avfilter_deps avcodec enabled ebur128_filter enabled swresample prepend avfilter_deps swresample enabled elbg_filter prepend avfilter_deps avcodec +enabled fftfilt_filter prepend avfilter_deps avcodec enabled mcdeint_filter prepend avfilter_deps avcodec enabled movie_filter prepend avfilter_deps avformat avcodec enabled pan_filter prepend avfilter_deps swresample -- 1.7.9.5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
On Sat, Mar 07, 2015 at 04:09:09PM +0530, arwa arif wrote: Updated the patch. doc/filters.texi | 38 + libavfilter/Makefile |1 libavfilter/allfilters.c |1 libavfilter/vf_fftfilt.c | 344 +++ 4 files changed, 384 insertions(+) 97c8a8fce142d3c4f3e42ab941afb4087f6c0206 0001-Add-FFT-domain-filter.patch From 4e73a3876d0e33af33ea3af27d38ce4e5755ad25 Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Add FFT domain filter. ive renamed some luma to weight as its also used for chroma now, and fixed copy_rev(), i possibly didnt explain it clearly enough before and applied Thanks! [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
Updated the patch. From 4e73a3876d0e33af33ea3af27d38ce4e5755ad25 Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Add FFT domain filter. --- doc/filters.texi | 38 + libavfilter/Makefile |1 + libavfilter/allfilters.c |1 + libavfilter/vf_fftfilt.c | 344 ++ 4 files changed, 384 insertions(+) create mode 100644 libavfilter/vf_fftfilt.c diff --git a/doc/filters.texi b/doc/filters.texi index 485efcb..10034e5 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -4591,6 +4591,44 @@ fade=t=in:st=5.5:d=0.5 @end itemize +@section fftfilt +Adjust gain and luminance. It uses frequency domain filtering. + +@table @option +@item dc_Y +Adjust the dc value (gain) of the luma plane of the image. The filter +accepts an integer value in range @code{0} to @code{1000}. The default +value is set to @code{0}. + +@item dc_U +Adjust the dc value (gain) of the 1st chroma plane of the image. The +filter accepts an integer value in range @code{0} to @code{1000}. The +default value is set to @code{0}. + +@item dc_V +Adjust the dc value (gain) of the 2nd chroma plane of the image. The +filter accepts an integer value in range @code{0} to @code{1000}. The +default value is set to @code{0}. + +@item lum_Y +Set the luminance expression for the luma plane. + +@item lum_U +Set the luminance expression for the 1st chroma plane. + +@item lum_V +Set the luminance expression for the 2nd chroma plane. + +The filter accepts the following variables: +@item X +@item Y +The coordinates of the current sample. + +@item W +@item H +The width and height of the image. +@end table + @section field Extract a single field from an interlaced image using stride diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 289c63b..b184f07 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -120,6 +120,7 @@ OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o +OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o OBJS-$(CONFIG_FIELD_FILTER) += vf_field.o OBJS-$(CONFIG_FIELDMATCH_FILTER) += vf_fieldmatch.o OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 55de154..043ac56 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -136,6 +136,7 @@ void avfilter_register_all(void) REGISTER_FILTER(EQ, eq, vf); REGISTER_FILTER(EXTRACTPLANES, extractplanes, vf); REGISTER_FILTER(FADE, fade, vf); +REGISTER_FILTER(FFTFILT,fftfilt,vf); REGISTER_FILTER(FIELD, field, vf); REGISTER_FILTER(FIELDMATCH, fieldmatch, vf); REGISTER_FILTER(FIELDORDER, fieldorder, vf); diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c new file mode 100644 index 000..dfed875 --- /dev/null +++ b/libavfilter/vf_fftfilt.c @@ -0,0 +1,344 @@ +/* + * Copyright (c) 2015 Arwa Arif arwaarif1...@gmail.com + * + * 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 + * FFT domain filtering. + */ + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h +#include libavutil/eval.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_hbits[3]; +int rdft_vbits[3]; +size_t rdft_hlen[3]; +size_t rdft_vlen[3]; +FFTSample *rdft_hdata[3]; +FFTSample *rdft_vdata[3]; + +int dc[3]; +char *lum_str[3]; +AVExpr *lum_expr[3]; +double *lum_data[3]; + +} FFTFILTContext; + +static const char *const var_names[] = { X, Y, W, H, NULL}; +enum { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_VARS_NB }; + +enum { Y = 0, U, V }; + +#define OFFSET(x) offsetof(FFTFILTContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM +
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
On 07/03/15 7:39 AM, arwa arif wrote: Updated the patch. Please send a patch to add the relevant dependencies to configure. Look how showspectrum is handled to get an idea. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
On Tue, Mar 03, 2015 at 12:06:09PM +0530, arwa arif wrote: I tried to change the name to fft, but it is conflicting with libavcodec/fft. So, I am unable to change that. I have updated the patch, adding support to coloured images. yes, the names could conflict in configure indeed [...] + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h +#include libavutil/eval.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_hbits[3]; +int rdft_vbits[3]; +size_t rdft_hlen[3]; +size_t rdft_vlen[3]; +FFTSample *rdft_hdata[3]; +FFTSample *rdft_vdata[3]; + +int dc; +char *lum_str; +AVExpr *lum_expr; +double *lum_data; + +} FFTFILTContext; + +static const char *const var_names[] = { X, Y, W, H, NULL}; +enum { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_VARS_NB }; + +#define OFFSET(x) offsetof(FFTFILTContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption fftfilt_options[] = { +{ dc, adjust gain, OFFSET(dc), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1000, FLAGS }, +{ lum, set luminance expression, OFFSET(lum_str), AV_OPT_TYPE_STRING, {.str = 1}, CHAR_MIN, CHAR_MAX, FLAGS }, +{NULL}, The user should be able to set seperate dc / lum for teh 3 planes that is if only the first dc and first exression is set then they should be used for all 3 planes otherwise, if teh user set 3 dc values and 3 expressions then each plane should use the specific expression [...] + +memset(fftfilt-rdft_hdata[plane] + i * fftfilt-rdft_hlen[plane], 0, + fftfilt-rdft_hlen[plane] * sizeof(*fftfilt-rdft_hdata[plane])); the memseting should ideally be replaced by mirroring, this leads to better quality for example matrixbench_mpeg2.mpg -vf fftfilt=dc=128:lum='(1 / (1 + exp(-(Y+X)/10.0+H/100.0)))' results in a pink border due to this that is instead of for each line 1 2 3 3 7 9 10 11 23 it should not be changed to: 1 2 3 3 7 9 10 11 23 0 0 0 0 0 0 0 but 1 2 3 3 7 9 10 11 23 23 11 10 x 3 2 1 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No human being will ever know the Truth, for even if they happen to say it by chance, they would not even known they had done so. -- Xenophanes signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
On Tue, Mar 03, 2015 at 12:06:09PM +0530, arwa arif wrote: I tried to change the name to fft, but it is conflicting with libavcodec/fft. So, I am unable to change that. I have updated the patch, adding support to coloured images. doc/filters.texi | 22 +++ libavfilter/Makefile |1 libavfilter/allfilters.c |1 libavfilter/vf_fftfilt.c | 294 +++ 4 files changed, 318 insertions(+) 1ad6ddaa83fe13ae3234b4e359c8c1d719047f30 0001-Add-FFT-domain-filter.patch From 7b479d2236067e5599f6e4670f319be4a643 Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Add FFT domain filter. [...] +AVFilter ff_vf_fftfilt = { +.name= fftfilt, +.description = NULL_IF_CONFIG_SMALL(Adjust dc value and luminance.), something like Apply arbitrary expressions to samples in frequency domain maybe sounds better [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
On Tue, Mar 3, 2015 at 6:11 PM, Michael Niedermayer michae...@gmx.at wrote: On Tue, Mar 03, 2015 at 12:06:09PM +0530, arwa arif wrote: I tried to change the name to fft, but it is conflicting with libavcodec/fft. So, I am unable to change that. I have updated the patch, adding support to coloured images. yes, the names could conflict in configure indeed [...] + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h +#include libavutil/eval.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_hbits[3]; +int rdft_vbits[3]; +size_t rdft_hlen[3]; +size_t rdft_vlen[3]; +FFTSample *rdft_hdata[3]; +FFTSample *rdft_vdata[3]; + +int dc; +char *lum_str; +AVExpr *lum_expr; +double *lum_data; + +} FFTFILTContext; + +static const char *const var_names[] = { X, Y, W, H, NULL}; +enum { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_VARS_NB }; + +#define OFFSET(x) offsetof(FFTFILTContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption fftfilt_options[] = { +{ dc, adjust gain, OFFSET(dc), AV_OPT_TYPE_INT,{.i64 = 0}, 0, 1000, FLAGS }, +{ lum, set luminance expression, OFFSET(lum_str), AV_OPT_TYPE_STRING, {.str = 1}, CHAR_MIN, CHAR_MAX, FLAGS }, +{NULL}, The user should be able to set seperate dc / lum for teh 3 planes that is if only the first dc and first exression is set then they should be used for all 3 planes otherwise, if teh user set 3 dc values and 3 expressions then each plane should use the specific expression [...] + +memset(fftfilt-rdft_hdata[plane] + i * fftfilt-rdft_hlen[plane], 0, + fftfilt-rdft_hlen[plane] * sizeof(*fftfilt-rdft_hdata[plane])); the memseting should ideally be replaced by mirroring, this leads to better quality for example matrixbench_mpeg2.mpg -vf fftfilt=dc=128:lum='(1 / (1 + exp(-(Y+X)/10.0+H/100.0)))' results in a pink border due to this that is instead of for each line 1 2 3 3 7 9 10 11 23 it should not be changed to: 1 2 3 3 7 9 10 11 23 0 0 0 0 0 0 0 but 1 2 3 3 7 9 10 11 23 23 11 10 x 3 2 1 But, we want to clear the block of memory. Why do we want to mirror it? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No human being will ever know the Truth, for even if they happen to say it by chance, they would not even known they had done so. -- Xenophanes ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
On Tue, Mar 03, 2015 at 10:50:09PM +0530, arwa arif wrote: On Tue, Mar 3, 2015 at 6:11 PM, Michael Niedermayer michae...@gmx.at wrote: On Tue, Mar 03, 2015 at 12:06:09PM +0530, arwa arif wrote: I tried to change the name to fft, but it is conflicting with libavcodec/fft. So, I am unable to change that. I have updated the patch, adding support to coloured images. yes, the names could conflict in configure indeed [...] + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h +#include libavutil/eval.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_hbits[3]; +int rdft_vbits[3]; +size_t rdft_hlen[3]; +size_t rdft_vlen[3]; +FFTSample *rdft_hdata[3]; +FFTSample *rdft_vdata[3]; + +int dc; +char *lum_str; +AVExpr *lum_expr; +double *lum_data; + +} FFTFILTContext; + +static const char *const var_names[] = { X, Y, W, H, NULL}; +enum { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_VARS_NB }; + +#define OFFSET(x) offsetof(FFTFILTContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption fftfilt_options[] = { +{ dc, adjust gain, OFFSET(dc), AV_OPT_TYPE_INT,{.i64 = 0}, 0, 1000, FLAGS }, +{ lum, set luminance expression, OFFSET(lum_str), AV_OPT_TYPE_STRING, {.str = 1}, CHAR_MIN, CHAR_MAX, FLAGS }, +{NULL}, The user should be able to set seperate dc / lum for teh 3 planes that is if only the first dc and first exression is set then they should be used for all 3 planes otherwise, if teh user set 3 dc values and 3 expressions then each plane should use the specific expression [...] + +memset(fftfilt-rdft_hdata[plane] + i * fftfilt-rdft_hlen[plane], 0, + fftfilt-rdft_hlen[plane] * sizeof(*fftfilt-rdft_hdata[plane])); the memseting should ideally be replaced by mirroring, this leads to better quality for example matrixbench_mpeg2.mpg -vf fftfilt=dc=128:lum='(1 / (1 + exp(-(Y+X)/10.0+H/100.0)))' results in a pink border due to this that is instead of for each line 1 2 3 3 7 9 10 11 23 it should not be changed to: 1 2 3 3 7 9 10 11 23 0 0 0 0 0 0 0 but 1 2 3 3 7 9 10 11 23 23 11 10 x 3 2 1 But, we want to clear the block of memory. Why do we want to mirror it? The idea is to clear it with the same data as is in the input picture not with 0 bytes so instead of 99900 99900 9..9..9..9900 99900 9.99.9900 9....9900 99900 99900 it is 9 9 9..9..9.. 9 9.99. 9.... 9 9 because when the image is filtered the additional outside padding will affect the vissible area consider: 9900 - 865100 vs - 99 the vissible part is: 86 vs 99 or said differently the 0 padding gets smeared into the vissible image, so the more similar it is to the input image the less artifacts this creates [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Rewriting code that is poorly written but fully understood is good. Rewriting code that one doesnt understand is a sign that one is less smart then the original author, trying to rewrite it will not make it better. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
I tried to change the name to fft, but it is conflicting with libavcodec/fft. So, I am unable to change that. I have updated the patch, adding support to coloured images. From 7b479d2236067e5599f6e4670f319be4a643 Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Add FFT domain filter. --- doc/filters.texi | 22 libavfilter/Makefile |1 + libavfilter/allfilters.c |1 + libavfilter/vf_fftfilt.c | 294 ++ 4 files changed, 318 insertions(+) create mode 100644 libavfilter/vf_fftfilt.c diff --git a/doc/filters.texi b/doc/filters.texi index 485efcb..d4ad1cb 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -4591,6 +4591,28 @@ fade=t=in:st=5.5:d=0.5 @end itemize +@section fftfilt +Adjust gain and luminance. It uses frequency domain filtering. + +@table @option +@item dc +Adjust the dc value (gain) of the image. The filter accepts an +integer value in range @code{0} to @code{1000}. The default value +is set to @code{0}. + +@item lum +Set the luminance expression. The filter accepts the following +variables: + +@item X +@item Y +The coordinates of the current sample. + +@item W +@item H +The width and height of the image. +@end table + @section field Extract a single field from an interlaced image using stride diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 289c63b..b184f07 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -120,6 +120,7 @@ OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o +OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o OBJS-$(CONFIG_FIELD_FILTER) += vf_field.o OBJS-$(CONFIG_FIELDMATCH_FILTER) += vf_fieldmatch.o OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 55de154..043ac56 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -136,6 +136,7 @@ void avfilter_register_all(void) REGISTER_FILTER(EQ, eq, vf); REGISTER_FILTER(EXTRACTPLANES, extractplanes, vf); REGISTER_FILTER(FADE, fade, vf); +REGISTER_FILTER(FFTFILT,fftfilt,vf); REGISTER_FILTER(FIELD, field, vf); REGISTER_FILTER(FIELDMATCH, fieldmatch, vf); REGISTER_FILTER(FIELDORDER, fieldorder, vf); diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c new file mode 100644 index 000..93b6a93 --- /dev/null +++ b/libavfilter/vf_fftfilt.c @@ -0,0 +1,294 @@ +/* + * Copyright (c) 2015 Arwa Arif arwaarif1...@gmail.com + * + * 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 + * FFT domain filtering. + */ + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h +#include libavutil/eval.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_hbits[3]; +int rdft_vbits[3]; +size_t rdft_hlen[3]; +size_t rdft_vlen[3]; +FFTSample *rdft_hdata[3]; +FFTSample *rdft_vdata[3]; + +int dc; +char *lum_str; +AVExpr *lum_expr; +double *lum_data; + +} FFTFILTContext; + +static const char *const var_names[] = { X, Y, W, H, NULL}; +enum { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_VARS_NB }; + +#define OFFSET(x) offsetof(FFTFILTContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption fftfilt_options[] = { +{ dc, adjust gain, OFFSET(dc), AV_OPT_TYPE_INT,{.i64 = 0}, 0, 1000, FLAGS }, +{ lum, set luminance expression, OFFSET(lum_str), AV_OPT_TYPE_STRING, {.str = 1}, CHAR_MIN, CHAR_MAX, FLAGS }, +{NULL}, +}; + +AVFILTER_DEFINE_CLASS(fftfilt); + +static inline double lum(void *priv, double x, double y) +{ +FFTFILTContext *fftfilt = priv; +return
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
On date Saturday 2015-02-28 20:22:49 +0530, Arwa Arif encoded: Updated the patch. From ba761516b97b146f4c62d6c5c08dc5ea02c06af5 Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Port FFT domain filter. Subject: lavfi: add FFT domain filter --- libavfilter/Makefile |1 + libavfilter/allfilters.c |1 + libavfilter/vf_fftfilt.c | 258 ++ this could be renamed to fft, the filt part is redundant. Also missing documentation. 3 files changed, 260 insertions(+) create mode 100644 libavfilter/vf_fftfilt.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 289c63b..b184f07 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -120,6 +120,7 @@ OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o +OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o OBJS-$(CONFIG_FIELD_FILTER) += vf_field.o OBJS-$(CONFIG_FIELDMATCH_FILTER) += vf_fieldmatch.o OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 55de154..043ac56 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -136,6 +136,7 @@ void avfilter_register_all(void) REGISTER_FILTER(EQ, eq, vf); REGISTER_FILTER(EXTRACTPLANES, extractplanes, vf); REGISTER_FILTER(FADE, fade, vf); +REGISTER_FILTER(FFTFILT,fftfilt,vf); REGISTER_FILTER(FIELD, field, vf); REGISTER_FILTER(FIELDMATCH, fieldmatch, vf); REGISTER_FILTER(FIELDORDER, fieldorder, vf); diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c new file mode 100644 index 000..6d0a961 --- /dev/null +++ b/libavfilter/vf_fftfilt.c @@ -0,0 +1,258 @@ +/* + * Copyright (c) 2015 Arwa Arif arwaarif1...@gmail.com + * + * 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 + * FFT domain filtering. + */ + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h +#include libavutil/eval.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_hbits; +int rdft_vbits; +size_t rdft_hlen; +size_t rdft_vlen; +FFTSample *rdft_hdata; +FFTSample *rdft_vdata; + +int dc; +char *lum_str; +AVExpr *lum_expr; +double *lum_data; + +} FFTFILTContext; + +static const char *const var_names[] = { X, Y, W, H, NULL}; +enum { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_VARS_NB }; + +#define OFFSET(x) offsetof(FFTFILTContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption fftfilt_options[] = { +{ dc, adjust gain, OFFSET(dc), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1000, FLAGS }, +{ lum, set luminance expression, OFFSET(lum_str), AV_OPT_TYPE_STRING, {.str = 1}, CHAR_MIN, CHAR_MAX, FLAGS }, +{NULL}, +}; + +AVFILTER_DEFINE_CLASS(fftfilt); + +static inline double lum(void *priv, double x, double y) +{ +FFTFILTContext *fftfilt = priv; +FFTSample *rdft_data = fftfilt-rdft_vdata; +size_t rdft_vlen = fftfilt-rdft_vlen; + +return rdft_data[(int)x * rdft_vlen + (int)y]; simpler return fft-rdft_data[(int)x * fft-rdft_vlen + (int)y]; +} + +static av_cold int initialize(AVFilterContext *ctx) +{ +FFTFILTContext *fftfilt = ctx-priv; +int ret = 0; + +static double (*p[])(void *, double, double) = {lum}; +const char *const func2_names[] = {lum, NULL }; +double (*func2[])(void *, double, double) = {lum, p[0], NULL }; why this p thing indirection? +ret = av_expr_parse(fftfilt-lum_expr, fftfilt-lum_str, var_names, NULL, NULL,
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
arwa arif arwaarif1994 at gmail.com writes: * FFmpeg is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by If you want this filter to be licensed under GPL you have to add a line to configure. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
On Sat, Feb 28, 2015 at 04:00:36PM +0530, arwa arif wrote: On Sat, Feb 28, 2015 at 2:42 PM, Carl Eugen Hoyos ceho...@ag.or.at wrote: arwa arif arwaarif1994 at gmail.com writes: * FFmpeg is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by If you want this filter to be licensed under GPL you have to add a line to configure. I am sorry I didn't pay attention to the licensing part. I have updated it to LGPL. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel Makefile |1 allfilters.c |1 vf_fftfilt.c | 238 +++ 3 files changed, 240 insertions(+) c188c2ed10576d2cc68771bee64a02782bff29de 0001-Port-FFT-domain-filter.patch From 63bd20d116464dc37db1a02b714a934a7d1ca912 Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Port FFT domain filter. --- libavfilter/Makefile |1 + libavfilter/allfilters.c |1 + libavfilter/vf_fftfilt.c | 238 ++ 3 files changed, 240 insertions(+) create mode 100644 libavfilter/vf_fftfilt.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 289c63b..b184f07 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -120,6 +120,7 @@ OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o +OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o OBJS-$(CONFIG_FIELD_FILTER) += vf_field.o OBJS-$(CONFIG_FIELDMATCH_FILTER) += vf_fieldmatch.o OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 55de154..043ac56 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -136,6 +136,7 @@ void avfilter_register_all(void) REGISTER_FILTER(EQ, eq, vf); REGISTER_FILTER(EXTRACTPLANES, extractplanes, vf); REGISTER_FILTER(FADE, fade, vf); +REGISTER_FILTER(FFTFILT,fftfilt,vf); REGISTER_FILTER(FIELD, field, vf); REGISTER_FILTER(FIELDMATCH, fieldmatch, vf); REGISTER_FILTER(FIELDORDER, fieldorder, vf); diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c new file mode 100644 index 000..a9dc107 --- /dev/null +++ b/libavfilter/vf_fftfilt.c @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2015 Arwa Arif arwaarif1...@gmail.com + * + * 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 + * FFT domain filtering. + */ + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h +#include libavutil/eval.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_hbits; +int rdft_vbits; +size_t rdft_vlen; +FFTSample *rdft_hdata; +FFTSample *rdft_vdata; + +int dc; +char *lum_str; +AVExpr *lum_expr; + +} FFTFILTContext; + +static const char *const var_names[] = { X, Y, W, H, NULL}; +enum { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_VARS_NB }; + +#define OFFSET(x) offsetof(FFTFILTContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption fftfilt_options[] = { +{ dc, adjust gain, OFFSET(dc), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1000,FLAGS }, +{ lum, set luminance expression, OFFSET(lum_str), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, +{NULL}, +}; + +AVFILTER_DEFINE_CLASS(fftfilt); + +static inline double lum(void *priv, double x, double y) +{ +FFTFILTContext *fftfilt
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
Updated the patch. From ba761516b97b146f4c62d6c5c08dc5ea02c06af5 Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Port FFT domain filter. --- libavfilter/Makefile |1 + libavfilter/allfilters.c |1 + libavfilter/vf_fftfilt.c | 258 ++ 3 files changed, 260 insertions(+) create mode 100644 libavfilter/vf_fftfilt.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 289c63b..b184f07 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -120,6 +120,7 @@ OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o +OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o OBJS-$(CONFIG_FIELD_FILTER) += vf_field.o OBJS-$(CONFIG_FIELDMATCH_FILTER) += vf_fieldmatch.o OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 55de154..043ac56 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -136,6 +136,7 @@ void avfilter_register_all(void) REGISTER_FILTER(EQ, eq, vf); REGISTER_FILTER(EXTRACTPLANES, extractplanes, vf); REGISTER_FILTER(FADE, fade, vf); +REGISTER_FILTER(FFTFILT,fftfilt,vf); REGISTER_FILTER(FIELD, field, vf); REGISTER_FILTER(FIELDMATCH, fieldmatch, vf); REGISTER_FILTER(FIELDORDER, fieldorder, vf); diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c new file mode 100644 index 000..6d0a961 --- /dev/null +++ b/libavfilter/vf_fftfilt.c @@ -0,0 +1,258 @@ +/* + * Copyright (c) 2015 Arwa Arif arwaarif1...@gmail.com + * + * 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 + * FFT domain filtering. + */ + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h +#include libavutil/eval.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_hbits; +int rdft_vbits; +size_t rdft_hlen; +size_t rdft_vlen; +FFTSample *rdft_hdata; +FFTSample *rdft_vdata; + +int dc; +char *lum_str; +AVExpr *lum_expr; +double *lum_data; + +} FFTFILTContext; + +static const char *const var_names[] = { X, Y, W, H, NULL}; +enum { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_VARS_NB }; + +#define OFFSET(x) offsetof(FFTFILTContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption fftfilt_options[] = { +{ dc, adjust gain, OFFSET(dc), AV_OPT_TYPE_INT,{.i64 = 0}, 0, 1000, FLAGS }, +{ lum, set luminance expression, OFFSET(lum_str), AV_OPT_TYPE_STRING, {.str = 1}, CHAR_MIN, CHAR_MAX, FLAGS }, +{NULL}, +}; + +AVFILTER_DEFINE_CLASS(fftfilt); + +static inline double lum(void *priv, double x, double y) +{ +FFTFILTContext *fftfilt = priv; +FFTSample *rdft_data = fftfilt-rdft_vdata; +size_t rdft_vlen = fftfilt-rdft_vlen; + +return rdft_data[(int)x * rdft_vlen + (int)y]; +} + +static av_cold int initialize(AVFilterContext *ctx) +{ +FFTFILTContext *fftfilt = ctx-priv; +int ret = 0; + +static double (*p[])(void *, double, double) = {lum}; +const char *const func2_names[] = {lum, NULL }; +double (*func2[])(void *, double, double) = {lum, p[0], NULL }; +ret = av_expr_parse(fftfilt-lum_expr, fftfilt-lum_str, var_names, NULL, NULL, func2_names, func2, 0, ctx); +return ret; +} + +static int config_props(AVFilterLink *inlink) +{ +FFTFILTContext *fftfilt = inlink-dst-priv; +int w = inlink-w; +int h = inlink-h; +int rdft_hbits, rdft_vbits, i, j; +double values[VAR_VARS_NB]; + +/* RDFT - Array initialization for Horizontal pass*/ +for (rdft_hbits = 1; 1 rdft_hbits w; rdft_hbits++); +fftfilt-rdft_hbits = rdft_hbits; +fftfilt-rdft_hlen
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
On Sat, Feb 28, 2015 at 2:42 PM, Carl Eugen Hoyos ceho...@ag.or.at wrote: arwa arif arwaarif1994 at gmail.com writes: * FFmpeg is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by If you want this filter to be licensed under GPL you have to add a line to configure. I am sorry I didn't pay attention to the licensing part. I have updated it to LGPL. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel From 63bd20d116464dc37db1a02b714a934a7d1ca912 Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Port FFT domain filter. --- libavfilter/Makefile |1 + libavfilter/allfilters.c |1 + libavfilter/vf_fftfilt.c | 238 ++ 3 files changed, 240 insertions(+) create mode 100644 libavfilter/vf_fftfilt.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 289c63b..b184f07 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -120,6 +120,7 @@ OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o +OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o OBJS-$(CONFIG_FIELD_FILTER) += vf_field.o OBJS-$(CONFIG_FIELDMATCH_FILTER) += vf_fieldmatch.o OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 55de154..043ac56 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -136,6 +136,7 @@ void avfilter_register_all(void) REGISTER_FILTER(EQ, eq, vf); REGISTER_FILTER(EXTRACTPLANES, extractplanes, vf); REGISTER_FILTER(FADE, fade, vf); +REGISTER_FILTER(FFTFILT,fftfilt,vf); REGISTER_FILTER(FIELD, field, vf); REGISTER_FILTER(FIELDMATCH, fieldmatch, vf); REGISTER_FILTER(FIELDORDER, fieldorder, vf); diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c new file mode 100644 index 000..a9dc107 --- /dev/null +++ b/libavfilter/vf_fftfilt.c @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2015 Arwa Arif arwaarif1...@gmail.com + * + * 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 + * FFT domain filtering. + */ + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h +#include libavutil/eval.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_hbits; +int rdft_vbits; +size_t rdft_vlen; +FFTSample *rdft_hdata; +FFTSample *rdft_vdata; + +int dc; +char *lum_str; +AVExpr *lum_expr; + +} FFTFILTContext; + +static const char *const var_names[] = { X, Y, W, H, NULL}; +enum { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_VARS_NB }; + +#define OFFSET(x) offsetof(FFTFILTContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption fftfilt_options[] = { +{ dc, adjust gain, OFFSET(dc), AV_OPT_TYPE_INT,{.i64 = 0}, 0, 1000,FLAGS }, +{ lum, set luminance expression, OFFSET(lum_str), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, +{NULL}, +}; + +AVFILTER_DEFINE_CLASS(fftfilt); + +static inline double lum(void *priv, double x, double y) +{ +FFTFILTContext *fftfilt = priv; +FFTSample *rdft_data = fftfilt-rdft_vdata; +size_t rdft_vlen = fftfilt-rdft_vlen; + +return rdft_data[(int)x * rdft_vlen + (int)y]; +} + +static av_cold int initialize(AVFilterContext *ctx) +{ +FFTFILTContext *fftfilt = ctx-priv; +int ret = 0; + +static double (*p[])(void *, double, double) = {lum}; +const char *const func2_names[]= {lum, NULL }; +double (*func2[])(void *, double, double) = {lum,
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
On Sat, Feb 28, 2015 at 08:22:49PM +0530, arwa arif wrote: Updated the patch. Makefile |1 allfilters.c |1 vf_fftfilt.c | 258 +++ 3 files changed, 260 insertions(+) dde368ae2972c85600e209bee3a9e26a05938baf 0001-Port-FFT-domain-filter.patch From ba761516b97b146f4c62d6c5c08dc5ea02c06af5 Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Port FFT domain filter. --- libavfilter/Makefile |1 + libavfilter/allfilters.c |1 + libavfilter/vf_fftfilt.c | 258 ++ 3 files changed, 260 insertions(+) create mode 100644 libavfilter/vf_fftfilt.c [...] +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ +AVFilterContext *ctx = inlink-dst; +AVFilterLink *outlink = inlink-dst-outputs[0]; +FFTFILTContext *fftfilt = ctx-priv; +AVFrame *out; +int w = inlink-w; +int h = inlink-h; +size_t rdft_hlen = fftfilt-rdft_hlen; +size_t rdft_vlen = fftfilt-rdft_vlen; +int i, j; + +out = ff_get_video_buffer(outlink, inlink-w, inlink-h); +if (!out) +return AVERROR(ENOMEM); + +av_frame_copy_props(out, in); + +/*Horizontal pass - RDFT*/ +fftfilt-rdft = av_rdft_init(fftfilt-rdft_hbits, DFT_R2C); +for (i = 0; i h; i++) +{ +memset(fftfilt-rdft_hdata + i * rdft_hlen, 0, rdft_hlen * sizeof(*fftfilt-rdft_hdata)); +for (j = 0; j w; j++) +fftfilt-rdft_hdata[i * rdft_hlen + j] = *(in-data[0] + in-linesize[0] * i + j); +} + +for (i = 0; i h; i++) +av_rdft_calc(fftfilt-rdft, fftfilt-rdft_hdata + i * rdft_hlen); + +av_rdft_end(fftfilt-rdft); + +/*Vertical pass - RDFT*/ +fftfilt-rdft = av_rdft_init(fftfilt-rdft_vbits, DFT_R2C); +for (i = 0; i rdft_hlen; i++) +{ +memset(fftfilt-rdft_vdata + i * rdft_vlen, 0, rdft_vlen * sizeof(*fftfilt-rdft_vdata)); +for (j = 0; j h; j++) +fftfilt-rdft_vdata[i * rdft_vlen + j] = fftfilt-rdft_hdata[j * rdft_hlen + i]; +} + +for (i = 0; i rdft_hlen; i++) +av_rdft_calc(fftfilt-rdft, fftfilt-rdft_vdata + i * rdft_vlen); + +av_rdft_end(fftfilt-rdft); + +/*Change user defined parameters*/ +for (i = 0; i rdft_hlen; i++) +for (j = 0; j rdft_vlen; j++) +fftfilt-rdft_vdata[i * rdft_vlen + j] *= fftfilt-lum_data[i * rdft_vlen + j]; +fftfilt-rdft_vdata[0] += rdft_hlen * rdft_vlen * fftfilt-dc; + +/*Vertical pass - IRDFT*/ +fftfilt-rdft = av_rdft_init(fftfilt-rdft_vbits, IDFT_C2R); + +for (i = 0; i rdft_hlen; i++) +av_rdft_calc(fftfilt-rdft, fftfilt-rdft_vdata + i * rdft_vlen); + +for (i = 0; i rdft_hlen; i++) +for (j = 0; j h; j++) +fftfilt-rdft_hdata[j * rdft_hlen + i] = fftfilt-rdft_vdata[i * rdft_vlen + j]; + +av_rdft_end(fftfilt-rdft); + +/*Horizontal pass - IRDFT*/ +fftfilt-rdft = av_rdft_init(fftfilt-rdft_hbits, IDFT_C2R); + +for (i = 0; i h; i++) +av_rdft_calc(fftfilt-rdft, fftfilt-rdft_hdata + i * rdft_hlen); + +for (i = 0; i h; i++) +for (j = 0; j w; j++) +*(out-data[0] + out-linesize[0] * i + j) = av_clip(fftfilt-rdft_hdata[i * rdft_hlen + j] + * 4 / (rdft_hlen * rdft_vlen), 0, 255); + +av_rdft_end(fftfilt-rdft); + +av_free(fftfilt-rdft_hdata); +av_free(fftfilt-rdft_vdata); these should be freed in uninit() otherwise the code will crash on the 2nd frame, i guess you tested with just a single picture + +av_frame_free(in); + +return ff_filter_frame(outlink, out); +} + +static av_cold void uninit(AVFilterContext *ctx) +{ +FFTFILTContext *fftfilt = ctx-priv; +av_expr_free(fftfilt-lum_expr); +av_free(fftfilt-lum_data); +} + +static int query_formats(AVFilterContext *ctx) +{ +static const enum AVPixelFormat pixel_fmts_fftfilt[] = { +AV_PIX_FMT_GRAY8, +AV_PIX_FMT_NONE gray8 works nicely if you want, you can try to add yuv support maybe AV_PIX_FMT_YUV444P first, it should be easiest as chroma planes have the same size as luma. For the other YUV formats chroma planes are smaller, av_pix_fmt_get_chroma_sub_sample() can be used to find out by how much they are smaller [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Old school: Use the lowest level language in which you can solve the problem conveniently. New school: Use the highest level language in which the latest supercomputer can solve the problem without the user falling asleep waiting. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
I have updated the patch. From 738612efdbd580bbf6a41bcce36a10813eba67f0 Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Port FFT domain filter. --- libavfilter/Makefile |1 + libavfilter/allfilters.c |1 + libavfilter/vf_fftfilt.c | 238 ++ 3 files changed, 240 insertions(+) create mode 100644 libavfilter/vf_fftfilt.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 289c63b..b184f07 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -120,6 +120,7 @@ OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o +OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o OBJS-$(CONFIG_FIELD_FILTER) += vf_field.o OBJS-$(CONFIG_FIELDMATCH_FILTER) += vf_fieldmatch.o OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 55de154..043ac56 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -136,6 +136,7 @@ void avfilter_register_all(void) REGISTER_FILTER(EQ, eq, vf); REGISTER_FILTER(EXTRACTPLANES, extractplanes, vf); REGISTER_FILTER(FADE, fade, vf); +REGISTER_FILTER(FFTFILT,fftfilt,vf); REGISTER_FILTER(FIELD, field, vf); REGISTER_FILTER(FIELDMATCH, fieldmatch, vf); REGISTER_FILTER(FIELDORDER, fieldorder, vf); diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c new file mode 100644 index 000..a65ec1f --- /dev/null +++ b/libavfilter/vf_fftfilt.c @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2015 Arwa Arif arwaarif1...@gmail.com + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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 + * FFT domain filtering. + */ + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h +#include libavutil/eval.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_hbits; +int rdft_vbits; +size_t rdft_vlen; +FFTSample *rdft_hdata; +FFTSample *rdft_vdata; + +int dc; +char *lum_str; +AVExpr *lum_expr; + +} FFTFILTContext; + +static const char *const var_names[] = { X, Y, W, H, NULL}; +enum { VAR_X, VAR_Y, VAR_W, VAR_H, VAR_VARS_NB }; + +#define OFFSET(x) offsetof(FFTFILTContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption fftfilt_options[] = { +{ dc, adjust gain, OFFSET(dc), AV_OPT_TYPE_INT,{.i64 = 0}, 0, 1000,FLAGS }, +{ lum, set luminance expression, OFFSET(lum_str), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, +{NULL}, +}; + +AVFILTER_DEFINE_CLASS(fftfilt); + +static inline double lum(void *priv, double x, double y) +{ +FFTFILTContext *fftfilt = priv; +FFTSample *rdft_data = fftfilt-rdft_vdata; +size_t rdft_vlen = fftfilt-rdft_vlen; + +return rdft_data[(int)x * rdft_vlen + (int)y]; +} + +static av_cold int initialize(AVFilterContext *ctx) +{ +FFTFILTContext *fftfilt = ctx-priv; +int ret = 0; + +static double (*p[])(void *, double, double) = {lum}; +const char *const func2_names[]= {lum, NULL }; +double (*func2[])(void *, double, double) = {lum, p[0], NULL }; +ret = av_expr_parse(fftfilt-lum_expr, fftfilt-lum_str, var_names, NULL, NULL, func2_names, func2, 0, ctx); +return ret; +} + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ +AVFilterContext *ctx = inlink-dst; +AVFilterLink *outlink = inlink-dst-outputs[0]; +FFTFILTContext *fftfilt = ctx-priv; +AVFrame *out; +int i, j, rdft_hbits, rdft_vbits; +size_t rdft_hlen, rdft_vlen, w, h; +double values[VAR_VARS_NB]; + +w = inlink-w; +h = inlink-h; + +/* RDFT - Array initialization for Horizontal pass*/ +for (rdft_hbits = 1;
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
I have updated the patch. Can you please explain me which user options to include? From b44034b68233cc5734924f64185f3c830a2e227d Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Port FFT domain filter. --- libavfilter/Makefile |1 + libavfilter/allfilters.c |1 + libavfilter/vf_fftfilt.c | 169 ++ 3 files changed, 171 insertions(+) create mode 100644 libavfilter/vf_fftfilt.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 289c63b..b184f07 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -120,6 +120,7 @@ OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o +OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o OBJS-$(CONFIG_FIELD_FILTER) += vf_field.o OBJS-$(CONFIG_FIELDMATCH_FILTER) += vf_fieldmatch.o OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 55de154..043ac56 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -136,6 +136,7 @@ void avfilter_register_all(void) REGISTER_FILTER(EQ, eq, vf); REGISTER_FILTER(EXTRACTPLANES, extractplanes, vf); REGISTER_FILTER(FADE, fade, vf); +REGISTER_FILTER(FFTFILT,fftfilt,vf); REGISTER_FILTER(FIELD, field, vf); REGISTER_FILTER(FIELDMATCH, fieldmatch, vf); REGISTER_FILTER(FIELDORDER, fieldorder, vf); diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c new file mode 100644 index 000..0ce2e8b --- /dev/null +++ b/libavfilter/vf_fftfilt.c @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2015 Arwa Arif arwaarif1...@gmail.com + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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 + * FFT domain filtering. + */ + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_hbits; +int rdft_vbits; +FFTSample *rdft_hdata; +FFTSample *rdft_vdata; + +} FFTFILTContext; + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ +AVFilterContext *ctx = inlink-dst; +AVFilterLink *outlink = inlink-dst-outputs[0]; +FFTFILTContext *fftfilt = ctx-priv; +AVFrame *out; +int i, j, rdft_hbits, rdft_vbits; +size_t rdft_hlen, rdft_vlen, w, h; + +w = inlink-w; +h = inlink-h; + +/* RDFT - Array initialization for Horizontal pass*/ +for (rdft_hbits = 1; 1 rdft_hbits 2 * w; rdft_hbits++); +rdft_hlen = 1 rdft_hbits; +fftfilt-rdft_hdata = av_malloc_array(h, rdft_hlen * sizeof(FFTSample)); + +/* RDFT - Array initialization for Vertical pass*/ +for (rdft_vbits = 1; 1 rdft_vbits 2 * h; rdft_vbits++); +rdft_vlen = 1 rdft_vbits; +fftfilt-rdft_vdata = av_malloc_array(w, rdft_hlen * rdft_vlen * sizeof(FFTSample)); + +out = ff_get_video_buffer(outlink, inlink-w, inlink-h); +if (!out) +return AVERROR(ENOMEM); + +av_frame_copy_props(out, in); + +/*Horizontal pass - RDFT*/ +fftfilt-rdft = av_rdft_init(rdft_hbits, DFT_R2C); +for (i = 0; i h; i++) +{ +memset(fftfilt-rdft_hdata + i * rdft_hlen, 0, rdft_hlen * sizeof(*fftfilt-rdft_hdata)); +for (j = 0; j w; j++) +fftfilt-rdft_hdata[i * rdft_hlen + j] = *(in-data[0] + in-linesize[0] * i + j); +} + +for (i = 0; i h; i++) +av_rdft_calc(fftfilt-rdft, fftfilt-rdft_hdata + i * rdft_hlen); + +av_rdft_end(fftfilt-rdft); + +/*Vertical pass - RDFT*/ +fftfilt-rdft = av_rdft_init(rdft_vbits, DFT_R2C); +for (i = 0; i rdft_hlen; i++) +{ +memset(fftfilt-rdft_vdata + i * rdft_vlen, 0, rdft_vlen * sizeof(*fftfilt-rdft_vdata)); +for (j = 0; j h; j++) +fftfilt-rdft_vdata[i * rdft_vlen + j] = fftfilt-rdft_hdata[j * rdft_hlen +
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
On Thu, Feb 26, 2015 at 01:41:08PM +0530, arwa arif wrote: I have updated the patch. Can you please explain me which user options to include? yes it could be similar to the vf_geq.c flter so something like -vf fftfilt=dc=128:lum='(1 / (1 + exp(-Y/10.0+H/100.0)))' could result in the equivalent of this: @@ -97,6 +98,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) av_rdft_end(fftfilt-rdft); +for (i = 0; i rdft_hlen; i++) +{ +for (j = 0; j rdft_vlen; j++) +fftfilt-rdft_vdata[i * rdft_vlen + j] *= (1 / (1 + exp(-j/10.0+h/100.0))); +} +fftfilt-rdft_vdata[0] += rdft_hlen * rdft_vlen * 128; + /*Vertical pass - IRDFT*/ fftfilt-rdft = av_rdft_init(rdft_vbits, IDFT_C2R); further comments below [...] +/* RDFT - Array initialization for Horizontal pass*/ +for (rdft_hbits = 1; 1 rdft_hbits 2 * w; rdft_hbits++); +rdft_hlen = 1 rdft_hbits; +fftfilt-rdft_hdata = av_malloc_array(h, rdft_hlen * sizeof(FFTSample)); + +/* RDFT - Array initialization for Vertical pass*/ +for (rdft_vbits = 1; 1 rdft_vbits 2 * h; rdft_vbits++); without the 2 * the code will be faster +rdft_vlen = 1 rdft_vbits; +fftfilt-rdft_vdata = av_malloc_array(w, rdft_hlen * rdft_vlen * sizeof(FFTSample)); ftfilt-rdft_vdata = av_malloc_array(rdft_hlen, rdft_vlen * sizeof(FFTSample)); that is without the w also the av_malloc_array return values need to be checked, the functions could fail if there is npt enough memory [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Asymptotically faster algorithms should always be preferred if you have asymptotical amounts of data signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
On Wed, Feb 25, 2015 at 11:55:51AM +0530, arwa arif wrote: On Tue, Feb 24, 2015 at 4:12 PM, Michael Niedermayer michae...@gmx.at wrote: On Tue, Feb 24, 2015 at 02:27:01PM +0530, arwa arif wrote: Hello, I have written a very primitive code for porting FFT domain filter. It accepts only gray8 format images. The output should be a grayscale image, but the ouput image is coming out to be a black and white image. Also, I am getting confused when to do the vertical pass. After taking irdft of the horizontal pass or before it? you can do both rdft first and then the 2 irdft passes, this should give more possibilities in filtering but it could be done the other way around too I have attached the patch. Makefile |1 allfilters.c |1 vf_fftfilt.c | 139 +++ 3 files changed, 141 insertions(+) d4b25d6a204534a66400f52c1f5312652e8208af 0001-Port-FFT-domain-filter.patch From 455a261d7e2b3afba767aac2e73448aeee02d159 Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Port FFT domain filter. --- libavfilter/Makefile |1 + libavfilter/allfilters.c |1 + libavfilter/vf_fftfilt.c | 139 ++ 3 files changed, 141 insertions(+) create mode 100644 libavfilter/vf_fftfilt.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 289c63b..b184f07 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -120,6 +120,7 @@ OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o +OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o OBJS-$(CONFIG_FIELD_FILTER) += vf_field.o OBJS-$(CONFIG_FIELDMATCH_FILTER) += vf_fieldmatch.o OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 55de154..043ac56 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -136,6 +136,7 @@ void avfilter_register_all(void) REGISTER_FILTER(EQ, eq, vf); REGISTER_FILTER(EXTRACTPLANES, extractplanes, vf); REGISTER_FILTER(FADE, fade, vf); +REGISTER_FILTER(FFTFILT,fftfilt,vf); REGISTER_FILTER(FIELD, field, vf); REGISTER_FILTER(FIELDMATCH, fieldmatch, vf); REGISTER_FILTER(FIELDORDER, fieldorder, vf); diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c new file mode 100644 index 000..753bc8e --- /dev/null +++ b/libavfilter/vf_fftfilt.c @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2015 Arwa Arif arwaarif1...@gmail.com + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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 + * FFT domain filtering. + */ + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_bits; +FFTSample *rdft_data; + +} FFTFILTContext; + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ +AVFilterContext *ctx = inlink-dst; +AVFilterLink *outlink = inlink-dst-outputs[0]; +FFTFILTContext *fftfilt = ctx-priv; +AVFrame *out; +int i, j, k, rdft_bits; +size_t rdft_len, w, h; + +w = inlink-w; +h = inlink-h; + +/* RDFT window size (precision) according to the requested output frame height */ +for (rdft_bits = 1; 1 rdft_bits 2 * w; rdft_bits++); +rdft_len = 1 rdft_bits; +fftfilt-rdft_data = av_malloc_array(h, rdft_len * sizeof(FFTSample)); +memset(fftfilt-rdft_data, 0, rdft_len * h *
[FFmpeg-devel] [PATCH] Port FFT domain filter.
Hello, I have written a very primitive code for porting FFT domain filter. It accepts only gray8 format images. The output should be a grayscale image, but the ouput image is coming out to be a black and white image. Also, I am getting confused when to do the vertical pass. After taking irdft of the horizontal pass or before it? I have attached the patch. From 455a261d7e2b3afba767aac2e73448aeee02d159 Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Port FFT domain filter. --- libavfilter/Makefile |1 + libavfilter/allfilters.c |1 + libavfilter/vf_fftfilt.c | 139 ++ 3 files changed, 141 insertions(+) create mode 100644 libavfilter/vf_fftfilt.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 289c63b..b184f07 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -120,6 +120,7 @@ OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o +OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o OBJS-$(CONFIG_FIELD_FILTER) += vf_field.o OBJS-$(CONFIG_FIELDMATCH_FILTER) += vf_fieldmatch.o OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 55de154..043ac56 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -136,6 +136,7 @@ void avfilter_register_all(void) REGISTER_FILTER(EQ, eq, vf); REGISTER_FILTER(EXTRACTPLANES, extractplanes, vf); REGISTER_FILTER(FADE, fade, vf); +REGISTER_FILTER(FFTFILT,fftfilt,vf); REGISTER_FILTER(FIELD, field, vf); REGISTER_FILTER(FIELDMATCH, fieldmatch, vf); REGISTER_FILTER(FIELDORDER, fieldorder, vf); diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c new file mode 100644 index 000..753bc8e --- /dev/null +++ b/libavfilter/vf_fftfilt.c @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2015 Arwa Arif arwaarif1...@gmail.com + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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 + * FFT domain filtering. + */ + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_bits; +FFTSample *rdft_data; + +} FFTFILTContext; + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ +AVFilterContext *ctx = inlink-dst; +AVFilterLink *outlink = inlink-dst-outputs[0]; +FFTFILTContext *fftfilt = ctx-priv; +AVFrame *out; +int i, j, k, rdft_bits; +size_t rdft_len, w, h; + +w = inlink-w; +h = inlink-h; + +/* RDFT window size (precision) according to the requested output frame height */ +for (rdft_bits = 1; 1 rdft_bits 2 * w; rdft_bits++); +rdft_len = 1 rdft_bits; +fftfilt-rdft_data = av_malloc_array(h, rdft_len * sizeof(FFTSample)); +memset(fftfilt-rdft_data, 0, rdft_len * h * sizeof(FFTSample)); + +out = ff_get_video_buffer(outlink, inlink-w, inlink-h); +if (!out) +return AVERROR(ENOMEM); + +av_frame_copy_props(out, in); + +/*Horizontal pass - RDFT*/ +fftfilt-rdft = av_rdft_init(rdft_bits, DFT_R2C); +k = 0; +for (i = 0; i h; i++) +for (j = 0; j w; j++) +{ +fftfilt-rdft_data[k] = *(in-data[0] + in-linesize[0] * i + j); +k++; +} + +for (i = 0; i h; i++) +av_rdft_calc(fftfilt-rdft, fftfilt-rdft_data + i * rdft_len); + +av_rdft_end(fftfilt-rdft); + +/*Horizontal pass - IRDFT*/ +fftfilt-rdft = av_rdft_init(rdft_bits, IDFT_C2R); + +for (i = 0; i h; i++) +av_rdft_calc(fftfilt-rdft, fftfilt-rdft_data + i * rdft_len); + +k = 0; +for (i = 0; i h; i++) +for (j = 0; j w; j++) +{ +*(out-data[0] + out-linesize[0] * i + j) = fftfilt-rdft_data[k]; +k++; +
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
On Tue, Feb 24, 2015 at 02:27:01PM +0530, arwa arif wrote: Hello, I have written a very primitive code for porting FFT domain filter. It accepts only gray8 format images. The output should be a grayscale image, but the ouput image is coming out to be a black and white image. Also, I am getting confused when to do the vertical pass. After taking irdft of the horizontal pass or before it? you can do both rdft first and then the 2 irdft passes, this should give more possibilities in filtering but it could be done the other way around too I have attached the patch. Makefile |1 allfilters.c |1 vf_fftfilt.c | 139 +++ 3 files changed, 141 insertions(+) d4b25d6a204534a66400f52c1f5312652e8208af 0001-Port-FFT-domain-filter.patch From 455a261d7e2b3afba767aac2e73448aeee02d159 Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Port FFT domain filter. --- libavfilter/Makefile |1 + libavfilter/allfilters.c |1 + libavfilter/vf_fftfilt.c | 139 ++ 3 files changed, 141 insertions(+) create mode 100644 libavfilter/vf_fftfilt.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 289c63b..b184f07 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -120,6 +120,7 @@ OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o +OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o OBJS-$(CONFIG_FIELD_FILTER) += vf_field.o OBJS-$(CONFIG_FIELDMATCH_FILTER) += vf_fieldmatch.o OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 55de154..043ac56 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -136,6 +136,7 @@ void avfilter_register_all(void) REGISTER_FILTER(EQ, eq, vf); REGISTER_FILTER(EXTRACTPLANES, extractplanes, vf); REGISTER_FILTER(FADE, fade, vf); +REGISTER_FILTER(FFTFILT,fftfilt,vf); REGISTER_FILTER(FIELD, field, vf); REGISTER_FILTER(FIELDMATCH, fieldmatch, vf); REGISTER_FILTER(FIELDORDER, fieldorder, vf); diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c new file mode 100644 index 000..753bc8e --- /dev/null +++ b/libavfilter/vf_fftfilt.c @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2015 Arwa Arif arwaarif1...@gmail.com + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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 + * FFT domain filtering. + */ + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_bits; +FFTSample *rdft_data; + +} FFTFILTContext; + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ +AVFilterContext *ctx = inlink-dst; +AVFilterLink *outlink = inlink-dst-outputs[0]; +FFTFILTContext *fftfilt = ctx-priv; +AVFrame *out; +int i, j, k, rdft_bits; +size_t rdft_len, w, h; + +w = inlink-w; +h = inlink-h; + +/* RDFT window size (precision) according to the requested output frame height */ +for (rdft_bits = 1; 1 rdft_bits 2 * w; rdft_bits++); +rdft_len = 1 rdft_bits; +fftfilt-rdft_data = av_malloc_array(h, rdft_len * sizeof(FFTSample)); +memset(fftfilt-rdft_data, 0, rdft_len * h * sizeof(FFTSample)); + +out = ff_get_video_buffer(outlink, inlink-w, inlink-h); +if (!out) +return AVERROR(ENOMEM); + +av_frame_copy_props(out, in); + +/*Horizontal pass - RDFT*/ +fftfilt-rdft = av_rdft_init(rdft_bits, DFT_R2C); +k = 0; +for (i = 0; i h; i++) +for (j = 0; j w; j++) +{ +
Re: [FFmpeg-devel] [PATCH] Port FFT domain filter.
On Tue, Feb 24, 2015 at 4:12 PM, Michael Niedermayer michae...@gmx.at wrote: On Tue, Feb 24, 2015 at 02:27:01PM +0530, arwa arif wrote: Hello, I have written a very primitive code for porting FFT domain filter. It accepts only gray8 format images. The output should be a grayscale image, but the ouput image is coming out to be a black and white image. Also, I am getting confused when to do the vertical pass. After taking irdft of the horizontal pass or before it? you can do both rdft first and then the 2 irdft passes, this should give more possibilities in filtering but it could be done the other way around too I have attached the patch. Makefile |1 allfilters.c |1 vf_fftfilt.c | 139 +++ 3 files changed, 141 insertions(+) d4b25d6a204534a66400f52c1f5312652e8208af 0001-Port-FFT-domain-filter.patch From 455a261d7e2b3afba767aac2e73448aeee02d159 Mon Sep 17 00:00:00 2001 From: Arwa Arif arwaarif1...@gmail.com Date: Tue, 24 Feb 2015 12:17:30 +0530 Subject: [PATCH] Port FFT domain filter. --- libavfilter/Makefile |1 + libavfilter/allfilters.c |1 + libavfilter/vf_fftfilt.c | 139 ++ 3 files changed, 141 insertions(+) create mode 100644 libavfilter/vf_fftfilt.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 289c63b..b184f07 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -120,6 +120,7 @@ OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o +OBJS-$(CONFIG_FFTFILT_FILTER)+= vf_fftfilt.o OBJS-$(CONFIG_FIELD_FILTER) += vf_field.o OBJS-$(CONFIG_FIELDMATCH_FILTER) += vf_fieldmatch.o OBJS-$(CONFIG_FIELDORDER_FILTER) += vf_fieldorder.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 55de154..043ac56 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -136,6 +136,7 @@ void avfilter_register_all(void) REGISTER_FILTER(EQ, eq, vf); REGISTER_FILTER(EXTRACTPLANES, extractplanes, vf); REGISTER_FILTER(FADE, fade, vf); +REGISTER_FILTER(FFTFILT,fftfilt,vf); REGISTER_FILTER(FIELD, field, vf); REGISTER_FILTER(FIELDMATCH, fieldmatch, vf); REGISTER_FILTER(FIELDORDER, fieldorder, vf); diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c new file mode 100644 index 000..753bc8e --- /dev/null +++ b/libavfilter/vf_fftfilt.c @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2015 Arwa Arif arwaarif1...@gmail.com + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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 + * FFT domain filtering. + */ + +#include libavfilter/internal.h +#include libavutil/common.h +#include libavutil/imgutils.h +#include libavutil/opt.h +#include libavutil/pixdesc.h +#include libavcodec/avfft.h + +typedef struct { +const AVClass *class; + +RDFTContext *rdft; +int rdft_bits; +FFTSample *rdft_data; + +} FFTFILTContext; + +static int filter_frame(AVFilterLink *inlink, AVFrame *in) +{ +AVFilterContext *ctx = inlink-dst; +AVFilterLink *outlink = inlink-dst-outputs[0]; +FFTFILTContext *fftfilt = ctx-priv; +AVFrame *out; +int i, j, k, rdft_bits; +size_t rdft_len, w, h; + +w = inlink-w; +h = inlink-h; + +/* RDFT window size (precision) according to the requested output frame height */ +for (rdft_bits = 1; 1 rdft_bits 2 * w; rdft_bits++); +rdft_len = 1 rdft_bits; +fftfilt-rdft_data = av_malloc_array(h, rdft_len * sizeof(FFTSample)); +memset(fftfilt-rdft_data, 0, rdft_len * h * sizeof(FFTSample)); + +out = ff_get_video_buffer(outlink, inlink-w, inlink-h); +if (!out) +return AVERROR(ENOMEM); + +av_frame_copy_props(out, in); + +