]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/asf-enc.c
add png fourcc
[ffmpeg] / libavformat / asf-enc.c
index 1f8a993c66e8066d80c132ff642ce36930a225a3..f72fef97a1187c9859ce02766bb0ecc37bcbaad1 100644 (file)
@@ -1,30 +1,30 @@
 /*
- * Adaptive stream format encoder
+ * Adaptive stream format muxer
  * Copyright (c) 2000, 2001 Fabrice Bellard.
  *
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include "avformat.h"
-#include "avi.h"
+#include "riff.h"
 #include "asf.h"
 
 #undef NDEBUG
 #include <assert.h>
 
-#ifdef CONFIG_MUXERS
-
 
 #define ASF_INDEXED_INTERVAL    10000000
 #define ASF_INDEX_BLOCK         600
@@ -269,8 +269,8 @@ static int64_t unix_to_file_time(int ti)
 {
     int64_t t;
 
-    t = ti * int64_t_C(10000000);
-    t += int64_t_C(116444736000000000);
+    t = ti * INT64_C(10000000);
+    t += INT64_C(116444736000000000);
     return t;
 }
 
@@ -284,7 +284,9 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
     AVCodecContext *enc;
     int64_t header_offset, cur_pos, hpos;
     int bit_rate;
+    int64_t duration;
 
+    duration = asf->duration + preroll_time * 10000;
     has_title = (s->title[0] || s->author[0] || s->copyright[0] || s->comment[0]);
 
     bit_rate = 0;
@@ -314,8 +316,8 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
     file_time = 0;
     put_le64(pb, unix_to_file_time(file_time));
     put_le64(pb, asf->nb_packets); /* number of packets */
-    put_le64(pb, asf->duration); /* end time stamp (in 100ns units) */
-    put_le64(pb, asf->duration); /* duration (in 100ns units) */
+    put_le64(pb, duration); /* end time stamp (in 100ns units) */
+    put_le64(pb, duration); /* duration (in 100ns units) */
     put_le32(pb, preroll_time); /* start time stamp */
     put_le32(pb, 0); /* ??? */
     put_le32(pb, asf->is_streamed ? 1 : 0); /* ??? */
@@ -349,7 +351,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
     /* stream headers */
     for(n=0;n<s->nb_streams;n++) {
         int64_t es_pos;
-        uint8_t *er_spr = NULL;
+        const uint8_t *er_spr = NULL;
         int er_spr_len = 0;
         //        ASFStream *stream = &asf->streams[n];
 
@@ -360,7 +362,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
 
         if (enc->codec_type == CODEC_TYPE_AUDIO) {
             if (enc->codec_id == CODEC_ID_ADPCM_G726) {
-                er_spr     = (uint8_t *)error_spread_ADPCM_G726;
+                er_spr     = error_spread_ADPCM_G726;
                 er_spr_len = sizeof(error_spread_ADPCM_G726);
             }
         }
@@ -737,7 +739,7 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
     pts = (pkt->pts != AV_NOPTS_VALUE) ? pkt->pts : pkt->dts;
     if (pts == AV_NOPTS_VALUE) {
         if (codec->codec_type == CODEC_TYPE_AUDIO) {
-            duration = (codec->frame_number * (int64_t)codec->frame_size * int64_t_C(10000000)) /
+            duration = (codec->frame_number * (int64_t)codec->frame_size * INT64_C(10000000)) /
                 codec->sample_rate;
         } else {
             duration = av_rescale(codec->frame_number * (int64_t)codec->time_base.num, 10000000, codec->time_base.den);
@@ -753,8 +755,8 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
 
     /* check index */
     if ((!asf->is_streamed) && (codec->codec_type == CODEC_TYPE_VIDEO) && (pkt->flags & PKT_FLAG_KEY)) {
-        start_sec = (int)(duration / int64_t_C(10000000));
-        if (start_sec != (int)(asf->last_indexed_pts / int64_t_C(10000000))) {
+        start_sec = (int)(duration / INT64_C(10000000));
+        if (start_sec != (int)(asf->last_indexed_pts / INT64_C(10000000))) {
             for(i=asf->nb_index_count;i<start_sec;i++) {
                 if (i>=asf->nb_index_memory_alloc) {
                     asf->nb_index_memory_alloc += ASF_INDEX_BLOCK;
@@ -823,13 +825,14 @@ static int asf_write_trailer(AVFormatContext *s)
     return 0;
 }
 
-AVOutputFormat asf_oformat = {
+#ifdef CONFIG_ASF_MUXER
+AVOutputFormat asf_muxer = {
     "asf",
     "asf format",
     "video/x-ms-asf",
     "asf,wmv,wma",
     sizeof(ASFContext),
-#ifdef CONFIG_MP3LAME
+#ifdef CONFIG_LIBMP3LAME
     CODEC_ID_MP3,
 #else
     CODEC_ID_MP2,
@@ -840,14 +843,16 @@ AVOutputFormat asf_oformat = {
     asf_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
 };
+#endif
 
-AVOutputFormat asf_stream_oformat = {
+#ifdef CONFIG_ASF_STREAM_MUXER
+AVOutputFormat asf_stream_muxer = {
     "asf_stream",
     "asf format",
     "video/x-ms-asf",
     "asf,wmv,wma",
     sizeof(ASFContext),
-#ifdef CONFIG_MP3LAME
+#ifdef CONFIG_LIBMP3LAME
     CODEC_ID_MP3,
 #else
     CODEC_ID_MP2,
@@ -858,4 +863,4 @@ AVOutputFormat asf_stream_oformat = {
     asf_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
 };
-#endif //CONFIG_MUXERS
+#endif //CONFIG_ASF_STREAM_MUXER