Open Besha1 opened 3 years ago
Yes, that seems correct there might not be on the 16th bit. At the time I assumed it was on the 16th. Some blog posts of B.Stuard mentioned that is not the case, but I didn't fix it - the original sample rate also has some issues. You can make a merge request if you have it working.
Can pull request be merged?
It's not a pull request
I ran into a problem that MQA_identifier does not define all MQA files as MQA I compared the work of MQA_identifier with the work of is_mqa.py this guy here https://github.com/redsudo/mqaid So MQA_identifier does not find many MQA files where is_mqa.py find
I looked at your implementation and the implementation is_mqa.py.They are similar and I found the problem as it seems to me.
The problem is that you check once if (buffer == 0xbe0498c88) found in buffer |= ((static_cast(s[0]) ^ static_cast(s[1])) >> pos) & 1u;
from the value const auto pos = (this->decoder.bps - 16u);
In is_mqa.py the check takes place in the range from 16 to 24 samples = list(iter_data(sound_data)) streams = (Bits((x ^ y) >> p & 1 for x, y in zip(samples[::2], samples[1::2])) for p in range(16, 24))
My tests showed that need to check at least three times Need to check with at least three values from pos
something like this
uint64_t buffer = 0; uint64_t buffer1 = 0; uint64_t buffer2 = 0;
const auto pos = (this->decoder.bps - 16u); // aim for 16th bit
for (const auto &s: this->decoder.samples) { buffer |= ((static_cast(s[0]) ^ static_cast(s[1])) >> pos) & 1u;
buffer1 |= ((static_cast(s[0]) ^ static_cast(s[1])) >> pos +1) & 1u;
buffer2 |= ((static_cast(s[0]) ^ static_cast(s[1])) >> pos+2) & 1u;
} return false;
With such changes, MQA_identifier works perfectly,
If you are interested, I also added in the MQA_identifier If MQA is found, Vorbis tags are added to the flac file ENCODER = MQAEncode v1.1, 2.3.3+800 (a505918) MQAENCODER = MQAEncode v1.1, 2.3.3+800 (a505918) ORIGINALSAMPLERATE = value from MQA_identifier id.originalSampleRate()