/* Write a number in EBML variable length format. */
static void put_ebml_num(ByteIOContext *pb, uint64_t num, int bytes)
/* Write a number in EBML variable length format. */
static void put_ebml_num(ByteIOContext *pb, uint64_t num, int bytes)
{
    int i, needed_bytes = ebml_num_size(num);
    assert(num < (1ULL<<56)-1);
    if (bytes == 0)
        bytes = needed_bytes;
    assert(bytes >= needed_bytes);
    num |= 1ULL << bytes*7;
    for (i = bytes - 1; i >= 0; i--)
        put_byte(pb, num >> i*8);
}