Re: [FFmpeg-devel] [PATCH] lavfi: add erosion dilation filter
On 27/02/15 5:19 AM, Paul B Mahol wrote: On 2/26/15, James Almer jamr...@gmail.com wrote: On 25/02/15 11:55 AM, Paul B Mahol wrote: +static inline void line_copy8(uint8_t *line, const uint8_t *srcp, int width, int mergin) Unless I'm missing something, mergin seems to always be 1. The code below could be simplified. The function could be used with other arguments for mergin in later patch(es). Ok, no more comments from me. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavfi: add erosion dilation filter
On 2/26/15, James Almer jamr...@gmail.com wrote: On 25/02/15 11:55 AM, Paul B Mahol wrote: +static inline void line_copy8(uint8_t *line, const uint8_t *srcp, int width, int mergin) Unless I'm missing something, mergin seems to always be 1. The code below could be simplified. The function could be used with other arguments for mergin in later patch(es). +{ +memcpy(line, srcp, width); + +for (int i = mergin; i 0; i--) { +line[-i] = line[i]; +line[width - 1 + i] = line[width - 1 - i]; +} +} ___ 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] lavfi: add erosion dilation filter
On 2/26/15, Clement Boesch u...@pkh.me wrote: On Wed, Feb 25, 2015 at 02:55:58PM +, Paul B Mahol wrote: Signed-off-by: Paul B Mahol one...@gmail.com --- doc/filters.texi | 34 ++ libavfilter/Makefile | 2 + libavfilter/allfilters.c | 2 + libavfilter/vf_neighbor.c | 289 ++ 4 files changed, 327 insertions(+) create mode 100644 libavfilter/vf_neighbor.c diff --git a/doc/filters.texi b/doc/filters.texi index baef346..13ba797 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3728,6 +3728,23 @@ FFmpeg was configured with @code{--enable-opencl}. Default value is 0. @end table +@section dilation + +Apply dilation effect to the video. + +This filter replaces the pixel by the local(3x3) maximum. + +It accepts the following parameters: + +@table @option +@item threshold +Allows to limit the maximum change, default is 65535. + +@item coordinates +Flag which specifies the pixel to refer to. Default is 255 ie. all eight +pixels are used. +@end table + @section drawbox Draw a colored box on the input image. @@ -4437,6 +4454,23 @@ value. @end table +@section erosion + +Apply erosion effect to the video. + +This filter replaces the pixel by the local(3x3) minimum. + +It accepts the following parameters: + +@table @option +@item threshold +Allows to limit the maximum change, default is 65535. + +@item coordinates +Flag which specifies the pixel to refer to. Default is 255 ie. all eight +pixels are used. +@end table + [...] +static int config_input(AVFilterLink *inlink) +{ +EDContext *s = inlink-dst-priv; +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink-format); +int ret; + +if ((ret = av_image_fill_linesizes(s-linesize, inlink-format, inlink-w)) 0) +return ret; + +s-planeheight[1] = s-planeheight[2] = FF_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); +s-buffer = av_malloc(3 * (s-linesize[0] + 32)); av_malloc_array() relevant? +if (!s-buffer) +return AVERROR(ENOMEM); + +return 0; +} + +static inline void line_copy8(uint8_t *line, const uint8_t *srcp, int width, int mergin) +{ +memcpy(line, srcp, width); + +for (int i = mergin; i 0; i--) { int should be declared out of the scope +line[-i] = line[i]; +line[width - 1 + i] = line[width - 1 - i]; +} +} + [...] No other comment from me. May I ask if there was a special use case of this or that's just because the effect were neat and simple to implement? Is was neat and simple to implement and I may add other effects too. -- Clement B. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavfi: add erosion dilation filter
On 25/02/15 11:55 AM, Paul B Mahol wrote: +static inline void line_copy8(uint8_t *line, const uint8_t *srcp, int width, int mergin) Unless I'm missing something, mergin seems to always be 1. The code below could be simplified. +{ +memcpy(line, srcp, width); + +for (int i = mergin; i 0; i--) { +line[-i] = line[i]; +line[width - 1 + i] = line[width - 1 - i]; +} +} ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavfi: add erosion dilation filter
On Wed, Feb 25, 2015 at 02:55:58PM +, Paul B Mahol wrote: Signed-off-by: Paul B Mahol one...@gmail.com --- doc/filters.texi | 34 ++ libavfilter/Makefile | 2 + libavfilter/allfilters.c | 2 + libavfilter/vf_neighbor.c | 289 ++ 4 files changed, 327 insertions(+) create mode 100644 libavfilter/vf_neighbor.c diff --git a/doc/filters.texi b/doc/filters.texi index baef346..13ba797 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3728,6 +3728,23 @@ FFmpeg was configured with @code{--enable-opencl}. Default value is 0. @end table +@section dilation + +Apply dilation effect to the video. + +This filter replaces the pixel by the local(3x3) maximum. + +It accepts the following parameters: + +@table @option +@item threshold +Allows to limit the maximum change, default is 65535. + +@item coordinates +Flag which specifies the pixel to refer to. Default is 255 ie. all eight +pixels are used. +@end table + @section drawbox Draw a colored box on the input image. @@ -4437,6 +4454,23 @@ value. @end table +@section erosion + +Apply erosion effect to the video. + +This filter replaces the pixel by the local(3x3) minimum. + +It accepts the following parameters: + +@table @option +@item threshold +Allows to limit the maximum change, default is 65535. + +@item coordinates +Flag which specifies the pixel to refer to. Default is 255 ie. all eight +pixels are used. +@end table + [...] +static int config_input(AVFilterLink *inlink) +{ +EDContext *s = inlink-dst-priv; +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink-format); +int ret; + +if ((ret = av_image_fill_linesizes(s-linesize, inlink-format, inlink-w)) 0) +return ret; + +s-planeheight[1] = s-planeheight[2] = FF_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); +s-buffer = av_malloc(3 * (s-linesize[0] + 32)); av_malloc_array() relevant? +if (!s-buffer) +return AVERROR(ENOMEM); + +return 0; +} + +static inline void line_copy8(uint8_t *line, const uint8_t *srcp, int width, int mergin) +{ +memcpy(line, srcp, width); + +for (int i = mergin; i 0; i--) { int should be declared out of the scope +line[-i] = line[i]; +line[width - 1 + i] = line[width - 1 - i]; +} +} + [...] No other comment from me. May I ask if there was a special use case of this or that's just because the effect were neat and simple to implement? -- Clément B. pgp55nEF6uOeE.pgp Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavfi: add erosion dilation filter
On Wed, Feb 25, 2015 at 02:55:58PM +, Paul B Mahol wrote: Signed-off-by: Paul B Mahol one...@gmail.com --- doc/filters.texi | 34 ++ libavfilter/Makefile | 2 + libavfilter/allfilters.c | 2 + libavfilter/vf_neighbor.c | 289 ++ 4 files changed, 327 insertions(+) create mode 100644 libavfilter/vf_neighbor.c [...] If you put 1 filters in the same file, you need to protect with CONFIG_*_FILTER. -- Clément B. pgpLwMeMhKlvv.pgp Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavfi: add erosion dilation filter
On 2/25/15, Clement Boesch u...@pkh.me wrote: On Wed, Feb 25, 2015 at 02:55:58PM +, Paul B Mahol wrote: Signed-off-by: Paul B Mahol one...@gmail.com --- doc/filters.texi | 34 ++ libavfilter/Makefile | 2 + libavfilter/allfilters.c | 2 + libavfilter/vf_neighbor.c | 289 ++ 4 files changed, 327 insertions(+) create mode 100644 libavfilter/vf_neighbor.c [...] If you put 1 filters in the same file, you need to protect with CONFIG_*_FILTER. -- Clement B. locally fixed ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel