diff mbox

[FFmpeg-devel,1/2] docs/filters: add documentation to all existing OpenCL filters

Message ID 1533050059-29919-1-git-send-email-danyaschenko@gmail.com
State Superseded
Headers show

Commit Message

Danil Iashchenko July 31, 2018, 3:14 p.m. UTC
docs/filters: add documentation to all existing OpenCL filters

---

Thanks for your comments! Most of the issues have been fixed.

>The filer source has many more options defined.
>In addition, there are many missing values for the tonemap algo; it appears not all are effected. If that's the case, remove or note that in the AVOptions table.

It seems I'd need more time than expected to fully acquaint myself with tonemap_opencl so as to write appropriately detailed documentation, (as you said, there are a lot of options, and it's unclear which ones are actually working). 
This hinders overall progress on the documentation and filter implementation of my GSoC project and there is not much time left. I suggest putting it on the backburner for the moment and leaving it out until the next patch.
Again, only tonemap_opencl presents an issue; the rest of the documentation is fine.

 doc/filters.texi | 413 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 413 insertions(+)

Comments

Ruiling Song Aug. 2, 2018, 1:32 a.m. UTC | #1
> -----Original Message-----

> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of

> Danil Iashchenko

> Sent: Tuesday, July 31, 2018 8:14 AM

> To: ffmpeg-devel@ffmpeg.org

> Cc: Danil Iashchenko <danyaschenko@gmail.com>

> Subject: [FFmpeg-devel] [PATCH 1/2] docs/filters: add documentation to all

> existing OpenCL filters

> 

> docs/filters: add documentation to all existing OpenCL filters

> 

> ---

> 

> Thanks for your comments! Most of the issues have been fixed.

> 

> >The filer source has many more options defined.

> >In addition, there are many missing values for the tonemap algo; it appears not

> all are effected. If that's the case, remove or note that in the AVOptions table.

> 

> It seems I'd need more time than expected to fully acquaint myself with

