]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/cafenc.c
lavfi: convert remaining input/output list compound literals to named objects.
[ffmpeg] / libavformat / cafenc.c
index fa8d5838c486877c388b697baa703f7aa97667ff..92b61c9e1e6b79f8e3312e2faeb9f34a21874715 100644 (file)
@@ -25,6 +25,7 @@
 #include "isom.h"
 #include "avio_internal.h"
 #include "libavutil/intfloat.h"
+#include "libavutil/dict.h"
 
 typedef struct {
     int64_t data;
@@ -74,6 +75,7 @@ static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels) {
         return 64;
     case AV_CODEC_ID_AMR_NB:
     case AV_CODEC_ID_GSM:
+    case AV_CODEC_ID_ILBC:
     case AV_CODEC_ID_QCELP:
         return 160;
     case AV_CODEC_ID_GSM_MS:
@@ -102,7 +104,9 @@ static int caf_write_header(AVFormatContext *s)
     AVIOContext *pb = s->pb;
     AVCodecContext *enc = s->streams[0]->codec;
     CAFContext *caf = s->priv_data;
+    AVDictionaryEntry *t = NULL;
     unsigned int codec_tag = ff_codec_get_tag(ff_codec_caf_tags, enc->codec_id);
+    int64_t chunk_size = 0;
 
     switch (enc->codec_id) {
     case AV_CODEC_ID_AAC:
@@ -180,6 +184,20 @@ static int caf_write_header(AVFormatContext *s)
         avio_write(pb, enc->extradata, enc->extradata_size);
     }
 
+    if (av_dict_count(s->metadata)) {
+        ffio_wfourcc(pb, "info"); //< Information chunk
+        while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) {
+            chunk_size += strlen(t->key) + strlen(t->value) + 2;
+        }
+        avio_wb64(pb, chunk_size + 4);
+        avio_wb32(pb, av_dict_count(s->metadata));
+        t = NULL;
+        while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) {
+            avio_put_str(pb, t->key);
+            avio_put_str(pb, t->value);
+        }
+    }
+
     ffio_wfourcc(pb, "data"); //< Audio Data chunk
     caf->data = avio_tell(pb);
     avio_wb64(pb, -1);        //< mChunkSize
@@ -249,7 +267,7 @@ static int caf_write_trailer(AVFormatContext *s)
 
 AVOutputFormat ff_caf_muxer = {
     .name           = "caf",
-    .long_name      = NULL_IF_CONFIG_SMALL("Apple Core Audio Format"),
+    .long_name      = NULL_IF_CONFIG_SMALL("Apple CAF (Core Audio Format)"),
     .mime_type      = "audio/x-caf",
     .extensions     = "caf",
     .priv_data_size = sizeof(CAFContext),
@@ -258,5 +276,5 @@ AVOutputFormat ff_caf_muxer = {
     .write_header   = caf_write_header,
     .write_packet   = caf_write_packet,
     .write_trailer  = caf_write_trailer,
-    .codec_tag= (const AVCodecTag* const []){ff_codec_caf_tags, 0},
+    .codec_tag      = (const AVCodecTag* const []){ff_codec_caf_tags, 0},
 };