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 3DD8A46381 for ; Mon, 15 May 2023 19:13:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4CBBB68BEBD; Mon, 15 May 2023 22:13:04 +0300 (EEST) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4FFC968B121 for ; Mon, 15 May 2023 22:12:57 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 506F560003 for ; Mon, 15 May 2023 19:12:55 +0000 (UTC) Date: Mon, 15 May 2023 21:12:54 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20230515191254.GP1391451@pb2> References: <20230515000547.1703-1-michael@niedermayer.cc> <20230515000547.1703-2-michael@niedermayer.cc> <44818a16-abab-605a-6348-07d2f258a738@gmail.com> MIME-Version: 1.0 In-Reply-To: <44818a16-abab-605a-6348-07d2f258a738@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH 2/3] avformat: add ff_match_url_ext() 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 Content-Type: multipart/mixed; boundary="===============5507085646334802125==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============5507085646334802125== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="YPYi+6JBnn8IjLOH" Content-Disposition: inline --YPYi+6JBnn8IjLOH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, May 14, 2023 at 11:10:00PM -0400, Leo Izen wrote: > On 5/14/23 20:05, Michael Niedermayer wrote: > > Match url against a list of extensions similar to av_match_ext() > >=20 > > Signed-off-by: Michael Niedermayer > > --- > > libavformat/format.c | 25 +++++++++++++++++++++++++ > > libavformat/internal.h | 9 +++++++++ > > 2 files changed, 34 insertions(+) > >=20 > > diff --git a/libavformat/format.c b/libavformat/format.c > > index 52b814e67d..04fdbacec0 100644 > > --- a/libavformat/format.c > > +++ b/libavformat/format.c > > @@ -50,6 +50,31 @@ int av_match_ext(const char *filename, const char *e= xtensions) > > return 0; > > } > > +int ff_match_url_ext(const char *url, const char *extensions) > > +{ > > + const char *ext; > > + URLComponents uc; > > + int ret; > > + char scratchpad[128]; > > + > > + if (!url) > > + return 0; > > + > > + ret =3D ff_url_decompose(&uc, url, NULL); > > + if (ret < 0 || !URL_COMPONENT_HAVE(uc, scheme)) > > + return ret; > > + for (ext =3D uc.query; *ext !=3D '.' && ext > uc.path; ext--) > > + ; > + > > + if (*ext !=3D '.') > > + return 0; > > + if (uc.query - ext > sizeof(scratchpad)) > > + return AVERROR(ENOMEM); //not enough memory in our scratchpad > > + av_strlcpy(scratchpad, ext + 1, FFMIN(sizeof(scratchpad), uc.query= - ext)); >=20 > This FFMIN is superfluous as sizeof(scratchpad) will always be greater th= an > or equal to uc.query - ext after the check above it. yes, ill remove it, if noone else did it before me >=20 > > + > > + return av_match_name(scratchpad, extensions); > > +} > > + > > const AVOutputFormat *av_guess_format(const char *short_name, const c= har *filename, > > const char *mime_type) > > { > > diff --git a/libavformat/internal.h b/libavformat/internal.h > > index f575064e8f..43466fbe6d 100644 > > --- a/libavformat/internal.h > > +++ b/libavformat/internal.h > > @@ -705,6 +705,15 @@ int ff_unlock_avformat(void); > > */ > > void ff_format_set_url(AVFormatContext *s, char *url); > > +/** > > + * Return a positive value if the given url has one of the given > > + * extensions, 0 otherwise. > > + * > > + * @param filename file name to check against the given extensions >=20 > Copy/paste error, this should be @param url. too late, ive already pushed the patch with this fixed thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. U= ser questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML. --YPYi+6JBnn8IjLOH Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZGKEMQAKCRBhHseHBAsP q3w8AJ9qNLp+Z3xbgZsP4d7UQ7fJNRaIVQCfQLSv7CmEEo6XEZSmXTf9Kkhi6Xc= =EZf/ -----END PGP SIGNATURE----- --YPYi+6JBnn8IjLOH-- --===============5507085646334802125== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============5507085646334802125==--