static int parse_read_intervals(const char *intervals_spec)

{

    int ret, n, i;

    char *p, *spec = av_strdup(intervals_spec);

    if (!spec)

        return AVERROR(ENOMEM);



    /* preparse specification, get number of intervals */

    for (n = 0, p = spec; *p; p++)

        if (*p == ',')

            n++;

    n++;



    read_intervals = av_malloc(n * sizeof(*read_intervals));

    if (!read_intervals) {

        ret = AVERROR(ENOMEM);

        goto end;

    }

    read_intervals_nb = n;



    /* parse intervals */

    p = spec;

    for (i = 0; i < n; i++) {

        char *next = strchr(p, ',');

        if (next)

            *next++ = 0;



        read_intervals[i].id = i;

        ret = parse_read_interval(p, &read_intervals[i]);

        if (ret < 0) {

            av_log(NULL, AV_LOG_ERROR, "Error parsing read interval #%d '%s'\n",

                   i, p);

            goto end;

        }

        av_log(NULL, AV_LOG_VERBOSE, "Parsed log interval ");

        log_read_interval(&read_intervals[i], NULL, AV_LOG_VERBOSE);

        p = next;

        av_assert0(i <= read_intervals_nb);

    }

    av_assert0(i == read_intervals_nb);



end:

    av_free(spec);

    return ret;

}

static int parse_read_intervals(const char *intervals_spec)

{

    int ret, n, i;

    char *p, *spec = av_strdup(intervals_spec);

    if (!spec)

        return AVERROR(ENOMEM);



    

    for (n = 0, p = spec; *p; p++)

        if (*p == ',')

            n++;

    n++;



    read_intervals = av_malloc(n * sizeof(*read_intervals));

    if (!read_intervals) {

        ret = AVERROR(ENOMEM);

        goto end;

    }

    read_intervals_nb = n;



    

    p = spec;

    for (i = 0; i < n; i++) {

        char *next = strchr(p, ',');

        if (next)

            *next++ = 0;



        read_intervals[i].id = i;

        ret = parse_read_interval(p, &read_intervals[i]);

        if (ret < 0) {

            av_log(NULL, AV_LOG_ERROR, "Error parsing read interval #%d '%s'\n",

                   i, p);

            goto end;

        }

        av_log(NULL, AV_LOG_VERBOSE, "Parsed log interval ");

        log_read_interval(&read_intervals[i], NULL, AV_LOG_VERBOSE);

        p = next;

        av_assert0(i <= read_intervals_nb);

    }

    av_assert0(i == read_intervals_nb);



end:

    av_free(spec);

    return ret;

}

static int FUNC_0(const char *VAR_0)

{

    int VAR_1, VAR_2, VAR_3;

    char *VAR_4, *VAR_5 = av_strdup(VAR_0);

    if (!VAR_5)

        return AVERROR(ENOMEM);



    

    for (VAR_2 = 0, VAR_4 = VAR_5; *VAR_4; VAR_4++)

        if (*VAR_4 == ',')

            VAR_2++;

    VAR_2++;



    read_intervals = av_malloc(VAR_2 * sizeof(*read_intervals));

    if (!read_intervals) {

        VAR_1 = AVERROR(ENOMEM);

        goto end;

    }

    read_intervals_nb = VAR_2;



    

    VAR_4 = VAR_5;

    for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {

        char *VAR_6 = strchr(VAR_4, ',');

        if (VAR_6)

            *VAR_6++ = 0;



        read_intervals[VAR_3].id = VAR_3;

        VAR_1 = parse_read_interval(VAR_4, &read_intervals[VAR_3]);

        if (VAR_1 < 0) {

            av_log(NULL, AV_LOG_ERROR, "Error parsing read interval #%d '%s'\VAR_2",

                   VAR_3, VAR_4);

            goto end;

        }

        av_log(NULL, AV_LOG_VERBOSE, "Parsed log interval ");

        log_read_interval(&read_intervals[VAR_3], NULL, AV_LOG_VERBOSE);

        VAR_4 = VAR_6;

        av_assert0(VAR_3 <= read_intervals_nb);

    }

    av_assert0(VAR_3 == read_intervals_nb);



end:

    av_free(VAR_5);

    return VAR_1;

}

static int FUNC_0(const char *VAR_0)
{ int VAR_1, VAR_2, VAR_3; char *VAR_4, *VAR_5 = av_strdup(VAR_0); if (!VAR_5)
return AVERROR(ENOMEM); for (VAR_2 = 0, VAR_4 = VAR_5; *VAR_4; VAR_4++) if (*VAR_4 == ',')
VAR_2++; VAR_2++; read_intervals = av_malloc(VAR_2 * sizeof(*read_intervals)); if (!read_intervals) { VAR_1 = AVERROR(ENOMEM); goto end; } read_intervals_nb = VAR_2; VAR_4 = VAR_5; for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) { char *VAR_6 = strchr(VAR_4, ','); if (VAR_6)
*VAR_6++ = 0; read_intervals[VAR_3].id = VAR_3; VAR_1 = parse_read_interval(VAR_4, &read_intervals[VAR_3]); if (VAR_1 < 0) { av_log(NULL, AV_LOG_ERROR, "Error parsing read interval #%d '%s'\VAR_2",
VAR_3, VAR_4); goto end; } av_log(NULL, AV_LOG_VERBOSE, "Parsed log interval "); log_read_interval(&read_intervals[VAR_3], NULL, AV_LOG_VERBOSE); VAR_4 = VAR_6; av_assert0(VAR_3 <= read_intervals_nb); } av_assert0(VAR_3 == read_intervals_nb); end:
av_free(VAR_5); return VAR_1; }