Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2017-03-27 02:05:18 +0300
committerClément Bœsch <u@pkh.me>2017-03-29 15:49:29 +0300
commitbfdcdd6d829c13eb019c194e214db0ec7dcf76cd (patch)
tree91c7276cdc77b15099aa9537de3f5a4ed2d6dff6 /libavutil
parentc1d822c554ac448b3a6d037ad507578f0793c847 (diff)
lavu: add av_fourcc_make_string() and av_fourcc2str()
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/avutil.h14
-rw-r--r--libavutil/utils.c23
-rw-r--r--libavutil/version.h2
3 files changed, 38 insertions, 1 deletions
diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index e9aaa03722..4d633156d1 100644
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -343,6 +343,20 @@ FILE *av_fopen_utf8(const char *path, const char *mode);
*/
AVRational av_get_time_base_q(void);
+#define AV_FOURCC_MAX_STRING_SIZE 32
+
+#define av_fourcc2str(fourcc) av_fourcc_make_string((char[AV_FOURCC_MAX_STRING_SIZE]){0}, fourcc)
+
+/**
+ * Fill the provided buffer with a string containing a FourCC (four-character
+ * code) representation.
+ *
+ * @param buf a buffer with size in bytes of at least AV_FOURCC_MAX_STRING_SIZE
+ * @param fourcc the fourcc to represent
+ * @return the buffer in input
+ */
+char *av_fourcc_make_string(char *buf, uint32_t fourcc);
+
/**
* @}
* @}
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};
diff --git a/libavutil/version.h b/libavutil/version.h
index 3c86c26638..d6d78e7dc2 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 55
-#define LIBAVUTIL_VERSION_MINOR 51
+#define LIBAVUTIL_VERSION_MINOR 52
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \