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 D7699437FB for ; Wed, 29 Jun 2022 06:34:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 87E0B68B6A1; Wed, 29 Jun 2022 09:34:03 +0300 (EEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 82D3068AF1C for ; Wed, 29 Jun 2022 09:33:55 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656484441; x=1688020441; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=IYR8XUwKlj+wHdhMoBWYkmfNO1QamE/XcqsEP+Vc2eA=; b=QoZqc4w/cBjLxVWa1O3TSnz3jkmleTedryE5mF7kelJz+/UAOh4ALCeM LMLT2yxXaRtGv1O4c6BJetKZY2aVuEKqgjeZVq7/FA6yKVcgnghGoIr8I acw7S6Qd1COVf7ZgpOcLW5BTskpQ3FKG0f+KDLkb3+/WVxOlm9Wm4RTp7 WgBF50u1nZAK+U2Aw+BJ1XINiNrJKb1MciJQs0s+BG+oxLmsqdmQb3+bZ m84fcQj7BKQKMX8/15oTVjsQYpe1+HhfMLl+sY90YaGajVIKbXx7niTn9 9aCwCLBYHuC2DCd0d1wZAGfDuz0PkhHSSTNux8ffRiOhwtFypHniALuDB Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10392"; a="281973012" X-IronPort-AV: E=Sophos;i="5.92,230,1650956400"; d="scan'208";a="281973012" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 23:33:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,230,1650956400"; d="scan'208";a="595108599" Received: from desktop-qn7n0nf.sh.intel.com (HELO localhost.localdomain) ([10.239.160.39]) by fmsmga007.fm.intel.com with ESMTP; 28 Jun 2022 23:33:52 -0700 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Wed, 29 Jun 2022 14:32:44 +0800 Message-Id: <20220629063246.183-1-tong1.wu@intel.com> X-Mailer: git-send-email 2.35.1.windows.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] 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 | 12 ++++++++++++ libavutil/hwcontext.h | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index ab9ad3703e..3521ed34f4 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -80,6 +80,18 @@ static const char *const hw_type_names[] = { [AV_HWDEVICE_TYPE_VULKAN] = "vulkan", }; +enum AVHWDeviceType av_hwdevice_get_type_by_pix_fmt(enum AVPixelFormat fmt) +{ + int i, j; + for (i = 0; hw_table[i]; i++) { + for (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..97f94403e2 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -229,6 +229,15 @@ typedef struct AVHWFramesContext { int width, height; } AVHWFramesContext; +/** + * Get the device type by a given pixel format. + * + * @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".