diff options
author | Clément Bœsch <u@pkh.me> | 2017-03-27 01:05:18 +0200 |
---|---|---|
committer | Clément Bœsch <u@pkh.me> | 2017-03-29 14:49:29 +0200 |
commit | bfdcdd6d829c13eb019c194e214db0ec7dcf76cd (patch) | |
tree | 91c7276cdc77b15099aa9537de3f5a4ed2d6dff6 /libavutil/utils.c | |
parent | c1d822c554ac448b3a6d037ad507578f0793c847 (diff) | |
download | ffmpeg-bfdcdd6d829c13eb019c194e214db0ec7dcf76cd.tar.gz |
lavu: add av_fourcc_make_string() and av_fourcc2str()
Diffstat (limited to 'libavutil/utils.c')
-rw-r--r-- | libavutil/utils.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libavutil/utils.c b/libavutil/utils.c index 36e4dd5fdb..8cc7a9516c 100644 --- a/libavutil/utils.c +++ b/libavutil/utils.c @@ -121,6 +121,29 @@ unsigned av_int_list_length_for_size(unsigned elsize, return i; } +char *av_fourcc_make_string(char *buf, uint32_t fourcc) +{ + int i; + char *orig_buf = buf; + size_t buf_size = AV_FOURCC_MAX_STRING_SIZE; + + for (i = 0; i < 4; i++) { + const int c = fourcc & 0xff; + const int print_chr = (c >= '0' && c <= '9') || + (c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (c && strchr(". -_", c)); + const int len = snprintf(buf, buf_size, print_chr ? "%c" : "[%d]", c); + if (len < 0) + break; + buf += len; + buf_size = buf_size > len ? buf_size - len : 0; + fourcc >>= 8; + } + + return orig_buf; +} + AVRational av_get_time_base_q(void) { return (AVRational){1, AV_TIME_BASE}; |