]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/aiffenc.c
avformat: Constify all muxer/demuxers
[ffmpeg] / libavformat / aiffenc.c
index 53a2f97e227f6a23f1292962479022ebc4a0920d..24bc17400e016e768e4982c753c7ad629cd14586 100644 (file)
@@ -37,7 +37,7 @@ typedef struct AIFFOutputContext {
     int64_t frames;
     int64_t ssnd;
     int audio_stream_idx;
-    AVPacketList *pict_list, *pict_list_end;
+    PacketList *pict_list, *pict_list_end;
     int write_id3v2;
     int id3v2_version;
 } AIFFOutputContext;
@@ -48,7 +48,7 @@ static int put_id3v2_tags(AVFormatContext *s, AIFFOutputContext *aiff)
     uint64_t pos, end, size;
     ID3v2EncContext id3v2 = { 0 };
     AVIOContext *pb = s->pb;
-    AVPacketList *pict_list = aiff->pict_list;
+    PacketList *pict_list = aiff->pict_list;
 
     if (!s->metadata && !s->nb_chapters && !aiff->pict_list)
         return 0;
@@ -210,9 +210,6 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt)
     if (pkt->stream_index == aiff->audio_stream_idx)
         avio_write(pb, pkt->data, pkt->size);
     else {
-        if (s->streams[pkt->stream_index]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
-            return 0;
-
         /* warn only once for each stream */
         if (s->streams[pkt->stream_index]->nb_frames == 1) {
             av_log(s, AV_LOG_WARNING, "Got more than one picture in stream %d,"
@@ -236,25 +233,12 @@ static int aiff_write_trailer(AVFormatContext *s)
     AVCodecParameters *par = s->streams[aiff->audio_stream_idx]->codecpar;
 
     /* Chunks sizes must be even */
-    int64_t file_size, end_size;
-    end_size = file_size = avio_tell(pb);
-    if (file_size & 1) {
+    int64_t file_size, data_size;
+    data_size = avio_tell(pb);
+    if (data_size & 1)
         avio_w8(pb, 0);
-        end_size++;
-    }
 
     if (s->pb->seekable & AVIO_SEEKABLE_NORMAL) {
-        /* Number of sample frames */
-        avio_seek(pb, aiff->frames, SEEK_SET);
-        avio_wb32(pb, (file_size - aiff->ssnd - 12) / par->block_align);
-
-        /* Sound Data chunk size */
-        avio_seek(pb, aiff->ssnd, SEEK_SET);
-        avio_wb32(pb, file_size - aiff->ssnd - 4);
-
-        /* return to the end */
-        avio_seek(pb, end_size, SEEK_SET);
-
         /* Write ID3 tags */
         if (aiff->write_id3v2)
             if ((ret = put_id3v2_tags(s, aiff)) < 0)
@@ -264,6 +248,14 @@ static int aiff_write_trailer(AVFormatContext *s)
         file_size = avio_tell(pb);
         avio_seek(pb, aiff->form, SEEK_SET);
         avio_wb32(pb, file_size - aiff->form - 4);
+
+        /* Number of sample frames */
+        avio_seek(pb, aiff->frames, SEEK_SET);
+        avio_wb32(pb, (data_size - aiff->ssnd - 12) / par->block_align);
+
+        /* Sound Data chunk size */
+        avio_seek(pb, aiff->ssnd, SEEK_SET);
+        avio_wb32(pb, data_size - aiff->ssnd - 4);
     }
 
     return ret;
@@ -293,7 +285,7 @@ static const AVClass aiff_muxer_class = {
     .version        = LIBAVUTIL_VERSION_INT,
 };
 
-AVOutputFormat ff_aiff_muxer = {
+const AVOutputFormat ff_aiff_muxer = {
     .name              = "aiff",
     .long_name         = NULL_IF_CONFIG_SMALL("Audio IFF"),
     .mime_type         = "audio/aiff",