[Ffmpeg-devel] [PATCH] allow ffmpeg to read mp3s beginning with partial frames

Michael Niedermayer michaelni
Sat Sep 9 10:39:37 CEST 2006


Hi

On Sat, Sep 09, 2006 at 07:51:04AM +0200, Andreas ?man wrote:
> Michael Niedermayer wrote:
> 
> >>>yes thats why i am so much against doing it in lavf/mp3.c, it belongs
> >>>to the mp3 parser (libavcodec/parser.c)
> >>>
> >>>
> >>Turns out im wrong it does. libavcodec/parser.c handles initial partial
> >>frame and files work fine with just the change to mp3_read_probe as
> >>supplied. 
> >
> >patch looks ok
> >
> 
> I have to disagree. With this new patch ffmpeg still thinks some of my 
> files are mp3-files (especially .ts-files)

hmm, the ts files would have to begin in the middle of a packet for that
to be possible and only 1 out of about 500 so cut files should be affected
your patch though might missdetect half of all mpeg-ps files with mp3 in
them even uncut

IMHO mp3 detection
-> must NEVER return more then AVPROBE_SCORE_MAX/2+1 so it does not override
   mpeg-ps
-> must find at least 3 consecutive valid frames to return 
   AVPROBE_SCORE_MAX/2+1
-> if it finds less then 3 consecutive valid frames then it should return a
   smaller score

and the implementation should look like the following, not with duplicated
checks for each frame

for(buf=0; buf<XYZ; buf++){
    buf2=buf;
    for(frames=0; buf2<XYZ; frames++){
        size= FOOBAR(buf2);
        if(size<0)
            break;
        buf2 += size;
    }
    max_frames= FFMAX(max_frames, frames);
}
if     (max_frames>=3) return AVPROBE_SCORE_MAX/2+1;
else if(max_frames==2) return AVPROBE_SCORE_MAX/4;
else if(max_frames==1) return 1;
else                   return 0;

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-devel mailing list