[FFmpeg-devel] [PATCH] smv detection in wav demuxer

Jesse L. Zamora xtremek2008
Mon Sep 15 13:28:10 CEST 2008


On Monday 15 September 2008 06:50:43 am Benjamin Larsson wrote:
> Hi.
>
> Jesse L. Zamora wrote:
> > Hello,
> >
> > This patch allows the wav.c demuxer detect the wav file to see if it's an
> > SMV. It exits if it detects that it's an smv file.
> >
> > Xtreme Kommander
> >
> >
> > ------------------------------------------------------------------------
> >
> > --- wav.c 2008-09-14 19:49:51.000000000 -0400
> > +++ wav2.c    2008-09-14 19:49:16.000000000 -0400
> > @@ -147,12 +147,22 @@ static int wav_probe(AVProbeData *p)
> >          p->buf[2] == 'F' && p->buf[3] == 'F' &&
> >          p->buf[8] == 'W' && p->buf[9] == 'A' &&
> >          p->buf[10] == 'V' && p->buf[11] == 'E')
> > +    {
> >          /*
> >            Since ACT demuxer has standard WAV header at top of it's own,
> >            returning score is decreased to avoid probe conflict
> >            between ACT and WAV.
> >          */
> > +
> > +        /* It is now necessary to check to see if it's an SMV... */
> > +        if(strcmp(p->filename + (sizeof(p->filename) - 4), ".smv") != 0)
> > +        {
> > +            printf("warning: by the extension (.smv), this file implies
> > that it is not WAV!\n");
>
> printf is not allowed.
>
> > +            return AVPROBE_SCORE_MAX / 2;
> > +        }
> > +
> >          return AVPROBE_SCORE_MAX - 1;
> > +    }
> >      else
> >          return 0;
> >  }
> > @@ -194,6 +204,20 @@ static int wav_read_header(AVFormatConte
> >      if (size < 0)
> >          return -1;
> >      wav->data_end= url_ftell(pb) + size;
> > +
> > +    /* Check to make sure that the file IS NOT smv!
> > +       Since the SMV format begins with a WAV file,
> > +       it is easily mistaken for one. */
> > +    unsigned char smv_header_buffer[10];
> > +
> > +    url_fseek(pb, wav->data_end, SEEK_SET);
>
> This breaks streaming of wav files.
>
> > +    get_buffer(pb, smv_header_buffer, 9);
> > +    if(strcmp(smv_header_buffer, "SMV002000"))
> > +    {
> > +        av_log(s, AV_LOG_ERROR, "This file is SMV! Use -f smv
> > instead."); +        return -1;
> > +    }
> > +
> >      return 0;
> >  }
>
> I think the most clean way to do this is to let the smv probe return a
> higher score then the wav probe. And let the smv probe only act on the
> suffix on the filename(.smv). This would keep the wav stuff working
> while still enabling automatic detection of smv when the filename is
> correct. If implemented as proposed the only change needed in the
> wav_probe is an addition to the probe score.
>
> MvH
> Benjamin Larsson
>

Ok, that's good. I guess I didn't think about that....

Xtremek Kommander




More information about the ffmpeg-devel mailing list