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 3EBD443827 for ; Thu, 30 Jun 2022 08:43:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BED5A68B2BA; Thu, 30 Jun 2022 11:43:24 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5C05168AF8A for ; Thu, 30 Jun 2022 11:43:17 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5F901240179; Thu, 30 Jun 2022 10:43:16 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id PUnpc3cHxDZK; Thu, 30 Jun 2022 10:43:15 +0200 (CEST) Received: from lain.khirnov.net (lain.khirnov.net [IPv6:2001:67c:1138:4306::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "lain.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id C698A2400F5; Thu, 30 Jun 2022 10:43:15 +0200 (CEST) Received: by lain.khirnov.net (Postfix, from userid 1000) id 2C7741601B2; Thu, 30 Jun 2022 10:43:16 +0200 (CEST) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: <20220630024558.1444-1-tong1.wu@intel.com> References: <20220630024558.1444-1-tong1.wu@intel.com> Mail-Followup-To: FFmpeg development discussions and patches , Tong Wu Date: Thu, 30 Jun 2022 10:43:16 +0200 Message-ID: <165657859616.10358.12321681270835950968@lain.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v2 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: Quoting Tong Wu (2022-06-30 04:45:56) > 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; Nit: you can and should declare loop indices in the loop statement itself > + 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); I wonder if we should consider the possibility of a format being supported by more than one device type. -- Anton Khirnov _______________________________________________ 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".