From patchwork Sun Jan 22 23:20:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Koshevoy X-Patchwork-Id: 2286 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp998392vsb; Sun, 22 Jan 2017 15:20:22 -0800 (PST) X-Received: by 10.223.153.98 with SMTP id x89mr20494328wrb.181.1485127222048; Sun, 22 Jan 2017 15:20:22 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 7si12014247wmz.24.2017.01.22.15.20.21; Sun, 22 Jan 2017 15:20:22 -0800 (PST) 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=@gmail.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E5B15689E70; Mon, 23 Jan 2017 01:20:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 39EEF689BEC for ; Mon, 23 Jan 2017 01:19:59 +0200 (EET) Received: by mail-pf0-f196.google.com with SMTP id f144so8768950pfa.2 for ; Sun, 22 Jan 2017 15:20:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JjpAoSgwIy1TsoSR2aTlHUzS6Qry0a31+c2S/ZR1u+E=; b=QaCtHgpGtfFnazbkknrPl5obOjT4MgFUwlKHBW7iz4/qBsCeecK/fFzQ3raNGgzeMC 7KSQdbZhq/JagDfi8wj+7LSSKOiVUjHYHc+fEtPoBuXtbUZ00Z2OSnaCKL7agJ/3/Cni ZgqtTcypm8T5MezruDBZjtUF/C6IaFfoPbzqSbHQre7CNtfunzqxZPsUnsLuZlvIqLQb IZDeCbyaS7Q8UbAVgu2lO+uVuK6RX6xegmkGsVM362SVNUqlpffeSLTMH4okM5MHT1Kb HAbrg0vsfNOI/WtRKuKShMsk7+97fUEacSuThF5irkUaznYMiPL+zT3vdwNVJSCCkUSk fDGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JjpAoSgwIy1TsoSR2aTlHUzS6Qry0a31+c2S/ZR1u+E=; b=ctp1yyOu/5EGNx7rgtE4fbXN/gBmPlqWrHs1BwlM7iejz7u1wnvUnbHH3ADsPsCI+R OHQL1KXPmAuVjkqdLL7yQksvea6zQCDmezLrtQJGnWHZmlmhKN4ZNuQ78uJn8TLHbtwc 0IAfld5AhE4512L0B3Px5R85n31rq/S8jZ7hbKCktNqPA45iraUXGINIJjgRi7bkWwxi DR/j/MFxSqg+LDkKrtoA6IK5We6E/SIsMNeDXMRAIGiflJ1LLF0aRyuZkhmzRltp+x3W OwwMZriX8UWakSTPY2CqgXivaQwNJRCv1q3aLPue45+QgcimNMKkXI6dS774XLTpSmeD z4xA== X-Gm-Message-State: AIkVDXJpnkzzw6XHf5Pcg0nc3ZAh8gtZXS6ukVYj3FKsdK4/PaXyNM4BT1TUFXS0w89wRw== X-Received: by 10.99.185.74 with SMTP id v10mr28586169pgo.98.1485127209717; Sun, 22 Jan 2017 15:20:09 -0800 (PST) Received: from homestead.aragog.com ([136.60.170.51]) by smtp.gmail.com with ESMTPSA id q26sm31575733pfk.94.2017.01.22.15.20.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Jan 2017 15:20:09 -0800 (PST) From: pkoshevoy@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Jan 2017 16:20:05 -0700 Message-Id: <1485127205-14995-1-git-send-email-pkoshevoy@gmail.com> X-Mailer: git-send-email 2.6.6 In-Reply-To: <20170122114051.365cc008@fido6> References: <20170122114051.365cc008@fido6> Subject: [FFmpeg-devel] [PATCH] lavc/cuvid: fail early if GPU can't handle video resolution (v5) 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 Cc: Pavel Koshevoy MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Pavel Koshevoy CUVID on GeForce GT 730 and GeForce GTX 1060 does not report any when decoding 8K h264 packets. However, it does return an error during cuvidCreateDecoder call if the indicated video resolution is not supported. Given that stream resolution is typically known as a result of probing it is better to use this information during avcodec_open2 call to fail immediately, rather than proceeding to decode and never receiving any frames from the decoder nor receiving any indication of decode failure. --- libavcodec/cuvid.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c index 8fc713d..9b35476 100644 --- a/libavcodec/cuvid.c +++ b/libavcodec/cuvid.c @@ -612,7 +612,10 @@ static av_cold int cuvid_decode_end(AVCodecContext *avctx) return 0; } -static int cuvid_test_dummy_decoder(AVCodecContext *avctx, CUVIDPARSERPARAMS *cuparseinfo) +static int cuvid_test_dummy_decoder(AVCodecContext *avctx, + const CUVIDPARSERPARAMS *cuparseinfo, + int probed_width, + int probed_height) { CuvidContext *ctx = avctx->priv_data; CUVIDDECODECREATEINFO cuinfo; @@ -625,8 +628,8 @@ static int cuvid_test_dummy_decoder(AVCodecContext *avctx, CUVIDPARSERPARAMS *cu cuinfo.ChromaFormat = cudaVideoChromaFormat_420; cuinfo.OutputFormat = cudaVideoSurfaceFormat_NV12; - cuinfo.ulWidth = 1280; - cuinfo.ulHeight = 720; + cuinfo.ulWidth = probed_width; + cuinfo.ulHeight = probed_height; cuinfo.ulTargetWidth = cuinfo.ulWidth; cuinfo.ulTargetHeight = cuinfo.ulHeight; @@ -669,6 +672,9 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx) AV_PIX_FMT_NV12, AV_PIX_FMT_NONE }; + int probed_width = avctx->coded_width ? avctx->coded_width : 1280; + int probed_height = avctx->coded_height ? avctx->coded_height : 720; + // Accelerated transcoding scenarios with 'ffmpeg' require that the // pix_fmt be set to AV_PIX_FMT_CUDA early. The sw_pix_fmt, and the // pix_fmt for non-accelerated transcoding, do not need to be correct @@ -824,7 +830,9 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx) if (ret < 0) goto error; - ret = cuvid_test_dummy_decoder(avctx, &ctx->cuparseinfo); + ret = cuvid_test_dummy_decoder(avctx, &ctx->cuparseinfo, + probed_width, + probed_height); if (ret < 0) goto error;