From patchwork Mon Jul 4 08:09:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Tong1" X-Patchwork-Id: 36641 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp2666269pzh; Mon, 4 Jul 2022 01:11:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vA1LC6EaUcyY1BwL2soQ/QVB9Sfa4ItGSf3an5glNZKU2SlgEnQzmGez0WTpYL08dJGEO+ X-Received: by 2002:a05:6402:2741:b0:434:fe8a:1f96 with SMTP id z1-20020a056402274100b00434fe8a1f96mr37930637edd.331.1656922289172; Mon, 04 Jul 2022 01:11:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656922289; cv=none; d=google.com; s=arc-20160816; b=n7VwSh5JQ7MvwHkDlP3sZGEkdLzSbye4he35ix6l6bbWTw5Mgw6FQpST76HYISZBTG JJlrUDyYE0t4Cho0EZyYqZdZ5i8dZ1zdla0aUZGNmGPkeGsgyeFXUi2ZvuZ/3yyXou9G HDS3bIbJE/DxdYdPo0R+NqyG79HpFHTh8grAzTP+rKA1zGyxf0z4JM5JrDyt9r6mPgXd 3ajhgTa0YTenEYG8ITAsaZ65pV9JvsaK9fnfpt1Me3hSwDiUfGYiSRLtoopXo/DH/pkZ dAZzFBudX0B/GZ755bJdSIPAfxdWBoQ9xHUZQ/OdQRFbtFCU9EVO+SBl2EIIRqhtB/xf pPKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=njHaXZf5l/1L6XsThpyr0BRHVMD0iicBBJG2r5JBKJY=; b=gF0wf9uWeFat8PR53goeRkij1GFGUdegOvK5E8IMn4K4GWKLZAUnZtoKYbKNLSIk8F SSCMFT1g+Rm5YGmK6glhVE/kQrsth9eMUkt9OmPSi6uKY18H/jwA0sGJsVD+uWFcwGnZ v/8ZF42+boYY8ykGQtZUVFc3aq13S/KBjn9L4IcIvTSstmPVVQfAtWnWN3PFQehbELJJ Ad+SrISR9nQ9zXu4v18n8oQ05G7brOBNU/T9/V15pbyp5K1nhn7yX2ZHKkcH5/BACCw3 rqgm9d3SplZmLHloGvYs5ebVfZs0Ifa3kY74B2zMjfsZny7kZ1mSSRX4aQawbKNtqxxA VdRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=Rv94aaGp; 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 i24-20020a05640200d800b0042df92502a1si8291173edu.329.2022.07.04.01.11.28; Mon, 04 Jul 2022 01:11:29 -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=@intel.com header.s=Intel header.b=Rv94aaGp; 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 3B75B68B9E8; Mon, 4 Jul 2022 11:11:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4149E68B320 for ; Mon, 4 Jul 2022 11:11:07 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656922272; x=1688458272; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fPZ87X4OL+EVQ1rCHSoguqWAsxkiSM5XnwOhtEYcza0=; b=Rv94aaGpwoL0ntVtmcOA2xs7R35/1GhlCBmia18Yj4D4B9xQlThFsYdU eEeh9fHFJpvSa/bA1aHz7G3ftpJjbwDSg4Uim892qiEVPWbxRkhzovqPg 7njoq6DK8br2CobLD+CSVpWnXPrR59ESLo+SrEE1eVXqbQ/W400eDTrrK /YQrfz4Ah/ETNYDu6ClKrX+LNuGj5SCHg0Lb1a/mKVNEeRkb5sUspdlpo QrJqvYgWFLyF1Uf/1T//QcLgEe4m3ewKmgM1ylgvA+qce5Q/mUCmYzhen 5/hedQT1917EPhQr1ZOjPK/h7jJETDDgRMsgMthCVtLMEAr+M4FOV9UZJ g==; X-IronPort-AV: E=McAfee;i="6400,9594,10397"; a="262861131" X-IronPort-AV: E=Sophos;i="5.92,243,1650956400"; d="scan'208";a="262861131" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2022 01:11:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,243,1650956400"; d="scan'208";a="660122906" Received: from desktop-qn7n0nf.sh.intel.com (HELO localhost.localdomain) ([10.239.160.39]) by fmsmga004.fm.intel.com with ESMTP; 04 Jul 2022 01:11:03 -0700 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Jul 2022 16:09:54 +0800 Message-Id: <20220704080957.425-2-tong1.wu@intel.com> X-Mailer: git-send-email 2.35.1.windows.2 In-Reply-To: <20220704080957.425-1-tong1.wu@intel.com> References: <20220704080957.425-1-tong1.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 2/5] avfilter/vf_hwmap: get the AVHWDeviceType from outlink format X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Tong Wu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 6Wevc0LFmdg+ When a derive_device_type is not specified, the hwmap filter should be able to retrieve AVHWDeviceType from outlink->format and create corresponding hwdevice context. Signed-off-by: Tong Wu --- libavfilter/vf_hwmap.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_hwmap.c b/libavfilter/vf_hwmap.c index 2e03dfc1fe..328395e352 100644 --- a/libavfilter/vf_hwmap.c +++ b/libavfilter/vf_hwmap.c @@ -70,18 +70,27 @@ static int hwmap_config_output(AVFilterLink *outlink) device_is_derived = 0; if (inlink->hw_frames_ctx) { + enum AVHWDeviceType type; hwfc = (AVHWFramesContext*)inlink->hw_frames_ctx->data; if (ctx->derive_device_type) { - enum AVHWDeviceType type; - type = av_hwdevice_find_type_by_name(ctx->derive_device_type); if (type == AV_HWDEVICE_TYPE_NONE) { av_log(avctx, AV_LOG_ERROR, "Invalid device type.\n"); err = AVERROR(EINVAL); goto fail; } + } else { + type = av_hwdevice_get_type_by_pix_fmt(outlink->format); + if (type == AV_HWDEVICE_TYPE_NONE) { + av_log(avctx, AV_LOG_ERROR, "Could not get device type from " + "format %s.\n", av_get_pix_fmt_name(outlink->format)); + err = AVERROR(EINVAL); + goto fail; + } + } + if (!device || ctx->derive_device_type) { err = av_hwdevice_ctx_create_derived(&device, type, hwfc->device_ref, 0); if (err < 0) {