mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-28 12:32:17 +02:00
af_format: prefer strtok_r() over strsep()
strsep() is not POSIX compliant, and thus not supported on some platform. Fix compilation on Solaris.
This commit is contained in:
parent
a719679561
commit
86ca51acb0
1
configure
vendored
1
configure
vendored
@ -1501,6 +1501,7 @@ tcp_protocol_deps="network"
|
|||||||
udp_protocol_deps="network"
|
udp_protocol_deps="network"
|
||||||
|
|
||||||
# filters
|
# filters
|
||||||
|
aformat_filter_deps="strtok_r"
|
||||||
blackframe_filter_deps="gpl"
|
blackframe_filter_deps="gpl"
|
||||||
boxblur_filter_deps="gpl"
|
boxblur_filter_deps="gpl"
|
||||||
cropdetect_filter_deps="gpl"
|
cropdetect_filter_deps="gpl"
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
* format audio filter
|
* format audio filter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _BSD_SOURCE
|
|
||||||
#include "libavutil/audioconvert.h"
|
#include "libavutil/audioconvert.h"
|
||||||
|
#include "libavutil/avstring.h"
|
||||||
#include "avfilter.h"
|
#include "avfilter.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
@ -35,51 +35,74 @@ typedef struct {
|
|||||||
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
|
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
|
||||||
{
|
{
|
||||||
AFormatContext * const aformat = ctx->priv;
|
AFormatContext * const aformat = ctx->priv;
|
||||||
char *arg, *fmt_str;
|
char *fmts_str = NULL, *fmt_str, *ptr = NULL;
|
||||||
int64_t fmt;
|
int64_t fmt;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
arg = strsep(&args, ":");
|
if (!args)
|
||||||
if (!arg) goto arg_fail;
|
goto arg_fail;
|
||||||
if (!strcmp(arg, "all")) {
|
|
||||||
|
fmts_str = av_get_token(&args, ":");
|
||||||
|
if (!fmts_str || !*fmts_str)
|
||||||
|
goto arg_fail;
|
||||||
|
if (!strcmp(fmts_str, "all")) {
|
||||||
aformat->formats = avfilter_all_formats(AVMEDIA_TYPE_AUDIO);
|
aformat->formats = avfilter_all_formats(AVMEDIA_TYPE_AUDIO);
|
||||||
} else {
|
} else {
|
||||||
while (fmt_str = strsep(&arg, ",")) {
|
for (fmt_str = fmts_str;
|
||||||
if ((ret = ff_parse_sample_format((int*)&fmt, fmt_str, ctx)) < 0)
|
fmt_str = strtok_r(fmt_str, ",", &ptr); fmt_str = NULL) {
|
||||||
|
if ((ret = ff_parse_sample_format((int*)&fmt, fmt_str, ctx)) < 0) {
|
||||||
|
av_freep(&fmts_str);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
avfilter_add_format(&aformat->formats, fmt);
|
avfilter_add_format(&aformat->formats, fmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
av_freep(&fmts_str);
|
||||||
|
|
||||||
arg = strsep(&args, ":");
|
if (*args)
|
||||||
if (!arg) goto arg_fail;
|
args++;
|
||||||
if (!strcmp(arg, "all")) {
|
fmts_str = av_get_token(&args, ":");
|
||||||
|
if (!fmts_str || !*fmts_str)
|
||||||
|
goto arg_fail;
|
||||||
|
if (!strcmp(fmts_str, "all")) {
|
||||||
aformat->chlayouts = avfilter_all_channel_layouts();
|
aformat->chlayouts = avfilter_all_channel_layouts();
|
||||||
} else {
|
} else {
|
||||||
while (fmt_str = strsep(&arg, ",")) {
|
for (fmt_str = fmts_str;
|
||||||
if ((ret = ff_parse_channel_layout(&fmt, fmt_str, ctx)) < 0)
|
fmt_str = strtok_r(fmt_str, ",", &ptr); fmt_str = NULL) {
|
||||||
|
if ((ret = ff_parse_channel_layout(&fmt, fmt_str, ctx)) < 0) {
|
||||||
|
av_freep(&fmts_str);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
avfilter_add_format(&aformat->chlayouts, fmt);
|
avfilter_add_format(&aformat->chlayouts, fmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
av_freep(&fmts_str);
|
||||||
|
|
||||||
arg = strsep(&args, ":");
|
if (*args)
|
||||||
if (!arg) goto arg_fail;
|
args++;
|
||||||
if (!strcmp(arg, "all")) {
|
fmts_str = av_get_token(&args, ":");
|
||||||
|
if (!fmts_str || !*fmts_str)
|
||||||
|
goto arg_fail;
|
||||||
|
if (!strcmp(fmts_str, "all")) {
|
||||||
aformat->packing = avfilter_all_packing_formats();
|
aformat->packing = avfilter_all_packing_formats();
|
||||||
} else {
|
} else {
|
||||||
while (fmt_str = strsep(&arg, ",")) {
|
for (fmt_str = fmts_str;
|
||||||
if ((ret = ff_parse_packing_format((int*)&fmt, fmt_str, ctx)) < 0)
|
fmt_str = strtok_r(fmt_str, ",", &ptr); fmt_str = NULL) {
|
||||||
|
if ((ret = ff_parse_packing_format((int*)&fmt, fmt_str, ctx)) < 0) {
|
||||||
|
av_freep(&fmts_str);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
avfilter_add_format(&aformat->packing, fmt);
|
avfilter_add_format(&aformat->packing, fmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
av_freep(&fmts_str);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
arg_fail:
|
arg_fail:
|
||||||
av_log(ctx, AV_LOG_ERROR, "Invalid arguments, they must be of the form "
|
av_log(ctx, AV_LOG_ERROR, "Invalid arguments, they must be of the form "
|
||||||
"sample_fmts:channel_layouts:packing_fmts\n");
|
"sample_fmts:channel_layouts:packing_fmts\n");
|
||||||
|
av_freep(&fmts_str);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user