[SCM] libav/experimental: simplify ac3_probe() and eac3_probe(). patch by Aurelien Jacobs.

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 16:29:13 UTC 2013


The following commit has been merged in the experimental branch:
commit 75198e7a6d478b43f1c685c08e7494e1a773da73
Author: Aurelien Jacobs <aurel at gnuage.org>
Date:   Mon Sep 1 15:31:14 2008 +0000

    simplify ac3_probe() and eac3_probe(). patch by Aurelien Jacobs.
    
    Originally committed as revision 15145 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavformat/raw.c b/libavformat/raw.c
index b5a5258..9e3d8d2 100644
--- a/libavformat/raw.c
+++ b/libavformat/raw.c
@@ -488,18 +488,18 @@ static int dirac_probe(AVProbeData *p)
 #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 @@ 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))
                 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 @@ static int ac3_eac3_probe(AVProbeData *p, int *codec_id)
 #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
 

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list