The math utility classes in Common are now used by more than just Bink
Video i.e. Huffman is used by SVQ1, RDFT by QDM2 etc. so need to remove
conditional inclusion of objects in the Common Library.
This was done as these functions are very large wrt. binary size.
This is mainly due to the sine, cosine and log tables which should be
reconsidered as to whether these are needed or can be replaced by
standard sin()/cos() calls.
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.
The number of channels in AAC can differ from the actual number of channels needed making us require this. The channel count inside the container is always the correct one.
This changes the decoder function return flag meaning from "result
error" to "resultValid". This makes it more consistent with normal
C standard of returning 0 on success.
Since the returned int values from the decoding functions are just
0 for good or -1 for error, have changed these into an errorFlag
bool. This improves readability and cleans up some of the error
checking code. In addition, have fixed some oversights in formatting
spacing for readability.
This is a temporary workaround during development.
Keyframe (I) decoding is now working correctly, but Deltaframe (P) is
still giving corrupted output...
Header was incorrectly documnented in reference documents.
Corrected with reference to FFMPEG.
Also, added missing buffering of last frame for P frame decoding.
It was possible to bypass the initialization of r11, and
mask was being read before the corresponding bounds check.
Thanks to fuzzie for analysis and LordHoto for testing.
This fixes bug #3500023 and a crash in the DOTT ending.