static int parse_read_interval(const char *interval_spec,

                               ReadInterval *interval)

{

    int ret = 0;

    char *next, *p, *spec = av_strdup(interval_spec);

    if (!spec)

        return AVERROR(ENOMEM);



    if (!*spec) {

        av_log(NULL, AV_LOG_ERROR, "Invalid empty interval specification\n");

        ret = AVERROR(EINVAL);

        goto end;

    }



    p = spec;

    next = strchr(spec, '%');

    if (next)

        *next++ = 0;



    /* parse first part */

    if (*p) {

        interval->has_start = 1;



        if (*p == '+') {

            interval->start_is_offset = 1;

            p++;

        } else {

            interval->start_is_offset = 0;

        }



        ret = av_parse_time(&interval->start, p, 1);

        if (ret < 0) {

            av_log(NULL, AV_LOG_ERROR, "Invalid interval start specification '%s'\n", p);

            goto end;

        }

    } else {

        interval->has_start = 0;

    }



    /* parse second part */

    p = next;

    if (p && *p) {

        int64_t us;

        interval->has_end = 1;



        if (*p == '+') {

            interval->end_is_offset = 1;

            p++;

        } else {

            interval->end_is_offset = 0;

        }



        if (interval->end_is_offset && *p == '#') {

            long long int lli;

            char *tail;

            interval->duration_frames = 1;

            p++;

            lli = strtoll(p, &tail, 10);

            if (*tail || lli < 0) {

                av_log(NULL, AV_LOG_ERROR,

                       "Invalid or negative value '%s' for duration number of frames\n", p);

                goto end;

            }

            interval->end = lli;

        } else {


            ret = av_parse_time(&us, p, 1);

            if (ret < 0) {

                av_log(NULL, AV_LOG_ERROR, "Invalid interval end/duration specification '%s'\n", p);

                goto end;

            }

            interval->end = us;

        }

    } else {

        interval->has_end = 0;

    }



end:

    av_free(spec);

    return ret;

}
static int parse_read_interval(const char *interval_spec,

                               ReadInterval *interval)

{

    int ret = 0;

    char *next, *p, *spec = av_strdup(interval_spec);

    if (!spec)

        return AVERROR(ENOMEM);



    if (!*spec) {

        av_log(NULL, AV_LOG_ERROR, "Invalid empty interval specification\n");

        ret = AVERROR(EINVAL);

        goto end;

    }



    p = spec;

    next = strchr(spec, '%');

    if (next)

        *next++ = 0;



    

    if (*p) {

        interval->has_start = 1;



        if (*p == '+') {

            interval->start_is_offset = 1;

            p++;

        } else {

            interval->start_is_offset = 0;

        }



        ret = av_parse_time(&interval->start, p, 1);

        if (ret < 0) {

            av_log(NULL, AV_LOG_ERROR, "Invalid interval start specification '%s'\n", p);

            goto end;

        }

    } else {

        interval->has_start = 0;

    }



    

    p = next;

    if (p && *p) {

        int64_t us;

        interval->has_end = 1;



        if (*p == '+') {

            interval->end_is_offset = 1;

            p++;

        } else {

            interval->end_is_offset = 0;

        }



        if (interval->end_is_offset && *p == '#') {

            long long int lli;

            char *tail;

            interval->duration_frames = 1;

            p++;

            lli = strtoll(p, &tail, 10);

            if (*tail || lli < 0) {

                av_log(NULL, AV_LOG_ERROR,

                       "Invalid or negative value '%s' for duration number of frames\n", p);

                goto end;

            }

            interval->end = lli;

        } else {


            ret = av_parse_time(&us, p, 1);

            if (ret < 0) {

                av_log(NULL, AV_LOG_ERROR, "Invalid interval end/duration specification '%s'\n", p);

                goto end;

            }

            interval->end = us;

        }

    } else {

        interval->has_end = 0;

    }



end:

    av_free(spec);

    return ret;

}
static int FUNC_0(const char *VAR_0,

                               ReadInterval *VAR_1)

