[vlc-devel] [PATCH 3/5] demux: always use strongly-typed file extensions

RĂ©mi Denis-Courmont remi at remlab.net
Thu Sep 24 16:40:19 CEST 2020


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.
---
 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,
-- 
2.28.0



More information about the vlc-devel mailing list