]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
put_ebml_void()
authorconrad <conrad@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Wed, 5 Sep 2007 00:23:09 +0000 (00:23 +0000)
committerconrad <conrad@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Wed, 5 Sep 2007 00:23:09 +0000 (00:23 +0000)
git-svn-id: file:///var/local/repositories/ffmpeg/trunk@10311 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavformat/matroskaenc.c

index 7fd0fb9cfd045a6e03b89a683c6f6773a71edea0..a3be93511a257994794b2f52ab9a8d9fe1a66ad0 100644 (file)
@@ -90,6 +90,24 @@ static void put_ebml_string(ByteIOContext *pb, unsigned int elementid, const cha
     put_ebml_binary(pb, elementid, str, strlen(str));
 }
 
+// this reserves exactly the amount of space specified by size, which must be at least 2
+static void put_ebml_void(ByteIOContext *pb, uint64_t size)
+{
+    offset_t currentpos = url_ftell(pb);
+
+    if (size < 2)
+        return;
+
+    put_ebml_id(pb, EBML_ID_VOID);
+    // we need to subtract the length needed to store the size from the size we need to reserve
+    // so 2 cases, we use 8 bytes to store the size if possible, 1 byte otherwise
+    if (size < 10)
+        put_ebml_size(pb, size-1, 0);
+    else
+        put_ebml_size(pb, size-9, 7);
+    url_fseek(pb, currentpos + size, SEEK_SET);
+}
+
 static offset_t start_ebml_master(ByteIOContext *pb, unsigned int elementid)
 {
     put_ebml_id(pb, elementid);