From patchwork Tue Mar 3 17:00:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 18017 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 37730449B8E for ; Tue, 3 Mar 2020 19:07:26 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1343F68B5F4; Tue, 3 Mar 2020 19:07:26 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DFEC268AF0F for ; Tue, 3 Mar 2020 19:07:19 +0200 (EET) Received: by mail-qk1-f170.google.com with SMTP id z12so4072338qkg.12 for ; Tue, 03 Mar 2020 09:07:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=uvD8ZJxmxTtbhILDXdMNCUOgWvFAF6J8otPrbgwHdKE=; b=DwY7MVgM4IWUSS+aV7/2P57c1Y4FdlFmOETgYdL51ObZCYh5hWsmzKJF+AV9Tauwnz LU0TygNah4UOg4cM0MQu3/idVWp/SBw7CooVMuylefso4oyx5bc4gc/IFKNg1QcHGLXY l0qsZDHU4xmjU67h0TSvOux8YPA8011QDwU5GbLtPf3O/sg1qHN6kkkfehsC+PuCcfBD mWMQPDyPi0zcdNuElxoNoxIZ10STQD51xXm8dZr+utzg0sy6ALNWhg1GhV2OapvWUshk cGQwyVZP5qQmM0LKMNjOrc3UwB3J8KOTObdL4FJGfuiAl4m0CdvqicDYcBiG2Gk3DEDR Tbpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=uvD8ZJxmxTtbhILDXdMNCUOgWvFAF6J8otPrbgwHdKE=; b=DdNv+1AEY+NMLSP1eZ23iDVDFfUahLlUOYLwgB/pRMu99U4dVTUsFoeb1KsG2kITYs YsB1cIyBO6CBc0qAAJWZxMf7OYNmPAh7IbQ4dahgY6ihYpBXuoaTdaa2p49uPj83z0NI V9Zme0NHQ1oT4Wd40UBkeNo47T/xQ+Ed+31H6dEfPVEx+l0ctnGTY5cNcfcmxypb25NJ fDoQ8RbRcAEn5G7GP2/fAl2w/0Bn0I2tlYzDPq+UwCE4qopNf0RhBgkoQ+WC5xAt/vLg TO0h/lw69aKB+RtvDixmiKp6/bOUGAbE1yXcS2v4Vb/tHATYJylTqG90QhVFwhjoJz6T jNjg== X-Gm-Message-State: ANhLgQ0EKCPafOh77qq1oRXRHSV7eiXBLKeM+TTm6ky6xnYeqQKkJmdd BTJvx4cprQ4js7MktmODY6gJzY5w X-Google-Smtp-Source: ADFU+vuZoXIWejksYPfJq5XhuiatjNVs3VTLNtmwVJ+x7FhB3+2IziBg1M+0w2/3eN63QRU85vhsJw== X-Received: by 2002:ac8:4c86:: with SMTP id j6mr5289449qtv.139.1583254927069; Tue, 03 Mar 2020 09:02:07 -0800 (PST) Received: from localhost.localdomain ([191.83.221.116]) by smtp.gmail.com with ESMTPSA id z194sm12542554qkb.28.2020.03.03.09.02.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 09:02:06 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 Mar 2020 14:00:33 -0300 Message-Id: <20200303170033.4543-1-jamrial@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] ffmpeg: remove superfluous custom 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" It's apparently not working, and is a duplicate of the properly implemented nvdec libavcodec hwaccel. Signed-off-by: James Almer --- When i try decoding a sample using -hwaccel cuvid I get [h264 @ 000001ab70730020] decoder->cvdl->cuvidCreateDecoder(&decoder->decoder, params) failed -> CUDA_ERROR_INVALID_VALUE: invalid argument [h264 @ 000001ab70730020] Failed setup for format cuda: hwaccel initialisation returned error That same sample works just fine if i instead use -hwaccel nvdec. And seeing this hwaccel is merely a ffmpeg.c specific implementation using AVHWFramesContext, much like the libavcodec hwaccel, i figured it was best to just remove it and map cuvid to nvdec in order to not break existing cli scripts. The same can probably be done with the VideoToolbox one, but not the QSV as there's no such hwaccel in libavcodec (One should probably be written). fftools/Makefile | 1 - fftools/ffmpeg.h | 2 -- fftools/ffmpeg_cuvid.c | 73 ------------------------------------------ fftools/ffmpeg_opt.c | 5 +-- 4 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 fftools/ffmpeg_cuvid.c diff --git a/fftools/Makefile b/fftools/Makefile index 6cec666dd9..5affaa3f56 100644 --- a/fftools/Makefile +++ b/fftools/Makefile @@ -10,7 +10,6 @@ ALLAVPROGS = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF)) ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF)) OBJS-ffmpeg += fftools/ffmpeg_opt.o fftools/ffmpeg_filter.o fftools/ffmpeg_hw.o -OBJS-ffmpeg-$(CONFIG_CUVID) += fftools/ffmpeg_cuvid.o OBJS-ffmpeg-$(CONFIG_LIBMFX) += fftools/ffmpeg_qsv.o ifndef CONFIG_VIDEOTOOLBOX OBJS-ffmpeg-$(CONFIG_VDA) += fftools/ffmpeg_videotoolbox.o diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 7b6f802082..c0b8eb599f 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -61,7 +61,6 @@ enum HWAccelID { HWACCEL_GENERIC, HWACCEL_VIDEOTOOLBOX, HWACCEL_QSV, - HWACCEL_CUVID, }; typedef struct HWAccel { @@ -654,7 +653,6 @@ int ffmpeg_parse_options(int argc, char **argv); 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/fftools/ffmpeg_cuvid.c b/fftools/ffmpeg_cuvid.c deleted file mode 100644 index 3ff3b40f17..0000000000 --- a/fftools/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/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 3bf90bd20c..1b721c4954 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -72,9 +72,6 @@ const HWAccel hwaccels[] = { #endif #if CONFIG_LIBMFX { "qsv", qsv_init, HWACCEL_QSV, AV_PIX_FMT_QSV }, -#endif -#if CONFIG_CUVID - { "cuvid", cuvid_init, HWACCEL_CUVID, AV_PIX_FMT_CUDA }, #endif { 0 }, }; @@ -822,7 +819,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st); if (hwaccel) { // The NVDEC hwaccels use a CUDA device, so remap the name here. - if (!strcmp(hwaccel, "nvdec")) + if (!strcmp(hwaccel, "nvdec") || !strcmp(hwaccel, "cuvid")) hwaccel = "cuda"; if (!strcmp(hwaccel, "none"))