static int find_image_range(int *pfirst_index, int *plast_index,

                            const char *path)

{

    char buf[1024];

    int range, last_index, range1, first_index;



    /* find the first image */

    for(first_index = 0; first_index < 5; first_index++) {

        if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){

            *pfirst_index =

            *plast_index = 1;

            if (avio_check(buf, AVIO_FLAG_READ) > 0)

                return 0;

            return -1;

        }

        if (avio_check(buf, AVIO_FLAG_READ) > 0)

            break;

    }

    if (first_index == 5)

        goto fail;



    /* find the last image */

    last_index = first_index;

    for(;;) {

        range = 0;

        for(;;) {

            if (!range)

                range1 = 1;

            else

                range1 = 2 * range;

            if (av_get_frame_filename(buf, sizeof(buf), path,

                                      last_index + range1) < 0)

                goto fail;

            if (avio_check(buf, AVIO_FLAG_READ) <= 0)

                break;

            range = range1;

            /* just in case... */

            if (range >= (1 << 30))

                goto fail;

        }

        /* we are sure than image last_index + range exists */

        if (!range)

            break;

        last_index += range;

    }

    *pfirst_index = first_index;

    *plast_index = last_index;

    return 0;

 fail:

    return -1;

}

static int find_image_range(int *pfirst_index, int *plast_index,

                            const char *path)

{

    char buf[1024];

    int range, last_index, range1, first_index;



    

    for(first_index = 0; first_index < 5; first_index++) {

        if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){

            *pfirst_index =

            *plast_index = 1;

            if (avio_check(buf, AVIO_FLAG_READ) > 0)

                return 0;

            return -1;

        }

        if (avio_check(buf, AVIO_FLAG_READ) > 0)

            break;

    }

    if (first_index == 5)

        goto fail;



    

    last_index = first_index;

    for(;;) {

        range = 0;

        for(;;) {

            if (!range)

                range1 = 1;

            else

                range1 = 2 * range;

            if (av_get_frame_filename(buf, sizeof(buf), path,

                                      last_index + range1) < 0)

                goto fail;

            if (avio_check(buf, AVIO_FLAG_READ) <= 0)

                break;

            range = range1;

            

            if (range >= (1 << 30))

                goto fail;

        }

        

        if (!range)

            break;

        last_index += range;

    }

    *pfirst_index = first_index;

    *plast_index = last_index;

    return 0;

 fail:

    return -1;

}

static int FUNC_0(int *VAR_0, int *VAR_1,

                            const char *VAR_2)

{

    char VAR_3[1024];

    int VAR_4, VAR_5, VAR_6, VAR_7;



    

    for(VAR_7 = 0; VAR_7 < 5; VAR_7++) {

        if (av_get_frame_filename(VAR_3, sizeof(VAR_3), VAR_2, VAR_7) < 0){

            *VAR_0 =

            *VAR_1 = 1;

            if (avio_check(VAR_3, AVIO_FLAG_READ) > 0)

                return 0;

            return -1;

        }

        if (avio_check(VAR_3, AVIO_FLAG_READ) > 0)

            break;

    }

    if (VAR_7 == 5)

        goto fail;



    

    VAR_5 = VAR_7;

    for(;;) {

        VAR_4 = 0;

        for(;;) {

            if (!VAR_4)

                VAR_6 = 1;

            else

                VAR_6 = 2 * VAR_4;

            if (av_get_frame_filename(VAR_3, sizeof(VAR_3), VAR_2,

                                      VAR_5 + VAR_6) < 0)

                goto fail;

            if (avio_check(VAR_3, AVIO_FLAG_READ) <= 0)

                break;

            VAR_4 = VAR_6;

            

            if (VAR_4 >= (1 << 30))

                goto fail;

        }

        

        if (!VAR_4)

            break;

        VAR_5 += VAR_4;

    }

    *VAR_0 = VAR_7;

    *VAR_1 = VAR_5;

    return 0;

 fail:

    return -1;

}

static int FUNC_0(int *VAR_0, int *VAR_1,
const char *VAR_2)
{ char VAR_3[1024]; int VAR_4, VAR_5, VAR_6, VAR_7; for(VAR_7 = 0; VAR_7 < 5; VAR_7++) { if (av_get_frame_filename(VAR_3, sizeof(VAR_3), VAR_2, VAR_7) < 0){ *VAR_0 =
*VAR_1 = 1; if (avio_check(VAR_3, AVIO_FLAG_READ) > 0)
return 0; return -1; } if (avio_check(VAR_3, AVIO_FLAG_READ) > 0)
break; } if (VAR_7 == 5)
goto fail; VAR_5 = VAR_7; for(;;) { VAR_4 = 0; for(;;) { if (!VAR_4)
VAR_6 = 1; else
VAR_6 = 2 * VAR_4; if (av_get_frame_filename(VAR_3, sizeof(VAR_3), VAR_2,
VAR_5 + VAR_6) < 0)
goto fail; if (avio_check(VAR_3, AVIO_FLAG_READ) <= 0)
break; VAR_4 = VAR_6; if (VAR_4 >= (1 << 30))
goto fail; } if (!VAR_4)
break; VAR_5 += VAR_4; } *VAR_0 = VAR_7; *VAR_1 = VAR_5; return 0; fail:
return -1; }