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 CEA9E45E9B for ; Mon, 15 May 2023 03:10:13 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 63D9C68BFFC; Mon, 15 May 2023 06:10:10 +0300 (EEST) Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E9D2668BD8B for ; Mon, 15 May 2023 06:10:03 +0300 (EEST) Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-ba6fc11831dso729380276.1 for ; Sun, 14 May 2023 20:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684120201; x=1686712201; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Gr+g0Pspj87BTVehwYEJTDpD5zYnlhT98V+ah4E5O7w=; b=RZ2A8os/k79ed0GFhEGW29JYL65jYVxy4WVnKSXXI/8XwSklMTNetx50YPXW3u3uW5 zZ3D6/UFdI55qNL2T7qwPuQUzVVpAWGV/7Zo7kf/Cuctr91oil2Be5WNs224lyIfPep7 aRzbIFjjv+tSy2XlLaZbySpAG7gAMqGBXie8x6lfOTTZRozjsvkEHbM2Dl4tfpnbkxo4 TuzWmuXIrd2bYI6mCFXd8tpv5C/s1HegxhHWdCr1PE7muglg0vZ4kWGJPLicJRE59LQf 06TUDB+9Teno0olObRNIBQ8tGWeC5sRZyDdDPuVAi8t30z9OwOWkDjLQKBivpv/SGLo7 VUng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684120201; x=1686712201; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Gr+g0Pspj87BTVehwYEJTDpD5zYnlhT98V+ah4E5O7w=; b=jPMSzKEl55oL+Kx9PjAcQ+1R9azH4dtRynEYrYtIfmK7R5+wl5hyQIIzasuYOXJ19S oKDza2ULYI6SF2TFwTh8IIT1PfbbU1wLIh6O/iykObhJ4vJZbBnJDQHshMco4AVI9PzV O7WBcQWRXihKtOcvDO1p40S5UKLjVEkF0r/MuZT1EOSycDEmLGdLSIh7ueMNOftD9ArZ mZQIYT0RMwh7v7cowudaceNR7wPNtpRfCWGoqxSTCynQFjlk+Gs8I9JzWc7etq+g4qqw +aQa3919T9A9iicYGX32pwV4+6GEVsC3sajlSbaR/WeVxbtfqePjq7y1Zq7fUlRiTVkq ngFw== X-Gm-Message-State: AC+VfDwdL+e06bBpSJSnl2BW6/HBqcnUwzokX/3VJf+0Uaby9e04NFoR PFNgyb6u+rXWO5rXS/9WCDcrITHhwHc= X-Google-Smtp-Source: ACHHUZ7yFnoQSoTRkhHrEtByNQ/rOOntcLWOJKy2pBhxZuZn7VDozYrDwvCU9+vgPZPO9NW35QOCwQ== X-Received: by 2002:a81:1786:0:b0:55a:6115:98f5 with SMTP id 128-20020a811786000000b0055a611598f5mr28515175ywx.1.1684120201471; Sun, 14 May 2023 20:10:01 -0700 (PDT) Received: from [192.168.1.35] (c-98-224-219-15.hsd1.mi.comcast.net. [98.224.219.15]) by smtp.gmail.com with ESMTPSA id r129-20020a818187000000b0055a7c2375dfsm7424148ywf.101.2023.05.14.20.10.00 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 14 May 2023 20:10:01 -0700 (PDT) Message-ID: <44818a16-abab-605a-6348-07d2f258a738@gmail.com> Date: Sun, 14 May 2023 23:10:00 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-US-large To: ffmpeg-devel@ffmpeg.org References: <20230515000547.1703-1-michael@niedermayer.cc> <20230515000547.1703-2-michael@niedermayer.cc> From: Leo Izen In-Reply-To: <20230515000547.1703-2-michael@niedermayer.cc> 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 5/14/23 20:05, Michael Niedermayer wrote: > Match url against a list of extensions similar to av_match_ext() > > Signed-off-by: Michael Niedermayer > --- > libavformat/format.c | 25 +++++++++++++++++++++++++ > libavformat/internal.h | 9 +++++++++ > 2 files changed, 34 insertions(+) > > 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 *extensions) > 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 = ff_url_decompose(&uc, url, NULL); > + if (ret < 0 || !URL_COMPONENT_HAVE(uc, scheme)) > + return ret; > + for (ext = uc.query; *ext != '.' && ext > uc.path; ext--) > + ; > + > + if (*ext != '.') > + 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)); This FFMIN is superfluous as sizeof(scratchpad) will always be greater than or equal to uc.query - ext after the check above it. > + > + return av_match_name(scratchpad, extensions); > +} > + > const AVOutputFormat *av_guess_format(const char *short_name, const char *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 Copy/paste error, this should be @param url. > + * @param extensions a comma-separated list of filename extensions > + */ > +int ff_match_url_ext(const char *url, const char *extensions); > + > struct FFOutputFormat; > void avpriv_register_devices(const struct FFOutputFormat * const o[], const AVInputFormat * const i[]); > _______________________________________________ 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".