[FFmpeg-devel] [PATCH] Move av_open_input_file probe loop to its own method
Micah F. Galizia
micahgalizia
Tue Mar 23 01:41:44 CET 2010
On 10-03-21 01:04 PM, Michael Niedermayer wrote:
> On Sat, Mar 20, 2010 at 05:14:40PM -0400, Micah F. Galizia wrote:
> [..]
>> Sorry,the last one has a memory leak -- probe_buffer9.diff corrects it.
>>
>> --
>> Micah F. Galizia
>> micahgalizia at gmail.com
>>
>> "The mark of an immature man is that he wants to die nobly for a cause,
>> while the mark of the mature man is that he wants to live humbly for one."
>> --W. Stekel
>
>> utils.c | 8 ++++++--
>> 1 file changed, 6 insertions(+), 2 deletions(-)
>> e3511efa72382199d1a4855b4a761ad0964c0ead probe_buffer9.diff
>
>> Index: libavformat/utils.c
>> ===================================================================
>> --- libavformat/utils.c (revision 22608)
>> +++ libavformat/utils.c (working copy)
>> @@ -478,7 +478,8 @@
>> return AVERROR(EINVAL);
>> }
>>
>> - for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size&& !*fmt&& ret>= 0; probe_size<<=1){
>> + for(probe_size= PROBE_BUF_MIN; probe_size<=max_probe_size&& !*fmt&& ret>= 0;
>> + probe_size = FFMIN(probe_size<<1, max_probe_size)){
>
> hmm, this doesnt behave reasonable at all, the check is never false and
> theres lots of dead code after the loop and you duplicate this inside the loop
> incorrectly without a goto fail where a break should do i think
I'm not sure I understand all of what your saying or agree that the code
is dead. Also, I dont see why a using a goto and adding a fail label is
preferred to returning an error, which will do the same job (with less
code in this case).
> something like:
> FFMIN(probe_size<<1, FFMAX(max_probe_size, probe_size+1))
> might simplify it but maybe there are better alternatives ..
That is a good one-liner to achieve desired effect. I've used it in the
new patch attached, which does not require a break inside the loop for
the loop to finish.
TIA
--
Micah F. Galizia
micahgalizia at gmail.com
"The mark of an immature man is that he wants to die nobly for a cause,
while the mark of the mature man is that he wants to live humbly for
one." --W. Stekel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: probe_buffer10.diff
Type: text/x-diff
Size: 902 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100322/c2ee8295/attachment.diff>
More information about the ffmpeg-devel
mailing list