[FFmpeg-devel] [PATCH 3/3] avfilter/scale_cuda: add CUDA scale filter

Michael Niedermayer michael at niedermayer.cc
Sun May 14 05:01:32 EEST 2017


On Fri, May 12, 2017 at 09:40:16PM +0200, Timo Rothenpieler wrote:
> From: Yogender Gupta <ygupta at nvidia.com>
> 
> ---
>  libavfilter/Makefile         |   1 +
>  libavfilter/allfilters.c     |   1 +
>  libavfilter/vf_scale_cuda.c  | 555 +++++++++++++++++++++++++++++++++++++++++++
>  libavfilter/vf_scale_cuda.cu | 212 +++++++++++++++++
>  4 files changed, 769 insertions(+)
>  create mode 100644 libavfilter/vf_scale_cuda.c
>  create mode 100644 libavfilter/vf_scale_cuda.cu
> 
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index f7dfe8ad54..f177fdb42b 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -267,6 +267,7 @@ OBJS-$(CONFIG_REVERSE_FILTER)                += f_reverse.o
>  OBJS-$(CONFIG_ROTATE_FILTER)                 += vf_rotate.o
>  OBJS-$(CONFIG_SAB_FILTER)                    += vf_sab.o
>  OBJS-$(CONFIG_SCALE_FILTER)                  += vf_scale.o scale.o
> +OBJS-$(CONFIG_SCALE_CUDA_FILTER)             += vf_scale_cuda.o vf_scale_cuda.ptx.o
>  OBJS-$(CONFIG_SCALE_NPP_FILTER)              += vf_scale_npp.o scale.o
>  OBJS-$(CONFIG_SCALE_QSV_FILTER)              += vf_scale_qsv.o
>  OBJS-$(CONFIG_SCALE_VAAPI_FILTER)            += vf_scale_vaapi.o scale.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index cd35ae4c9c..a8939b9094 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -278,6 +278,7 @@ static void register_all(void)
>      REGISTER_FILTER(ROTATE,         rotate,         vf);
>      REGISTER_FILTER(SAB,            sab,            vf);
>      REGISTER_FILTER(SCALE,          scale,          vf);
> +    REGISTER_FILTER(SCALE_CUDA,     scale_cuda,     vf);
>      REGISTER_FILTER(SCALE_NPP,      scale_npp,      vf);
>      REGISTER_FILTER(SCALE_QSV,      scale_qsv,      vf);
>      REGISTER_FILTER(SCALE_VAAPI,    scale_vaapi,    vf);
> diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c
> new file mode 100644
> index 0000000000..1f643197ac
> --- /dev/null
> +++ b/libavfilter/vf_scale_cuda.c
> @@ -0,0 +1,555 @@
> +/*
> +* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
> +*
> +* Permission is hereby granted, free of charge, to any person obtaining a
> +* copy of this software and associated documentation files (the "Software"),
> +* to deal in the Software without restriction, including without limitation
> +* the rights to use, copy, modify, merge, publish, distribute, sublicense,
> +* and/or sell copies of the Software, and to permit persons to whom the
> +* Software is furnished to do so, subject to the following conditions:
> +*
> +* The above copyright notice and this permission notice shall be included in
> +* all copies or substantial portions of the Software.
> +*
> +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> +* DEALINGS IN THE SOFTWARE.
> +*/
> +
> +#include <cuda.h>
> +#include <stdio.h>
> +#include <string.h>
> +
> +#include "libavutil/avstring.h"
> +#include "libavutil/common.h"
> +#include "libavutil/hwcontext.h"
> +#include "libavutil/hwcontext_cuda_internal.h"
> +#include "libavutil/internal.h"
> +#include "libavutil/opt.h"
> +#include "libavutil/pixdesc.h"
> +
> +#include "avfilter.h"
> +#include "formats.h"
> +#include "internal.h"
> +#include "scale.h"
> +#include "video.h"
> +
> +static const enum AVPixelFormat supported_formats[] = {
> +    AV_PIX_FMT_YUV420P,
> +    AV_PIX_FMT_NV12,
> +    AV_PIX_FMT_YUV444P,
> +    AV_PIX_FMT_P010,
> +    AV_PIX_FMT_P016
> +};
> +
> +#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) )

> +#define ALIGN_UP(a, b) ((a + b -1) & ~(b-1))

this is missing () to protect the arguments

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170514/7ad447d2/attachment.sig>


More information about the ffmpeg-devel mailing list