[FFmpeg-devel] [PATCH] S/PDIF demuxer (was:[PATCH] Detect DTS?in wav (issue70) + about ac3-in-wav)

Anssi Hannula anssi.hannula
Wed Jul 28 04:12:21 CEST 2010


Michael Niedermayer kirjoitti tiistai, 27. hein?kuuta 2010 16:59:27:
> On Tue, Jul 27, 2010 at 07:59:13AM +0300, Anssi Hannula wrote:
> > Michael Niedermayer kirjoitti perjantai, 23. hein?kuuta 2010 16:32:50:
> > > On Fri, Jul 23, 2010 at 08:00:21AM +0300, Anssi Hannula wrote:
> > > [...]
> > > 
> > > >  }
> > > > 
> > > > +#if CONFIG_SPDIF_MUXER
> > > > 
> > > >  static int spdif_header_ac3(AVFormatContext *s, AVPacket *pkt)
> > 
> > [...]
> > 
> > > if it compiles without the ifdefs then please remove them
> > > its the compilers job to remove unused static functions
> > > (might needs a av_unused))
> > 
> > It compiles, but warnings are emitted about unused functions when one of
> > spdif demuxer or muxer is disabled (and I assumed you didn't want me to
> > add av_unused to every function).
> 
> you also could just put the demuxer in a seperate file if this is possible

Ok, will just do that then.

> > Attached is a new version with unnecessary ifdefs removed and a better
> > probe function.
> 
> [...]
> 
> > +static int spdif_probe(AVProbeData *p)
> > +{
> > +    const uint8_t *buf = p->buf;
> > +    /* probe for 64 bytes to find initial sync word */
> > +    const uint8_t *probe_end = p->buf + FFMIN(64, p->buf_size - 1);
> 
> this looks like it wont work if the stream is randomly cut
> it would be nice if that worked too though
> 

Ah, will change it so that it works like that as well.

> [...]
> 
> > +    if (sync_codes == consecutive_codes + 1 &&
> > +        !memcmp(p->buf + 8, "WAVE", 4) && !memcmp(p->buf, "RIFF", 4))
> > +        /* all sync codes (except first one as it was only after WAV
> > headers)
> > +           were consecutive, but the buffer was too small;
> > +           also, this looks like a WAV file, so we need to delay wav
> > demuxer
> > +           from grabbing this file until we get a big enough
> > buffer to see if
> > +           there are more consecutive codes (we want
> > to be selected for
> > +           (ac3-in-)spdif-in-wav as chained demuxers
> > are not yet supported),
> > +           therefore return the same score as
> > wav demuxer to make it a tie */
> > +        return AVPROBE_SCORE_MAX - 1;
> 
> or make the wav demuxer only return a low score for small probe sizes
> above would for example behave oddly if the wav demuxer is disabled

How low?

I mean, if we change it to AVPROBE_SCORE_MAX / 8 or so, every wav file would 
needlessy be probed 1MB, even while 2k would have been enough (if no spdif 
sync codes were in first 2k).

On the other hand, if we change both to return AVPROBE_SCORE_MAX / 4 + 1 on 
small buffers so that the needless wav probe doesn't happen, spdif would 
wrongly be detected with just one sync code.

-- 
Anssi Hannula



More information about the ffmpeg-devel mailing list