[FFmpeg-devel] Add waveformat extensible support in wav muxer (SoC qualification task)

Michael Niedermayer michaelni
Thu Apr 2 15:04:17 CEST 2009


On Thu, Apr 02, 2009 at 08:36:49PM +0800, zhentan feng wrote:
> Hi
> 
> 2009/4/2 Michael Niedermayer <michaelni at gmx.at>
> 
> > On Thu, Apr 02, 2009 at 07:28:13PM +0800, zhentan feng wrote:
> > [...]
> > > here is the new patch attached below.
> > >
> > > zhentan
> > > --
> > > Best wishes~
> >
> > > Index: libavformat/riff.c
> > > ===================================================================
> > > --- libavformat/riff.c        (revision 18184)
> > > +++ libavformat/riff.c        (working copy)
> > > @@ -282,18 +282,34 @@
> > >  int put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
> > >  {
> > >      int bps, blkalign, bytespersec;
> > > +    int waveformatextensible;
> > >      int hdrsize = 18;
> > > +    int pre_size = enc->extradata_size;
> > >
> > >      if(!enc->codec_tag || enc->codec_tag > 0xffff)
> > >          return -1;
> > >
> > > -    put_le16(pb, enc->codec_tag);
> > > +    waveformatextensible = enc->channels > 2 && enc->channel_layout;
> > > +    if (waveformatextensible) {
> > > +        put_le16(pb, 0xfffe);
> > > +        pre_size += 22; /* 22 is the size of
> > WAVEFORMATEXTENSIBLE-WAVEFORMATEX */
> > > +    } else
> > > +        put_le16(pb, enc->codec_tag);
> > > +
> > >      put_le16(pb, enc->channels);
> >
> > >      put_le32(pb, enc->sample_rate);
> > >      if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3
> > || enc->codec_id == CODEC_ID_GSM_MS) {
> > >          bps = 0;
> > > +        if (enc->codec_id == CODEC_ID_MP2)
> > > +            pre_size += 22; /* wav_extra_size */
> > > +        else if(enc->codec_id == CODEC_ID_MP3)
> > > +            pre_size += 12; /* wav_extra_size */
> > > +        else
> > > +            pre_size += 2; /* wav_extra_size */
> >
> > it should be
> > if{
> > }else
> >
> > as this makes possible future patchs more readable
> >
> > also the code while simpler is not correct at all, the size
> > written does not match the amount written in several cases
> >
> 
> do you mean i miss caculating some fields or writing more fields than the
> size?
> I just carefully read the code several times and still can't find where is
> the bug, could you please give more details?

you always add extradata_size but not always write extradata

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090402/7eb32bb0/attachment.pgp>



More information about the ffmpeg-devel mailing list