various: replace mp_splitext() with bstr_get_ext()
This will allow removing mp_splitext().
This commit is contained in:
1 parent
9ffc0cd861
commit
1a09154988
6 files changed
+11
-12
No files matched your search
@@ -249,14 +249,14 @@ static int parse_m3u(struct pl_parser *p)
|
||||
if (p->probing && !bstr_equals0(line, "#EXTM3U")) {
|
||||
// Last resort: if the file extension is m3u, it might be headerless.
|
||||
if (p->check_level == DEMUX_CHECK_UNSAFE) {
|
||||
char *ext = mp_splitext(p->real_stream->url, NULL);
|
||||
bstr ext = bstr_get_ext(bstr0(p->real_stream->url));
|
||||
char probe[PROBE_SIZE];
|
||||
int len = stream_read_peek(p->real_stream, probe, sizeof(probe));
|
||||
bstr data = {probe, len};
|
||||
if (ext && data.len >= 2 && maybe_text(data)) {
|
||||
if (ext.len && data.len >= 2 && maybe_text(data)) {
|
||||
const char *exts[] = {"m3u", "m3u8", "strm", NULL};
|
||||
for (int n = 0; exts[n]; n++) {
|
||||
if (strcasecmp(ext, exts[n]) == 0)
|
||||
if (bstrcasecmp(ext, bstr0(exts[n])) == 0)
|
||||
goto ok;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ void mp_load_auto_profiles(struct MPContext *mpctx)
|
||||
mp_auto_load_profile(mpctx, "protocol",
|
||||
mp_split_proto(bstr0(mpctx->filename), NULL));
|
||||
mp_auto_load_profile(mpctx, "extension",
|
||||
bstr0(mp_splitext(mpctx->filename, NULL)));
|
||||
bstr_get_ext(bstr0(mpctx->filename)));
|
||||
|
||||
mp_load_per_file_config(mpctx);
|
||||
}
|
||||
|
||||
+1
-2
@@ -489,8 +489,7 @@ void cmd_screenshot_to_file(void *p)
|
||||
int mode = cmd->args[1].v.i;
|
||||
struct image_writer_opts opts = *mpctx->opts->screenshot_image_opts;
|
||||
|
||||
char *ext = mp_splitext(filename, NULL);
|
||||
int format = image_writer_format_from_ext(ext);
|
||||
int format = image_writer_format_from_ext(bstr_get_ext(bstr0(filename)));
|
||||
if (format)
|
||||
opts.format = format;
|
||||
bool high_depth = image_writer_high_depth(&opts);
|
||||
|
||||
+3
-3
@@ -104,8 +104,8 @@ static MP_THREAD_VOID script_thread(void *p)
|
||||
|
||||
static int64_t mp_load_script(struct MPContext *mpctx, const char *fname)
|
||||
{
|
||||
char *ext = mp_splitext(fname, NULL);
|
||||
if (ext && strcasecmp(ext, "disable") == 0)
|
||||
bstr ext = bstr_get_ext(bstr0(fname));
|
||||
if (bstrcasecmp0(ext, "disable") == 0)
|
||||
return 0;
|
||||
|
||||
void *tmp = talloc_new(NULL);
|
||||
@@ -144,7 +144,7 @@ static int64_t mp_load_script(struct MPContext *mpctx, const char *fname)
|
||||
} else {
|
||||
for (int n = 0; scripting_backends[n]; n++) {
|
||||
const struct mp_scripting *b = scripting_backends[n];
|
||||
if (ext && strcasecmp(ext, b->file_ext) == 0) {
|
||||
if (bstrcasecmp0(ext, b->file_ext) == 0) {
|
||||
backend = b;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -584,10 +584,10 @@ bool image_writer_flexible_csp(const struct image_writer_opts *opts)
|
||||
|| opts->format == AV_CODEC_ID_PNG;
|
||||
}
|
||||
|
||||
int image_writer_format_from_ext(const char *ext)
|
||||
int image_writer_format_from_ext(bstr ext)
|
||||
{
|
||||
for (int n = 0; mp_image_writer_formats[n].name; n++) {
|
||||
if (ext && strcmp(mp_image_writer_formats[n].name, ext) == 0)
|
||||
if (bstrcmp0(ext, mp_image_writer_formats[n].name) == 0)
|
||||
return mp_image_writer_formats[n].value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -52,7 +52,7 @@ bool image_writer_high_depth(const struct image_writer_opts *opts);
|
||||
bool image_writer_flexible_csp(const struct image_writer_opts *opts);
|
||||
|
||||
// Map file extension to format ID - return 0 (which is invalid) if unknown.
|
||||
int image_writer_format_from_ext(const char *ext);
|
||||
int image_writer_format_from_ext(bstr ext);
|
||||
|
||||
/*
|
||||
* Save the given image under the given filename. The parameters csp and opts
|
||||
|
||||
Reference in new issue
Block a user