diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2007-03-18 19:32:22 +0000 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2007-03-18 19:32:22 +0000 |
commit | f8b9830b6c48a44821bc623d5fc4673db76099a5 (patch) | |
tree | e1876fe8efca921d6eb24a0a6875006feb141248 /libavformat/raw.c | |
parent | 9a44385e1a640693a7f636ffa44b53152433e8e7 (diff) | |
download | ffmpeg-streaming-f8b9830b6c48a44821bc623d5fc4673db76099a5.zip ffmpeg-streaming-f8b9830b6c48a44821bc623d5fc4673db76099a5.tar.gz |
improve ac3_probe by counting consecutive frames
Originally committed as revision 8441 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/raw.c')
-rw-r--r-- | libavformat/raw.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/libavformat/raw.c b/libavformat/raw.c index 0f60d6a..ee43e39 100644 --- a/libavformat/raw.c +++ b/libavformat/raw.c @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avformat.h" +#include "ac3.h" #ifdef CONFIG_MUXERS /* simple formats */ @@ -408,18 +409,33 @@ static int h261_probe(AVProbeData *p) static int ac3_probe(AVProbeData *p) { - int score=0; + int max_frames, first_frames, frames; + uint8_t *buf, *buf2, *end; + AC3HeaderInfo hdr; - if(p->buf_size < 6) + if(p->buf_size < 7) return 0; - if((p->buf[0] == 0x0B) && (p->buf[1] == 0x77) && // sync word - ((p->buf[4] >> 6) != 3) && // fscod - ((p->buf[5] >> 3) <= 16)) { // bsid - score = AVPROBE_SCORE_MAX / 2 + 10; - } + max_frames = 0; + buf = p->buf; + end = buf + FFMIN(4096, p->buf_size - 7); + + for(; buf < end; buf++) { + buf2 = buf; - return score; + for(frames = 0; buf2 < end; frames++) { + if(ff_ac3_parse_header(buf2, &hdr) < 0) + break; + buf2 += hdr.frame_size; + } + max_frames = FFMAX(max_frames, frames); + if(buf == p->buf) + first_frames = frames; + } + if (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4; + else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2; + else if(max_frames>=1) return 1; + else return 0; } AVInputFormat shorten_demuxer = { |