mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-28 12:32:17 +02:00
avcodec/bsf: switch to av_get_token to parse bsf list string
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.
This commit is contained in:
parent
70874e024a
commit
301d275301
@ -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)
|
int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
|
||||||
{
|
{
|
||||||
AVBSFList *lst;
|
AVBSFList *lst;
|
||||||
char *bsf_str, *buf, *dup, *saveptr;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
@ -530,24 +529,18 @@ int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
|
|||||||
if (!lst)
|
if (!lst)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
if (!(dup = buf = av_strdup(str))) {
|
do {
|
||||||
ret = AVERROR(ENOMEM);
|
char *bsf_str = av_get_token(&str, ",");
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (bsf_str = av_strtok(buf, ",", &saveptr)) {
|
|
||||||
ret = bsf_parse_single(bsf_str, lst);
|
ret = bsf_parse_single(bsf_str, lst);
|
||||||
|
av_free(bsf_str);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto end;
|
goto end;
|
||||||
|
} while (*str && *++str);
|
||||||
buf = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = av_bsf_list_finalize(&lst, bsf_lst);
|
ret = av_bsf_list_finalize(&lst, bsf_lst);
|
||||||
end:
|
end:
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
av_bsf_list_free(&lst);
|
av_bsf_list_free(&lst);
|
||||||
av_free(dup);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user