[vlc-commits] demux: always use strongly-typed file extensions
Rémi Denis-Courmont
git at videolan.org
Fri Sep 25 18:05:48 CEST 2020
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Sep 24 17:11:52 2020 +0300| [c16039c911c2fa95d2007cd3f5bf3e65edd9215c] | committer: Rémi Denis-Courmont
demux: always use strongly-typed file extensions
There are two sets of file extension to demux module mapping:
- The "strong" set contains file extensions deemed reliable, either
because the demux probe is reasonably strict and safe, or because
the extension is rarely mismatched.
- The "quick" set contains file extensions that are not considered
reliable. This is essentially "mp3" which is supposedly (?) often
misused for non-MPGA (or non-raw ES) files.
The quick set cannot be used in normal parsing, as it could pick the
the wrong demuxer (that is to say, MPEG ES). It was introduced in the
original preparsing changeset, presumably to limit the overhead.
There are however no obvious reasons not to use the strong set for
preparsing. This patch does exactly that, and then removes duplicated
mappings for Ogg and WMA.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c16039c911c2fa95d2007cd3f5bf3e65edd9215c
---
src/input/demux.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/src/input/demux.c b/src/input/demux.c
index 9190b7d5fc..ccefec76e7 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -120,21 +120,14 @@ static const char* DemuxNameFromExtension( char const* ext,
static demux_mapping quick[] =
{ /* NOTE: shall be sorted in asc order */
{ "mp3", "mpga" },
- { "ogg", "ogg" },
- { "wma", "asf" },
};
- struct {
- demux_mapping* data;
- size_t size;
+ demux_mapping *res = demux_lookup(ext, strong, ARRAY_SIZE(strong));
- } lookup = {
- .data = b_preparsing ? quick : strong,
- .size = b_preparsing ? ARRAY_SIZE( quick ) : ARRAY_SIZE( strong )
- };
+ if (res == NULL && b_preparsing)
+ res = demux_lookup(ext, quick, ARRAY_SIZE(quick));
- demux_mapping* result = demux_lookup( ext, lookup.data, lookup.size );
- return result ? result->name : NULL;
+ return (res != NULL) ? res->name : NULL;
}
demux_t *demux_New( vlc_object_t *p_obj, const char *psz_name,
More information about the vlc-commits
mailing list