{

    int VAR_2 = 0;

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

    if (!VAR_5)

        return AVERROR(ENOMEM);



    if (!*VAR_5) {

        av_log(NULL, AV_LOG_ERROR, "Invalid empty VAR_1 specification\n");

        VAR_2 = AVERROR(EINVAL);

        goto end;

    }



    VAR_4 = VAR_5;

    VAR_3 = strchr(VAR_5, '%');

    if (VAR_3)

        *VAR_3++ = 0;



    

    if (*VAR_4) {

        VAR_1->has_start = 1;



        if (*VAR_4 == '+') {

            VAR_1->start_is_offset = 1;

            VAR_4++;

        } else {

            VAR_1->start_is_offset = 0;

        }



        VAR_2 = av_parse_time(&VAR_1->start, VAR_4, 1);

        if (VAR_2 < 0) {

            av_log(NULL, AV_LOG_ERROR, "Invalid VAR_1 start specification '%s'\n", VAR_4);

            goto end;

        }

    } else {

        VAR_1->has_start = 0;

    }



    

    VAR_4 = VAR_3;

    if (VAR_4 && *VAR_4) {

        int64_t us;

        VAR_1->has_end = 1;



        if (*VAR_4 == '+') {

            VAR_1->end_is_offset = 1;

            VAR_4++;

        } else {

            VAR_1->end_is_offset = 0;

        }



        if (VAR_1->end_is_offset && *VAR_4 == '#') {

            long long int VAR_6;

            char *VAR_7;

            VAR_1->duration_frames = 1;

            VAR_4++;

            VAR_6 = strtoll(VAR_4, &VAR_7, 10);

            if (*VAR_7 || VAR_6 < 0) {

                av_log(NULL, AV_LOG_ERROR,

                       "Invalid or negative value '%s' for duration number of frames\n", VAR_4);

                goto end;

            }

            VAR_1->end = VAR_6;

        } else {


            VAR_2 = av_parse_time(&us, VAR_4, 1);

            if (VAR_2 < 0) {

                av_log(NULL, AV_LOG_ERROR, "Invalid VAR_1 end/duration specification '%s'\n", VAR_4);

                goto end;

            }

            VAR_1->end = us;

        }

    } else {

        VAR_1->has_end = 0;

    }



end:

    av_free(VAR_5);

    return VAR_2;

}
static int FUNC_0(const char *VAR_0,
ReadInterval *VAR_1)
{ int VAR_2 = 0; char *VAR_3, *VAR_4, *VAR_5 = av_strdup(VAR_0); if (!VAR_5)
return AVERROR(ENOMEM); if (!*VAR_5) { av_log(NULL, AV_LOG_ERROR, "Invalid empty VAR_1 specification\n"); VAR_2 = AVERROR(EINVAL); goto end; } VAR_4 = VAR_5; VAR_3 = strchr(VAR_5, '%'); if (VAR_3)
*VAR_3++ = 0; if (*VAR_4) { VAR_1->has_start = 1; if (*VAR_4 == '+') { VAR_1->start_is_offset = 1; VAR_4++; } else { VAR_1->start_is_offset = 0; } VAR_2 = av_parse_time(&VAR_1->start, VAR_4, 1); if (VAR_2 < 0) { av_log(NULL, AV_LOG_ERROR, "Invalid VAR_1 start specification '%s'\n", VAR_4); goto end; } } else { VAR_1->has_start = 0; } VAR_4 = VAR_3; if (VAR_4 && *VAR_4) { int64_t us; VAR_1->has_end = 1; if (*VAR_4 == '+') { VAR_1->end_is_offset = 1; VAR_4++; } else { VAR_1->end_is_offset = 0; } if (VAR_1->end_is_offset && *VAR_4 == '#') { long long int VAR_6; char *VAR_7; VAR_1->duration_frames = 1; VAR_4++; VAR_6 = strtoll(VAR_4, &VAR_7, 10); if (*VAR_7 || VAR_6 < 0) { av_log(NULL, AV_LOG_ERROR,
"Invalid or negative value '%s' for duration number of frames\n", VAR_4); goto end; } VAR_1->end = VAR_6; } else { VAR_2 = av_parse_time(&us, VAR_4, 1); if (VAR_2 < 0) { av_log(NULL, AV_LOG_ERROR, "Invalid VAR_1 end/duration specification '%s'\n", VAR_4); goto end; } VAR_1->end = us; } } else { VAR_1->has_end = 0; } end:
av_free(VAR_5); return VAR_2; }