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 2BF1D45829 for ; Tue, 25 Apr 2023 07:30:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 489DB68BBFD; Tue, 25 Apr 2023 10:30:08 +0300 (EEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2233B68B681 for ; Tue, 25 Apr 2023 10:30:00 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682407806; x=1713943806; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=HJDdNtvpNRh3dbUo5WArmnTRUurDJfuuIiuMXdUVk+Y=; b=Rft6GL/dcjyuE+E5qF6gKW8PW+h8qgolh8t7Gl+We0cmbLUcXoMtaGsu abaZfhS05ZRuxmIsrBnG4a4+CatoS4KDUEEn4x23+Y6GQEH2YAdAPJMiN q2D53GMgHeViR/nCtK7Lo1B71WDgGo/oxG4HChZCKMdXhDOHHbQQ/4D2T indRAK5NOHvgmWMfO9QLfxcrayylJmX3ctFLaj623TRkz65bV/HwnSoVV VEQIJ5s8eotfMutIPRjPUfMBvjxQjhUbXxS6yV/6X+hjx76Wov4yEViC/ JKjD0dwXDN9Bb+YWRKCMDc1mQSK79J4o5uVKozXLFwkaVCFYz3wWZ0gO8 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10690"; a="374630971" X-IronPort-AV: E=Sophos;i="5.99,224,1677571200"; d="scan'208";a="374630971" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2023 00:29:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10690"; a="867798300" X-IronPort-AV: E=Sophos;i="5.99,224,1677571200"; d="scan'208";a="867798300" Received: from desktop-qn7n0nf.sh.intel.com (HELO localhost.localdomain) ([10.239.160.59]) by orsmga005.jf.intel.com with ESMTP; 25 Apr 2023 00:29:56 -0700 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Apr 2023 15:26:16 +0800 Message-Id: <20230425072620.512-1-tong1.wu@intel.com> X-Mailer: git-send-email 2.39.1.windows.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v5 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 3396598269..3042bf9af0 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 7ff08c8608..940c7a6a46 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.39.1.windows.1 _______________________________________________ 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".