comparison raw.c @ 5183:3f35ada98286 libavformat

Rewrite h261_probe(). New code can detect h261 startcodes even when the first is damaged or not at the begin. It also passes probetest v2 & v3.
author michael
date Mon, 14 Sep 2009 21:29:19 +0000
parents 34ec401808a8
children 2d15ea28c450
comparison
equal deleted inserted replaced
5182:34ec401808a8 5183:3f35ada98286
487 #endif 487 #endif
488 488
489 #if CONFIG_H261_DEMUXER 489 #if CONFIG_H261_DEMUXER
490 static int h261_probe(AVProbeData *p) 490 static int h261_probe(AVProbeData *p)
491 { 491 {
492 int code; 492 uint32_t code= -1;
493 const uint8_t *d; 493 int i;
494 494 int valid_psc=0;
495 d = p->buf; 495 int invalid_psc=0;
496 code = (d[0] << 12) | (d[1] << 4) | (d[2] >> 4); 496 int next_gn=0;
497 if (code == 0x10) { 497 int src_fmt=0;
498 GetBitContext gb;
499
500 init_get_bits(&gb, p->buf, p->buf_size*8);
501
502 for(i=0; i<p->buf_size*8; i++){
503 code = (code<<1) + get_bits1(&gb);
504 if ((code & 0xffff0000) == 0x10000) {
505 int gn= (code>>12)&0xf;
506 if(!gn)
507 src_fmt= code&8;
508 if(gn != next_gn) invalid_psc++;
509 else valid_psc++;
510
511 if(src_fmt){ // CIF
512 next_gn= (gn+1 )%13;
513 }else{ //QCIF
514 next_gn= (gn+1+!!gn)% 7;
515 }
516 }
517 }
518 if(valid_psc > 2*invalid_psc + 4){
498 return 50; 519 return 50;
499 } 520 }else if(valid_psc > 2*invalid_psc + 2)
521 return 25;
500 return 0; 522 return 0;
501 } 523 }
502 #endif 524 #endif
503 525
504 #if CONFIG_DTS_DEMUXER 526 #if CONFIG_DTS_DEMUXER