Helper function for stringifying a FourCC

This commit is contained in:
Moritz Bunkus 2011-09-18 11:58:49 +02:00
parent fb7b44517a
commit 350ad93b10
2 changed files with 14 additions and 0 deletions

View File

@ -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<char *>(buffer), 4);
}

View File

@ -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