avformat/mpegts: Skip over broken 0x80 headers
This fixes demuxing of 01c56b0dc1.ts Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
ea41ab0987
commit
dbe1dd59e0
1 changed files with 9 additions and 3 deletions
|
@ -2354,7 +2354,7 @@ static void reanalyze(MpegTSContext *ts) {
|
||||||
|
|
||||||
/* XXX: try to find a better synchro over several packets (use
|
/* XXX: try to find a better synchro over several packets (use
|
||||||
* get_packet_size() ?) */
|
* get_packet_size() ?) */
|
||||||
static int mpegts_resync(AVFormatContext *s, int seekback)
|
static int mpegts_resync(AVFormatContext *s, int seekback, const uint8_t *current_packet)
|
||||||
{
|
{
|
||||||
MpegTSContext *ts = s->priv_data;
|
MpegTSContext *ts = s->priv_data;
|
||||||
AVIOContext *pb = s->pb;
|
AVIOContext *pb = s->pb;
|
||||||
|
@ -2363,6 +2363,12 @@ static int mpegts_resync(AVFormatContext *s, int seekback)
|
||||||
|
|
||||||
avio_seek(pb, -FFMIN(seekback, pos), SEEK_CUR);
|
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++) {
|
for (i = 0; i < ts->resync_size; i++) {
|
||||||
c = avio_r8(pb);
|
c = avio_r8(pb);
|
||||||
if (avio_feof(pb))
|
if (avio_feof(pb))
|
||||||
|
@ -2394,7 +2400,7 @@ static int read_packet(AVFormatContext *s, uint8_t *buf, int raw_packet_size,
|
||||||
if ((*data)[0] != 0x47) {
|
if ((*data)[0] != 0x47) {
|
||||||
/* find a new packet start */
|
/* find a new packet start */
|
||||||
|
|
||||||
if (mpegts_resync(s, raw_packet_size) < 0)
|
if (mpegts_resync(s, raw_packet_size, *data) < 0)
|
||||||
return AVERROR(EAGAIN);
|
return AVERROR(EAGAIN);
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
@ -2749,7 +2755,7 @@ static av_unused int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index,
|
||||||
if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
|
if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
|
||||||
return AV_NOPTS_VALUE;
|
return AV_NOPTS_VALUE;
|
||||||
if (buf[0] != 0x47) {
|
if (buf[0] != 0x47) {
|
||||||
if (mpegts_resync(s, TS_PACKET_SIZE) < 0)
|
if (mpegts_resync(s, TS_PACKET_SIZE, buf) < 0)
|
||||||
return AV_NOPTS_VALUE;
|
return AV_NOPTS_VALUE;
|
||||||
pos = avio_tell(s->pb);
|
pos = avio_tell(s->pb);
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue