diff mbox

[FFmpeg-devel] Select cubic and lanczos as alternative where super-sampling is not supported

Message ID 5110d61f-f58f-11f7-df3e-03e4a35ca3e6@sky.com
State Superseded
Headers show

Commit Message

Sven C. Dack Sept. 9, 2016, 9:55 a.m. UTC
CUDA/NPP doesn't allow super-sampling in some cases and the module then prints 
an error message "NPP resize error: -23".

Example:
$ ffmpeg -f lavfi -i testsrc=duration=1:size=hd1080:rate=1 -pix_fmt nv12 -vf 
hwupload_cuda,scale_npp=w=1920:h=720:interp_algo=super:format=nv12,hwdownload -f 
null -
ffmpeg version N-81609-g7b3bc36 Copyright (c) 2000-2016 the FFmpeg developers
   built with gcc 6.2.0 (GCC)
   configuration: --prefix=/home/sven/av --enable-gpl --enable-version3 
--enable-nonfree --arch=x86_64 --cpu=native --enable-debug --disable-shared 
--enable-static --enable-libvorbis --enable-libopus --enable-libx264 
--enable-libx265 --enable-opengl --enable-opencl --enable-vaapi --enable-vdpau 
--enable-cuda --enable-cuvid --enable-nvenc --enable-libnpp 
--extra-cflags='-I/home/sven/av/include -I/usr/local/cuda/include 
-I/usr/local/Video_Codec_SDK_7.0.1/Samples/common/inc' 
--extra-ldflags='-L/home/sven/av/lib -L/usr/local/cuda/lib64' --ar=gcc-ar 
--nm=gcc-nm --ranlib=true
   libavutil      55. 29.100 / 55. 29.100
   libavcodec     57. 55.101 / 57. 55.101
   libavformat    57. 48.103 / 57. 48.103
   libavdevice    57.  0.102 / 57.  0.102
   libavfilter     6. 61.100 /  6. 61.100
   libswscale      4.  1.100 /  4.  1.100
   libswresample   2.  1.100 /  2.  1.100
   libpostproc    54.  0.100 / 54.  0.100
Input #0, lavfi, from 'testsrc=duration=1:size=hd1080:rate=1':
   Duration: N/A, start: 0.000000, bitrate: N/A
     Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1920x1080 [SAR 
1:1 DAR 16:9], 1 tbr, 1 tbn, 1 tbc
[null @ 0x36aa440] Using AVStream.codec to pass codec parameters to muxers is 
deprecated, use AVStream.codecpar instead.
Output #0, null, to 'pipe:':
   Metadata:
     encoder         : Lavf57.48.103
     Stream #0:0: Video: wrapped_avframe, nv12, 1920x720 [SAR 2:3 DAR 16:9], 
q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc
     Metadata:
       encoder         : Lavc57.55.101 wrapped_avframe
Stream mapping:
   Stream #0:0 -> #0:0 (rawvideo (native) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
[Parsed_scale_npp_1 @ 0x3ae8fa0] NPP resize error: -23
Failed to inject frame into filter network: Unknown error occurred
Conversion failed!

Super-sampling is currently only supported by CUDA/NPP when the output 
dimensions are both smaller than the input dimensions. The patch lets ffmpeg 
select an alternative algorithm and prints a warning in such cases.

Sven

Comments

Carl Eugen Hoyos Sept. 9, 2016, 10:03 a.m. UTC | #1
2016-09-09 11:55 GMT+02:00 Sven C. Dack <sven.c.dack@sky.com>:

> Super-sampling is currently only supported by CUDA/NPP when the output
> dimensions are both smaller than the input dimensions. The patch lets ffmpeg
> select an alternative algorithm and prints a warning in such cases.

Tabs (as in your patch) cannot be committed to our git repository, please
remove them.
You can use the script tools/patcheck to find them.

Carl Eugen
Sven C. Dack Oct. 14, 2016, 11:32 a.m. UTC | #2
*ping*

The patch didn't seem to have caught anyone's interest. Could somebody please 
apply it or say what's wrong?

Thanks

