From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id B89954222F for ; Thu, 30 Jun 2022 02:47:33 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A1A7B68B7A1; Thu, 30 Jun 2022 05:47:25 +0300 (EEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 137F268B791 for ; Thu, 30 Jun 2022 05:47:17 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656557243; x=1688093243; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VTVU6VTM9SA0K33No4B79KdBGL9MhosH2TQTkdpLHeI=; b=Ktj7n7atFYRVoSfoIqtjRsmCH6oIkQvuHGzvr7DU9aCm34cI5uuLzLrS GWJgj5Xub5VV59n1uK/EGSYWSA+XX+nZgxs3ybC43XMlQxi7ZPfJqX10d YhmNt4vWdNYAie5WT9KRUJV/Nae4SmoIs26e9Bpv3bZ+/S09xtbciUj1s f/1GUDgTm1iHIuhDgR6vZkoWdvvgLsDGx2N4fyJE2vVlqZWBqyadjk25E 0miywq3PlfsUK84LHCwrLVXdgUR7zV0HPutOte/4F0CeF4z7CW/+wcC9V 3pvTIlcqXrP/FOb+I7JUTJOEajC677mpRZuUP0BBmRcUUIsVAt6Dk3A7i w==; X-IronPort-AV: E=McAfee;i="6400,9594,10393"; a="265257546" X-IronPort-AV: E=Sophos;i="5.92,232,1650956400"; d="scan'208";a="265257546" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2022 19:47:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,232,1650956400"; d="scan'208";a="837387148" Received: from desktop-qn7n0nf.sh.intel.com (HELO localhost.localdomain) ([10.239.160.39]) by fmsmga006.fm.intel.com with ESMTP; 29 Jun 2022 19:47:13 -0700 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Thu, 30 Jun 2022 10:45:57 +0800 Message-Id: <20220630024558.1444-2-tong1.wu@intel.com> X-Mailer: git-send-email 2.35.1.windows.2 In-Reply-To: <20220630024558.1444-1-tong1.wu@intel.com> References: <20220630024558.1444-1-tong1.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/3] 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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 | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_hwmap.c b/libavfilter/vf_hwmap.c index 2e03dfc1fe..136980c982 100644 --- a/libavfilter/vf_hwmap.c +++ b/libavfilter/vf_hwmap.c @@ -70,23 +70,32 @@ 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); + hwfc->device_ref, 0); if (err < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to created derived " - "device context: %d.\n", err); + "device context: %d.\n", err); goto fail; } device_is_derived = 1; -- 2.35.1.windows.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".