[FFmpeg-devel] [PATCH] Add SUP/PGS subtitle demuxer

Michael Niedermayer michaelni at gmx.at
Sun Aug 31 11:40:14 CEST 2014


On Sun, Aug 31, 2014 at 09:41:49AM +0200, Reimar Döffinger wrote:
> On 30.08.2014, at 15:38, wm4 <nfxjfg at googlemail.com> wrote:
> > +    // The packet-size is stored as part of the packet.
> > +    if ((ret = avio_read(s->pb, tmp, 3)) < 0)
> > +        return ret;
> > +
> > +    len = AV_RB16(tmp + 1);
> > +
> > +    if ((ret = av_new_packet(pkt, len + 3)) < 0)
> > +        return ret;
> > +
> > +    memcpy(pkt->data, tmp, 3);
> > +
> > +    if ((ret = avio_read(s->pb, pkt->data + 3, len)) < 0) {
> > +        av_free_packet(pkt);
> > +        return ret;
> > +    }
> 
> I think this will not handle short reads correctly, retuning uninitialised data.

> My suggestion would be to read the length, then seek back (buffering should ensure this is no issue even if we read from stdin) and then use the functions to read the full packet with all the proper error handling.

note, for guranteed seekback on non seekable input
ffio_ensure_seekback() is needed


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

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140831/a52e5122/attachment.asc>


More information about the ffmpeg-devel mailing list