On 09/09/16 10:55, Sven C. Dack wrote:
> CUDA/NPP doesn't allow super-sampling in some cases and the module then prints 
> an error message "NPP resize error: -23".
>
> Example:
> $ ffmpeg -f lavfi -i testsrc=duration=1:size=hd1080:rate=1 -pix_fmt nv12 -vf 
> hwupload_cuda,scale_npp=w=1920:h=720:interp_algo=super:format=nv12,hwdownload 
> -f null -
> ffmpeg version N-81609-g7b3bc36 Copyright (c) 2000-2016 the FFmpeg developers
>   built with gcc 6.2.0 (GCC)
>   configuration: --prefix=/home/sven/av --enable-gpl --enable-version3 
> --enable-nonfree --arch=x86_64 --cpu=native --enable-debug --disable-shared 
> --enable-static --enable-libvorbis --enable-libopus --enable-libx264 
> --enable-libx265 --enable-opengl --enable-opencl --enable-vaapi --enable-vdpau 
> --enable-cuda --enable-cuvid --enable-nvenc --enable-libnpp 
> --extra-cflags='-I/home/sven/av/include -I/usr/local/cuda/include 
> -I/usr/local/Video_Codec_SDK_7.0.1/Samples/common/inc' 
> --extra-ldflags='-L/home/sven/av/lib -L/usr/local/cuda/lib64' --ar=gcc-ar 
> --nm=gcc-nm --ranlib=true
>   libavutil      55. 29.100 / 55. 29.100
>   libavcodec     57. 55.101 / 57. 55.101
>   libavformat    57. 48.103 / 57. 48.103
>   libavdevice    57.  0.102 / 57.  0.102
>   libavfilter     6. 61.100 /  6. 61.100
>   libswscale      4.  1.100 /  4.  1.100
>   libswresample   2.  1.100 /  2.  1.100
>   libpostproc    54.  0.100 / 54.  0.100
> Input #0, lavfi, from 'testsrc=duration=1:size=hd1080:rate=1':
>   Duration: N/A, start: 0.000000, bitrate: N/A
>     Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1920x1080 [SAR 
> 1:1 DAR 16:9], 1 tbr, 1 tbn, 1 tbc
> [null @ 0x36aa440] Using AVStream.codec to pass codec parameters to muxers is 
> deprecated, use AVStream.codecpar instead.
> Output #0, null, to 'pipe:':
>   Metadata:
>     encoder         : Lavf57.48.103
>     Stream #0:0: Video: wrapped_avframe, nv12, 1920x720 [SAR 2:3 DAR 16:9], 
> q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc
>     Metadata:
>       encoder         : Lavc57.55.101 wrapped_avframe
> Stream mapping:
>   Stream #0:0 -> #0:0 (rawvideo (native) -> wrapped_avframe (native))
> Press [q] to stop, [?] for help
> [Parsed_scale_npp_1 @ 0x3ae8fa0] NPP resize error: -23
> Failed to inject frame into filter network: Unknown error occurred
> Conversion failed!
>
> Super-sampling is currently only supported by CUDA/NPP when the output 
> dimensions are both smaller than the input dimensions. The patch lets ffmpeg 
> select an alternative algorithm and prints a warning in such cases.
>
> Sven
>
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
diff mbox

Patch

From aacd8ecc2f39a45bbfdf6780d9b3b13e6ed0fb41 Mon Sep 17 00:00:00 2001
From: "Sven C. Dack" <sven@debian-linux.no.domain>
Date: Fri, 9 Sep 2016 10:18:07 +0100
Subject: [PATCH] Select cubic and lanczos as alternative where super-sampling
 is not supported

---
 libavfilter/vf_scale_npp.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_scale_npp.c b/libavfilter/vf_scale_npp.c
index 68cee39..82ba2f4 100644
--- a/libavfilter/vf_scale_npp.c
+++ b/libavfilter/vf_scale_npp.c
@@ -294,9 +294,21 @@  static int init_processing_chain(AVFilterContext *ctx, int in_width, int in_heig
 
     /* figure out which stages need to be done */
     if (in_width != out_width || in_height != out_height ||
-        in_deinterleaved_format != out_deinterleaved_format)
+        in_deinterleaved_format != out_deinterleaved_format) {
         s->stages[STAGE_RESIZE].stage_needed = 1;
 
+	if (s->interp_algo == NPPI_INTER_SUPER &&
+	    (out_width > in_width && out_height > in_height)) {
+	    s->interp_algo = NPPI_INTER_LANCZOS;
+	    av_log(ctx, AV_LOG_WARNING, "super-sampling not supported for output dimensions, using lanczos instead.\n");
+	}
+	if (s->interp_algo == NPPI_INTER_SUPER &&
+	    !(out_width < in_width && out_height < in_height)) {
+	    s->interp_algo = NPPI_INTER_CUBIC;
+	    av_log(ctx, AV_LOG_WARNING, "super-sampling not supported for output dimensions, using cubic instead.\n");
+	}
+    }
+
     if (!s->stages[STAGE_RESIZE].stage_needed && in_format == out_format)
         s->passthrough = 1;
 
-- 
2.9.3