From patchwork Sat Jun 24 23:40:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 4106 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.76 with SMTP id 73csp302128vsb; Sat, 24 Jun 2017 16:50:41 -0700 (PDT) X-Received: by 10.28.236.19 with SMTP id k19mr3680950wmh.30.1498348241720; Sat, 24 Jun 2017 16:50:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498348241; cv=none; d=google.com; s=arc-20160816; b=Mc+wmKuJwthoFTQyDtjSKaqLf2pu9SEHohYOA2WGHqvX+X19mrl96S2oujnRgnap65 uhlaLJ6xwxFmC6C86a/pGz/BZwN3tSuV2jfNJEK5B6eS8veW0sB33kSIiUtb4MBjIc4H GYo/ZZxXxyS9KiZiFui/KFiMP2juDUfYhLcC4aCVIpG2jvQG9bk5xpELlhZta4CgO6Go MrwywslJ0n7nGra3YM53crc1L+hydvlcd97cDtPqofdLkA93dJW2ODe9v85FohIIPFP/ t4d6idwNhn1ouiazhbLVgq2tEoX/3/vG+2v20QckemTXz9YU20j6DzeQd3ULyEGGDmgF FATA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:domainkey-signature:dkim-signature :delivered-to:arc-authentication-results; bh=ZJXL7jD9L1JnIMjQ+Nk4DrpdpKn9YXJkQb4bKfBDv2U=; b=vmiJKXh3MU298vzvsyrwt7vpwt7Q2hpOGP0ZodMVcNytcezYM1bc77w2Fs80hTmybj uHcUqm4VvVGI4H+yVCryIMYENXDXY4SGLjYUKvkAwgmvFRM4SEh1bDPDU+8HCnwX4d2u ypLHk65Abf4s5c0yHR4UvBylXLisXLR7wXeUIX0//1nb73ZMV/g9R2IyXfNwmw0FFR86 oId/Wdoh+McMoIaGKKPD/FcY4lCSuOarz1h/R320LvxzA8CPN5v43C8/YV3Y/bgwKKzg bcY/5JSWnt/Jj8+QrkV0B1G/FpgUlmTFBH0+buXimtI0jAMSmce6pL3wrPjeaHmuqJjN oUMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.b=Uvk1jhmO; dkim=neutral (body hash did not verify) header.i=@overt.org header.b=CQnTTBko; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v52si8080470wrc.210.2017.06.24.16.50.41; Sat, 24 Jun 2017 16:50:41 -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=@overt.org header.b=Uvk1jhmO; dkim=neutral (body hash did not verify) header.i=@overt.org header.b=CQnTTBko; 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 1938268A176; Sun, 25 Jun 2017 02:50:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-s67.mailgun.info (mail-s67.mailgun.info [184.173.153.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 93C2568839A for ; Sun, 25 Jun 2017 02:50:22 +0300 (EEST) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=overt.org; q=dns/txt; s=k1; t=1498348222; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=d0Mpo9xLm9sHF+PdwI2YMnjxlQrCWg/7OdeFHqteb4k=; b=Uvk1jhmOmxzhMVCoJQ5XmwWsPN+evWaGAl7zSwDH6eteRol3ujAd7sPMEXKDhxO/7OeLUQqU JLMNe1yy4feD1OFusMUrufCvu0nNhCZ+0NpB0PZAjTa00Ncw5TOINu2JV9Oxa+SyVi4S3fbV YEPqnNqtaOzew3UbL11hiVp7tCs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=overt.org; s=k1; q=dns; h=Sender: From: To: Cc: Subject: Date: Message-Id: In-Reply-To: References; b=Me3WG0lt1HzIsKkzBV39oMY1+Ab27uP3kx13vfdib9khMQseK7jW44HXmx/5RTuaze5tf5 HwMU7hzrfUhnEQutYZlyyj4swjwqBBaSdffm0sLqmGGQnTthkMAMo5KoUK1J1Egw6suz8jQ7 EQTY243zam1LAfmryirHopXZTn2N4= X-Mailgun-Sending-Ip: 184.173.153.195 X-Mailgun-Sid: WyIyM2Q3MCIsICJmZm1wZWctZGV2ZWxAZmZtcGVnLm9yZyIsICI0YTg5NjEiXQ== Received: from mail.overt.org (155.208.178.107.bc.googleusercontent.com [107.178.208.155]) by mxa.mailgun.org with ESMTP id 594ef85d.7f308c14fdc0-smtp-out-n03; Sat, 24 Jun 2017 23:40:13 -0000 (UTC) Received: from authenticated-user (mail.overt.org [107.178.208.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id E7C886360A; Sat, 24 Jun 2017 23:40:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1498347613; bh=vCdXcl1JjBhkmoXdeWypsN4tC0gnio7iNikoI9GX/g4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CQnTTBkoffOUrRRQ4RXPhpKY2tuvG0+q0mPiJw5bDY10eZ8iumpv16hoxhZXqiNE+ pGxxvqRMBuVm6iHAwpPMhe7Y2WmhVjuBkBx7epTA27iPXIcVck8n/Ux4tDcJr9L8ps +Q8F5IpB9ZHsKauAfRdPJ5TgdWF6QPP+2dZQTzqrEYGIpkCPF73NRLiDZ9XSyBBgSm vwqWupM6s7j0JQht6MXbRwr0OaNYHTdKkZO2HWt9sVNkgBTINJEJC53In79LoEsA6T xo48srezcxfMZjsA3kMKAf+6sCNpaSgQ2fA/elaXUkX/7lUZVzpM+2IfEK+Nq2sqFz oSE+cts17VzCQ== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Sat, 24 Jun 2017 16:40:03 -0700 Message-Id: <20170624234003.25615-3-philipl@overt.org> In-Reply-To: <20170624234003.25615-1-philipl@overt.org> References: <20170624234003.25615-1-philipl@overt.org> Subject: [FFmpeg-devel] [PATCH 2/2] ffmpeg: Require output format when using cuvid hwaccel 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: Philip Langdale MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This is another approach to dealing with the behavioural change when switching to generic hwaccel. Full hardware transcoding will not happen if no output format is specified, where this was not true previously. So, let's force the user to deal with this change by refusing to run without an output format. Signed-off-by: Philip Langdale --- ffmpeg.h | 1 + ffmpeg_opt.c | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ffmpeg.h b/ffmpeg.h index fa81427471..1a0aec5862 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -76,6 +76,7 @@ typedef struct HWAccel { enum HWAccelID id; enum AVPixelFormat pix_fmt; enum AVHWDeviceType device_type; + int require_output_format; } HWAccel; typedef struct HWDevice { diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 6dc4ad43d2..abdd8bae58 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -68,31 +68,38 @@ const HWAccel hwaccels[] = { #if HAVE_VDPAU_X11 { "vdpau", hwaccel_decode_init, HWACCEL_VDPAU, AV_PIX_FMT_VDPAU, - AV_HWDEVICE_TYPE_VDPAU }, + AV_HWDEVICE_TYPE_VDPAU, + .require_output_format = 0 }, #endif #if HAVE_DXVA2_LIB { "dxva2", dxva2_init, HWACCEL_DXVA2, AV_PIX_FMT_DXVA2_VLD, - AV_HWDEVICE_TYPE_NONE }, + AV_HWDEVICE_TYPE_NONE, + .require_output_format = 0 }, #endif #if CONFIG_VDA { "vda", videotoolbox_init, HWACCEL_VDA, AV_PIX_FMT_VDA, - AV_HWDEVICE_TYPE_NONE }, + AV_HWDEVICE_TYPE_NONE, + .require_output_format = 0 }, #endif #if CONFIG_VIDEOTOOLBOX { "videotoolbox", videotoolbox_init, HWACCEL_VIDEOTOOLBOX, AV_PIX_FMT_VIDEOTOOLBOX, - AV_HWDEVICE_TYPE_NONE }, + AV_HWDEVICE_TYPE_NONE, + .require_output_format = 0 }, #endif #if CONFIG_LIBMFX { "qsv", qsv_init, HWACCEL_QSV, AV_PIX_FMT_QSV, - AV_HWDEVICE_TYPE_NONE }, + AV_HWDEVICE_TYPE_NONE, + .require_output_format = 0 }, #endif #if CONFIG_VAAPI { "vaapi", hwaccel_decode_init, HWACCEL_VAAPI, AV_PIX_FMT_VAAPI, - AV_HWDEVICE_TYPE_VAAPI }, + AV_HWDEVICE_TYPE_VAAPI, + .require_output_format = 0 }, #endif #if CONFIG_CUVID { "cuvid", hwaccel_decode_init, HWACCEL_CUVID, AV_PIX_FMT_CUDA, - AV_HWDEVICE_TYPE_CUDA }, + AV_HWDEVICE_TYPE_CUDA, + .require_output_format = 1 }, #endif { 0 }, }; @@ -708,6 +715,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) char *discard_str = NULL; const AVClass *cc = avcodec_get_class(); const AVOption *discard_opt = av_opt_find(&cc, "skip_frame", NULL, 0, 0); + int require_output_format; if (!ist) exit_program(1); @@ -805,6 +813,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) for (i = 0; hwaccels[i].name; i++) { if (!strcmp(hwaccels[i].name, hwaccel)) { ist->hwaccel_id = hwaccels[i].id; + require_output_format = hwaccels[i].require_output_format; break; } } @@ -836,6 +845,12 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output " "format: %s", hwaccel_output_format); } + } else if (require_output_format) { + av_log(NULL, AV_LOG_FATAL, "No hwaccel output format specified. " + "Specify one using -hwaccel_output_format. To enable full " + "hardware transcoding with cuvid/nvenc, use the 'cuda' " + "format.\n"); + exit_program(1); } else { ist->hwaccel_output_format = AV_PIX_FMT_NONE; }