From patchwork Sat Jul 3 16:54:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 28746 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp2667418ios; Sat, 3 Jul 2021 09:55:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHI5+V8ur9yv6siNNDrC3uY5rU0+1br6BOrPy3ACARbdof1e3yy0SJFWp4ZXlq8o6SfWed X-Received: by 2002:aa7:dd14:: with SMTP id i20mr6069685edv.171.1625331330332; Sat, 03 Jul 2021 09:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625331330; cv=none; d=google.com; s=arc-20160816; b=KiEDJ1oA/rqPByZrMCRz93msJSMDOlrnkL2LbAedlnWLV0BihpC7h3JMe+Y5uAfKhT AMkguE2j3y2uA1tpiA3gSexYBsRbj9NNL3F6VjEW43nVDWM0yWmgJmpyYV249jM2KgMg /JCKlwLbJoDn0rKPzhGrVTVjVBemj6CBVkJJEvVEy+13uEopRh3G/baybb7fdzJIyY7Y 4v1UmMAPHFDjUKQFCokzJHAgQG+7QEaJML0x3Mb+OI5MkjL7EQkkPb0eJp95NTcTfAGU m8yf9I8YdvdPebtWYuxXgu9naQzf7V0npoNQsWP6ClRwQCAkrrdbzEjVKVTu6ZKTkbV9 cTJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=ndfcsHMESiiS91wcKWdNluvDaVQc5l4kPr/w68nZlOs=; b=1Hdx1qCBOcb1XL/tktMMWvvCDtjWlyFtqzWrVQUHUAJ++owmSH7hVBKuG+RWtDKaW+ /WUJtvAOyvsmpVhTZnu0nULj1ULs7PjwUJIY58JrsbAuvosyoyPjzYVQ9MezkVVqNgVC 2lOqCgeo107PNZHBSWzCfrvJWiaBL+2tyWKVr8liYkWKC1C8KroE3GTShd/Uecc2T7oE J9nYSjaGK+xO83XFC5V8lK+xjbIbD83a/bv15VOEBkgm2y+1yUn2faWnjMx28CejvvCY Qz8qwl+vJGOSm7YBSJKkEKOTVlqDhBbF6o8NAey+xQCL1K0sbxsFqZxcatvRw0eBkMOh 8VNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gt37si6202431ejc.122.2021.07.03.09.55.29; Sat, 03 Jul 2021 09:55:30 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3DDBB689A6F; Sat, 3 Jul 2021 19:55:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0097868094F for ; Sat, 3 Jul 2021 19:55:19 +0300 (EEST) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4GHJ3W0n1PzQk95 for ; Sat, 3 Jul 2021 18:55:19 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id eMSUAHZEnCTW for ; Sat, 3 Jul 2021 18:55:15 +0200 (CEST) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Jul 2021 22:24:58 +0530 Message-Id: <20210703165458.1749-1-ffmpeg@gyani.pro> MIME-Version: 1.0 X-MBO-SPAM-Probability: *** X-Rspamd-Score: 3.32 / 15.00 / 15.00 X-Rspamd-Queue-Id: 4190D180C X-Rspamd-UID: 55ca5b Subject: [FFmpeg-devel] [PATCH v2] avcodec/bsf: switch to av_get_token to parse bsf list string 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: HNhAxUQxoJeP The recently added setts bsf makes use of the eval API whose expressions can contain commas. The existing parsing in av_bsf_list_parse_str() uses av_strtok to naively split the string at commas, thus preventing the use of setts filter with expressions containing commas. av_get_token can work with escaped commas, allowing full use of setts. --- libavcodec/bsf.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c index 9d67ea5395..0305244f8d 100644 --- a/libavcodec/bsf.c +++ b/libavcodec/bsf.c @@ -520,7 +520,6 @@ static int bsf_parse_single(char *str, AVBSFList *bsf_lst) int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst) { AVBSFList *lst; - char *bsf_str, *buf, *dup, *saveptr; int ret; if (!str) @@ -530,24 +529,18 @@ int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst) if (!lst) return AVERROR(ENOMEM); - if (!(dup = buf = av_strdup(str))) { - ret = AVERROR(ENOMEM); - goto end; - } - - while (bsf_str = av_strtok(buf, ",", &saveptr)) { + do { + char *bsf_str = av_get_token(&str, ","); ret = bsf_parse_single(bsf_str, lst); + av_free(bsf_str); if (ret < 0) goto end; - - buf = NULL; - } + } while (*str && *++str); ret = av_bsf_list_finalize(&lst, bsf_lst); end: if (ret < 0) av_bsf_list_free(&lst); - av_free(dup); return ret; }