[vlc-commits] input/demux: introduce demux_lookup
Filip Roséen
git at videolan.org
Tue Aug 2 15:47:21 CEST 2016
vlc | branch: master | Filip Roséen <filip at atch.se> | Sat Jul 30 06:10:03 2016 +0200| [b98fc39f91f49445f5cb211909c861610bbd3499] | committer: Jean-Baptiste Kempf
input/demux: introduce demux_lookup
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b98fc39f91f49445f5cb211909c861610bbd3499
---
src/input/demux.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/input/demux.c b/src/input/demux.c
index 3750ed4..7c663f3 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -51,6 +51,12 @@ static int demux_mapping_cmp( const void *k, const void *v )
return vlc_ascii_strcasecmp( k, entry->key );
}
+static demux_mapping* demux_lookup( char const* key,
+ demux_mapping* data, size_t size )
+{
+ return bsearch( key, data, size, sizeof( *data ), demux_mapping_cmp );
+}
+
static const char *demux_NameFromContentType(const char *mime)
{
static demux_mapping types[] =
@@ -66,8 +72,7 @@ static const char *demux_NameFromContentType(const char *mime)
{ "video/nsa", "nsv" },
{ "video/nsv", "nsv" },
};
- demux_mapping *type = bsearch( mime, types, ARRAY_SIZE( types ),
- sizeof( *type ), demux_mapping_cmp );
+ demux_mapping *type = demux_lookup( mime, types, ARRAY_SIZE( types ) );
return (type != NULL) ? type->name : "any";
}
@@ -132,9 +137,7 @@ static const char* DemuxNameFromExtension( char const* ext,
.size = b_preparsing ? ARRAY_SIZE( quick ) : ARRAY_SIZE( strong )
};
- demux_mapping* result = bsearch( ext, lookup.data, lookup.size,
- sizeof( *lookup.data ), demux_mapping_cmp );
-
+ demux_mapping* result = demux_lookup( ext, lookup.data, lookup.size );
return result ? result->name : NULL;
}
More information about the vlc-commits
mailing list