Fixes out of bounds reads in the Myst ME intro videos.
OOB reads may happen because:
- The bitstream implementation reads 4 bytes at a time, and the buffer
size is not guaranteed to be a multiple of 4.
- The huffman parsing code reads a fixed amount of bits when it
sometimes needs not all of them.
Also fixed bits vs bytes mismatch for the size parameter of the calls to
the bitstream constructor, and removed a few unnecessary heap
allocations.
Fixes#10220.
All users of BitStream were in fact using a specific, hardcoded variant,
so we can hardcode that variant, removing the need for virtual calls,
and enabling inlining.
This should allow the QDM2 codec to work again with Common::Bitstream
instead of the older getBits() reader, but this aborts with a reading
past end of stream error...
getBits(n) would cause a runtime error if n is greater than 32,
but using getBits() to skip is no longer necessary as the newer
BitStream class has a skip method, which is used instead.
This removes the internal getBitContext bitwise reading code and
replaces with Common::BitStream.
However, this breaks the codec as in one location, the internal buffer
of getBitContext reader is used and this can't be directly replaced.
This will need to be understood and rewritten.
find -name '*.h' -or -name '*.cpp' | xargs sed -r -i 's@\(([A-Za-z0-9]+)\*\)@(\1 *)@g'
This seems to have caught some params as well which is not undesirable IMO.
It also caught some strings containing this which is undesirable so I
excluded them manually. (engines/sci/engine/kernel_tables.h)