]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/blobdiff - libavformat/swfenc.c
frsh: Export information about the last RTP contract and VRES
[frescor/ffmpeg.git] / libavformat / swfenc.c
index 0fc244e1263d98547c94aa02c575f8b87ad96d05..af5da4ab3f5e6c35ada4006f6b0f79c54cb57471 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Flash Compatible Streaming Format muxer
- * Copyright (c) 2000 Fabrice Bellard.
- * Copyright (c) 2003 Tinic Uro.
+ * Copyright (c) 2000 Fabrice Bellard
+ * Copyright (c) 2003 Tinic Uro
  *
  * This file is part of FFmpeg.
  *
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavcodec/bitstream.h"
+#include "libavcodec/put_bits.h"
 #include "avformat.h"
 #include "swf.h"
 
@@ -44,7 +44,7 @@ static void put_swf_end_tag(AVFormatContext *s)
 {
     SWFContext *swf = s->priv_data;
     ByteIOContext *pb = s->pb;
-    offset_t pos;
+    int64_t pos;
     int tag_len, tag;
 
     pos = url_ftell(pb);
@@ -102,7 +102,7 @@ static void put_swf_rect(ByteIOContext *pb,
     put_bits(&p, nbits, ymax & mask);
 
     flush_put_bits(&p);
-    put_buffer(pb, buf, pbBufPtr(&p) - p.buf);
+    put_buffer(pb, buf, put_bits_ptr(&p) - p.buf);
 }
 
 static void put_swf_line_edge(PutBitContext *pb, int dx, int dy)
@@ -167,7 +167,7 @@ static void put_swf_matrix(ByteIOContext *pb,
     put_bits(&p, nbits, ty);
 
     flush_put_bits(&p);
-    put_buffer(pb, buf, pbBufPtr(&p) - p.buf);
+    put_buffer(pb, buf, put_bits_ptr(&p) - p.buf);
 }
 
 static int swf_write_header(AVFormatContext *s)
@@ -192,7 +192,7 @@ static int swf_write_header(AVFormatContext *s)
                     return -1;
                 }
                 swf->audio_enc = enc;
-                av_fifo_init(&swf->audio_fifo, AUDIO_FIFO_SIZE);
+                swf->audio_fifo= av_fifo_alloc(AUDIO_FIFO_SIZE);
             } else {
                 av_log(s, AV_LOG_ERROR, "SWF muxer only supports MP3\n");
                 return -1;
@@ -293,7 +293,7 @@ static int swf_write_header(AVFormatContext *s)
         put_bits(&p, 5, 0);
 
         flush_put_bits(&p);
-        put_buffer(pb, buf1, pbBufPtr(&p) - p.buf);
+        put_buffer(pb, buf1, put_bits_ptr(&p) - p.buf);
 
         put_swf_end_tag(s);
     }
@@ -344,6 +344,7 @@ static int swf_write_video(AVFormatContext *s,
             /* create a new video object */
             put_swf_tag(s, TAG_VIDEOSTREAM);
             put_le16(pb, VIDEO_ID);
+            swf->vframes_pos = url_ftell(pb);
             put_le16(pb, 15000); /* hard flash player limit */
             put_le16(pb, enc->width);
             put_le16(pb, enc->height);
@@ -413,12 +414,12 @@ static int swf_write_video(AVFormatContext *s,
     swf->swf_frame_number++;
 
     /* streaming sound always should be placed just before showframe tags */
-    if (swf->audio_enc && av_fifo_size(&swf->audio_fifo)) {
-        int frame_size = av_fifo_size(&swf->audio_fifo);
+    if (swf->audio_enc && av_fifo_size(swf->audio_fifo)) {
+        int frame_size = av_fifo_size(swf->audio_fifo);
         put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG);
         put_le16(pb, swf->sound_samples);
         put_le16(pb, 0); // seek samples
-        av_fifo_generic_read(&swf->audio_fifo, frame_size, &put_buffer, pb);
+        av_fifo_generic_read(swf->audio_fifo, pb, frame_size, &put_buffer);
         put_swf_end_tag(s);
 
         /* update FIFO */
@@ -435,7 +436,7 @@ static int swf_write_video(AVFormatContext *s,
 }
 
 static int swf_write_audio(AVFormatContext *s,
-                           AVCodecContext *enc, const uint8_t *buf, int size)
+                           AVCodecContext *enc, uint8_t *buf, int size)
 {
     SWFContext *swf = s->priv_data;
 
@@ -443,12 +444,12 @@ static int swf_write_audio(AVFormatContext *s,
     if (swf->swf_frame_number == 16000)
         av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
 
-    if (av_fifo_size(&swf->audio_fifo) + size > AUDIO_FIFO_SIZE) {
+    if (av_fifo_size(swf->audio_fifo) + size > AUDIO_FIFO_SIZE) {
         av_log(s, AV_LOG_ERROR, "audio fifo too small to mux audio essence\n");
         return -1;
     }
 
-    av_fifo_generic_write(&swf->audio_fifo, buf, size, NULL);
+    av_fifo_generic_write(swf->audio_fifo, buf, size, NULL);
     swf->sound_samples += enc->frame_size;
 
     /* if audio only stream make sure we add swf frames */
@@ -480,7 +481,7 @@ static int swf_write_trailer(AVFormatContext *s)
         if (enc->codec_type == CODEC_TYPE_VIDEO)
             video_enc = enc;
         else
-            av_fifo_free(&swf->audio_fifo);
+            av_fifo_free(swf->audio_fifo);
     }
 
     put_swf_tag(s, TAG_END);
@@ -494,16 +495,18 @@ static int swf_write_trailer(AVFormatContext *s)
         url_fseek(pb, 4, SEEK_SET);
         put_le32(pb, file_size);
         url_fseek(pb, swf->duration_pos, SEEK_SET);
-        put_le16(pb, video_enc->frame_number);
+        put_le16(pb, swf->video_frame_number);
+        url_fseek(pb, swf->vframes_pos, SEEK_SET);
+        put_le16(pb, swf->video_frame_number);
         url_fseek(pb, file_size, SEEK_SET);
     }
     return 0;
 }
 
-#ifdef CONFIG_SWF_MUXER
+#if CONFIG_SWF_MUXER
 AVOutputFormat swf_muxer = {
     "swf",
-    "Flash format",
+    NULL_IF_CONFIG_SMALL("Flash format"),
     "application/x-shockwave-flash",
     "swf",
     sizeof(SWFContext),
@@ -514,10 +517,10 @@ AVOutputFormat swf_muxer = {
     swf_write_trailer,
 };
 #endif
-#ifdef CONFIG_AVM2_MUXER
+#if CONFIG_AVM2_MUXER
 AVOutputFormat avm2_muxer = {
     "avm2",
-    "Flash 9 (AVM2) format",
+    NULL_IF_CONFIG_SMALL("Flash 9 (AVM2) format"),
     "application/x-shockwave-flash",
     NULL,
     sizeof(SWFContext),