OK, now I have simple and not very correct AAC encoder. Because of quantization step missing (spectral coefficients should be downscaled by cube root from them) resulting AAC becomes louder and FAAD complain on quantisation value being too large. FFmpeg future AAC decoder just silently clips it. In any case, it produces sound close to original.
Since no psychoacoustics is employed for now, bitrate is too high (~400kbps per channel, no joint stereo savings too).
So, the plan is to:
- Fix and optimize bitstream writing (yes, bitstream packing is far from optimal too)
- Psychoacoustic model (I hope it will be easier than multichannel audio API in FFmpeg)
- Bitrate control
Back to work…