detect audio-only program streams and broken files made by VDR

Originally committed as revision 5546 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Måns Rullgård 19 years ago
parent 344a18c3b8
commit 25c533a2c2
  1. 18
      libavformat/mpeg.c

@ -1269,21 +1269,21 @@ static int mpegps_probe(AVProbeData *p)
for(i=0; i<p->buf_size; i++){ for(i=0; i<p->buf_size; i++){
code = (code<<8) + p->buf[i]; code = (code<<8) + p->buf[i];
if ((code & 0xffffff00) == 0x100) { if ((code & 0xffffff00) == 0x100) {
switch(code){ if(code == SYSTEM_HEADER_START_CODE) sys++;
case SYSTEM_HEADER_START_CODE: sys++; break; else if(code == PRIVATE_STREAM_1) priv1++;
case PRIVATE_STREAM_1: priv1++; break; else if(code == PACK_START_CODE) pspack++;
case PACK_START_CODE: pspack++; break; else if((code & 0xf0) == VIDEO_ID) vid++;
case (VIDEO_ID + 0x100): vid++; break; else if((code & 0xe0) == AUDIO_ID) audio++;
case (AUDIO_ID + 0x100): audio++; break;
}
} }
} }
if(sys && sys*9 <= pspack*10) if(sys && sys*9 <= pspack*10)
return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg
if((priv1 || vid) && (priv1+vid)*9 <= pspack*10) if((priv1 || vid || audio) && (priv1+vid+audio)*9 <= pspack*10)
return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg
if((!!vid ^ !!audio) && !sys && !pspack) /* PES stream */ if((!!vid ^ !!audio) && !sys && !pspack) /* PES stream */
return AVPROBE_SCORE_MAX/2; return AVPROBE_SCORE_MAX/2+2;
if(vid || audio) /* invalid VDR files */
return AVPROBE_SCORE_MAX/2+2;
return 0; return 0;
} }

Loading…
Cancel
Save