]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/aiffenc.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavformat / aiffenc.c
index ba5f607ff8d2f70f1747a9394311bc715a386e30..525bd4962318cdd24b4bb7bbd6a4459d5c7573a2 100644 (file)
@@ -25,6 +25,7 @@
 #include "aiff.h"
 #include "avio_internal.h"
 #include "isom.h"
+#include "rawenc.h"
 
 typedef struct {
     int64_t form;
@@ -32,6 +33,22 @@ typedef struct {
     int64_t ssnd;
 } AIFFOutputContext;
 
+static void put_meta(AVFormatContext *s, const char *key, uint32_t id)
+{
+    AVDictionaryEntry *tag;
+    AVIOContext *pb = s->pb;
+
+    if (tag = av_dict_get(s->metadata, key, NULL, 0)) {
+        int size = strlen(tag->value);
+
+        avio_wl32(pb, id);
+        avio_wb32(pb, FFALIGN(size, 2));
+        avio_write(pb, tag->value, size);
+        if (size & 1)
+            avio_w8(pb, 0);
+    }
+}
+
 static int aiff_write_header(AVFormatContext *s)
 {
     AIFFOutputContext *aiff = s->priv_data;
@@ -69,6 +86,11 @@ static int aiff_write_header(AVFormatContext *s)
         ff_mov_write_chan(pb, enc->channel_layout);
     }
 
+    put_meta(s, "title",     MKTAG('N', 'A', 'M', 'E'));
+    put_meta(s, "author",    MKTAG('A', 'U', 'T', 'H'));
+    put_meta(s, "copyright", MKTAG('(', 'c', ')', ' '));
+    put_meta(s, "comment",   MKTAG('A', 'N', 'N', 'O'));
+
     /* Common chunk */
     ffio_wfourcc(pb, "COMM");
     avio_wb32(pb, aifc ? 24 : 18); /* size */
@@ -118,13 +140,6 @@ static int aiff_write_header(AVFormatContext *s)
     return 0;
 }
 
-static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    AVIOContext *pb = s->pb;
-    avio_write(pb, pkt->data, pkt->size);
-    return 0;
-}
-
 static int aiff_write_trailer(AVFormatContext *s)
 {
     AVIOContext *pb = s->pb;
@@ -170,7 +185,7 @@ AVOutputFormat ff_aiff_muxer = {
     .audio_codec       = AV_CODEC_ID_PCM_S16BE,
     .video_codec       = AV_CODEC_ID_NONE,
     .write_header      = aiff_write_header,
-    .write_packet      = aiff_write_packet,
+    .write_packet      = ff_raw_write_packet,
     .write_trailer     = aiff_write_trailer,
     .codec_tag         = (const AVCodecTag* const []){ ff_codec_aiff_tags, 0 },
 };