diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2012-05-26 01:38:03 +0200 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2012-05-29 01:02:50 +0200 |
commit | 67b763104052a4135ff095a56d446c9691c0d098 (patch) | |
tree | ce8a1b42982b88b2f7c866dad76deb844118e987 | |
parent | fa6cb2fdffe59fdd38bf127ff82d09a4fcf46b76 (diff) | |
download | ffmpeg-67b763104052a4135ff095a56d446c9691c0d098.tar.gz |
lavc: prettify printing of some codec tags which contains 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.
-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 15dd05ac34..74329e1bd8 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1774,9 +1774,14 @@ size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_ta { int i, len, ret = 0; +#define IS_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); + IS_PRINT(codec_tag&0xFF) ? "%c" : "[%d]", codec_tag&0xFF); buf += len; buf_size = buf_size > len ? buf_size - len : 0; ret += len; |