changeset 3864:b31edc09d556 libavformat

simplify ac3_probe() and eac3_probe(). patch by Aurelien Jacobs.
author jbr
date Mon, 01 Sep 2008 15:31:14 +0000
parents 9c384a47085f
children a9b8842d33ab
files raw.c
diffstat 1 files changed, 6 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/raw.c	Mon Sep 01 15:28:15 2008 +0000
+++ b/raw.c	Mon Sep 01 15:31:14 2008 +0000
@@ -488,18 +488,18 @@
 #endif
 
 #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;
     uint8_t *buf, *buf2, *end;
     AC3HeaderInfo hdr;
     GetBitContext gbc;
+    enum CodecID codec_id = CODEC_ID_AC3;
 
     max_frames = 0;
     buf = p->buf;
     end = buf + p->buf_size;
 
-    *codec_id = CODEC_ID_AC3;
     for(; buf < end; buf++) {
         buf2 = buf;
 
@@ -511,13 +511,14 @@
                av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2))
                 break;
             if (hdr.bitstream_id > 10)
-                *codec_id = CODEC_ID_EAC3;
+                codec_id = CODEC_ID_EAC3;
             buf2 += hdr.frame_size;
         }
         max_frames = FFMAX(max_frames, frames);
         if(buf == p->buf)
             first_frames = frames;
     }
+    if(codec_id != expected_codec_id) return 0;
     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;
@@ -528,22 +529,14 @@
 #ifdef CONFIG_AC3_DEMUXER
 static int ac3_probe(AVProbeData *p)
 {
-    int codec_id = CODEC_ID_NONE;
-    int score = ac3_eac3_probe(p, &codec_id);
-    if(codec_id == CODEC_ID_AC3)
-        return score;
-    return 0;
+    return ac3_eac3_probe(p, CODEC_ID_AC3);
 }
 #endif
 
 #ifdef CONFIG_EAC3_DEMUXER
 static int eac3_probe(AVProbeData *p)
 {
-    int codec_id = CODEC_ID_NONE;
-    int score = ac3_eac3_probe(p, &codec_id);
-    if(codec_id == CODEC_ID_EAC3)
-        return score;
-    return 0;
+    return ac3_eac3_probe(p, CODEC_ID_EAC3);
 }
 #endif