H!
In my system minimum accessible variable is 16 bits wide. So I can use two technique I. Use low part of my 16 bits wide char. Use default #define CHAR_BIT 8 - this one working well.
II. Try to use #define CHAR_BIT 16. This one has several problems
1. in decode_header() here sync: ... else if (!(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) { ... goto fail; } I solve it by else if (!((ptr[0] & 0xffe0) == 0xffe0)) it works.
2. III_huffdecode() function. I guess problem is here:
// ---- align bit reads to byte boundaries ----- takes up to 32 bit ?? cachesz = mad_bit_bitsleft(&peek); cachesz += ((32 - 1 - 24) + (24 - cachesz)) & ~7; ...
or here:
if (cachesz < 21) { unsigned int bits; bits = ((32 - 1 - 21) + (21 - cachesz)) & ~7; ...
It isn't work - at the middle of mp3 file I have MAD_ERROR_BADHUFFDATA
So could you say to me these numbers: 32, 24, ... - what is the reason and how to calculate them for my case #define CHAR_BIT 16 ?
And what I need to do more - to work with 16 bits wide char?
Thanks for answers.