summaryrefslogtreecommitdiffstats
path: root/libavformat/asfdec_f.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-07-22 01:09:14 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-07-22 01:21:17 +0200
commit5d79a0731675496c636379553af02c739bae030c (patch)
treeb8e9f0de6940cda764ee010ce3cf89c7533e532a /libavformat/asfdec_f.c
parent385eb066ce8c4be42a3f1d8c390137499cb35dd5 (diff)
downloadffmpeg-streaming-5d79a0731675496c636379553af02c739bae030c.zip
ffmpeg-streaming-5d79a0731675496c636379553af02c739bae030c.tar.gz
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: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/asfdec_f.c')
-rw-r--r--libavformat/asfdec_f.c81
1 files changed, 46 insertions, 35 deletions
diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index ee22de3..8c93b6a 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -113,6 +113,8 @@ typedef struct ASFContext {
int no_resync_search;
int export_xmp;
+
+ int uses_std_ecc;
} ASFContext;
static const AVOption options[] = {
@@ -956,44 +958,53 @@ static int asf_get_packet(AVFormatContext *s, AVIOContext *pb)
int rsize = 8;
int c, d, e, off;
- // if we do not know packet size, allow skipping up to 32 kB
- off = 32768;
- if (asf->no_resync_search)
- off = 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;
- d = e;
- e = avio_r8(pb);
- if (c == 0x82 && !d && !e)
- break;
- }
+ if (asf->uses_std_ecc >= 0) {
+ // if we do not know packet size, allow skipping up to 32 kB
+ off = 32768;
+ if (asf->no_resync_search)
+ off = 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;
+ d = e;
+ e = avio_r8(pb);
+ if (c == 0x82 && !d && !e)
+ break;
+ }
- if (c != 0x82) {
- /* This code allows handling of -EAGAIN at packet boundaries (i.e.
- * if the packet sync code above triggers -EAGAIN). This does not
- * imply complete -EAGAIN handling support at random positions in
- * the stream. */
- if (pb->error == AVERROR(EAGAIN))
- return AVERROR(EAGAIN);
- if (!avio_feof(pb))
- av_log(s, AV_LOG_ERROR,
- "ff asf bad header %x at:%"PRId64"\n", c, avio_tell(pb));
- }
- if ((c & 0x8f) == 0x82) {
- if (d || e) {
+ if (!asf->uses_std_ecc) {
+ asf->uses_std_ecc = (c == 0x82 && !d && !e) ? 1 : -1;
+ }
+
+ if (c != 0x82) {
+ /* This code allows handling of -EAGAIN at packet boundaries (i.e.
+ * if the packet sync code above triggers -EAGAIN). This does not
+ * imply complete -EAGAIN handling support at random positions in
+ * the stream. */
+ if (pb->error == AVERROR(EAGAIN))
+ return AVERROR(EAGAIN);
if (!avio_feof(pb))
- av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
- return AVERROR_INVALIDDATA;
+ av_log(s, AV_LOG_ERROR,
+ "ff asf bad header %x at:%"PRId64"\n", c, avio_tell(pb));
}
- c = avio_r8(pb);
- d = avio_r8(pb);
- rsize += 3;
- } else if(!avio_feof(pb)) {
- avio_seek(pb, -1, SEEK_CUR); // FIXME
+ if ((c & 0x8f) == 0x82) {
+ if (d || e) {
+ if (!avio_feof(pb))
+ av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
+ 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;
OpenPOWER on IntegriCloud