mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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>
This commit is contained in:
parent
d65522e826
commit
70762508ec
@ -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;
|
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++) {
|
for (i = 0; i < 4; i++) {
|
||||||
len = snprintf(buf, buf_size,
|
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 += len;
|
||||||
buf_size = buf_size > len ? buf_size - len : 0;
|
buf_size = buf_size > len ? buf_size - len : 0;
|
||||||
ret += len;
|
ret += len;
|
||||||
|
Loading…
Reference in New Issue
Block a user