[Ffmpeg-devel] [PATCH] read multiple frames in ac3_probe
Justin Ruggles
justinruggles
Sun Mar 18 15:55:48 CET 2007
Michael Niedermayer wrote:
> Hi
>
> On Sat, Mar 17, 2007 at 10:31:31PM -0500, Justin Ruggles wrote:
> [...]
>
>>>[...]
>>>
>>>
>>>>+ 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?
>
>
> well, the problem is you dont know if its really a ac3 frame or just random
> data, if you where sure its a ac3 frame you wouldnt need the search for more
> than 1
> and speedwise theres no gain either as in random data there will be little
> skipped ...
I do see your point now that in the scheme of things, unless the file is
AC-3, you don't have any speed gain by skipping detected frames. And
the likelyhood of 3 consecutive false positives with random data is near
enough 0.
>>>> }
>>>>-
>>>>- 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.
>
>
> are these files available somewhere?
I got one of them from mplayer samples:
http://samples.mplayerhq.hu/A-codecs/AC3-samples/a52dec-streams/thx_2_0/stream
But all the samples I have now are properly detected with the new
ac3_probe. I was having issues when writing the original version when I
only set it to (AVPROBE_SCORE_MAX / 2) because a false positive on
MPEG-PS was giving a score 2 higher than the AC-3 score.
So using (AVPROBE_SCORE_MAX / 2) will be fine.
New patch attached.
-Justin
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ffmpeg-ac3_probe-multiple_frames-2.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070318/b4c365f2/attachment.txt>
More information about the ffmpeg-devel
mailing list