[FFmpeg-devel] [PATCH] probe max read size

Baptiste Coudurier baptiste.coudurier
Sun May 31 23:21:16 CEST 2009


Baptiste Coudurier wrote:
> Baptiste Coudurier wrote:
>> Hi,
>>
>> After some tests, it seems more reasonable to stop probing after some
>> max size to avoid consuming to much memory.
>>
>> I propose to raise probesize default to MAX_READ_SIZE
>>
>> /* absolute maximum size we read until we abort */
>> #define MAX_READ_SIZE        5000000
>>
>> And also to replace all MAX_READ_SIZE occurence with s->probesize to
>> make it configurable.
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> Index: libavformat/utils.c
>> ===================================================================
>> --- libavformat/utils.c	(revision 19024)
>> +++ libavformat/utils.c	(working copy)
>> @@ -523,7 +523,7 @@
>>  
>>  int av_read_packet(AVFormatContext *s, AVPacket *pkt)
>>  {
>> -    int ret, i;
>> +    int ret, i, read_size = 0;
>>      AVStream *st;
>>  
>>      for(;;){
>> @@ -541,13 +541,16 @@
>>  
>>          av_init_packet(pkt);
>>          ret= s->iformat->read_packet(s, pkt);
>> -        if (ret < 0) {
>> -            if (!pktl || ret == AVERROR(EAGAIN))
>> -                return ret;
>> +        if (ret < 0 && (!pktl || ret == AVERROR(EAGAIN)))
>> +            return ret;
>> +        if (ret < 0 || read_size >= s->probesize) {
>>              for (i = 0; i < s->nb_streams; i++)
>>                  s->streams[i]->probe_packets = 0;
>>              continue;
>>          }
>> +
>> +        read_size += pkt->size;
>> +
>>          st= s->streams[pkt->stream_index];
>>  
>>          switch(st->codec->codec_type){
>>
> 
> Well there is a problem in the patch, packet just read must be buffered
> before "continue", this whole codec probing stuff is really non easy.
> 
> I'll check it tomorrow, if noones beats me ;)
> 

Maybe something like that.

-- 
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: probe_max_read_size.patch
Type: text/x-diff
Size: 973 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090531/14689fac/attachment.patch>



More information about the ffmpeg-devel mailing list