summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-05 12:50:11 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-06 23:26:21 +0200
commit661d909f8e0fdb9157b858e24db0c23ab61e55e9 (patch)
tree2a53f9912dc5b09f7becfd264bea883da89cc5f8 /libmpdemux
parent348332af3a5404f7c9e71fd4ef571ba5fdb651cf (diff)
downloadmpv-661d909f8e0fdb9157b858e24db0c23ab61e55e9.tar.bz2
mpv-661d909f8e0fdb9157b858e24db0c23ab61e55e9.tar.xz
demux_lavf: more future proof AVInputFormat name comparison
AVInputFormat name fields consist of comma-separated components, more of which may be added in backwards-compatible versions. demux_lavf did a strcmp against the whole field at once; this would break if a component was added. Change the code to search for individual component matches within the field instead.
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/demux_lavf.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c
index 21ff9514d3..ef4a20ae7f 100644
--- a/libmpdemux/demux_lavf.c
+++ b/libmpdemux/demux_lavf.c
@@ -23,6 +23,7 @@
// #include <unistd.h>
#include <limits.h>
#include <stdbool.h>
+#include <string.h>
#include "config.h"
#include "options.h"
@@ -205,13 +206,28 @@ static int lavf_check_file(demuxer_t *demuxer){
return DEMUXER_TYPE_LAVF;
}
+static bool matches_avinputformat_name(struct lavf_priv *priv,
+ const char *name)
+{
+ const char *avifname = priv->avif->name;
+ while (1) {
+ const char *next = strchr(avifname, ',');
+ if (!next)
+ return !strcmp(avifname, name);
+ int len = next - avifname;
+ if (len == strlen(name) && !memcmp(avifname, name, len))
+ return true;
+ avifname = next + 1;
+ }
+}
+
static const char * const preferred_list[] = {
"dxa",
"flv",
"gxf",
"nut",
"nuv",
- "mov,mp4,m4a,3gp,3g2,mj2",
+ "mov", "mp4", // "mov,mp4,m4a,3gp,3g2,mj2" is one AVInputFormat
"mpc",
"mpc8",
"mxf",
@@ -225,13 +241,11 @@ static const char * const preferred_list[] = {
static int lavf_check_preferred_file(demuxer_t *demuxer){
if (lavf_check_file(demuxer)) {
- const char * const *p = preferred_list;
+ const char * const *p;
lavf_priv_t *priv = demuxer->priv;
- while (*p) {
- if (strcmp(*p, priv->avif->name) == 0)
+ for (p = preferred_list; *p; p++)
+ if (matches_avinputformat_name(priv, *p))
return DEMUXER_TYPE_LAVF_PREFERRED;
- p++;
- }
}
return 0;
}