Re: [FFmpeg-devel] [PATCH] avfilter: add estdif video filter
Will apply soon! ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avfilter: add estdif video filter
Signed-off-by: Paul B Mahol --- doc/filters.texi | 64 ++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_estdif.c | 469 +++ 4 files changed, 535 insertions(+) create mode 100644 libavfilter/vf_estdif.c diff --git a/doc/filters.texi b/doc/filters.texi index 813e35c2f9..9fbc4de7d2 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -11065,6 +11065,70 @@ Flags to local 3x3 coordinates maps like this: This filter supports the all above options as @ref{commands}. +@section estdif + +Deinterlace the input video ("estdif" stands for "Edge Slope +Tracing Deinterlacing Filter"). + +Spatial only filter that uses edge slope tracing algorithm +to interpolate missing lines. +It accepts the following parameters: + +@table @option +@item mode +The interlacing mode to adopt. It accepts one of the following values: + +@table @option +@item frame +Output one frame for each frame. +@item field +Output one frame for each field. +@end table + +The default value is @code{field}. + +@item parity +The picture field parity assumed for the input interlaced video. It accepts one +of the following values: + +@table @option +@item ff +Assume the top field is first. +@item bff +Assume the bottom field is first. +@item auto +Enable automatic detection of field parity. +@end table + +The default value is @code{auto}. +If the interlacing is unknown or the decoder does not export this information, +top field first will be assumed. + +@item deint +Specify which frames to deinterlace. Accepts one of the following +values: + +@table @option +@item all +Deinterlace all frames. +@item interlaced +Only deinterlace frames marked as interlaced. +@end table + +The default value is @code{all}. + +@item rslope +Specify the search radius for edge slope tracing. Default value is 1. +Allowed range is from 1 to 15. + +@item redge +Specify the search radius for best edge matching. Default value is 2. +Allowed range is from 0 to 3. +@end table + +@subsection Commands +This filter supports same @ref{commands} as options. + @section extractplanes Extract color channel components from input video stream into diff --git a/libavfilter/Makefile b/libavfilter/Makefile index ad1046d526..44afa79963 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -252,6 +252,7 @@ OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EROSION_FILTER)+= vf_neighbor.o OBJS-$(CONFIG_EROSION_OPENCL_FILTER) += vf_neighbor_opencl.o opencl.o \ opencl/neighbor.o +OBJS-$(CONFIG_ESTDIF_FILTER) += vf_estdif.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o OBJS-$(CONFIG_FFTDNOIZ_FILTER) += vf_fftdnoiz.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index ce317dfa1c..471844a603 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -237,6 +237,7 @@ extern AVFilter ff_vf_entropy; extern AVFilter ff_vf_eq; extern AVFilter ff_vf_erosion; extern AVFilter ff_vf_erosion_opencl; +extern AVFilter ff_vf_estdif; extern AVFilter ff_vf_extractplanes; extern AVFilter ff_vf_fade; extern AVFilter ff_vf_fftdnoiz; diff --git a/libavfilter/vf_estdif.c b/libavfilter/vf_estdif.c new file mode 100644 index 00..5d83e66906 --- /dev/null +++ b/libavfilter/vf_estdif.c @@ -0,0 +1,469 @@ +/* + * 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 + */ + +#include "libavutil/common.h" +#include "libavutil/imgutils.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "video.h" + +typedef struct ESTDIFContext { +const AVClass *class; + +int mode; ///< 0 is frame, 1 is field +int parity; ///< frame field parity +int deint;///< which frames to deinterlace +int rslope; ///< best edge slope search radius +int redge;///< best edge match search radius +int linesize[4]; ///< bytes of pixel data per line for each plane +int planewidth[4];///< width of each plane +int planeheight[4];
[FFmpeg-devel] [PATCH] avfilter: add estdif video filter
Signed-off-by: Paul B Mahol --- TODO: add working >8 depth support --- doc/filters.texi | 56 ++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_estdif.c | 372 +++ 4 files changed, 430 insertions(+) create mode 100644 libavfilter/vf_estdif.c diff --git a/doc/filters.texi b/doc/filters.texi index 01ae540c5c..d5cfb1b4ff 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -11065,6 +11065,62 @@ Flags to local 3x3 coordinates maps like this: This filter supports the all above options as @ref{commands}. +@section estdif + +Deinterlace the input video ("estdif" stands for "Edge Slope +Tracing Deinterlacing Filter"). + +Spatial only filter that uses simple edge slope tracing algorithm +to interpolate missing lines. +It accepts the following parameters: + +@table @option +@item mode +The interlacing mode to adopt. It accepts one of the following values: + +@table @option +@item frame +Output one frame for each frame. +@item field +Output one frame for each field. +@end table + +The default value is @code{field}. + +@item parity +The picture field parity assumed for the input interlaced video. It accepts one +of the following values: + +@table @option +@item ff +Assume the top field is first. +@item bff +Assume the bottom field is first. +@item auto +Enable automatic detection of field parity. +@end table + +The default value is @code{auto}. +If the interlacing is unknown or the decoder does not export this information, +top field first will be assumed. + +@item deint +Specify which frames to deinterlace. Accepts one of the following +values: + +@table @option +@item all +Deinterlace all frames. +@item interlaced +Only deinterlace frames marked as interlaced. +@end table + +The default value is @code{all}. +@end table + +@subsection Commands +This filter supports same @ref{commands} as options. + @section extractplanes Extract color channel components from input video stream into diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 526da8d69e..7939381616 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -252,6 +252,7 @@ OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o OBJS-$(CONFIG_EROSION_FILTER)+= vf_neighbor.o OBJS-$(CONFIG_EROSION_OPENCL_FILTER) += vf_neighbor_opencl.o opencl.o \ opencl/neighbor.o +OBJS-$(CONFIG_ESTDIF_FILTER) += vf_estdif.o OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o OBJS-$(CONFIG_FFTDNOIZ_FILTER) += vf_fftdnoiz.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index ce317dfa1c..471844a603 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -237,6 +237,7 @@ extern AVFilter ff_vf_entropy; extern AVFilter ff_vf_eq; extern AVFilter ff_vf_erosion; extern AVFilter ff_vf_erosion_opencl; +extern AVFilter ff_vf_estdif; extern AVFilter ff_vf_extractplanes; extern AVFilter ff_vf_fade; extern AVFilter ff_vf_fftdnoiz; diff --git a/libavfilter/vf_estdif.c b/libavfilter/vf_estdif.c new file mode 100644 index 00..ec2cd42a96 --- /dev/null +++ b/libavfilter/vf_estdif.c @@ -0,0 +1,372 @@ +/* + * 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 + */ + +#include "libavutil/common.h" +#include "libavutil/imgutils.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "video.h" + +typedef struct ESTDIFContext { +const AVClass *class; + +int mode; ///< 0 is frame, 1 is field +int parity; ///< frame field parity +int deint;///< which frames to deinterlace +int linesize[4]; ///< bytes of pixel data per line for each plane +int planewidth[4];///< width of each plane +int planeheight[4]; ///< height of each plane +int field;///< which field are we on, 0 or 1 +int eof; +int nb_planes; +int nb_threads; +int max; +int64_t pts; +AVFrame *prev; + +int *work_line[4]; +} ESTDIFContext; + +#define OFFSET(x) offsetof(ESTDIFContext, x) +#define FLAGS