[libbluray-devel] Factorize common tables from mpls_dump.c and clpi_dump.c
hpi1
git at videolan.org
Wed Aug 30 08:49:36 CEST 2017
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sun Aug 27 16:15:06 2017 +0300| [dc8011c907952d75d56fd8bc89f312424106641f] | committer: hpi1
Factorize common tables from mpls_dump.c and clpi_dump.c
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=dc8011c907952d75d56fd8bc89f312424106641f
---
src/devtools/clpi_dump.c | 89 +--------------------------------------
src/devtools/mpls_dump.c | 87 +-------------------------------------
src/devtools/strings.h | 107 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 109 insertions(+), 174 deletions(-)
diff --git a/src/devtools/clpi_dump.c b/src/devtools/clpi_dump.c
index 98aa9cd1..fa224dd2 100644
--- a/src/devtools/clpi_dump.c
+++ b/src/devtools/clpi_dump.c
@@ -27,73 +27,10 @@
#include "bdnav/clpi_data.h"
#include "util.h"
+#include "strings.h"
static int verbose;
-typedef struct {
- int value;
- const char *str;
-} VALUE_MAP;
-
-static inline const char*
-_lookup_str(const VALUE_MAP *map, int val)
-{
- int ii;
-
- for (ii = 0; map[ii].str; ii++) {
- if (val == map[ii].value) {
- return map[ii].str;
- }
- }
- return "?";
-}
-
-const VALUE_MAP codec_map[] = {
- {0x01, "MPEG-1 Video"},
- {0x02, "MPEG-2 Video"},
- {0x03, "MPEG-1 Audio"},
- {0x04, "MPEG-2 Audio"},
- {0x80, "LPCM"},
- {0x81, "AC-3"},
- {0x82, "DTS"},
- {0x83, "TrueHD"},
- {0x84, "AC-3 Plus"},
- {0x85, "DTS-HD"},
- {0x86, "DTS-HD Master"},
- {0xa1, "AC-3 Plus for secondary audio"},
- {0xa2, "DTS-HD for secondary audio"},
- {0xea, "VC-1"},
- {0x1b, "H.264"},
- {0x20, "H.264 MVC dep."},
- {0x90, "Presentation Graphics"},
- {0x91, "Presentation Graphics"},
- {0x92, "Interactive Graphics"},
- {0, NULL}
-};
-
-const VALUE_MAP video_format_map[] = {
- {0, "Reserved"},
- {1, "480i"},
- {2, "576i"},
- {3, "480p"},
- {4, "1080i"},
- {5, "720p"},
- {6, "1080p"},
- {7, "576p"},
- {0, NULL}
-};
-
-const VALUE_MAP video_rate_map[] = {
- {0, "Reserved1"},
- {1, "23.976"},
- {2, "24"},
- {3, "25"},
- {4, "29.97"},
- {5, "Reserved2"},
- {6, "50"},
- {7, "59.94"},
- {0, NULL}
-};
const VALUE_MAP video_aspect_map[] = {
{0, "Reserved1"},
@@ -103,30 +40,6 @@ const VALUE_MAP video_aspect_map[] = {
{0, NULL}
};
-const VALUE_MAP audio_format_map[] = {
- {0, "Reserved1"},
- {1, "Mono"},
- {2, "Reserved2"},
- {3, "Stereo"},
- {4, "Reserved3"},
- {5, "Reserved4"},
- {6, "Multi Channel"},
- {12, "Combo"},
- {0, NULL}
-};
-
-const VALUE_MAP audio_rate_map[] = {
- {0, "Reserved1"},
- {1, "48 Khz"},
- {2, "Reserved2"},
- {3, "Reserved3"},
- {4, "96 Khz"},
- {5, "192 Khz"},
- {12, "48/192 Khz"},
- {14, "48/96 Khz"},
- {0, NULL}
-};
-
const VALUE_MAP application_type_map[] = {
{1, "Main TS for a main-path of Movie"},
{2, "Main TS for a main-path of Time based slide show"},
diff --git a/src/devtools/mpls_dump.c b/src/devtools/mpls_dump.c
index 81031d84..64274bbf 100644
--- a/src/devtools/mpls_dump.c
+++ b/src/devtools/mpls_dump.c
@@ -29,6 +29,7 @@
#include "bluray.h"
#include "util.h"
+#include "strings.h"
#ifdef _WIN32
# define DIR_SEP "\\"
@@ -41,80 +42,6 @@
static int verbose;
-typedef struct {
- int value;
- const char *str;
-} VALUE_MAP;
-
-const VALUE_MAP codec_map[] = {
- {0x01, "MPEG-1 Video"},
- {0x02, "MPEG-2 Video"},
- {0x03, "MPEG-1 Audio"},
- {0x04, "MPEG-2 Audio"},
- {0x80, "LPCM"},
- {0x81, "AC-3"},
- {0x82, "DTS"},
- {0x83, "TrueHD"},
- {0x84, "AC-3 Plus"},
- {0x85, "DTS-HD"},
- {0x86, "DTS-HD Master"},
- {0xa1, "AC-3 Plus for secondary audio"},
- {0xa2, "DTS-HD for secondary audio"},
- {0xea, "VC-1"},
- {0x1b, "H.264"},
- {0x90, "Presentation Graphics"},
- {0x91, "Interactive Graphics"},
- {0x92, "Text Subtitle"},
- {0, NULL}
-};
-
-const VALUE_MAP video_format_map[] = {
- {0, "Reserved"},
- {1, "480i"},
- {2, "576i"},
- {3, "480p"},
- {4, "1080i"},
- {5, "720p"},
- {6, "1080p"},
- {7, "576p"},
- {0, NULL}
-};
-
-const VALUE_MAP video_rate_map[] = {
- {0, "Reserved1"},
- {1, "23.976"},
- {2, "24"},
- {3, "25"},
- {4, "29.97"},
- {5, "Reserved2"},
- {6, "50"},
- {7, "59.94"},
- {0, NULL}
-};
-
-const VALUE_MAP audio_format_map[] = {
- {0, "Reserved1"},
- {1, "Mono"},
- {2, "Reserved2"},
- {3, "Stereo"},
- {4, "Reserved3"},
- {5, "Reserved4"},
- {6, "Multi Channel"},
- {12, "Combo"},
- {0, NULL}
-};
-
-const VALUE_MAP audio_rate_map[] = {
- {0, "Reserved1"},
- {1, "48 Khz"},
- {2, "Reserved2"},
- {3, "Reserved3"},
- {4, "96 Khz"},
- {5, "192 Khz"},
- {12, "48/192 Khz"},
- {14, "48/96 Khz"},
- {0, NULL}
-};
const VALUE_MAP subpath_type_map[] = {
{2, "Primary audio of the Browsable slideshow"},
@@ -141,18 +68,6 @@ const VALUE_MAP connection_type_map[] = {
{0, NULL}
};
-static const char*
-_lookup_str(const VALUE_MAP *map, int val)
-{
- int ii;
-
- for (ii = 0; map[ii].str; ii++) {
- if (val == map[ii].value) {
- return map[ii].str;
- }
- }
- return "?";
-}
static char *
_mk_path(const char *base, const char *sub)
diff --git a/src/devtools/strings.h b/src/devtools/strings.h
new file mode 100644
index 00000000..9f78dcaf
--- /dev/null
+++ b/src/devtools/strings.h
@@ -0,0 +1,107 @@
+/*
+ * This file is part of libbluray
+ * Copyright (C) 2009-2010 John Stebbins
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+typedef struct {
+ int value;
+ const char *str;
+} VALUE_MAP;
+
+const VALUE_MAP codec_map[] = {
+ {0x01, "MPEG-1 Video"},
+ {0x02, "MPEG-2 Video"},
+ {0x03, "MPEG-1 Audio"},
+ {0x04, "MPEG-2 Audio"},
+ {0x80, "LPCM"},
+ {0x81, "AC-3"},
+ {0x82, "DTS"},
+ {0x83, "TrueHD"},
+ {0x84, "AC-3 Plus"},
+ {0x85, "DTS-HD"},
+ {0x86, "DTS-HD Master"},
+ {0xa1, "AC-3 Plus for secondary audio"},
+ {0xa2, "DTS-HD for secondary audio"},
+ {0xea, "VC-1"},
+ {0x1b, "H.264"},
+ {0x20, "H.264 MVC dep."},
+ {0x90, "Presentation Graphics"},
+ {0x91, "Presentation Graphics"},
+ {0x92, "Interactive Graphics"},
+ {0, NULL}
+};
+
+const VALUE_MAP video_format_map[] = {
+ {0, "Reserved"},
+ {1, "480i"},
+ {2, "576i"},
+ {3, "480p"},
+ {4, "1080i"},
+ {5, "720p"},
+ {6, "1080p"},
+ {7, "576p"},
+ {0, NULL}
+};
+
+const VALUE_MAP video_rate_map[] = {
+ {0, "Reserved1"},
+ {1, "23.976"},
+ {2, "24"},
+ {3, "25"},
+ {4, "29.97"},
+ {5, "Reserved2"},
+ {6, "50"},
+ {7, "59.94"},
+ {0, NULL}
+};
+
+const VALUE_MAP audio_format_map[] = {
+ {0, "Reserved1"},
+ {1, "Mono"},
+ {2, "Reserved2"},
+ {3, "Stereo"},
+ {4, "Reserved3"},
+ {5, "Reserved4"},
+ {6, "Multi Channel"},
+ {12, "Combo"},
+ {0, NULL}
+};
+
+const VALUE_MAP audio_rate_map[] = {
+ {0, "Reserved1"},
+ {1, "48 Khz"},
+ {2, "Reserved2"},
+ {3, "Reserved3"},
+ {4, "96 Khz"},
+ {5, "192 Khz"},
+ {12, "48/192 Khz"},
+ {14, "48/96 Khz"},
+ {0, NULL}
+};
+
+static inline const char *
+_lookup_str(const VALUE_MAP *map, int val)
+{
+ int ii;
+
+ for (ii = 0; map[ii].str; ii++) {
+ if (val == map[ii].value) {
+ return map[ii].str;
+ }
+ }
+ return "?";
+}
More information about the libbluray-devel
mailing list