Commit 75198e7a authored by Aurelien Jacobs's avatar Aurelien Jacobs Committed by Justin Ruggles
Browse files

simplify ac3_probe() and eac3_probe(). patch by Aurelien Jacobs.

Originally committed as revision 15145 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 4d951ef8
...@@ -488,18 +488,18 @@ static int dirac_probe(AVProbeData *p) ...@@ -488,18 +488,18 @@ static int dirac_probe(AVProbeData *p)
#endif #endif
#if (ENABLE_AC3_DEMUXER || ENABLE_EAC3_DEMUXER) #if (ENABLE_AC3_DEMUXER || ENABLE_EAC3_DEMUXER)
static int ac3_eac3_probe(AVProbeData *p, int *codec_id) static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
{ {
int max_frames, first_frames = 0, frames; int max_frames, first_frames = 0, frames;
uint8_t *buf, *buf2, *end; uint8_t *buf, *buf2, *end;
AC3HeaderInfo hdr; AC3HeaderInfo hdr;
GetBitContext gbc; GetBitContext gbc;
enum CodecID codec_id = CODEC_ID_AC3;
max_frames = 0; max_frames = 0;
buf = p->buf; buf = p->buf;
end = buf + p->buf_size; end = buf + p->buf_size;
*codec_id = CODEC_ID_AC3;
for(; buf < end; buf++) { for(; buf < end; buf++) {
buf2 = buf; buf2 = buf;
...@@ -511,13 +511,14 @@ static int ac3_eac3_probe(AVProbeData *p, int *codec_id) ...@@ -511,13 +511,14 @@ static int ac3_eac3_probe(AVProbeData *p, int *codec_id)
av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2)) av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
break; break;
if (hdr.bitstream_id > 10) if (hdr.bitstream_id > 10)
*codec_id = CODEC_ID_EAC3; codec_id = CODEC_ID_EAC3;
buf2 += hdr.frame_size; buf2 += hdr.frame_size;
} }
max_frames = FFMAX(max_frames, frames); max_frames = FFMAX(max_frames, frames);
if(buf == p->buf) if(buf == p->buf)
first_frames = frames; first_frames = frames;
} }
if(codec_id != expected_codec_id) return 0;
if (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4; if (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4;
else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2; else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2;
else if(max_frames>=1) return 1; else if(max_frames>=1) return 1;
...@@ -528,22 +529,14 @@ static int ac3_eac3_probe(AVProbeData *p, int *codec_id) ...@@ -528,22 +529,14 @@ static int ac3_eac3_probe(AVProbeData *p, int *codec_id)
#ifdef CONFIG_AC3_DEMUXER #ifdef CONFIG_AC3_DEMUXER
static int ac3_probe(AVProbeData *p) static int ac3_probe(AVProbeData *p)
{ {
int codec_id = CODEC_ID_NONE; return ac3_eac3_probe(p, CODEC_ID_AC3);
int score = ac3_eac3_probe(p, &codec_id);
if(codec_id == CODEC_ID_AC3)
return score;
return 0;
} }
#endif #endif
#ifdef CONFIG_EAC3_DEMUXER #ifdef CONFIG_EAC3_DEMUXER
static int eac3_probe(AVProbeData *p) static int eac3_probe(AVProbeData *p)
{ {
int codec_id = CODEC_ID_NONE; return ac3_eac3_probe(p, CODEC_ID_EAC3);
int score = ac3_eac3_probe(p, &codec_id);
if(codec_id == CODEC_ID_EAC3)
return score;
return 0;
} }
#endif #endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment