Mercurial > libavformat.hg
comparison raw.c @ 3570:2adcaa7f6dff libavformat
h264_probe()
author | michael |
---|---|
date | Sat, 12 Jul 2008 19:50:48 +0000 |
parents | 45c3d2b2b2fb |
children | 68e5f9adb0f4 |
comparison
equal
deleted
inserted
replaced
3569:d5a8fa1db677 | 3570:2adcaa7f6dff |
---|---|
345 if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0) | 345 if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0) |
346 return AVPROBE_SCORE_MAX/2; | 346 return AVPROBE_SCORE_MAX/2; |
347 return 0; | 347 return 0; |
348 } | 348 } |
349 | 349 |
350 static int h264_probe(AVProbeData *p) | |
351 { | |
352 uint32_t code= -1; | |
353 int sps=0, pps=0, idr=0, res=0; | |
354 int i; | |
355 | |
356 for(i=0; i<p->buf_size; i++){ | |
357 code = (code<<8) + p->buf[i]; | |
358 if ((code & 0xffffff00) == 0x100) { | |
359 int ref_idc= (code>>5)&3; | |
360 int type = code & 0x1F; | |
361 static const int8_t ref_zero[32]={ | |
362 2, 0, 0, 0, 0,-1, 1,-1, | |
363 -1, 1, 1, 1, 1,-1, 2, 2, | |
364 2, 2, 2, 0, 2, 2, 2, 2, | |
365 2, 2, 2, 2, 2, 2, 2, 2 | |
366 }; | |
367 | |
368 if(code & 0x80) //forbidden bit | |
369 return 0; | |
370 | |
371 if(ref_zero[type] == 1 && ref_idc) | |
372 return 0; | |
373 if(ref_zero[type] ==-1 && !ref_idc) | |
374 return 0; | |
375 if(ref_zero[type] == 2) | |
376 res++; | |
377 | |
378 switch(type){ | |
379 case 5: idr++; break; | |
380 case 7: | |
381 if(p->buf[i+2]&0x0F) | |
382 return 0; | |
383 sps++; | |
384 break; | |
385 case 8: pps++; break; | |
386 } | |
387 } | |
388 } | |
389 if(sps && pps && idr && res<(sps+pps+idr)) | |
390 return AVPROBE_SCORE_MAX/2+1; // +1 for .mpg | |
391 return 0; | |
392 } | |
393 | |
350 static int h263_probe(AVProbeData *p) | 394 static int h263_probe(AVProbeData *p) |
351 { | 395 { |
352 int code; | 396 int code; |
353 const uint8_t *d; | 397 const uint8_t *d; |
354 | 398 |
645 | 689 |
646 AVInputFormat h264_demuxer = { | 690 AVInputFormat h264_demuxer = { |
647 "h264", | 691 "h264", |
648 NULL_IF_CONFIG_SMALL("raw H.264 video format"), | 692 NULL_IF_CONFIG_SMALL("raw H.264 video format"), |
649 0, | 693 0, |
650 NULL /*mpegvideo_probe*/, | 694 h264_probe, |
651 video_read_header, | 695 video_read_header, |
652 raw_read_partial_packet, | 696 raw_read_partial_packet, |
653 .flags= AVFMT_GENERIC_INDEX, | 697 .flags= AVFMT_GENERIC_INDEX, |
654 .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe | 698 .extensions = "h26l,h264,264", //FIXME remove after writing mpeg4_probe |
655 .value = CODEC_ID_H264, | 699 .value = CODEC_ID_H264, |