From 350ad93b10bc7cb6fdb3439d9c0d9671f56efb02 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 18 Sep 2011 11:58:49 +0200 Subject: [PATCH] Helper function for stringifying a FourCC --- src/common/output.cpp | 12 ++++++++++++ src/common/output.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/common/output.cpp b/src/common/output.cpp index 169265d3a..c7a4d7e09 100644 --- a/src/common/output.cpp +++ b/src/common/output.cpp @@ -14,6 +14,7 @@ #include "common/common_pch.h" #include "common/ebml.h" +#include "common/endian.h" #include "common/mm_io.h" #include "common/locale.h" #include "common/output.h" @@ -287,3 +288,14 @@ dump_ebml_elements(EbmlElement *element, dump_ebml_elements((*master)[i], with_values, level + 1); } +std::string +fourcc_to_string(uint32_t fourcc) { + unsigned char buffer[4], idx; + + put_uint32_be(buffer, fourcc); + for (idx = 0; 4 > idx; ++idx) + if (buffer[idx] < ' ') + buffer[idx] = ' '; + + return std::string(reinterpret_cast(buffer), 4); +} diff --git a/src/common/output.h b/src/common/output.h index 795b75f43..d83b3ab80 100644 --- a/src/common/output.h +++ b/src/common/output.h @@ -133,4 +133,6 @@ void MTX_DLL_API mxhexdump(unsigned int level, const void *buffer_to_dump, size_ void MTX_DLL_API dump_ebml_elements(EbmlElement *element, bool with_values = false, unsigned int level = 0); +std::string fourcc_to_string(uint32_t fourcc); + #endif // __MTX_COMMON_OUTPUT_H