From patchwork Fri Jun 16 14:41:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 4001 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.22.4 with SMTP id 4csp1324870vsw; Fri, 16 Jun 2017 07:52:38 -0700 (PDT) X-Received: by 10.28.142.211 with SMTP id q202mr7619766wmd.76.1497624758291; Fri, 16 Jun 2017 07:52:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497624758; cv=none; d=google.com; s=arc-20160816; b=NAFXT2vCUcg90AG3zdLDhO3qiwcCqcMR8pdWE6lQ3UXxxGvFPy6tM8wa7AgJt/SnIu fz5LCBFxRnWUhfoxvqw6jGrKjh3bA1xMQU1xLBt0FG5zXtcvYdA28hNXOuuyj0p4Itr1 WgZ1+vWNi8oUzOzxND8NfkO7JesYYK2bZezq80vhm2KhBh6h4EO38s2++bRKMEwcGIC1 hLFO4SUkTKFe3KGTrMlf6aYIpCrtpVWVAyoRj9esHvQztxJ4pG0iTKat3U52gG3OM3eh EvXKBqDhKt19x+MAS/gjx1SVOgFzCh6QxxBkVaX0WFiCo81fCicdGX6kM7KNlAXhkrMq PZTA== 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=OCFErEhPUOJzse3Y/SGQQmGlibqiq3rjN6LoVusJZzo1SNBzkdNYhTiHS2BolGjK+7 tbNOf1og/AIlPsOd2uYwYPAjqcX3Qj2Du/or9NSKvSRRtcd68P+c3OQup4BLN71s41Ho vFNRWf5H2kwBfRXSoNnCRZ0CsUSbsii3ckL40JJrrJIQcjbq27lXFsDPgrMzlNcklqQW cLFmRG4p8uB3xkW099bHxRw+vUB89KnNXE6Qs7wsTk+Mq8S9VbMIJ4RdQEWCMmG+rzHI T2OVBbJuCWMS6SklQczhMgAWFz+1zYRvHM1GnIq01e5UjayDnvsQ0X5NC7kzlK8X6Ch4 exrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.b=nyA0tro/; dkim=neutral (body hash did not verify) header.i=@overt.org header.b=f176P4wy; 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 10si3431897wmf.11.2017.06.16.07.52.37; Fri, 16 Jun 2017 07:52:38 -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=nyA0tro/; dkim=neutral (body hash did not verify) header.i=@overt.org header.b=f176P4wy; 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 D949068A24E; Fri, 16 Jun 2017 17:52:21 +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 5982768A216 for ; Fri, 16 Jun 2017 17:52:15 +0300 (EEST) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=overt.org; q=dns/txt; s=k1; t=1497624737; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=/rXP/2mxICYuZHtp1eaNikPqbIVX0WlFp6LrcInFo4Y=; b=nyA0tro/JDUJQsG9cYiaWd17spmuV/gTFbjpI7Hz0rOe81hNG/SkejMahMBDm/4cQuajH7vt wQ6HaxYPiQkRKTQczR1pERUGnCi7evtHq2+npkKPMoRj0QeQkk+4ZVeI3ULN/owVgQG746rl 2ms3l+mYW6CI3gHFipp3ABo/U7o= 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=CagWgkWJaw//y62dEB74OcG0EWTK+FrN886PJ4rT3ZQyDK84lfAan+Om12lvOKcxA5dJ7M MApB3epjrssU6T4JN94Oey0jLMmHRBkVDXpq/t+CCzC6NyAkttOMQEDV/nMTAdM7kjzN6c5f 7DulLMlEnnLJ4LgoZIpodCBWkbS+A= 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 5943ee19.7ffa9c677d18-smtp-out-n02; Fri, 16 Jun 2017 14:41:29 -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 9734B600FE; Fri, 16 Jun 2017 14:41:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1497624088; bh=Nlz07jn/mgvW29mj5KA+bpdrV7htR0M2L0WJnpiudpA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f176P4wy/guNl14n8EpPPci4XUs4pgygsQaUQEr4X/JrRvyKQKJBU4dHagYblqqaP YL6ndcJAepUMyUjpQprfuUsc1/PRYNGdx7NspXQ7EGkNlEb3Evpbbhamv47ODkKlim 5OwPYtp5mmGKpkJBvrufPOilFk1luF1eiQBxmTB7JYzN1s6jZZqioy14Rq1uT8pJVZ 8+TaJ5IPOnmzjpyYJyxi6AIRYxuA2mwNpANRarl+yuXAMBWXDO/mmKJ2uB4ryv+nl1 7hnSFiCq/ZitU6N7r1V3KIL90ZhUX7PRktALtNGCnPu3HazhfDSg5HJrWvPX3qx7Me xuP8HOxdNX/MQ== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2017 07:41:09 -0700 Message-Id: <20170616144109.3224-2-philipl@overt.org> In-Reply-To: <20170616144109.3224-1-philipl@overt.org> References: <20170616144109.3224-1-philipl@overt.org> Subject: [FFmpeg-devel] [PATCH 1/1] 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 }, };