[Ffmpeg-devel] [PATCH] read multiple frames in ac3_probe

Justin Ruggles justinruggles
Sun Mar 18 04:31:31 CET 2007


Michael Niedermayer wrote:
> Hi
> 
> On Sat, Mar 17, 2007 at 06:39:45PM -0500, Justin Ruggles wrote:
> 
>>Hello,
>>
>>Here is a patch to make ac3_probe() work like mp3_read_probe().  It
>>reads as many frames as are in the probe buffer and scores based on how
>>many valid frames are found at the start of the buffer and overall.
>>
>>The one thing I don't like so much is that it must call ac3_common_init.
>> So for AC-3 decoding or encoding, it means that function will get
>>called at least 3 times: probe, parse, decode/encode.  It might be worth
>>it to go back to hardcoding that AC-3 framesize table to avoid this.
>>What do you think?
> 
> 
> yes, i think hardcoding this 228 byte table is the simplest solution

OK, I'll do that first.

> [...]
> 
>>+    while(buf < end) {
>>+        buf2 = buf;
>>+
>>+        for(frames = 0; buf2 < end; frames++) {
>>+            if(ff_ac3_parse_header(buf2, &hdr) < 0)
>>+                break;
>>+            buf2 += hdr.frame_size;
>>+        }
>>+        max_frames = FFMAX(max_frames, frames);
>>+        if(buf == p->buf)
>>+            first_frames = frames;
>>+
>>+        if(!frames)
>>+            buf++;
>>+        else
> 
> 
>>+            buf = buf2;
> 
> 
> why?

If any frames are found, buf2 is increased to skip them.  why look again
for ac3 frames inside other ac3 frames?

> 
>>     }
>>-
>>-    return score;
>>+    if   (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4;
> 
> 
>>+    else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2 + 10;
> 
> 
> theres a possible problem with this, mpeg-ps generally returns
> AVPROBE_SCORE_MAX/2+2
> this returns more and mpeg-ps can contain several ac3 frames with no
> intervening mpeg-ps headers ...

OK.  I was having issues with a couple AC-3 files being misdetected as
MPEG-PS...but I'll go ahead and change it to AVPROBE_SCORE_MAX / 2.







More information about the ffmpeg-devel mailing list