[FFmpeg-devel] [PATCH]Support channel layout when muxing aif

Carl Eugen Hoyos cehoyos at ag.or.at
Fri Apr 22 20:05:37 CEST 2011


Hi!

Not documented (afaict), but tested successfully with current OS X.
Depends on my caf patch, Makefile change missing.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index cc3cbc4..e92ca09 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -22,6 +22,7 @@
 #include "avformat.h"
 #include "aiff.h"
 #include "avio_internal.h"
+#include "caf.h"
 
 typedef struct {
     int64_t form;
@@ -36,6 +37,7 @@ static int aiff_write_header(AVFormatContext *s)
     AVCodecContext *enc = s->streams[0]->codec;
     AVExtFloat sample_rate;
     int aifc = 0;
+    uint32_t layout_tag = ff_get_chan_layout_tag(enc->channel_layout);
 
     /* First verify if format is ok */
     if (!enc->codec_tag)
@@ -61,6 +63,16 @@ static int aiff_write_header(AVFormatContext *s)
         avio_wb32(pb, 0xA2805140);
     }
 
+    if (enc->channels > 2 && layout_tag) {
+        ffio_wfourcc(pb, "CHAN");
+        avio_wb32(pb, 12);         //< mChunkSize
+        avio_wb32(pb, layout_tag); //< mChannelLayoutTag
+        avio_wb32(pb, 0);          //< mChannelBitmap
+        avio_wb32(pb, 0);          //< mNumberChannelDescriptions
+    } else if (enc->channels > 2) {
+        av_log(s, AV_LOG_WARNING, "Unsupported channel layout\n");
+    }
+
     /* Common chunk */
     ffio_wfourcc(pb, "COMM");
     avio_wb32(pb, aifc ? 24 : 18); /* size */


More information about the ffmpeg-devel mailing list