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
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182017-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
182017-03-xx - xxxxxxx - lavf 57.68.100 - avformat.h222017-03-xx - xxxxxxx - lavf 57.68.100 - avformat.h
19 Deprecate that demuxers export the stream rotation angle in AVStream.metadata23 Deprecate that demuxers export the stream rotation angle in AVStream.metadata
20 (via an entry named "rotate"). Use av_stream_get_side_data() with24 (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
343 */343 */
344AVRational av_get_time_base_q(void);344AVRational av_get_time_base_q(void);
345 345
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 */
358char *av_fourcc_make_string(char *buf, uint32_t fourcc);
359
346/**360/**
347 * @}361 * @}
348 * @}362 * @}
libavutil/utils.c+23−0
@@ -121,6 +121,29 @@ unsigned av_int_list_length_for_size(unsigned elsize, · 120 unmodified lines
121 return i;121 return i;
122}122}
123 123
124char *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
124AVRational av_get_time_base_q(void)147AVRational av_get_time_base_q(void)
125{148{
126 return (AVRational){1, AV_TIME_BASE};149 return (AVRational){1, AV_TIME_BASE};
libavutil/version.h+1−1
@@ -79,7 +79,7 @@ · 78 unmodified lines
79 */79 */
80 80
81#define LIBAVUTIL_VERSION_MAJOR 5581#define LIBAVUTIL_VERSION_MAJOR 55
82#define LIBAVUTIL_VERSION_MINOR 5182#define LIBAVUTIL_VERSION_MINOR 52
83#define LIBAVUTIL_VERSION_MICRO 10083#define LIBAVUTIL_VERSION_MICRO 100
84 84
85#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \85#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