Commit 1c6a9199 authored by Paul B Mahol's avatar Paul B Mahol

avfilter: add pad opencl filter

parent 6d37ca8a
......@@ -35,6 +35,7 @@ version <next>:
- xfade video filter
- xfade_opencl filter
- afirsrc audio filter source
- pad_opencl filter
version 4.2:
......
......@@ -3535,6 +3535,7 @@ overlay_qsv_filter_deps="libmfx"
overlay_qsv_filter_select="qsvvpp"
overlay_vulkan_filter_deps="vulkan libglslang"
owdenoise_filter_deps="gpl"
pad_opencl_filter_deps="opencl"
pan_filter_deps="swresample"
perspective_filter_deps="gpl"
phase_filter_deps="gpl"
......
......@@ -21172,6 +21172,83 @@ The inputs have same memory layout for color channels , the overlay has addition
@end itemize
@section pad_opencl
Add paddings to the input image, and place the original input at the
provided @var{x}, @var{y} coordinates.
It accepts the following options:
@table @option
@item width, w
@item height, h
Specify an expression for the size of the output image with the
paddings added. If the value for @var{width} or @var{height} is 0, the
corresponding input size is used for the output.
The @var{width} expression can reference the value set by the
@var{height} expression, and vice versa.
The default value of @var{width} and @var{height} is 0.
@item x
@item y
Specify the offsets to place the input image at within the padded area,
with respect to the top/left border of the output image.
The @var{x} expression can reference the value set by the @var{y}
expression, and vice versa.
The default value of @var{x} and @var{y} is 0.
If @var{x} or @var{y} evaluate to a negative number, they'll be changed
so the input image is centered on the padded area.
@item color
Specify the color of the padded area. For the syntax of this option,
check the @ref{color syntax,,"Color" section in the ffmpeg-utils
manual,ffmpeg-utils}.
@item aspect
Pad to an aspect instead to a resolution.
@end table
The value for the @var{width}, @var{height}, @var{x}, and @var{y}
options are expressions containing the following constants:
@table @option
@item in_w
@item in_h
The input video width and height.
@item iw
@item ih
These are the same as @var{in_w} and @var{in_h}.
@item out_w
@item out_h
The output width and height (the size of the padded area), as
specified by the @var{width} and @var{height} expressions.
@item ow
@item oh
These are the same as @var{out_w} and @var{out_h}.
@item x
@item y
The x and y offsets as specified by the @var{x} and @var{y}
expressions, or NAN if not yet specified.
@item a
same as @var{iw} / @var{ih}
@item sar
input sample aspect ratio
@item dar
input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
@end table
@section prewitt_opencl
Apply the Prewitt operator (@url{https://en.wikipedia.org/wiki/Prewitt_operator}) to input video stream.
......
......@@ -329,6 +329,7 @@ OBJS-$(CONFIG_OVERLAY_QSV_FILTER) += vf_overlay_qsv.o framesync.o
OBJS-$(CONFIG_OVERLAY_VULKAN_FILTER) += vf_overlay_vulkan.o vulkan.o
OBJS-$(CONFIG_OWDENOISE_FILTER) += vf_owdenoise.o
OBJS-$(CONFIG_PAD_FILTER) += vf_pad.o
OBJS-$(CONFIG_PAD_OPENCL_FILTER) += vf_pad_opencl.o opencl.o opencl/pad.o
OBJS-$(CONFIG_PALETTEGEN_FILTER) += vf_palettegen.o
OBJS-$(CONFIG_PALETTEUSE_FILTER) += vf_paletteuse.o framesync.o
OBJS-$(CONFIG_PERMS_FILTER) += f_perms.o
......
......@@ -313,6 +313,7 @@ extern AVFilter ff_vf_overlay_qsv;
extern AVFilter ff_vf_overlay_vulkan;
extern AVFilter ff_vf_owdenoise;
extern AVFilter ff_vf_pad;
extern AVFilter ff_vf_pad_opencl;
extern AVFilter ff_vf_palettegen;
extern AVFilter ff_vf_paletteuse;
extern AVFilter ff_vf_perms;
......
/*
* 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
*/
const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE |
CLK_FILTER_NEAREST;
__kernel void pad (
__read_only image2d_t src,
__write_only image2d_t dst,
float4 color,
int2 xy)
{
int2 size_src = get_image_dim(src);
int2 loc = (int2)(get_global_id(0), get_global_id(1));
int2 src_pos = (int2)(get_global_id(0) - xy.x, get_global_id(1) - xy.y);
float4 pixel = loc.x >= size_src.x + xy.x ||
loc.y >= size_src.y + xy.y ||
loc.x < xy.x ||
loc.y < xy.y ? color : read_imagef(src, sampler, src_pos);
write_imagef(dst, loc, pixel);
}
......@@ -27,6 +27,7 @@ extern const char *ff_opencl_source_deshake;
extern const char *ff_opencl_source_neighbor;
extern const char *ff_opencl_source_nlmeans;
extern const char *ff_opencl_source_overlay;
extern const char *ff_opencl_source_pad;
extern const char *ff_opencl_source_tonemap;
extern const char *ff_opencl_source_transpose;
extern const char *ff_opencl_source_unsharp;
......
......@@ -30,7 +30,7 @@
#include "libavutil/version.h"
#define LIBAVFILTER_VERSION_MAJOR 7
#define LIBAVFILTER_VERSION_MINOR 75
#define LIBAVFILTER_VERSION_MINOR 76
#define LIBAVFILTER_VERSION_MICRO 100
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment