[FFmpeg-devel] [PATCH] CUDA Scale Filter

Timo Rothenpieler timo at rothenpieler.org
Thu May 11 12:46:49 EEST 2017


Am 10.05.2017 um 19:26 schrieb Yogender Gupta:
> Please find attached a patch for CUDA Scale Filter. I have modified the makefiles as suggested during the previous reviews to have all PTX generated during compile time.
> 
> Common.mak has changes for PTX generation
> Ptx2c.sh has been added in ffbuild folder. This is needed to covert PTX to C
> Users would be required to only include .c and .cu files when adding new CUDA filters.
> 
> Was tested under MingW.
> 
> Thanks,
> Yogender

This looks a lot better, thanks!

Some thought on this:
The CU2C = ... line seems to be an unused leftover?

The ptx2c.sh file can probably also be greatly simplified, as the C file
it generates can just include config.h and check for

#if ARCH_X86_64 || ARCH_PPC64

Eliminating most of the detection logic, as configure already takes care
of that.
But even that might be unneeded entirely, as that variable is also
available to the Makefile in ffbuild/config.mak, so the Makefile can
build only the correct .ptx file from the beginning, eliminating all the
arch logic from the .ptx.c file.
Would also be nice because of:
"nvcc warning : Compiling in the 32-bit mode when the host compiler
targets x86 or x86_64 is no longer supported on Linux"

This fails a plain ./configure build if you don't have the CUDA SDK in
your PATH and INCLUDE/LIB paths.
This is kind of due to the nature --enable-cuda not actually requiring
the CUDA SDK, but being satisfied by the bundled headers.
My idea for this situation would be to introduce a new flag,
--enable-cuda-sdk, which is disabled by default and if enabled requires
cuda.h and -lcuda (and whatever other libs might be needed).

Typo in ptx2c.sh:
done < libavfilter/libavfilter/${1}_32.ptx

I also suspect this might cause issues with out-of-tree builds, an mkdir
-p libavfilter might be needed.

Appropriate .gitignore entries for .ptx and .ptx.c files are needed, so
git does not list them as unversioned files.


Some comments on the filter code itself:

There seem to be quite a few unused variables in the CUDAScaleContext.

Entirely unused:
interp_algo, cu_event, format_str, w, h, shift_width, shift_height

cu_stream is never set to anything, but passed to cuLaunchKernel, can
probably just pass NULL.
format is only ever initialized to AV_PIX_FMT_NONE, and then never
changed again.


More information about the ffmpeg-devel mailing list