[FFmpeg-devel] [PATCH 2/2] avformat/mpegts: Skip over broken 0x80 headers

Michael Niedermayer michael at niedermayer.cc
Sun Apr 24 04:53:57 CEST 2016


On Sat, Apr 23, 2016 at 06:09:37PM -0700, Ronald S. Bultje wrote:
> Hi,
> 
> On Sun, Apr 10, 2016 at 11:12 AM, Michael Niedermayer <
> michael at niedermayer.cc> wrote:
> 
> > @@ -2344,6 +2344,12 @@ static int mpegts_resync(AVFormatContext *s, int
> > seekback)
> >
> >      avio_seek(pb, -FFMIN(seekback, pos), SEEK_CUR);
> >
> > +    //Special case for files like 01c56b0dc1.ts
> > +    if (current_packet[0] == 0x80 && current_packet[12] == 0x47) {
> > +        avio_seek(pb, 12, SEEK_CUR);
> > +        return 0;
> > +    }
> > +
> >      for (i = 0; i < ts->resync_size; i++) {
> >          c = avio_r8(pb);
> >          if (avio_feof(pb))
> 
> 
> This comment doesn't explain why this is OK. What is 0x47? What is 0x80?
> Why 0 and 12? Why is 01.ts broken and why does this fix it?
> 
> This may be really cleverly designed, but right now (b/c of the useless
> comment), it looks like a custom hack that nobody will ever understand. If
> Michael is hit by a bus, this code will thus be deleted. The file will
> re-break, even with this comment.

0x47 is expected to be at [0] but the affected files contain something
else sometimes in its place that starts with 0x80 and is 12 bytes long
it contains some counter or timestamp
without the code above it will almost always work but if the counter
contains a 0x47 in it resync can start at the wrong byte

I dont know what created these kind of files, so even if iam not
hit by a bus i think i am not too usefull here
i was hoping a bit my patch would lead to someone recognizing this ...

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160424/a8fadfb2/attachment.sig>


More information about the ffmpeg-devel mailing list