diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2012-05-26 01:38:03 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-03-07 08:50:29 +0200 |
commit | 70762508ec5919474edb92a5b1f266fd06640f9c (patch) | |
tree | f28641b753c987017e751d583cc3528a6793240a | |
parent | d65522e826fccd97c40d7cc4a170e027910c60b4 (diff) | |
download | ffmpeg-70762508ec5919474edb92a5b1f266fd06640f9c.tar.gz |
lavc: Prettify printing of codec tags containing non alphanumeric characters
Make av_get_codec_tag_string() show codec tag string characters in a more
intelligible ways. For example the ascii char "@" is used as a number, so
should be displayed like "[64]" rather than as a printable character.
Apart alphanumeric chars, only the characters ' ' and '.' are used
literally in codec tags, all the other characters represent numbers.
This also avoids relying on locale-dependent character class functions.
Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r-- | libavcodec/utils.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 4148264eb1..b2fdd32458 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1562,9 +1562,14 @@ size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_ta { int i, len, ret = 0; +#define TAG_PRINT(x) \ + (((x) >= '0' && (x) <= '9') || \ + ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || \ + ((x) == '.' || (x) == ' ')) + for (i = 0; i < 4; i++) { len = snprintf(buf, buf_size, - isprint(codec_tag & 0xFF) ? "%c" : "[%d]", codec_tag & 0xFF); + TAG_PRINT(codec_tag & 0xFF) ? "%c" : "[%d]", codec_tag & 0xFF); buf += len; buf_size = buf_size > len ? buf_size - len : 0; ret += len; |