summaryrefslogtreecommitdiff
path: root/libavformat/raw.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2009-09-14 19:06:36 +0000
committerMichael Niedermayer <michaelni@gmx.at>2009-09-14 19:06:36 +0000
commite4c01d408a30d9a89ee9a9509f68923b3b715bd9 (patch)
tree69e7c04faa96fbf88cf4c007c64eb1938f7dfad3 /libavformat/raw.c
parent21ab5c58270271dbebc061015187bca02e5d51ce (diff)
Rewrite h263_probe().
The new code should detect h263 even if the first startcode is damaged or somewhere else than the first byte. It also passes probetest v2 as just posted on ffmpeg-dev. Originally committed as revision 19841 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/raw.c')
-rw-r--r--libavformat/raw.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/libavformat/raw.c b/libavformat/raw.c
index c52235f47b..d88f3ee8a3 100644
--- a/libavformat/raw.c
+++ b/libavformat/raw.c
@@ -455,14 +455,33 @@ static int h264_probe(AVProbeData *p)
#if CONFIG_H263_DEMUXER
static int h263_probe(AVProbeData *p)
{
- int code;
- const uint8_t *d;
+ uint64_t code= -1;
+ int i;
+ int valid_psc=0;
+ int invalid_psc=0;
+ int res_change=0;
+ int src_fmt, last_src_fmt=-1;
- d = p->buf;
- code = (d[0] << 14) | (d[1] << 6) | (d[2] >> 2);
- if (code == 0x20) {
- return 50;
+ for(i=0; i<p->buf_size; i++){
+ code = (code<<8) + p->buf[i];
+ if ((code & 0xfffffc0000) == 0x800000) {
+ src_fmt= (code>>2)&3;
+ if( src_fmt != last_src_fmt
+ && last_src_fmt>0 && last_src_fmt<6
+ && src_fmt<6)
+ res_change++;
+
+ if((code&0x300)==0x200 && src_fmt){
+ valid_psc++;
+ }else
+ invalid_psc++;
+ last_src_fmt= src_fmt;
+ }
}
+ if(valid_psc > 2*invalid_psc + 2*res_change + 2){
+ return 50;
+ }else if(valid_psc > 2*invalid_psc)
+ return 25;
return 0;
}
#endif