History

lavu: add av_fourcc_make_string() and av_fourcc2str()

Clément Bœsch committed 9 years ago

Commit bfdcdd61 parent c1d822c4 files · +42 −1Browse files

Unified · Split

4 files
  1. doc/APIchanges +4 −0
  2. libavutil/avutil.h +14 −0
  3. libavutil/utils.c +23 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+4−0
@@ -15,6 +15,10 @@ libavutil: 2015-08-28 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2017-03-xx - xxxxxxx - lavu 55.52.100 - avutil.h
19+ add av_fourcc_make_string() function and av_fourcc2str() macro to replace
20+ av_get_codec_tag_string() from lavc.
21+
1822 2017-03-xx - xxxxxxx - lavf 57.68.100 - avformat.h
1923 Deprecate that demuxers export the stream rotation angle in AVStream.metadata
2024 (via an entry named "rotate"). Use av_stream_get_side_data() with
libavutil/avutil.h+14−0
@@ -343,6 +343,20 @@ FILE *av_fopen_utf8(const char *path, const char *mode); · 342 unmodified lines
343343 */
344344 AVRational av_get_time_base_q(void);
345345
346+#define AV_FOURCC_MAX_STRING_SIZE 32
347+
348+#define av_fourcc2str(fourcc) av_fourcc_make_string((char[AV_FOURCC_MAX_STRING_SIZE]){0}, fourcc)
349+
350+/**
351+ * Fill the provided buffer with a string containing a FourCC (four-character
352+ * code) representation.
353+ *
354+ * @param buf a buffer with size in bytes of at least AV_FOURCC_MAX_STRING_SIZE
355+ * @param fourcc the fourcc to represent
356+ * @return the buffer in input
357+ */
358+char *av_fourcc_make_string(char *buf, uint32_t fourcc);
359+
346360 /**
347361 * @}
348362 * @}
libavutil/utils.c+23−0
@@ -121,6 +121,29 @@ unsigned av_int_list_length_for_size(unsigned elsize, · 120 unmodified lines
121121 return i;
122122 }
123123
124+char *av_fourcc_make_string(char *buf, uint32_t fourcc)
125+{
126+ int i;
127+ char *orig_buf = buf;
128+ size_t buf_size = AV_FOURCC_MAX_STRING_SIZE;
129+
130+ for (i = 0; i < 4; i++) {
131+ const int c = fourcc & 0xff;
132+ const int print_chr = (c >= '0' && c <= '9') ||
133+ (c >= 'a' && c <= 'z') ||
134+ (c >= 'A' && c <= 'Z') ||
135+ (c && strchr(". -_", c));
136+ const int len = snprintf(buf, buf_size, print_chr ? "%c" : "[%d]", c);
137+ if (len < 0)
138+ break;
139+ buf += len;
140+ buf_size = buf_size > len ? buf_size - len : 0;
141+ fourcc >>= 8;
142+ }
143+
144+ return orig_buf;
145+}
146+
124147 AVRational av_get_time_base_q(void)
125148 {
126149 return (AVRational){1, AV_TIME_BASE};
libavutil/version.h+1−1
@@ -79,7 +79,7 @@ · 78 unmodified lines
7979 */
8080
8181 #define LIBAVUTIL_VERSION_MAJOR 55
82−#define LIBAVUTIL_VERSION_MINOR 51
82+#define LIBAVUTIL_VERSION_MINOR 52
8383 #define LIBAVUTIL_VERSION_MICRO 100
8484
8585 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t