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 6078C43993 for ; Mon, 4 Jul 2022 08:11:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AD11B68B9CA; Mon, 4 Jul 2022 11:11:12 +0300 (EEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5606668B844 for ; Mon, 4 Jul 2022 11:11:05 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656922270; x=1688458270; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=X67rUWLColLJTpR48nmyqHn2fB4QpDP+iB34C77FqVs=; b=l9oVwIWJNWGb5WiZanHMxvWx1Vy2d0XwKVUXSJITFFcCJZaWmSs42JaZ aJHzPkjUwEFssVa61fqHF+O2Qz9fYOwYM78hipGkCWi9IgY5nFNrHMhvO jnKUk3oCAUB5/yzf+OYcIN9jSgqkFuUpfROPggoe2qmyitt4lX5EJKUki PJU5A+6/4NyJw2JdrCO7KmSWDzuVuxyBqMJxBqb3mbdgKeHSvxz+ZbCFL 9gbuBIKjIzGTWXL4oFb60SLMZKd1FbDNTrGDWwLGd30OoDW9lJJS5VYsh 8m5+5SxMcTVwpMeIm00pgQcn78e97jXEABMWE0mxpGOwbJgcUngjJIbXj Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10397"; a="262861127" X-IronPort-AV: E=Sophos;i="5.92,243,1650956400"; d="scan'208";a="262861127" 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:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,243,1650956400"; d="scan'208";a="660122900" 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:02 -0700 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Jul 2022 16:09:53 +0800 Message-Id: <20220704080957.425-1-tong1.wu@intel.com> X-Mailer: git-send-email 2.35.1.windows.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 1/5] avutil/hwcontext: add a function to get the AVHWDeviceType 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: Add a function to get the corresponding AVHWDeviceType from a given hardware pixel format. Signed-off-by: Tong Wu --- libavutil/hwcontext.c | 11 +++++++++++ libavutil/hwcontext.h | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index ab9ad3703e..4d14cb2cb4 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -80,6 +80,17 @@ static const char *const hw_type_names[] = { [AV_HWDEVICE_TYPE_VULKAN] = "vulkan", }; +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum AVPixelFormat fmt) +{ + for (int i = 0; hw_table[i]; i++) { + for (int j = 0; hw_table[i]->pix_fmts[j] != AV_PIX_FMT_NONE; j++) { + if (hw_table[i]->pix_fmts[j] == fmt) + return hw_table[i]->type; + } + } + return AV_HWDEVICE_TYPE_NONE; +} + enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name) { int type; diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index c18b7e1e8b..49f3a799ed 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -229,6 +229,18 @@ typedef struct AVHWFramesContext { int width, height; } AVHWFramesContext; +/** + * Get the device type by a given pixel format. + * + * This function only returns a preferred device type which supports the given + * pixel format. There is no guarantee that the device type is unique. + * + * @param fmt Pixel format from enum AVPixelFormat. + * @return The type from enum AVHWDeviceType, or AV_HWDEVICE_TYPE_NONE if + * not found. + */ +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum AVPixelFormat fmt); + /** * Look up an AVHWDeviceType by name. * -- 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".