changeset 1257:6c654821b0ae libavformat

fix probing of 02-Penguin.flac = a single startcode should not override extension based detection
author michael
date Sat, 19 Aug 2006 08:39:00 +0000
parents 2cddf00f92a6
children 558c75bd81a0
files mpeg.c
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mpeg.c	Fri Aug 18 16:48:35 2006 +0000
+++ b/mpeg.c	Sat Aug 19 08:39:00 2006 +0000
@@ -1265,6 +1265,7 @@
     uint32_t code= -1;
     int sys=0, pspack=0, priv1=0, vid=0, audio=0;
     int i;
+    int score=0;
 
     for(i=0; i<p->buf_size; i++){
         code = (code<<8) + p->buf[i];
@@ -1276,15 +1277,20 @@
             else if((code & 0xe0) == AUDIO_ID)   audio++;
         }
     }
+
+    if(vid || audio)            /* invalid VDR files nd short PES streams */
+        score= AVPROBE_SCORE_MAX/4;
+
+//av_log(NULL, AV_LOG_ERROR, "%d %d %d %d %d\n", sys, priv1, pspack,vid, audio);
     if(sys && sys*9 <= pspack*10)
         return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg
     if((priv1 || vid || audio) && (priv1+vid+audio)*9 <= pspack*10)
         return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg
-    if((!!vid ^ !!audio) && !sys && !pspack) /* PES stream */
+    if((!!vid ^ !!audio) && (audio+vid > 1) && !sys && !pspack) /* PES stream */
         return AVPROBE_SCORE_MAX/2+2;
-    if(vid || audio)            /* invalid VDR files */
-        return AVPROBE_SCORE_MAX/2+2;
-    return 0;
+
+    //02-Penguin.flac has sys:0 priv1:0 pspack:0 vid:0 audio:1
+    return score;
 }