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
1515
1616 API changes, most recent first:
1717
18+2014-10-02 - xxxxxxx - lavu 54.8.100 - avstring.h
19+ Add av_match_list()
20+
1821 2014-09-24 - xxxxxxx - libpostproc 53.1.100
1922 Add visualization support
2023
libavformat/format.c+3−17
@@ -80,28 +80,14 @@ void av_register_output_format(AVOutputFormat *format) · 79 unmodified lines
8080
8181 int av_match_ext(const char *filename, const char *extensions)
8282 {
83− const char *ext, *p;
84− char ext1[32], *q;
83+ const char *ext;
8584
8685 if (!filename)
8786 return 0;
8887
8988 ext = strrchr(filename, '.');
90− if (ext) {
91− ext++;
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− }
89+ if (ext)
90+ return av_match_list(ext + 1, extensions, ',');
10591 return 0;
10692 }
10793
libavutil/avstring.c+21−0
@@ -402,6 +402,27 @@ end: · 401 unmodified lines
402402 return ret;
403403 }
404404
405+int 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+
405426 #ifdef TEST
406427
407428 int 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
357357 int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end,
358358 unsigned int flags);
359359
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+ */
365+int av_match_list(const char *name, const char *list, char separator);
366+
360367 /**
361368 * @}
362369 */
libavutil/version.h+2−2
@@ -56,8 +56,8 @@ · 55 unmodified lines
5656 */
5757
5858 #define LIBAVUTIL_VERSION_MAJOR 54
59−#define LIBAVUTIL_VERSION_MINOR 7
60−#define LIBAVUTIL_VERSION_MICRO 101
59+#define LIBAVUTIL_VERSION_MINOR 8
60+#define LIBAVUTIL_VERSION_MICRO 100
6161
6262 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
6363 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