Commit 1c84fdf3 authored by michael's avatar michael

Factorize stream id parsing.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@15556 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 3aca6bc1
...@@ -614,6 +614,15 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -614,6 +614,15 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
return 0; 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) static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
{ {
AVIContext *avi = s->priv_data; AVIContext *avi = s->priv_data;
...@@ -756,12 +765,7 @@ resync: ...@@ -756,12 +765,7 @@ resync:
size= d[4] + (d[5]<<8) + (d[6]<<16) + (d[7]<<24); size= d[4] + (d[5]<<8) + (d[6]<<16) + (d[7]<<24);
if( d[2] >= '0' && d[2] <= '9' n= get_stream_idx(d+2);
&& d[3] >= '0' && d[3] <= '9'){
n= (d[2] - '0') * 10 + (d[3] - '0');
}else{
n= 100; //invalid stream id
}
//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); //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) if(i + size > avi->fsize || d[0]<0)
continue; continue;
...@@ -776,12 +780,7 @@ resync: ...@@ -776,12 +780,7 @@ resync:
goto resync; goto resync;
} }
if( d[0] >= '0' && d[0] <= '9' n= get_stream_idx(d);
&& d[1] >= '0' && d[1] <= '9'){
n= (d[0] - '0') * 10 + (d[1] - '0');
}else{
n= 100; //invalid stream ID
}
//parse ##dc/##wb //parse ##dc/##wb
if(n < s->nb_streams){ if(n < s->nb_streams){
......
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