comparison raw.c @ 4254:d05b13327b07 libavformat

Fix probing of files with ID3v2 tags. Discussed at http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2009-January/059302.html
author alexc
date Mon, 19 Jan 2009 21:54:06 +0000
parents 77e0c7511d41
children d8803d0a4274
comparison
equal deleted inserted replaced
4253:b43c5c858f25 4254:d05b13327b07
24 #include "libavcodec/ac3_parser.h" 24 #include "libavcodec/ac3_parser.h"
25 #include "libavcodec/bitstream.h" 25 #include "libavcodec/bitstream.h"
26 #include "libavcodec/bytestream.h" 26 #include "libavcodec/bytestream.h"
27 #include "avformat.h" 27 #include "avformat.h"
28 #include "raw.h" 28 #include "raw.h"
29 #include "id3v2.h"
29 30
30 /* simple formats */ 31 /* simple formats */
31 #if CONFIG_FLAC_MUXER 32 #if CONFIG_FLAC_MUXER
32 static int flac_write_header(struct AVFormatContext *s) 33 static int flac_write_header(struct AVFormatContext *s)
33 { 34 {
580 #if CONFIG_AAC_DEMUXER 581 #if CONFIG_AAC_DEMUXER
581 static int adts_aac_probe(AVProbeData *p) 582 static int adts_aac_probe(AVProbeData *p)
582 { 583 {
583 int max_frames = 0, first_frames = 0; 584 int max_frames = 0, first_frames = 0;
584 int fsize, frames; 585 int fsize, frames;
586 uint8_t *buf0 = p->buf;
585 uint8_t *buf2; 587 uint8_t *buf2;
586 uint8_t *buf = p->buf; 588 uint8_t *buf;
587 uint8_t *end = buf + p->buf_size - 7; 589 uint8_t *end = buf0 + p->buf_size - 7;
590
591 if (ff_id3v2_match(buf0)) {
592 buf0 += ff_id3v2_tag_len(buf0);
593 }
594 buf = buf0;
588 595
589 for(; buf < end; buf= buf2+1) { 596 for(; buf < end; buf= buf2+1) {
590 buf2 = buf; 597 buf2 = buf;
591 598
592 for(frames = 0; buf2 < end; frames++) { 599 for(frames = 0; buf2 < end; frames++) {
597 if(fsize < 7) 604 if(fsize < 7)
598 break; 605 break;
599 buf2 += fsize; 606 buf2 += fsize;
600 } 607 }
601 max_frames = FFMAX(max_frames, frames); 608 max_frames = FFMAX(max_frames, frames);
602 if(buf == p->buf) 609 if(buf == buf0)
603 first_frames= frames; 610 first_frames= frames;
604 } 611 }
605 if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1; 612 if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
606 else if(max_frames>500)return AVPROBE_SCORE_MAX/2; 613 else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
607 else if(max_frames>=3) return AVPROBE_SCORE_MAX/4; 614 else if(max_frames>=3) return AVPROBE_SCORE_MAX/4;