[FFmpeg-devel] [PATCH] make mpeg-ps probe less happy with random data

Michael Niedermayer michaelni
Mon Dec 3 10:35:25 CET 2007


On Mon, Dec 03, 2007 at 09:14:50AM +0000, M?ns Rullg?rd wrote:
> Michael Niedermayer <michaelni at gmx.at> writes:
> 
> > currently the mpeg-ps probe code will detect various random things
> > as mpeg-ps
> > for example the O-MP3-5.mp3 posted by someone today
> >
> > i think returning AVPROBE_SCORE_MAX/2+2 for random data with 0 bytes
> > more frequently occuring is not good
> >
> > the attached patch reduces this problem and besides the extra complexity
> > is i think harmless
> > ill apply it in 3 days or so if noone objects
> >
> > Index: libavformat/mpeg.c
> > ===================================================================
> > --- libavformat/mpeg.c	(revision 11117)
> > +++ libavformat/mpeg.c	(working copy)
> > @@ -67,7 +67,7 @@
> >  static int mpegps_probe(AVProbeData *p)
> >  {
> >      uint32_t code= -1;
> > -    int sys=0, pspack=0, priv1=0, vid=0, audio=0;
> > +    int sys=0, pspack=0, priv1=0, vid=0, audio=0, invalid=0;
> >      int i;
> >      int score=0;
> >  
> > @@ -85,16 +85,19 @@
> >              else if(code == PACK_START_CODE)     pspack++;
> >              else if((code & 0xf0) == VIDEO_ID && pes) vid++;
> >              else if((code & 0xe0) == AUDIO_ID && pes) audio++;
> > +
> > +            else if((code & 0xf0) == VIDEO_ID && !pes) invalid++;
> > +            else if((code & 0xe0) == AUDIO_ID && !pes) invalid++;
> >          }
> >      }
> >  
> > -    if(vid || audio)            /* invalid VDR files nd short PES streams */
> > +    if(vid+audio > invalid)            /* invalid VDR files nd short PES streams */
>                                    ^^^^^^^
> Please remove that excess whitespace to make the line of proper
> length.

fixed


> 
> >          score= AVPROBE_SCORE_MAX/4;
> >  
> >  //av_log(NULL, AV_LOG_ERROR, "%d %d %d %d %d len:%d\n", sys, priv1, pspack,vid, audio, p->buf_size);
> > -    if(sys && sys*9 <= pspack*10)
> > +    if(sys>invalid && sys*9 <= pspack*10)
> >          return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg
> > -    if((priv1 || vid || audio) && (priv1+vid+audio)*9 <= pspack*10)
> > +    if(priv1 + vid + audio > invalid && (priv1+vid+audio)*9 <= pspack*10)
> >          return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg
> >      if((!!vid ^ !!audio) && (audio+vid > 1) && !sys && !pspack && p->buf_size>2048) /* PES stream */
> >          return AVPROBE_SCORE_MAX/2+2;
> 
> Looks OK, commit anytime.

applied

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071203/e56ae468/attachment.pgp>



More information about the ffmpeg-devel mailing list