GNOME Bugzilla – Bug 309325
Matroska: incorrect element size
Last modified: 2005-07-02 08:35:22 UTC
Please describe the problem: ebml writer wrongly encodes element size 127, 16383, ... According to the matroska specification (http://www.matroska.org/technical/specs/index.html), the sizes of 2^(7*i)-1 have to be encoded as i+1 bytes long sequence instead of i bytes. For example 127 should not be encoded as 0xff, but it should be 0x40 0x7f. Matroska muxer encodes 127 as 0xff, which makes all decoders crash. The attached patch fixes the encoding of size. Steps to reproduce: 1. 2. 3. Actual results: Expected results: Does this happen every time? Other information:
Index: ebml-write.c =================================================================== RCS file: /cvs/gstreamer/gst-plugins/gst/matroska/ebml-write.c,v retrieving revision 1.8 diff -c -p -u -p -r1.8 ebml-write.c --- ebml-write.c 1 Sep 2004 12:10:21 -0000 1.8 +++ ebml-write.c 2 Jul 2005 05:57:02 -0000 @@ -218,7 +218,7 @@ gst_ebml_write_element_size (GstBuffer * guint bytes = 1, mask = 0x80; /* how many bytes? */ - while ((size >> ((bytes - 1) * 8)) >= mask && bytes <= 8) { + while ((size >> ((bytes - 1) * 8)) >= (mask - 1) && bytes <= 8) { mask >>= 1; bytes++; }
Thanks, applied. I should've known that... :-(.