[FFmpeg-devel] [PATCH] WAVEFORMATEXTENSIBLE support in the wav muxer

Michael Niedermayer michaelni
Mon Dec 29 23:40:08 CET 2008


On Mon, Dec 29, 2008 at 09:23:23PM +0100, Benjamin Larsson wrote:
> Michael Niedermayer wrote:
> > On Mon, Dec 29, 2008 at 02:02:08PM +0100, Benjamin Larsson wrote:
> >> $topic, based on this:
> >> http://msdn.microsoft.com/en-us/library/ms713496.aspx
> >>
> >> MvH
> >> Benjamin Larsson
> > 
> >> Index: libavformat/riff.c
> >> ===================================================================
> >> --- libavformat/riff.c	(revision 16278)
> >> +++ libavformat/riff.c	(working copy)
> >> @@ -267,12 +267,18 @@
> >>  int put_wav_header(ByteIOContext *pb, AVCodecContext *enc)
> >>  {
> >>      int bps, blkalign, bytespersec;
> >> +    int waveformatextensible = 0;
> >>      int hdrsize = 18;
> >>  
> >>      if(!enc->codec_tag || enc->codec_tag > 0xffff)
> >>          return -1;
> >>  
> >> -    put_le16(pb, enc->codec_tag);
> >> +    if (enc->channels > 2 && enc->channel_layout) {
> >> +        put_le16(pb, 0xfffe);
> >> +        waveformatextensible = 1;
> >> +    } 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) {
> >> @@ -336,10 +342,21 @@
> >>          put_le16(pb, 2); /* wav_extra_size */
> >>          hdrsize += 2;
> >>          put_le16(pb, enc->frame_size); /* wSamplesPerBlock */
> >> -    } else if(enc->extradata_size){
> >> -        put_le16(pb, enc->extradata_size);
> >> +    } else if(enc->extradata_size || waveformatextensible){
> >> +        if (waveformatextensible) {                     /* write WAVEFORMATEXTENSIBLE extensions */
> >> +            put_le16(pb, enc->extradata_size+22);       /* 22 is the size of WAVEFORMATEXTENSIBLE-WAVEFORMATEX */
> >> +            put_le16(pb, enc->bits_per_coded_sample);   /* ValidBitsPerSample || SamplesPerBlock || Reserved */
> >> +            put_le32(pb, enc->channel_layout);          /* dwChannelMask */
> > 
> >> +            put_le32(pb, enc->codec_tag);               /* GUID + next 3 */
> >> +            put_le32(pb, 0);
> >> +            put_le32(pb, 0);
> >> +            put_le32(pb, 0);
> > 
> > This does not look correct, we should use the official GUIDs where such exist
> > and only fall back to tag+000 when none exists.
> 
> True, http://www.microsoft.com/whdc/device/audio/multichaud.mspx
> mentions this that you can convert 2CC/4CC to GUID
> (DEFINE_WAVEFORMATEX_GUID(x) ). Would that be acceptable? 

i do not know what DEFINE_WAVEFORMATEX_GUID() does. So i dont know if its
ok, if it concatenates some constant on the codec_tag then its ok.

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

The educated differ from the uneducated as much as the living from the
dead. -- 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/20081229/7a084649/attachment.pgp>



More information about the ffmpeg-devel mailing list