[FFmpeg-cvslog] aiffenc: metadata support

Paul B Mahol git at videolan.org
Thu Jan 3 20:38:07 CET 2013


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Dec 30 17:13:28 2012 +0000| [48340bbb366aeaa6af94a19c6baa211de4c14a47] | committer: Paul B Mahol

aiffenc: metadata support

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=48340bbb366aeaa6af94a19c6baa211de4c14a47
---

 libavformat/aiffenc.c |   21 +++++++++++++++++++++
 tests/ref/lavf/aiff   |    4 ++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index df6c756..525bd49 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -33,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;
@@ -70,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 */
diff --git a/tests/ref/lavf/aiff b/tests/ref/lavf/aiff
index e5d6fc3..2a5cd81 100644
--- a/tests/ref/lavf/aiff
+++ b/tests/ref/lavf/aiff
@@ -1,3 +1,3 @@
-379908755146d4ead062abe9c3b5c582 *./tests/data/lavf/lavf.aif
-90166 ./tests/data/lavf/lavf.aif
+b0d42747a6fc99a5cd1ab0e861671f3a *./tests/data/lavf/lavf.aif
+90182 ./tests/data/lavf/lavf.aif
 ./tests/data/lavf/lavf.aif CRC=0xf1ae5536



More information about the ffmpeg-cvslog mailing list