summaryrefslogtreecommitdiffstats
path: root/gst/matroska/ebml-write.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst/matroska/ebml-write.c')
-rw-r--r--gst/matroska/ebml-write.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gst/matroska/ebml-write.c b/gst/matroska/ebml-write.c
index 46cfd4a5..b6504867 100644
--- a/gst/matroska/ebml-write.c
+++ b/gst/matroska/ebml-write.c
@@ -391,7 +391,13 @@ gst_ebml_write_sint (GstEbmlWrite *ebml,
guint size = gst_ebml_write_get_uint_size (unum);
/* make unsigned */
- unum = (num < 0 ? -num : num) + (1LLU << ((8 * size) - 1));
+ if (num >= 0) {
+ unum = num;
+ } else {
+ unum = 0x80 << (size - 1);
+ unum += num;
+ unum |= 0x80 << (size - 1);
+ }
/* write */
gst_ebml_write_element_id (buf, id);