| 3008 | } |
| 3009 | |
| 3010 | static int parse_read_intervals(const char *intervals_spec) |
| 3011 | { |
| 3012 | int ret, n, i; |
| 3013 | char *p, *spec = av_strdup(intervals_spec); |
| 3014 | if (!spec) |
| 3015 | return AVERROR(ENOMEM); |
| 3016 | |
| 3017 | /* preparse specification, get number of intervals */ |
| 3018 | for (n = 0, p = spec; *p; p++) |
| 3019 | if (*p == ',') |
| 3020 | n++; |
| 3021 | n++; |
| 3022 | |
| 3023 | read_intervals = av_malloc_array(n, sizeof(*read_intervals)); |
| 3024 | if (!read_intervals) { |
| 3025 | ret = AVERROR(ENOMEM); |
| 3026 | goto end; |
| 3027 | } |
| 3028 | read_intervals_nb = n; |
| 3029 | |
| 3030 | /* parse intervals */ |
| 3031 | p = spec; |
| 3032 | for (i = 0; p; i++) { |
| 3033 | char *next; |
| 3034 | |
| 3035 | av_assert0(i < read_intervals_nb); |
| 3036 | next = strchr(p, ','); |
| 3037 | if (next) |
| 3038 | *next++ = 0; |
| 3039 | |
| 3040 | read_intervals[i].id = i; |
| 3041 | ret = parse_read_interval(p, &read_intervals[i]); |
| 3042 | if (ret < 0) { |
| 3043 | av_log(NULL, AV_LOG_ERROR, "Error parsing read interval #%d '%s'\n", |
| 3044 | i, p); |
| 3045 | goto end; |
| 3046 | } |
| 3047 | av_log(NULL, AV_LOG_VERBOSE, "Parsed log interval "); |
| 3048 | log_read_interval(&read_intervals[i], NULL, AV_LOG_VERBOSE); |
| 3049 | p = next; |
| 3050 | } |
| 3051 | av_assert0(i == read_intervals_nb); |
| 3052 | |
| 3053 | end: |
| 3054 | av_free(spec); |
| 3055 | return ret; |
| 3056 | } |
| 3057 | |
| 3058 | static int opt_read_intervals(void *optctx, const char *opt, const char *arg) |
| 3059 | { |
no test coverage detected