History

avutil/avstring: Factor av_match_list() out

Michael Niedermayer committed 12 years ago

Commit 0d92b0d1 parent 6ea357e5 files · +36 −19Browse files

Unified · Split

5 files
  1. doc/APIchanges +3 −0
  2. libavformat/format.c +3 −17
  3. libavutil/avstring.c +21 −0
  4. libavutil/avstring.h +7 −0
  5. libavutil/version.h +2 −2
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2014-08-09 · 14 unmodified lines
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182014-10-02 - xxxxxxx - lavu 54.8.100 - avstring.h
19 Add av_match_list()
20
182014-09-24 - xxxxxxx - libpostproc 53.1.100212014-09-24 - xxxxxxx - libpostproc 53.1.100
19 Add visualization support22 Add visualization support
20 23
libavformat/format.c+3−17
@@ -80,28 +80,14 @@ void av_register_output_format(AVOutputFormat *format) · 79 unmodified lines
80 80
81int av_match_ext(const char *filename, const char *extensions)81int av_match_ext(const char *filename, const char *extensions)
82{82{
83 const char *ext, *p;83 const char *ext;
84 char ext1[32], *q;
85 84
86 if (!filename)85 if (!filename)
87 return 0;86 return 0;
88 87
89 ext = strrchr(filename, '.');88 ext = strrchr(filename, '.');
90 if (ext) {89 if (ext)
91 ext++;90 return av_match_list(ext + 1, extensions, ',');
92 p = extensions;
93 for (;;) {
94 q = ext1;
95 while (*p != '\0' && *p != ',' && q - ext1 < sizeof(ext1) - 1)
96 *q++ = *p++;
97 *q = '\0';
98 if (!av_strcasecmp(ext1, ext))
99 return 1;
100 if (*p == '\0')
101 break;
102 p++;
103 }
104 }
105 return 0;91 return 0;
106}92}
107 93
libavutil/avstring.c+21−0
@@ -402,6 +402,27 @@ end: · 401 unmodified lines
402 return ret;402 return ret;
403}403}
404 404
405int av_match_list(const char *name, const char *list, char separator)
406{
407 const char *p;
408 char ext1[128], *q;
409 int i;
410
411 p = list;
412 for (i = 1;; i++) {
413 q = ext1;
414 while (*p != '\0' && *p != separator && q - ext1 < sizeof(ext1) - 1)
415 *q++ = *p++;
416 *q = '\0';
417 if (!av_strcasecmp(ext1, name))
418 return i;
419 if (*p == '\0')
420 break;
421 p++;
422 }
423 return 0;
424}
425
405#ifdef TEST426#ifdef TEST
406 427
407int main(void)428int main(void)
libavutil/avstring.h+7−0
@@ -357,6 +357,13 @@ int av_escape(char **dst, const char *src, const char *special_chars, · 356 unmodified lines
357int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end,357int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end,
358 unsigned int flags);358 unsigned int flags);
359 359
360/**
361 * Check if a name is in a list.
362 * @returns 0 if not found, or the 1 based index where it has been found in the
363 * list.
364 */
365int av_match_list(const char *name, const char *list, char separator);
366
360/**367/**
361 * @}368 * @}
362 */369 */
libavutil/version.h+2−2
@@ -56,8 +56,8 @@ · 55 unmodified lines
56 */56 */
57 57
58#define LIBAVUTIL_VERSION_MAJOR 5458#define LIBAVUTIL_VERSION_MAJOR 54
59#define LIBAVUTIL_VERSION_MINOR 759#define LIBAVUTIL_VERSION_MINOR 8
60#define LIBAVUTIL_VERSION_MICRO 10160#define LIBAVUTIL_VERSION_MICRO 100
61 61
62#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \62#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
63 LIBAVUTIL_VERSION_MINOR, \63 LIBAVUTIL_VERSION_MINOR, \

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