static int mov_open_dref(ByteIOContext **pb, char *src, MOVDref *ref)

{

    /* try absolute path */

    if (!url_fopen(pb, ref->path, URL_RDONLY))

        return 0;



    /* try relative path */

    if (ref->nlvl_to > 0 && ref->nlvl_from > 0) {

        char filename[1024];

        char *src_path;

        int i, l;



        /* find a source dir */

        src_path = strrchr(src, '/');

        if (src_path)

            src_path++;

        else

            src_path = src;



        /* find a next level down to target */

        for (i = 0, l = strlen(ref->path) - 1; l >= 0; l--)

            if (ref->path[l] == '/') {

                if (i == ref->nlvl_to - 1)

                    break;

                else

                    i++;

            }



        /* compose filename if next level down to target was found */

        if (i == ref->nlvl_to - 1) {

            memcpy(filename, src, src_path - src);

            filename[src_path - src] = 0;



            for (i = 1; i < ref->nlvl_from; i++)

                av_strlcat(filename, "../", 1024);



            av_strlcat(filename, ref->path + l + 1, 1024);



            if (!url_fopen(pb, filename, URL_RDONLY))

                return 0;

        }

    }



    return AVERROR(ENOENT);

};

static int mov_open_dref(ByteIOContext **pb, char *src, MOVDref *ref)

{

    

    if (!url_fopen(pb, ref->path, URL_RDONLY))

        return 0;



    

    if (ref->nlvl_to > 0 && ref->nlvl_from > 0) {

        char filename[1024];

        char *src_path;

        int i, l;



        

        src_path = strrchr(src, '/');

        if (src_path)

            src_path++;

        else

            src_path = src;



        

        for (i = 0, l = strlen(ref->path) - 1; l >= 0; l--)

            if (ref->path[l] == '/') {

                if (i == ref->nlvl_to - 1)

                    break;

                else

                    i++;

            }



        

        if (i == ref->nlvl_to - 1) {

            memcpy(filename, src, src_path - src);

            filename[src_path - src] = 0;



            for (i = 1; i < ref->nlvl_from; i++)

                av_strlcat(filename, "../", 1024);



            av_strlcat(filename, ref->path + l + 1, 1024);



            if (!url_fopen(pb, filename, URL_RDONLY))

                return 0;

        }

    }



    return AVERROR(ENOENT);

};

    if (!url_fopen(pb, ref->path, URL_RDONLY))         return 0;
static int FUNC_0(ByteIOContext **VAR_0, char *VAR_1, MOVDref *VAR_2)

{

    

    if (!url_fopen(VAR_0, VAR_2->path, URL_RDONLY))

        return 0;



    

    if (VAR_2->nlvl_to > 0 && VAR_2->nlvl_from > 0) {

        char VAR_3[1024];

        char *VAR_4;

        int VAR_5, VAR_6;



        

        VAR_4 = strrchr(VAR_1, '/');

        if (VAR_4)

            VAR_4++;

        else

            VAR_4 = VAR_1;



        

        for (VAR_5 = 0, VAR_6 = strlen(VAR_2->path) - 1; VAR_6 >= 0; VAR_6--)

            if (VAR_2->path[VAR_6] == '/') {

                if (VAR_5 == VAR_2->nlvl_to - 1)

                    break;

                else

                    VAR_5++;

            }



        

        if (VAR_5 == VAR_2->nlvl_to - 1) {

            memcpy(VAR_3, VAR_1, VAR_4 - VAR_1);

            VAR_3[VAR_4 - VAR_1] = 0;



            for (VAR_5 = 1; VAR_5 < VAR_2->nlvl_from; VAR_5++)

                av_strlcat(VAR_3, "../", 1024);



            av_strlcat(VAR_3, VAR_2->path + VAR_6 + 1, 1024);



            if (!url_fopen(VAR_0, VAR_3, URL_RDONLY))

                return 0;

        }

    }



    return AVERROR(ENOENT);

};

static int FUNC_0(ByteIOContext **VAR_0, char *VAR_1, MOVDref *VAR_2)
{ if (!url_fopen(VAR_0, VAR_2->path, URL_RDONLY))
return 0; if (VAR_2->nlvl_to > 0 && VAR_2->nlvl_from > 0) { char VAR_3[1024]; char *VAR_4; int VAR_5, VAR_6; VAR_4 = strrchr(VAR_1, '/'); if (VAR_4)
VAR_4++; else
VAR_4 = VAR_1; for (VAR_5 = 0, VAR_6 = strlen(VAR_2->path) - 1; VAR_6 >= 0; VAR_6--) if (VAR_2->path[VAR_6] == '/') { if (VAR_5 == VAR_2->nlvl_to - 1)
break; else
VAR_5++; } if (VAR_5 == VAR_2->nlvl_to - 1) { memcpy(VAR_3, VAR_1, VAR_4 - VAR_1); VAR_3[VAR_4 - VAR_1] = 0; for (VAR_5 = 1; VAR_5 < VAR_2->nlvl_from; VAR_5++) av_strlcat(VAR_3, "../", 1024); av_strlcat(VAR_3, VAR_2->path + VAR_6 + 1, 1024); if (!url_fopen(VAR_0, VAR_3, URL_RDONLY))
return 0; } } return AVERROR(ENOENT); };