From 564093e0ec4c27ec4d6bcf0dfb46d4a8f1a315a8 Mon Sep 17 00:00:00 2001 From: Evgeny Shulgin Date: Sun, 5 Mar 2017 20:18:13 +0300 Subject: [PATCH] Removed builtin code in Matroska --- src/lib_ccx/matroska.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lib_ccx/matroska.c b/src/lib_ccx/matroska.c index 3c4eb005..0ea674ce 100644 --- a/src/lib_ccx/matroska.c +++ b/src/lib_ccx/matroska.c @@ -33,11 +33,13 @@ UBYTE mkv_read_byte(FILE* file) { ULLONG read_vint_length(FILE* file) { UBYTE ch = mkv_read_byte(file); -#ifdef _WIN32 - int cnt = 8 - __lzcnt16(ch); -#else - int cnt = __builtin_clz(ch) - 24 + 1; -#endif + int cnt = 0; + for (int i = 7; i >= 0; i--) { + if ((ch & (1 << i)) != 0) { + cnt = 8 - i; + break; + } + } ch ^= (1 << (8 - cnt)); ULLONG ret = ch; for (int i = 1; i < cnt; i++) {