Message ID | 20180330164606.29914-1-onemda@gmail.com |
---|---|
State | New |
Headers | show |
On Fri, Mar 30, 2018 at 06:46:06PM +0200, Paul B Mahol wrote: > Fixes #4889. > > Signed-off-by: Paul B Mahol <onemda@gmail.com> > --- > libavformat/mpeg.c | 27 +++++++++++++++++++-------- > 1 file changed, 19 insertions(+), 8 deletions(-) > > diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c > index 69d4a9d8ac..f6e3439e68 100644 > --- a/libavformat/mpeg.c > +++ b/libavformat/mpeg.c > @@ -128,6 +128,7 @@ typedef struct MpegDemuxContext { > int sofdec; > int dvd; > int imkh_cctv; > + int raw_ac3; > #if CONFIG_VOBSUB_DEMUXER > AVFormatContext *sub_ctx; > FFDemuxSubtitlesQueue q[32]; > @@ -443,7 +444,15 @@ redo: > > if (startcode == PRIVATE_STREAM_1) { > startcode = avio_r8(s->pb); > - len--; > + if (avio_r8(s->pb) == 0x77 && startcode == 0x0b) { > + startcode = 0x80; > + m->raw_ac3 = 1; > + avio_skip(s->pb, -2); > + } else { > + m->raw_ac3 = 0; > + avio_skip(s->pb, -1); I think these seekbacks are not safe, they could fail once every few thousand times depending on buffer positions if the underlaying input is not seekable a ffio_ensure_seekback() call should avoid this thats unless iam missing something ... [...] thx
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 69d4a9d8ac..f6e3439e68 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -128,6 +128,7 @@ typedef struct MpegDemuxContext { int sofdec; int dvd; int imkh_cctv; + int raw_ac3; #if CONFIG_VOBSUB_DEMUXER AVFormatContext *sub_ctx; FFDemuxSubtitlesQueue q[32]; @@ -443,7 +444,15 @@ redo: if (startcode == PRIVATE_STREAM_1) { startcode = avio_r8(s->pb); - len--; + if (avio_r8(s->pb) == 0x77 && startcode == 0x0b) { + startcode = 0x80; + m->raw_ac3 = 1; + avio_skip(s->pb, -2); + } else { + m->raw_ac3 = 0; + avio_skip(s->pb, -1); + len--; + } } if (len < 0) goto error_redo; @@ -486,14 +495,16 @@ redo: if (len < 4) goto skip; - /* audio: skip header */ - avio_r8(s->pb); - lpcm_header_len = avio_rb16(s->pb); - len -= 3; - if (startcode >= 0xb0 && startcode <= 0xbf) { - /* MLP/TrueHD audio has a 4-byte header */ + if (!m->raw_ac3) { + /* audio: skip header */ avio_r8(s->pb); - len--; + lpcm_header_len = avio_rb16(s->pb); + len -= 3; + if (startcode >= 0xb0 && startcode <= 0xbf) { + /* MLP/TrueHD audio has a 4-byte header */ + avio_r8(s->pb); + len--; + } } }
Fixes #4889. Signed-off-by: Paul B Mahol <onemda@gmail.com> --- libavformat/mpeg.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)