From patchwork Fri Sep 9 09:55:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sven C. Dack" X-Patchwork-Id: 488 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp229547vsd; Fri, 9 Sep 2016 02:55:25 -0700 (PDT) X-Received: by 10.28.208.130 with SMTP id h124mr2114477wmg.101.1473414925599; Fri, 09 Sep 2016 02:55:25 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id fb17si2212803wjc.230.2016.09.09.02.55.25; Fri, 09 Sep 2016 02:55:25 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sky.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4677E68A093; Fri, 9 Sep 2016 12:55:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nm11-vm2.bullet.mail.ir2.yahoo.com (nm11-vm2.bullet.mail.ir2.yahoo.com [212.82.96.163]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2D2BC689D87 for ; Fri, 9 Sep 2016 12:55:06 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sky.com; s=s1024; t=1473414916; bh=3vKsdc3+AT+X/esbwbWd0zjr8AU6z+pfV0amoSrN+kU=; h=To:From:Subject:Date:From:Subject; b=L3UIbS+SsNOVYcJCDNQE1juk9Ftok9cZpEu6u79XI5i07Bij+PC+45BCfMJC6SyyBm46TkVDQAEjunYBZdb3RDmRTdKRP5OESjnHFkdaFL+bxjkmXmuKZUY/dAv1pc8WcWwN8bYRPDmxEA9tCGrPLUrWF10mH/exbjKi8WC/o1s= Received: from [212.82.98.56] by nm11.bullet.mail.ir2.yahoo.com with NNFMP; 09 Sep 2016 09:55:16 -0000 Received: from [46.228.39.71] by tm9.bullet.mail.ir2.yahoo.com with NNFMP; 09 Sep 2016 09:55:16 -0000 Received: from [127.0.0.1] by smtp108.mail.ir2.yahoo.com with NNFMP; 09 Sep 2016 09:55:16 -0000 X-Yahoo-Newman-Id: 14888.38574.bm@smtp108.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: b08jUt0VM1lEZD7zuqP82P67mOpdRjdZ5czNpGk4mYtiFYF VNrr1QTnI0d9oBzK47jI0UJn6fxid1sGedcMnsyx87duvt7zBHC0zIGotu.8 3B6XRGfLDo6IObrfifeEKvtLc_JeyGmmeZSovso98MlR42u0lw8rbb6NFsDC PZljpqA8VG_qHALijoxqxC6QR9fMRm32JdiHioVrEH5SCve3WNEYM88LX8EN li5gZdGnV7ok9SW05nit1W9yQcwatq8vesU1a_V7QyQq70s9ev8IYiIT6ksI XVkPwvTsE72R.j5kTaKRcXugxnvlIq9hAF6b7Es0ntyjbii8V7RYWqj1ISOT _zVaK7wGzmbkdH98nWvrynPo6nyK175l2.Um87Op41HuizqaEZqzNgxsAg3Y mj66msdSi2yrtN8hxZClXSuJdNfxRb3mBPtMHGsB2uFw5Cv4vufgwJfW5IOe 2zrGygENowS8MCQlW.6a.QD.bnv1F1KexFAHk_nXwE_XatcrFTS_LDF3N0.I .Y0bHsOYTFEa2Dapoehi3qH_6Jfnk7.8D5yHF7.CjtSyRgdsDrF0jjqlcBM2 vFnJhdaM8rQ-- X-Yahoo-SMTP: vPZU.OKswBC.RMkOW9onWi6Zk8BriyC1yj0kMdBuqpLuLjitZVXhzK.Ofd5b To: FFmpeg development discussions and patches From: "Sven C. Dack" Message-ID: <5110d61f-f58f-11f7-df3e-03e4a35ca3e6@sky.com> Date: Fri, 9 Sep 2016 10:55:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.2.0 MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH] Select cubic and lanczos as alternative where super-sampling is not supported X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 From aacd8ecc2f39a45bbfdf6780d9b3b13e6ed0fb41 Mon Sep 17 00:00:00 2001 From: "Sven C. Dack" 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