Originally committed as revision 18726 to svn://svn.ffmpeg.org/ffmpeg/trunk
Showing the changes to libavfilter/graphparser.c (1 of 1 file). Show all
Unified · Split
| @@ -26,6 +26,7 @@ · 25 unmodified lines | |||
| 26 | #include "graphparser.h" | 26 | #include "graphparser.h" |
| 27 | #include "avfilter.h" | 27 | #include "avfilter.h" |
| 28 | #include "avfiltergraph.h" | 28 | #include "avfiltergraph.h" |
| 29 | #include "parseutils.h" | ||
| 29 | 30 | ||
| 30 | #define WHITESPACES " \n\t" | 31 | #define WHITESPACES " \n\t" |
| 31 | 32 | ||
| @@ -43,49 +44,6 @@ static int link_filter(AVFilterContext *src, int srcpad, · 11 unmodified lines | |||
| 43 | return 0; | 44 | return 0; |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | /** | ||
| 47 | * Consumes a string from *buf. | ||
| 48 | * @return a copy of the consumed string, which should be free'd after use | ||
| 49 | */ | ||
| 50 | static char *consume_string(const char **buf) | ||
| 51 | { | ||
| 52 | char *out = av_malloc(strlen(*buf) + 1); | ||
| 53 | char *ret = out; | ||
| 54 | |||
| 55 | *buf += strspn(*buf, WHITESPACES); | ||
| 56 | |||
| 57 | do{ | ||
| 58 | char c = *(*buf)++; | ||
| 59 | switch (c) { | ||
| 60 | case '\\': | ||
| 61 | *out++ = *(*buf)++; | ||
| 62 | break; | ||
| 63 | case '\'': | ||
| 64 | while(**buf && **buf != '\'') | ||
| 65 | *out++ = *(*buf)++; | ||
| 66 | if(**buf) (*buf)++; | ||
| 67 | break; | ||
| 68 | case 0: | ||
| 69 | case ']': | ||
| 70 | case '[': | ||
| 71 | case '=': | ||
| 72 | case ',': | ||
| 73 | case ';': | ||
| 74 | case ' ': | ||
| 75 | case '\n': | ||
| 76 | *out++ = 0; | ||
| 77 | break; | ||
| 78 | default: | ||
| 79 | *out++ = c; | ||
| 80 | } | ||
| 81 | } while(out[-1]); | ||
| 82 | |||
| 83 | (*buf)--; | ||
| 84 | *buf += strspn(*buf, WHITESPACES); | ||
| 85 | |||
| 86 | return ret; | ||
| 87 | } | ||
| 88 | |||
| 89 | /** | 47 | /** |
| 90 | * Parse "[linkname]" | 48 | * Parse "[linkname]" |
| 91 | * @param name a pointer (that need to be free'd after use) to the name between | 49 | * @param name a pointer (that need to be free'd after use) to the name between |
| @@ -97,7 +55,7 @@ static char *parse_link_name(const char **buf, AVClass *log_ctx) · 5 unmodified lines | |||
| 97 | char *name; | 55 | char *name; |
| 98 | (*buf)++; | 56 | (*buf)++; |
| 99 | 57 | ||
| 100 | name = consume_string(buf); | 58 | name = av_get_token(buf, "]"); |
| 101 | 59 | ||
| 102 | if(!name[0]) { | 60 | if(!name[0]) { |
| 103 | av_log(log_ctx, AV_LOG_ERROR, | 61 | av_log(log_ctx, AV_LOG_ERROR, |
| @@ -162,12 +120,12 @@ static AVFilterContext *parse_filter(const char **buf, AVFilterGraph *graph, · 58 unmodified lines | |||
| 162 | int index, AVClass *log_ctx) | 120 | int index, AVClass *log_ctx) |
| 163 | { | 121 | { |
| 164 | char *opts = NULL; | 122 | char *opts = NULL; |
| 165 | char *name = consume_string(buf); | 123 | char *name = av_get_token(buf, "=,"); |
| 166 | AVFilterContext *ret; | 124 | AVFilterContext *ret; |
| 167 | 125 | ||
| 168 | if(**buf == '=') { | 126 | if(**buf == '=') { |
| 169 | (*buf)++; | 127 | (*buf)++; |
| 170 | opts = consume_string(buf); | 128 | opts = av_get_token(buf, "[],\n"); |
| 171 | } | 129 | } |
| 172 | 130 | ||
| 173 | ret = create_filter(graph, index, name, opts, log_ctx); | 131 | ret = create_filter(graph, index, name, opts, log_ctx); |