changeset 2449:1226842f8de0 libavformat

Calculate the size of a SimpleBlock before writing it so that bytes aren't wasted in writing the size
author conrad
date Wed, 05 Sep 2007 00:23:23 +0000
parents bc52328116ac
children 8ac88c6c10e4
files matroskaenc.c
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/matroskaenc.c	Wed Sep 05 00:23:21 2007 +0000
+++ b/matroskaenc.c	Wed Sep 05 00:23:23 2007 +0000
@@ -428,7 +428,6 @@
 {
     MatroskaMuxContext *mkv = s->priv_data;
     ByteIOContext *pb = &s->pb;
-    offset_t block;
 
     // start a new cluster every 5 MB or 5 sec
     if (url_ftell(pb) > mkv->cluster + 5*1024*1024 || pkt->pts > mkv->cluster_pts + 5000) {
@@ -442,12 +441,12 @@
         mkv->cluster_pts = pkt->pts;
     }
 
-    block = start_ebml_master(pb, MATROSKA_ID_SIMPLEBLOCK);
+    put_ebml_id(pb, MATROSKA_ID_SIMPLEBLOCK);
+    put_ebml_size(pb, pkt->size + 4, 0);
     put_byte(pb, 0x80 | (pkt->stream_index + 1));     // this assumes stream_index is less than 126
     put_be16(pb, pkt->pts - mkv->cluster_pts);
     put_byte(pb, !!(pkt->flags & PKT_FLAG_KEY));
     put_buffer(pb, pkt->data, pkt->size);
-    end_ebml_master(pb, block);
 
     mkv->duration = pkt->pts + pkt->duration;
     return 0;