diff aiff.c @ 1790:d30211065a35 libavformat

use aiff when we can, some players only support aiff
author bcoudurier
date Wed, 14 Feb 2007 11:01:05 +0000
parents f4a826a2215a
children 0523fb44aa72
line wrap: on
line diff
--- a/aiff.c	Wed Feb 14 09:16:02 2007 +0000
+++ b/aiff.c	Wed Feb 14 11:01:05 2007 +0000
@@ -163,26 +163,32 @@
     ByteIOContext *pb = &s->pb;
     AVCodecContext *enc = s->streams[0]->codec;
     AVExtFloat sample_rate;
+    int aifc = 0;
 
     /* First verify if format is ok */
     if (!enc->codec_tag) {
         return -1;
     }
 
+    if (enc->codec_tag != MKTAG('N','O','N','E'))
+        aifc = 1;
+
     /* FORM AIFF header */
     put_tag(pb, "FORM");
     aiff->form = url_ftell(pb);
     put_be32(pb, 0);                    /* file length */
-    put_tag(pb, "AIFC");
+    put_tag(pb, aifc ? "AIFC" : "AIFF");
 
+    if (aifc) {
     /* Version chunk */
     put_tag(pb, "FVER");
     put_be32(pb, 4);
     put_be32(pb, 0xA2805140);
+    }
 
     /* Common chunk */
     put_tag(pb, "COMM");
-    put_be32(pb, 24); /* size */
+    put_be32(pb, aifc ? 24 : 18); /* size */
     put_be16(pb, enc->channels);        /* Number of channels */
 
     aiff->frames = url_ftell(pb);
@@ -202,8 +208,10 @@
     sample_rate = av_dbl2ext((double)enc->sample_rate);
     put_buffer(pb, (uint8_t*)&sample_rate, sizeof(sample_rate));
 
+    if (aifc) {
     put_le32(pb, enc->codec_tag);
     put_be16(pb, 0);
+    }
 
     /* Sound data chunk */
     put_tag(pb, "SSND");