aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/avidec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2008-10-04 21:57:01 +0000
committerMichael Niedermayer <michaelni@gmx.at>2008-10-04 21:57:01 +0000
commitf080a7bd90bd093820156d2eefcad027f7139ea1 (patch)
treefe7c2c98ced3ccd868876cb16f6f959bc5f01fe1 /libavformat/avidec.c
parent6bc03a695bc4c1ecd212263c4a3c9cf638d025e0 (diff)
downloadffmpeg-f080a7bd90bd093820156d2eefcad027f7139ea1.tar.gz
Factorize stream id parsing.
Originally committed as revision 15556 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/avidec.c')
-rw-r--r--libavformat/avidec.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index c9c27e262d..1a9a11c439 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -614,6 +614,15 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
return 0;
}
+static int get_stream_idx(int *d){
+ if( d[0] >= '0' && d[0] <= '9'
+ && d[1] >= '0' && d[1] <= '9'){
+ return (d[0] - '0') * 10 + (d[1] - '0');
+ }else{
+ return 100; //invalid stream ID
+ }
+}
+
static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIContext *avi = s->priv_data;
@@ -756,12 +765,7 @@ resync:
size= d[4] + (d[5]<<8) + (d[6]<<16) + (d[7]<<24);
- if( d[2] >= '0' && d[2] <= '9'
- && d[3] >= '0' && d[3] <= '9'){
- n= (d[2] - '0') * 10 + (d[3] - '0');
- }else{
- n= 100; //invalid stream id
- }
+ n= get_stream_idx(d+2);
//av_log(NULL, AV_LOG_DEBUG, "%X %X %X %X %X %X %X %X %"PRId64" %d %d\n", d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], i, size, n);
if(i + size > avi->fsize || d[0]<0)
continue;
@@ -776,12 +780,7 @@ resync:
goto resync;
}
- if( d[0] >= '0' && d[0] <= '9'
- && d[1] >= '0' && d[1] <= '9'){
- n= (d[0] - '0') * 10 + (d[1] - '0');
- }else{
- n= 100; //invalid stream ID
- }
+ n= get_stream_idx(d);
//parse ##dc/##wb
if(n < s->nb_streams){