[FFmpeg-devel] [PATCH 6/8] add SRT muxer and demuxer

Aurelien Jacobs aurel
Thu Jul 22 22:27:43 CEST 2010


On Thu, Jul 22, 2010 at 02:18:43PM +0200, Michael Niedermayer wrote:
> On Wed, Jul 21, 2010 at 11:53:17AM +0200, Aurelien Jacobs wrote:
> [...]
> > +static int srt_read_packet(AVFormatContext *s, AVPacket *pkt)
> > +{
> > +    char buffer[2048], *ptr = buffer, *ptr2 = ptr;
> > +    int64_t pos = url_ftell(s->pb);
> > +    int res = AVERROR_EOF;
> > +
> > +    while (!is_eol(*ptr2) && !url_feof(s->pb) && ptr-buffer<sizeof(buffer)-1) {
> 
> that is_eol looks like its reading from uninited mem

Yes... It looks like it.
Fixed now.

> > +        ptr2 = ptr;
> > +        ptr += ff_get_line(s->pb, ptr, sizeof(buffer)+buffer-ptr);
> > +    }
> 
> besides why is ff_get_line() in a loop, i would naively have expected
> a single call to work?

A single call of ff_get_line() will only return a single line of text.
A single SRT subtitle event is composed of multiple lines, hence the
loop. Events are separated by an empty line.

Aurel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 06-add-srt-muxer-and-demuxer.patch
Type: text/x-diff
Size: 7029 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100722/6672ab1b/attachment.patch>



More information about the ffmpeg-devel mailing list