> tonemap_opencl so as to write appropriately detailed documentation, (as you

> said, there are a lot of options, and it's unclear which ones are actually working).

> This hinders overall progress on the documentation and filter implementation of

> my GSoC project and there is not much time left. I suggest putting it on the

> backburner for the moment and leaving it out until the next patch.

> Again, only tonemap_opencl presents an issue; the rest of the documentation is

> fine.

I am sorry for the late reply. I just write a patch to add the tonemap_opencl filter document.
It is based on this patch.

Thanks!
Ruiling
Gyan Aug. 2, 2018, 8:10 a.m. UTC | #2
On 31-07-2018 08:44 PM, Danil Iashchenko wrote:

> This hinders overall progress on the documentation and filter implementation of my GSoC project and there is not much time left. I suggest putting it on the backburner for the moment and leaving it out until the next patch.

  OK.

> +@item -init_hw_device @var{type}[=@var{name}][:@var{device}[,@var{key=value}...]]

s/type/opencl. This section is specifically opencl.

> +@item planes
> +Set which planes to filter. By default value @code{0xf}, all planes will be processed.

--> "Set which planes to filter. Default value is @code{0xf}, by which 
all planes are processed."

> +@item sizeY
> +Set vertical radius size, if zero it will be same as @code{sizeX}.
> +Range is @code{[1, 1024]} and default value is @code{0}.

--> "Set vertical radius size. Range is @code{[1, 1024]} and default 
value is @code{0}. If zero, @code{sizeX} value will be used."

> +@section convolution_opencl

> +@item 0mode
> +@item 1mode
> +@item 2mode
> +@item 3mode
> +Set matrix mode for each plane. Can be @var{square}, @var{row} or @var{column}.
> +Default is @var{square}.

The opencl filter does not have mode selection options, software one 
does. So I assume only square mode is used. Remove these entries and 
change the docs for the others to remove references to modes.

> +@section overlay_opencl

> +@item x
> +Set the x coordinate of the overlaid video on the main video.
> +By default value is @code{0}.

--> "Default value is @code{0}."

> +@item y
> +Set the x coordinate of the overlaid video on the main video.
> +By default value is @code{0}.

Same.

> +Insert a PNG logo in the top-left corner of the input

What if it's a JPG logo? :) See below.

> +@example
> +-i INPUT -i LOGO -filter_complex "[0:v]hwupload[a], [1:v]format=yuva420p, hwupload[b], [a][b]overlay_opencl, hwdownload" OUTPUT

So the reason, I suspect, you used PNG above is to indicate that pixel 
format conversion may be required. In your earlier patch version, you 
used JPG and no conversion.

So, for OpenCL, which all formats are acceptable without conversion? 
This should be mentioned just below the start of the overall section, 
after the device init part.

> +@section prewitt_opencl

> +@item planes
> +Set which planes will be processed, unprocessed planes will be copied.
> +By default value @code{0xf}, all planes will be processed.

Same as earlier.

> +@section roberts_opencl

> +@item planes
> +Set which planes will be processed, unprocessed planes will be copied.
> +By default value @code{0xf}, all planes will be processed.

Same as earlier.

> +@section sobel_opencl

> +@item planes
> +Set which planes will be processed, unprocessed planes will be copied.
> +By default value @code{0xf}, all planes will be processed.

Same as earlier.

> +@section unsharp_opencl

> +@item luma_msize_x, lx
> +Set the luma matrix horizontal size. It must be an odd integer between
> +@code{3} and @code{23}. The default value is @code{5}.

The source allows for value 1.

> +@item luma_msize_y, ly
 > +@item chroma_msize_x, cx
 > +@item chroma_msize_y, cy

Same.

> +@item luma_amount, la
> +Set the luma effect strength. It must be a floating point number, reasonable
> +values lay between @code{-1.5} and @code{1.5}.

Range missing.

> +@item chroma_amount, ca

Same.


I still had 3 warnings. In your editor, check for trailing whitespaces 
and remove those.


Regards,
Gyan
diff mbox

Patch

diff --git a/doc/filters.texi b/doc/filters.texi
index 705d48e..5c081d3 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -17545,6 +17545,419 @@  pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
 
 @c man end VIDEO FILTERS
 
+@chapter OpenCL Video Filters
+@c man begin OPENCL VIDEO FILTERS
+
+Below is a description of the currently available OpenCL video filters.
+
+To enable compilation of these filters you need to configure FFmpeg with
+@code{--enable-opencl}.
+
+Running OpenCL filters requires you to initialize a hardware device and to pass that device to all filters in any filter graph. 
+@table @option
+
+@item -init_hw_device @var{type}[=@var{name}][:@var{device}[,@var{key=value}...]]
+Initialise a new hardware device of type @var{opencl} called @var{name}, using the
+given device parameters.
+
+@item -filter_hw_device @var{name}
+Pass the hardware device called @var{name} to all filters in any filter graph.
+
+@end table
+
+For more detailed information see @url{https://www.ffmpeg.org/ffmpeg.html#Advanced-Video-options}
+
+@itemize
+@item
+Example of choosing the first device on the second platform and running avgblur_opencl filter with default parameters on it.
+@example
+-init_hw_device opencl=gpu:1.0 -filter_hw_device gpu -i INPUT -vf "hwupload, avgblur_opencl, hwdownload" OUTPUT 
+@end example
+@end itemize
+
+@section avgblur_opencl
+
+Apply average blur filter.
+
+The filter accepts the following options:
+
+@table @option
+@item sizeX
+Set horizontal radius size.
+Range is @code{[1, 1024]} and default value is @code{1}.
+
+@item planes
+Set which planes to filter. By default value @code{0xf}, all planes will be processed.
+
+@item sizeY
+Set vertical radius size, if zero it will be same as @code{sizeX}.
+Range is @code{[1, 1024]} and default value is @code{0}.
+@end table
+
+@subsection Example
+
+@itemize
+@item
+Apply average blur filter with horizontal and vertical size of 3, setting each pixel of the output to the average value of the 7x7 region centered on it in the input. For pixels on the edges of the image, the region does not extend beyond the image boundaries, and so out-of-range coordinates are not used in the calculations.
+@example
+-i INPUT -vf "hwupload, avgblur_opencl=3, hwdownload" OUTPUT
+@end example
+@end itemize
+
+@section boxblur_opencl
+
+Apply a boxblur algorithm to the input video.
+
+It accepts the following parameters:
+
+@table @option
+
+@item luma_radius, lr
+@item luma_power, lp
+@item chroma_radius, cr
+@item chroma_power, cp
+@item alpha_radius, ar
+@item alpha_power, ap
+
+@end table
+
+A description of the accepted options follows.
+
+@table @option
+@item luma_radius, lr
+@item chroma_radius, cr
+@item alpha_radius, ar
+Set an expression for the box radius in pixels used for blurring the
+corresponding input plane.
+
+The radius value must be a non-negative number, and must not be
+greater than the value of the expression @code{min(w,h)/2} for the
+luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
+planes.
+
+Default value for @option{luma_radius} is "2". If not specified,
+@option{chroma_radius} and @option{alpha_radius} default to the
+corresponding value set for @option{luma_radius}.
+
+The expressions can contain the following constants:
+@table @option
+@item w
+@item h
+The input width and height in pixels.
+
+@item cw
+@item ch
+The input chroma image width and height in pixels.
+
+@item hsub
+@item vsub
+The horizontal and vertical chroma subsample values. For example, for the
+pixel format "yuv422p", @var{hsub} is 2 and @var{vsub} is 1.
+@end table
+
+@item luma_power, lp
+@item chroma_power, cp
+@item alpha_power, ap
+Specify how many times the boxblur filter is applied to the
+corresponding plane.
+
+Default value for @option{luma_power} is 2. If not specified,
+@option{chroma_power} and @option{alpha_power} default to the
+corresponding value set for @option{luma_power}.
+
+A value of 0 will disable the effect.
+@end table
+
+@subsection Examples
+
+Apply boxblur filter, setting each pixel of the output to the average value of box-radiuses @var{luma_radius}, @var{chroma_radius}, @var{alpha_radius} for each plane respectively. The filter will apply @var{luma_power}, @var{chroma_power}, @var{alpha_power} times onto the corresponding plane. For pixels on the edges of the image, the radius does not extend beyond the image boundaries, and so out-of-range coordinates are not used in the calculations.
+
+@itemize
+@item
+Apply a boxblur filter with the luma, chroma, and alpha radius
+set to 2 and luma, chroma, and alpha power set to 3. The filter will run 3 times with box-radius set to 2 for every plane of the image.
+@example
+-i INPUT -vf "hwupload, boxblur_opencl=luma_radius=2:luma_power=3, hwdownload" OUTPUT
+-i INPUT -vf "hwupload, boxblur_opencl=2:3, hwdownload" OUTPUT
+@end example
+
+@item
+Apply a boxblur filter with luma radius set to 2, luma_power to 1, chroma_radius to 4, chroma_power to 5, alpha_radius to 3 and alpha_power to 7.
+
+For the luma plane, a 2x2 box radius will be run once.
+
+For the chroma plane, a 4x4 box radius will be run 5 times.
+
+For the alpha plane, a 3x3 box radius will be run 7 times.
+@example
+-i INPUT -vf "hwupload, boxblur_opencl=2:1:4:5:3:7, hwdownload" OUTPUT
+@end example
+@end itemize
+
+@section convolution_opencl
+
+Apply convolution of 3x3, 5x5, 7x7 or horizontal/vertical up to 49 elements.
+
+The filter accepts the following options:
+
+@table @option
+@item 0m
+@item 1m
+@item 2m
+@item 3m
+Set matrix for each plane.
+Matrix is sequence of 9, 25 or 49 signed integers in @var{square} mode,
+and from 1 to 49 odd number of signed integers in @var{row} mode.
+Default value for each plane is @code{0 0 0 0 1 0 0 0 0}.
+
+@item 0rdiv
+@item 1rdiv
+@item 2rdiv
+@item 3rdiv
+Set multiplier for calculated value for each plane.
+If unset or 0, it will be sum of all matrix elements.
+The option value must be a float number greater or equal to @code{0.0}. Default value is @code{1.0}.
+
+@item 0bias
+@item 1bias
+@item 2bias
+@item 3bias
+Set bias for each plane. This value is added to the result of the multiplication.
+Useful for making the overall image brighter or darker. 
+The option value must be a float number greater or equal to @code{0.0}. Default value is @code{0.0}.
+
+@item 0mode
+@item 1mode
+@item 2mode
+@item 3mode
+Set matrix mode for each plane. Can be @var{square}, @var{row} or @var{column}.
+Default is @var{square}.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Apply sharpen:
+@example
+-i INPUT -vf "hwupload, convolution_opencl=0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0, hwdownload" OUTPUT
+@end example
+
+@item
+Apply blur:
+@example
+-i INPUT -vf "hwupload, convolution_opencl=1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1/9:1/9:1/9:1/9, hwdownload" OUTPUT
+@end example
+
+@item
+Apply edge enhance:
+@example
+-i INPUT -vf "hwupload, convolution_opencl=0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:5:1:1:1:0:128:128:128, hwdownload" OUTPUT
+@end example
+
+@item
+Apply edge detect:
+@example
+-i INPUT -vf "hwupload, convolution_opencl=0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:5:5:5:1:0:128:128:128, hwdownload" OUTPUT
+@end example
+
+@item
+Apply laplacian edge detector which includes diagonals:
+@example
+-i INPUT -vf "hwupload, convolution_opencl=1 1 1 1 -8 1 1 1 1:1 1 1 1 -8 1 1 1 1:1 1 1 1 -8 1 1 1 1:1 1 1 1 -8 1 1 1 1:5:5:5:1:0:128:128:0, hwdownload" OUTPUT
+@end example
+
+@item
+Apply emboss:
+@example
+-i INPUT -vf "hwupload, convolution_opencl=-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2, hwdownload" OUTPUT
+@end example
+@end itemize
+
+@section overlay_opencl
+
+Overlay one video on top of another.
+
+It takes two inputs and has one output. The first input is the "main"
+video on which the second input is overlaid.
+
+The filter accepts the following options:
+
+@table @option
+
+@item x
+Set the x coordinate of the overlaid video on the main video.
+By default value is @code{0}.
+
+@item y
+Set the x coordinate of the overlaid video on the main video.
+By default value is @code{0}.
+
+@end table
+
+@subsection Example
+
+@itemize
+@item
+Insert a PNG logo in the top-left corner of the input
+@example
+-i INPUT -i LOGO -filter_complex "[0:v]hwupload[a], [1:v]format=yuva420p, hwupload[b], [a][b]overlay_opencl, hwdownload" OUTPUT
+@end example
+@end itemize
+
+@section prewitt_opencl
+
+Apply the Prewitt operator (@url{https://en.wikipedia.org/wiki/Prewitt_operator}) to input video stream.
+
+The filter accepts the following option:
+
+@table @option
+@item planes
+Set which planes will be processed, unprocessed planes will be copied.
+By default value @code{0xf}, all planes will be processed.
+
+@item scale
+Set value which will be multiplied with filtered result.
+Range is @code{[0.0, 65535]} and default value is @code{1.0}.
+
+@item delta
+Set value which will be added to filtered result.
+Range is @code{[-65535, 65535]} and default value is @code{0.0}.
+@end table
+
+@subsection Example
+
+@itemize
+@item
+Apply the Prewitt operator with scale set to 2 and delta set to 10.
+@example
+-i INPUT -vf "hwupload, prewitt_opencl=scale=2:delta=10, hwdownload" OUTPUT
+@end example
+@end itemize
+
+@section roberts_opencl
+Apply the Roberts cross operator (@url{https://en.wikipedia.org/wiki/Roberts_cross}) to input video stream.
+
+The filter accepts the following option:
+
+@table @option
+@item planes
+Set which planes will be processed, unprocessed planes will be copied.
+By default value @code{0xf}, all planes will be processed.
+
+@item scale
+Set value which will be multiplied with filtered result.
+Range is @code{[0.0, 65535]} and default value is @code{1.0}.
+
+@item delta
+Set value which will be added to filtered result.
+Range is @code{[-65535, 65535]} and default value is @code{0.0}.
+@end table
+
+@subsection Example
+
+@itemize
+@item
+Apply the Roberts cross operator with scale set to 2 and delta set to 10
+@example
+-i INPUT -vf "hwupload, roberts_opencl=scale=2:delta=10, hwdownload" OUTPUT
+@end example
+@end itemize
+
+@section sobel_opencl
+
+Apply the Sobel operator (@url{https://en.wikipedia.org/wiki/Sobel_operator}) to input video stream.
+
+The filter accepts the following option:
+
+@table @option
+@item planes
+Set which planes will be processed, unprocessed planes will be copied.
+By default value @code{0xf}, all planes will be processed.
+
+@item scale
+Set value which will be multiplied with filtered result.
+Range is @code{[0.0, 65535]} and default value is @code{1.0}.
+
+@item delta
+Set value which will be added to filtered result.
+Range is @code{[-65535, 65535]} and default value is @code{0.0}.
+@end table
+
+@subsection Example
+
+@itemize
+@item
+Apply sobel operator with scale set to 2 and delta set to 10
+@example
+-i INPUT -vf "hwupload, sobel_opencl=scale=2:delta=10, hwdownload" OUTPUT
+@end example
+@end itemize
+
+@section unsharp_opencl
+
+Sharpen or blur the input video.
+
+It accepts the following parameters:
+
+@table @option
+@item luma_msize_x, lx
+Set the luma matrix horizontal size. It must be an odd integer between
+@code{3} and @code{23}. The default value is @code{5}.
+
+@item luma_msize_y, ly
+Set the luma matrix vertical size. It must be an odd integer between @code{3}
+and @code{23}. The default value is @code{5}.
+
+@item luma_amount, la
+Set the luma effect strength. It must be a floating point number, reasonable
+values lay between @code{-1.5} and @code{1.5}.
+
+Negative values will blur the input video, while positive values will
+sharpen it, a value of zero will disable the effect.
+
+Default value is @code{1.0}.
+
+@item chroma_msize_x, cx
+Set the chroma matrix horizontal size. It must be an odd integer
+between @code{3} and @code{23}. The default value is @code{5}.
+
+@item chroma_msize_y, cy
+Set the chroma matrix vertical size. It must be an odd integer
+between @code{3} and @code{23}. The default value is @code{5}.
+
+@item chroma_amount, ca
+Set the chroma effect strength. It must be a floating point number, reasonable
+values lay between @code{-1.5} and @code{1.5}.
+
+Negative values will blur the input video, while positive values will
+sharpen it, a value of zero will disable the effect.
+
+Default value is @code{0.0}.
+
+@end table
+
+All parameters are optional and default to the equivalent of the
+string '5:5:1.0:5:5:0.0'.
+
+@subsection Examples
+
+@itemize
+@item
+Apply strong luma sharpen effect:
+@example
+-i INPUT -vf "hwupload, unsharp_opencl=luma_msize_x=7:luma_msize_y=7:luma_amount=2.5, hwdownload" OUTPUT
+@end example
+
+@item
+Apply a strong blur of both luma and chroma parameters:
+@example
+-i INPUT -vf "hwupload, unsharp_opencl=7:7:-2:7:7:-2, hwdownload" OUTPUT
+@end example
+@end itemize
+
+@c man end OPENCL VIDEO FILTERS
+
 @chapter Video Sources
 @c man begin VIDEO SOURCES