From patchwork Sun Jun 18 23:27:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 4031 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.22.4 with SMTP id 4csp667643vsw; Sun, 18 Jun 2017 16:38:11 -0700 (PDT) X-Received: by 10.223.134.43 with SMTP id 40mr15852162wrv.114.1497829091547; Sun, 18 Jun 2017 16:38:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497829091; cv=none; d=google.com; s=arc-20160816; b=o0wiEUu/IUcTNFoGvwfKZDnW2L1C18lFfgt0QdOEBUM+B6/Aj6CS9feEDe5VtmbElC Jnf222sFpuSz5XXH5HeyP7xrwmkHD6AD0ipcDWhdeziBRIPuTKZgcbyd6VVfwLw/+Q3Z naboMhlkjnpsY5n/3jnjNb0m31YtLinGxm0vVFmJa7MVgZ/TMpBq4tdDwg+XR+uKvGRg BpTDogUzCacbiwpc0OYYh3VMxdeW/JFSO0Fvt6prm5SrYzaDwLyzpW6Ionzg7vdT4kBu rQvdFes2bsqvxwT+xxVJdAXhfQYNw1vMDwC865TWLC1LxDccab3cBrbj26vwPJfbztaS //fg== 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=4fvm+yD29LN8d4kf2VQW4vSCPc6nHi9B1IgRfD0jZo0=; b=bS0PS1vWSkxP985XqU1bHK3My8vwB/M7rNyUn6JIreAdW2YzCPkLsO9x498CEoKUIM +aNFB0rSvlIbrx7WWXiP2tFLsx9yfRFZkZw8xEbW7NcGa3bMHS5/hOywAvlcv2QAh7cO fjrHkDVJXZTcPsWKRS4VCstY+Vd5mk3BTM01gGqcAfJ4LEU6rl2RlGtjIooJG36OEDIG Kt1L8rx+Wb+rXTr59+Z0QZa1JdIyWvV+lx7HkGRZo0ZIlTCIOs4/ySNcdhrIt55/oPgD fhOohcGHPyBAbJX8HAXlYIDX2j4OSWHq5uRTIVj8fb4I+YZOdhjv6/yGm7TNZ98J8/ud oyGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.b=Ublv3cQY; dkim=neutral (body hash did not verify) header.i=@overt.org header.b=tLqOs78z; 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 i22si8149502wrb.314.2017.06.18.16.38.11; Sun, 18 Jun 2017 16:38:11 -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=Ublv3cQY; dkim=neutral (body hash did not verify) header.i=@overt.org header.b=tLqOs78z; 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 36C6668A19E; Mon, 19 Jun 2017 02:37:55 +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 864E668A0FF for ; Mon, 19 Jun 2017 02:37:48 +0300 (EEST) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=overt.org; q=dns/txt; s=k1; t=1497829071; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=/rXP/2mxICYuZHtp1eaNikPqbIVX0WlFp6LrcInFo4Y=; b=Ublv3cQYHDwvRPUVXUeEeY/eduTMUaaJZdnUbSg84uruOJRQwG4DjzU1H7qkhk+PgEW2/eXf GdvgDdF/J0KsrVa+cMPxS4oMuhnz//Lfp87ADUlRi4McgFZRnB10ipZIBLz48WNTuXEoEcGZ DkCOSB4BmeXSCPRaqXw9HrE5Noo= 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=Xv0KHkmS9AyNTisOurINRoi5oyR+kcPxSL4PpdsGdCkzhiQW4E32foiCXQ1tYjZLcfCb6m yzR/+dWbBubn0wXyrYzDXu4ZiM3AIlsDXiGAhoetOXOkil2MBqw4/+wJUkhQAooJzycIqcSw qJJiaGlLw74ntFE9B+ai5cx+6fYQM= 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 59470c6e.7f270c1093b0-smtp-out-n02; Sun, 18 Jun 2017 23:27:42 -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 CA0C560253; Sun, 18 Jun 2017 23:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1497828462; bh=Nlz07jn/mgvW29mj5KA+bpdrV7htR0M2L0WJnpiudpA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tLqOs78z8dQRcFtKBX6xBKTVGsclEPonXciYmezI8Gx645xfZCqqhYRAp5L7ind+g H3quLdqPUijokhdB4is2nRutV1iG0BEQoMpbZrgOi7mdDHGqwMtq2bjcQBwViaBdYo zHl1DUn0frx5BKFY3BNy65zd9s3lJzLLy6adqjNZ+33ln2qPM8sWh66ENAl8sPIHg8 5xlT1SvFk8Y1Xj3mItkL+NvsEf8V0fpSRYrrX1+HrItjD0oNfAXaPcPRVpEELdkqyD W6UPwWL7kvfY7DXFP4JZ0mhf/CempyM4lDmC4T/xMld+Zs/LcGYUc4tSboOxt6+T0a IrUNs2S5GMs9w== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Jun 2017 16:27:29 -0700 Message-Id: <20170618232730.14614-2-philipl@overt.org> In-Reply-To: <20170618232730.14614-1-philipl@overt.org> References: <20170618232730.14614-1-philipl@overt.org> Subject: [FFmpeg-devel] [PATCH 1/2] ffmpeg: Switch cuvid to generic 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" With generic hwaccel, it is additionally necessary to specify the output format. If this is not done, we'll end up downloading the frames back and then re-uploading them. For example: ffmpeg -y -hwaccel cuvid -hwaccel_output_format cuda \ -c:v h264_cuvid -i sample.mp4 \ -c:v h264_nvenc -f rawvideo /dev/null Signed-off-by: Philip Langdale --- Makefile | 1 - ffmpeg.h | 1 - ffmpeg_cuvid.c | 73 ---------------------------------------------------------- ffmpeg_opt.c | 4 ++-- 4 files changed, 2 insertions(+), 77 deletions(-) delete mode 100644 ffmpeg_cuvid.c diff --git a/Makefile b/Makefile index ea90ec8b44..7ba3868fa1 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,6 @@ OBJS-ffmpeg-$(CONFIG_LIBMFX) += ffmpeg_qsv.o ifndef CONFIG_VIDEOTOOLBOX OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_videotoolbox.o endif -OBJS-ffmpeg-$(CONFIG_CUVID) += ffmpeg_cuvid.o OBJS-ffmpeg-$(HAVE_DXVA2_LIB) += ffmpeg_dxva2.o OBJS-ffserver += ffserver_config.o diff --git a/ffmpeg.h b/ffmpeg.h index c3854bcb4a..fa81427471 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -665,7 +665,6 @@ int dxva2_init(AVCodecContext *s); int vda_init(AVCodecContext *s); int videotoolbox_init(AVCodecContext *s); int qsv_init(AVCodecContext *s); -int cuvid_init(AVCodecContext *s); HWDevice *hw_device_get_by_name(const char *name); int hw_device_init_from_string(const char *arg, HWDevice **dev); diff --git a/ffmpeg_cuvid.c b/ffmpeg_cuvid.c deleted file mode 100644 index 3ff3b40f17..0000000000 --- a/ffmpeg_cuvid.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libavutil/hwcontext.h" -#include "libavutil/pixdesc.h" - -#include "ffmpeg.h" - -static void cuvid_uninit(AVCodecContext *avctx) -{ - InputStream *ist = avctx->opaque; - av_buffer_unref(&ist->hw_frames_ctx); -} - -int cuvid_init(AVCodecContext *avctx) -{ - InputStream *ist = avctx->opaque; - AVHWFramesContext *frames_ctx; - int ret; - - av_log(avctx, AV_LOG_VERBOSE, "Initializing cuvid hwaccel\n"); - - if (!hw_device_ctx) { - ret = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_CUDA, - ist->hwaccel_device, NULL, 0); - if (ret < 0) { - av_log(avctx, AV_LOG_ERROR, "Error creating a CUDA device\n"); - return ret; - } - } - - av_buffer_unref(&ist->hw_frames_ctx); - ist->hw_frames_ctx = av_hwframe_ctx_alloc(hw_device_ctx); - if (!ist->hw_frames_ctx) { - av_log(avctx, AV_LOG_ERROR, "Error creating a CUDA frames context\n"); - return AVERROR(ENOMEM); - } - - frames_ctx = (AVHWFramesContext*)ist->hw_frames_ctx->data; - - frames_ctx->format = AV_PIX_FMT_CUDA; - frames_ctx->sw_format = avctx->sw_pix_fmt; - frames_ctx->width = avctx->width; - frames_ctx->height = avctx->height; - - av_log(avctx, AV_LOG_DEBUG, "Initializing CUDA frames context: sw_format = %s, width = %d, height = %d\n", - av_get_pix_fmt_name(frames_ctx->sw_format), frames_ctx->width, frames_ctx->height); - - ret = av_hwframe_ctx_init(ist->hw_frames_ctx); - if (ret < 0) { - av_log(avctx, AV_LOG_ERROR, "Error initializing a CUDA frame pool\n"); - return ret; - } - - ist->hwaccel_uninit = cuvid_uninit; - - return 0; -} diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index bb6001f534..6dc4ad43d2 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -91,8 +91,8 @@ const HWAccel hwaccels[] = { AV_HWDEVICE_TYPE_VAAPI }, #endif #if CONFIG_CUVID - { "cuvid", cuvid_init, HWACCEL_CUVID, AV_PIX_FMT_CUDA, - AV_HWDEVICE_TYPE_NONE }, + { "cuvid", hwaccel_decode_init, HWACCEL_CUVID, AV_PIX_FMT_CUDA, + AV_HWDEVICE_TYPE_CUDA }, #endif { 0 }, };