[FFmpeg-devel] [PATCH] avcodec/bsf: switch to av_get_token to parse bsf list string
Gyan Doshi
ffmpeg at gyani.pro
Sat Jul 3 14:42:22 EEST 2021
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.
---
libavcodec/bsf.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index 9d67ea5395..726911785d 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -520,7 +520,8 @@ 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;
+ char *bsf_str, *dup;
+ const char *buf;
int ret;
if (!str)
@@ -530,18 +531,18 @@ int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
if (!lst)
return AVERROR(ENOMEM);
- if (!(dup = buf = av_strdup(str))) {
+ if (!(buf = dup = av_strdup(str))) {
ret = AVERROR(ENOMEM);
goto end;
}
- while (bsf_str = av_strtok(buf, ",", &saveptr)) {
+ do {
+ bsf_str = av_get_token(&buf, ",");
ret = bsf_parse_single(bsf_str, lst);
+ av_free(bsf_str);
if (ret < 0)
goto end;
-
- buf = NULL;
- }
+ } while (*buf == ',' && buf++);
ret = av_bsf_list_finalize(&lst, bsf_lst);
end:
--
2.32.0
More information about the ffmpeg-devel
mailing list