Commit 5d79a073 authored by Michael Niedermayer's avatar Michael Niedermayer

avformat/asfdec_f: Do not print errors if packets do not start with ECC

There is nothing wrong with such packets, the spec allows this
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 385eb066
...@@ -113,6 +113,8 @@ typedef struct ASFContext { ...@@ -113,6 +113,8 @@ typedef struct ASFContext {
int no_resync_search; int no_resync_search;
int export_xmp; int export_xmp;
int uses_std_ecc;
} ASFContext; } ASFContext;
static const AVOption options[] = { static const AVOption options[] = {
...@@ -956,44 +958,53 @@ static int asf_get_packet(AVFormatContext *s, AVIOContext *pb) ...@@ -956,44 +958,53 @@ static int asf_get_packet(AVFormatContext *s, AVIOContext *pb)
int rsize = 8; int rsize = 8;
int c, d, e, off; int c, d, e, off;
// if we do not know packet size, allow skipping up to 32 kB if (asf->uses_std_ecc >= 0) {
off = 32768; // if we do not know packet size, allow skipping up to 32 kB
if (asf->no_resync_search) off = 32768;
off = 3; if (asf->no_resync_search)
else if (s->packet_size > 0) off = 3;
off = (avio_tell(pb) - s->internal->data_offset) % s->packet_size + 3; else if (s->packet_size > 0)
off = (avio_tell(pb) - s->internal->data_offset) % s->packet_size + 3;
c = d = e = -1;
while (off-- > 0) { c = d = e = -1;
c = d; while (off-- > 0) {
d = e; c = d;
e = avio_r8(pb); d = e;
if (c == 0x82 && !d && !e) e = avio_r8(pb);
break; if (c == 0x82 && !d && !e)
} break;
}
if (c != 0x82) { if (!asf->uses_std_ecc) {
/* This code allows handling of -EAGAIN at packet boundaries (i.e. asf->uses_std_ecc = (c == 0x82 && !d && !e) ? 1 : -1;
* if the packet sync code above triggers -EAGAIN). This does not }
* imply complete -EAGAIN handling support at random positions in
* the stream. */ if (c != 0x82) {
if (pb->error == AVERROR(EAGAIN)) /* This code allows handling of -EAGAIN at packet boundaries (i.e.
return AVERROR(EAGAIN); * if the packet sync code above triggers -EAGAIN). This does not
if (!avio_feof(pb)) * imply complete -EAGAIN handling support at random positions in
av_log(s, AV_LOG_ERROR, * the stream. */
"ff asf bad header %x at:%"PRId64"\n", c, avio_tell(pb)); if (pb->error == AVERROR(EAGAIN))
} return AVERROR(EAGAIN);
if ((c & 0x8f) == 0x82) {
if (d || e) {
if (!avio_feof(pb)) if (!avio_feof(pb))
av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n"); av_log(s, AV_LOG_ERROR,
return AVERROR_INVALIDDATA; "ff asf bad header %x at:%"PRId64"\n", c, avio_tell(pb));
} }
c = avio_r8(pb); if ((c & 0x8f) == 0x82) {
d = avio_r8(pb); if (d || e) {
rsize += 3; if (!avio_feof(pb))
} else if(!avio_feof(pb)) { av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
avio_seek(pb, -1, SEEK_CUR); // FIXME return AVERROR_INVALIDDATA;
}
c = avio_r8(pb);
d = avio_r8(pb);
rsize += 3;
} else if(!avio_feof(pb)) {
avio_seek(pb, -1, SEEK_CUR); // FIXME
}
} else {
c = avio_r8(pb);
d = avio_r8(pb);
} }
asf->packet_flags = c; asf->packet_flags = c;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment