richgel999 / lzham_alpha

This is LZHAM Alpha8, now supplanted by LZHAM 1.x here: https://github.com/richgel999/lzham_codec
MIT License
3 stars 2 forks source link

lzham::math::total_bits() returns wrong value (VC++2012) #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. svn checkout -r96 http://lzham.googlecode.com/svn/trunk/ lzham-read-only
2. Open lzham.sln with VC++2012
3. Debug Build All & Start Debugging lzhamtest with VC++2012 Debugger

What is the expected output?
lzhamtest outputs "Compression test succeeded."

What do you see instead?
Assertion failed:
lzham-read-only\lzhamdecomp\lzham_prefix_coding.cpp(155): Assertion failed: "!c 
|| (math::total_bits(pCodes[i]) <= pCodesizes[i])"

What version of the product are you using? On what operating system?
version: lzham svn trunk r96
OS: Windows7 Professional SP1 64bit

Please provide any additional information below.
I've compiled with Visual Studio Express 2012 for Windows Desktop (VC++2012).

I think this patch will work:

// lzhamdecomp/lzham_math.h
      inline uint total_bits(uint v)
      {
         unsigned long l = 0;
         ...
#elif defined(LZHAM_USE_MSVC_INTRINSICS)
         if (_BitScanReverse(&l, v))
         {
            l++;
         }
+        else
+        {
+           l = 0;
+        }
#else
         ...
      }

Anyway, lzham looks very nice! I'm looking forward to the release ^_^

Original issue reported on code.google.com by takayuki...@gmail.com on 27 Sep 2012 at 6:46

GoogleCodeExporter commented 9 years ago
Thanks for the detailed error report takayuki. I haven't tested the lib with 
VC2012 yet - I'll try to repro this.

Original comment by richge...@gmail.com on 27 Sep 2012 at 8:30