Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Spectral Band Replication for HE-AAC v1 #13

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Conversation

devongovett
Copy link
Member

@devongovett devongovett commented Jul 6, 2016

Spectral Band Replication was added to the AAC-LC profile to create HE-AAC v1. It effectively allows cutting the sample rate in half by reconstructing the high-frequency bands using harmonics from the lower/mid frequencies and some small side data (~2kbps). This greatly increases the compression ratio while retaining decent quality at low bit rates. Here is a high level overview, and here is the MPEG/ISO spec.

This is a work in progress, but it kinda works on a few files I tested. Definitely needs more testing though. I'm sure there are tons of bugs.

TODO:

  • Implement non-coupled and single channel decoding.
  • Clean up the code and remove debug logging
  • Optimize performance. It's really slow right now due to memory allocations during decoding.
  • Polyfills for typed array methods not supported cross browser (e.g. sort and fill)?
  • Generate some tables at initialization time instead of hardcoding them to reduce code size.
  • Test against more files

Much faster than arrays of arrays of arrays... Using [babel-plugin-multidimensional-array](https://github.com/devongovett/babel-plugin-multidimensional-array) for compilation.
* No more long vs short tables.
* Precompute bit reversal table.
Yay, smaller build!
Separate method to compute just the middle half, excluding parts that can be derived by symmetry. Also should be faster.
Way faster than the previous method.

This is based on a procedure to implement the filterbank on the DCT-IV described in
Hsu, H.W. et al. "A Complex Quadrature Mirror Filterbanks for MPEG-4 HE-AAC", and implementation in ffmpeg.
http://sites.google.com/site/wenchiehlee1020/Papers/ComplexFB_AES_121paper144.pdf
@devongovett
Copy link
Member Author

devongovett commented Jul 10, 2016

This is quite a bit faster now. It used ~20% CPU on my iMac before (decoding in real time), and now uses ~3-4%, which isn't much higher than simple AAC-LC decoding. Implemented optimizations by pre-allocating memory, and using flattened multidimensional typed arrays rather than arrays of (arrays of...) typed arrays. Made a babel plugin to make this easier: https://github.com/devongovett/babel-plugin-multidimensional-array.

That brought CPU usage down to ~10%. The other optimization was switching the QMF filter banks to use IMDCT instead of multiplying by a matrix. This is based on a procedure to implement the filterbank on the DCT-IV described in Hsu, H.W. et al. "A Complex Quadrature Mirror Filterbanks for MPEG-4 HE-AAC", and implementation in ffmpeg. http://sites.google.com/site/wenchiehlee1020/Papers/ComplexFB_AES_121paper144.pdf

@jimmywarting
Copy link

Progress?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants