[FFmpeg-devel] [PATCH] mov reference files search improvement

Maksym Veremeyenko verem
Thu Sep 10 10:18:06 CEST 2009


Baptiste Coudurier ???????(??):
[...]
>> So i prepared newer patch that allocate and terminated string...
> 
> Changing existing code goes in a separate patch, that's a minor issue.
> New code should use malloc + [len] = 0 if Benoit prefers.
> 
newer patch posted in previous post already use "malloc + [len] = 0"

[...]
>> +        /* find a source dir */
>> +        src_path = FFMAX(strrchr(src, '/'), strrchr(src, '\\'));
> 
> Why are you checking for straight '\' in src ?
because of win32... if you give me a hint about macros name it could be 
written in a
[...]
         /* find a source dir */
#ifdef _WIN32
         src_path = FFMAX(strrchr(src, '/'), strrchr(src, '\\'));
#else /*  !_WIN32 */
         src_path = strrchr(src, '/');
#ifdef /* _WIN32 */
[...]

> 
>> +        if (src_path)
>> +            src_path++;
>> +        else
>> +            src_path = src;
>> +
>> +        /* find tail by ref->path and nlvl_To */
>> +        for (i = 0, l = strlen(ref->path) - 1; l>= 0; l--)
>> +            if ('/' == ref->path[l]) {
>> +                if(i == ref->nlvl_to - 1) break;
>> +                else                      i++;
>> +            }
>> +
>> +        /* check if it found */
>> +        if (i == ref->nlvl_to - 1) {
>> +            c = l + 1;
>> +
>> +            l = 1024;
>> +            filename[0] = 0;
>> +
>> +            strncat(filename, src, src_path - src);
>> +            l -= src_path - src;
>> +
>> +            for (i = 1; i<  ref->nlvl_from; i++, l -= 3)
>> +                strncat(filename, "../", l);
>> +
>> +            strncat(filename, ref->path + c, l);
>> +
>> +            /* probe open */
>> +            if (!url_fopen(pb, filename, URL_RDONLY))
>> +                return 0;
>> +        }
[...]
> Also please use av_strlcat.
ok

> 
>> +            /* probe open */
>> +            if (!url_fopen(pb, filename, URL_RDONLY))
>> +                return 0;
>> +        }
>> +    }
>> +
>> +    /* probe open */
>> +    return url_fopen(pb, ref->path, URL_RDONLY);
> 
> Absolute path must be tried first.
There is document 
http://developer.apple.com/legacy/mac/library/documentation/mac/files/Files-343.html 

/.../
  You can request either a relative or an absolute search. If you 
request an absolute search, you can specify whether the search should be 
either fast or exhaustive. (A relative search is always a fast search.) 
As you can see, there are three general search strategies available to 
your application for resolving alias records:

     * relative search (always fast)
     * absolute fast search
     * absolute exhaustive search
/.../
so i selected *relative search* as first, but if you say /must be tried 
first/ that will be tried first...

> 
> After thinking I'm not sure nlvl_to is worth using. I feel like it's 
> either file referenced is in the same directory "./", in dref->dir 
> "./<dref->dir", "../"*nlvl_from and maybe "../"*nlvl_from/dref->dir
> 
> What do you think ? Did you check how quicktime behave ?

i did more research on case #2 ( if (1 == ref->nlvl_to&&  ref->dir) { ) 
and can't build a proper tests to prove it used by Quicktime, so it 
seems it useless and could be dropped. It will be greate if somebody 
will describe method for relative search based on dref->dir, 
dref->filename and dref->nlvl_(to|from) if it really exist, like is said:
/.../
   - NOTE: the directory name is used in a relative search and the FS 
directory
            IDs are used inconjunction with the nlvl's (next level values)
/.../

*mov_refs_open_dref_v3.patch* attached.

BTW are there any avlimits.h so i can use constant instead of 1024 in 
filename size?

-- 
________________________________________
Maksym Veremeyenko
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mov_refs_open_dref_v3.patch
Type: text/x-patch
Size: 2463 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090910/b6f4c6e0/attachment.bin>



More information about the ffmpeg-devel mailing list