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

Michael Niedermayer michaelni
Thu Jun 25 12:46:20 CEST 2009


On Wed, Jun 24, 2009 at 04:15:22PM -0700, Baptiste Coudurier wrote:
> Michael Niedermayer wrote:
> > On Wed, Jun 24, 2009 at 12:47:14PM -0700, Baptiste Coudurier wrote:
> >> Hi Michael,
> >>
> >> Michael Niedermayer wrote:
> >>> On Wed, Jun 03, 2009 at 03:29:48PM -0700, Baptiste Coudurier wrote:
> >>>> Michael Niedermayer wrote:
> >>>>> On Mon, Jun 01, 2009 at 09:50:47PM -0700, Baptiste Coudurier wrote:
> >>>>>> Michael Niedermayer wrote:
> >>>>>>> On Mon, Jun 01, 2009 at 03:37:55PM -0700, Baptiste Coudurier wrote:
> >>>>>>>> Michael Niedermayer wrote:
> >>>>>>>>> On Mon, Jun 01, 2009 at 12:36:54PM -0700, Baptiste Coudurier wrote:
> >>>>>>>>>> Michael Niedermayer wrote:
> >>>>>>>>>>> On Sun, May 31, 2009 at 02:53:34AM -0700, Baptiste Coudurier wrote:
[...]
> >>>>>> Patch attached. I believe using probesize is a good opportunity and I
> >>>>>> plan to replace MAX_READ_SIZE by probesize too, changing probesize
> >>>>>> default to 5000000.
> >>>>>>
> >>>>>> I find the FFMAX a bit ugly but I feel it would be safer.
> >>>>> [...]
> >>>>>> @@ -532,8 +534,13 @@ int av_read_packet(AVFormatContext *s, AVPacket *p
> >>>>>>          if (pktl) {
> >>>>>>              *pkt = pktl->pkt;
> >>>>>>              if(s->streams[pkt->stream_index]->codec->codec_id != CODEC_ID_PROBE ||
> >>>>>> -               !s->streams[pkt->stream_index]->probe_packets){
> >>>>>> +               !s->streams[pkt->stream_index]->probe_packets ||
> >>>>>> +               s->raw_packet_buffer_remaining_size <= 0){
> >>>>>> +                AVProbeData *pd = &st->probe_data;
> >>>>>> +                av_freep(&pd->buf);
> >>>>>> +                pd->buf_size = 0;
> >>>>>>                  s->raw_packet_buffer = pktl->next;
> >>>>>> +                s->raw_packet_buffer_remaining_size += pkt->size;
> >>>>>>                  av_free(pktl);
> >>>>>>                  return 0;
> >>>>>>              }
> >>>>>> @@ -567,6 +574,8 @@ int av_read_packet(AVFormatContext *s, AVPacket *p
> >>>>>>              return ret;
> >>>>>>  
> >>>>>>          add_to_pktbuf(&s->raw_packet_buffer, pkt, &s->raw_packet_buffer_end);
> >>>>>> +        s->raw_packet_buffer_remaining_size =
> >>>>>> +            FFMAX(0, s->raw_packet_buffer_remaining_size - pkt->size);
> >>>>>>  
> >>>>>>          if(st->codec->codec_id == CODEC_ID_PROBE){
> >>>>>>              AVProbeData *pd = &st->probe_data;
> >>>>> is the combination of FFMAX here and the += pkt->size; above not able to
> >>>>> change raw_packet_buffer_remaining_size to a value that is beyond the
> >>>>> initial limit ?
> >>>> That's possible indeed, I was wondering is this would be safe. If you
> >>>> think it's safer to limit it as well, here is an updated patch.
> >>> i think it should be possible to remove both FFMIN&MAX
> >>> we just have to check the remaining size against the packet size instead
> >>> of against 0 then we can always saftely subtract it
> >> I'm not sure to understand what you mean here.
> >> Can you please clarify by code ?
> >>
> >> Do you mean
> >> if (s->raw_packet_buffer_remaining_size >= pkt->size)
> >>     remaining_size -= pkt->size;
> >>
> >> ?
> >>
> >> How would you change the check above ?
> > 
> > what i meant is to replace
> > if(raw_packet_buffer_remaining_size <= 0)
> >     end
> > by
> > if(raw_packet_buffer_remaining_size < next_packet)
> >     end
> > 
> > that way the next packet will always fit in raw_packet_buffer_remaining_size
> > and can be subtracted without MIN/MAX
> 
> Ok, patch attached.
> 
> -- 
> Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
> Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
> FFmpeg maintainer                                  http://www.ffmpeg.org

>  avformat.h |    7 +++++++
>  utils.c    |   11 ++++++++++-
>  2 files changed, 17 insertions(+), 1 deletion(-)
> 79a80d827ddafdbe8d82d00c650dd277711a76f2  raw_packet_buffer2.patch

ok

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090625/37abc4eb/attachment.pgp>



More information about the ffmpeg-devel mailing list