aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/avidec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-03-08 00:44:52 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-03-08 00:44:52 +0000
commit9bf9a5fcaeffd5a313f97fe9e4c75d8f47f5a149 (patch)
tree4844efd743f4a48df2b04e0fe8c7ae557b6603bd /libavformat/avidec.c
parent63f6082633e0ffbfe2ea8327197ecc63101f7d7d (diff)
downloadffmpeg-9bf9a5fcaeffd5a313f97fe9e4c75d8f47f5a149.tar.gz
reversing not yet reversed changes from r1.7 -> r1.8 except the static/const stuff
this seems to fix all avi parsing bugs kabi, can u explain what this was good for? Originally committed as revision 1644 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/avidec.c')
-rw-r--r--libavformat/avidec.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 4cba26918c..11fe838bcb 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -124,13 +124,16 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
get_le32(pb); /* XXX: initial frame ? */
get_le32(pb); /* scale */
get_le32(pb); /* rate */
- size -= 6 * 4;
+ url_fskip(pb, size - 7 * 4);
break;
case MKTAG('a', 'u', 'd', 's'):
codec_type = CODEC_TYPE_AUDIO;
/* nothing really useful */
+ url_fskip(pb, size - 4);
+ break;
+ default:
+ goto fail;
}
- url_fskip(pb, size - 4);
break;
case MKTAG('s', 't', 'r', 'f'):
/* stream header */
@@ -158,7 +161,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1);
url_fskip(pb, size - 5 * 4);
break;
- case CODEC_TYPE_AUDIO:
+ case CODEC_TYPE_AUDIO:
get_wav_header(pb, &st->codec, (size >= 18));
if (size%2) /* 2-aligned (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */
url_fskip(pb, 1);
@@ -194,25 +197,27 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
AVIContext *avi = s->priv_data;
ByteIOContext *pb = &s->pb;
int n, d1, d2, size;
-
- for(;;) {
- if (url_feof(pb) || url_ftell(pb) >= avi->movi_end)
- return -1;
- d1 = get_byte(pb) - '0';
- d2 = get_byte(pb) - '0';
- if (d1 < 0 || d1 > 9 || d2 < 0 || d2 > 9)
- continue;
-
- n = d1 * 10 + d2;
- if (n < 0 || n >= s->nb_streams)
- continue;
-
- d1 = get_byte(pb);
- d2 = get_byte(pb);
- if ((d1 == 'd' && d2 == 'c')
- || (d1 == 'w' && d2 == 'b'))
- break;
- }
+
+ find_next:
+ if (url_feof(pb) || url_ftell(pb) >= avi->movi_end)
+ return -1;
+ d1 = get_byte(pb);
+ if (d1 < '0' || d1 > '9')
+ goto find_next;
+ d2 = get_byte(pb);
+ if (d2 < '0' || d2 > '9')
+ goto find_next;
+ n = (d1 - '0') * 10 + (d2 - '0');
+
+ if (n < 0 || n >= s->nb_streams)
+ goto find_next;
+
+ d1 = get_byte(pb);
+ d2 = get_byte(pb);
+ if ((d1 != 'd' && d2 != 'c') &&
+ (d1 != 'w' && d2 != 'b'))
+ goto find_next;
+
size = get_le32(pb);
av_new_packet(pkt, size);
pkt->stream_index = n;