Archive for the ‘Audio’ Category

General psychoacoustic <-> coding interaction principles

Thursday, March 5th, 2009

OK, let’s suppose we have some abstract subband coder. What it does? It performs some transform on input block of data (like MDCT or QMF filterbank) then obtained frequencies are grouped, quantized and coded.

There could be many approaches but usually there are two general principles employed:

  • Some frequencies matter more than another.
  • Energy carried by subbands matters too.

Psychoacoustic model gives us a list of subband weights meaning their importance. Now what encoder could do with them? Quantize input data and code it. There are three approaches:

  1. Perform optimal coding using psychoacoustic data (good but slow)
  2. Do some heuristics to get some quick and dirty approximation (most popular approach)
  3. Ignore psychoacoustics completely (seems to be popular too)

Optimal coding may be done by employing Vitterbi method in one form or another. Heuristics are usually done in that way: give some initial prediction value for quantizer then refine it a bit until result is close enough to desired one.

More on AAC-specific coding later.

AAC encoder and psy model

Thursday, March 5th, 2009

As you may know, I am working (mostly NOT working though :(, but still remember about it) on AAC encoder. This morning I’ve made simpler psychoacoustic model inspired by FAAC (yes, Dark Shikari, FAAC has some sort of hardcoded psy model) work with my encoder.

I’ll try to use this blog with its original purpose — to formalize my thoughts on subject at hand. I thinks many posts on different aspects of psychoacoustics will follow before more or less suitable encoder will appear. “More or less suitable” means it should be at least a good audio encoding counterpart for x264 (while “fully suitable” means total world domination).

Too bad there’s not enough time (always).

A bit of audio news

Sunday, August 31st, 2008

Looks like I soon will run out of titles, have to switch to something else then.

I’m still working on improving AAC encoder, for now I’m trying to fit trellis-based quantizer selection, then optimal quantizing will follow. In a process FFmpeg may get generic psychoacoustic model interface (there’s new IIR filters interface in SVN, with implementation for lowpass Butterworth filter only though).

In other news – there was a raise of interest to DCA decoder. Of course FFmpeg does not have one (wink wink), but there were some patches to correct tables used by it and improve speed (to nonexistent decoder, that is). Also there’s a person who hasn’t written a DCA encoder, he now reads development mailinglist and submits patches to out nonexistent decoder. Welcome!

Disclaimer. Sorry for political language, but I remember the troubles caused to Videolan because they had developed and hosted DTS decoder.

Also there’s a rise of interest to TrueSpeech, since it is used in some messenger (I’ve never thought it would be popular). I have to update information about it in MultimediaWiki a bit.

AAC: Life goes on

Monday, August 25th, 2008

Well, Summer of Code 2008 goes to end. I think I’ve completed my task – creating simple AAC encoder with psychoacoustics
(here are my application link and a rough task description). I’ve written AAC encoder with psychoacoustic model made after 3GPP TS26.403 and it seems to work fine (on multichannel sources too).

Now there’s a small catch – to be included into FFmpeg it should be optimal in the terms of coding. That means minding rate distortion, choosing optimal quantizers and codebooks, etc. Now it’s a bit harder task, so I think final encoder will be in SVN this autumn or later. Any pointers on information how to optimally encode some part of stream are welcome (for miscellaneous stuff like pulses, temporary noise shaping, etc.).

Stay tuned (and use Flac instead 😉 ).

A bit more

Friday, August 8th, 2008

With low-pass filter my AAC encoder is more or less feature-complete. Of course there’s still more room for improvements but it’s pretty fine now. I’d like to submit it for review but it depends on some parts of AAC decoder and it’s still under review :-(. So I don’t have much to do until then.

So I switched to last GSoC task and hacked again at RV40 loop filter. Well, filter invoking pattern is almost there and I’ve fixed several bugs in actual filtering code. Bit it’s not there yet. Maybe in a month it will be so if AAC encoder won’t take all my time again.

News + Extra

Sunday, August 3rd, 2008

AAC front: to compete with other encoders I have to implement low-pass filter. Benjamin suggested Butterworth filter, so I will try it next week. Hopefully that will be the last big feature to do.

RV front: looks like deblocking pattern is generated from comparing motion vectors, if the difference for subblocks is greater than 3, then edge between them is scheduled for loop filtering. Don’t expect working loop filter implementation too soon though, I still have to deal with AAC encoder and it’s more important.

Extra: I’ve finally decided to buy ASUS Eee, it was easy thing to do – there’s only one model (Eee 701 4G with Win XP installed) for about the same price of four hundred bucks (maybe $450 in greedy shops). So the first thing I did with it was installing Linux and tearing down that stupid “Designed for Windows” label (which was surprisingly easy thing to do and left no marks on laptop surface).

Now here are complains about Ubuntu Eee (I don’t have USB DVD drive and Xandros hasn’t worked from USB flash drive for me): it requires some hacking of system configuration to make it work (like shutdown properly) but that I can live with, but the braindead thing is that gcc is installed (why?) without any development header or library, so you can’t compile even “Hello, world!” program. Both of those issues are resolved, so I just need to make this toy more useful to me 🙂

AAC: encoder progress

Friday, August 1st, 2008

If there are still people interested in my work on AAC encoder (I doubt though), here is a status report for you.

Tasks completed:

  • Make encoder provide lookahead samples
  • Make psy model use these samples to produce block switching decision
  • M/S case handling (at least I hope so)
  • Multichannel coding (from mono to 5.1, seems to work fine)

So there are only two bits left: tune model to produce better sound and commit that all to FFmpeg SVN.

The problem with current implementation is that it follows given bitrate too closely, so some frames may be coded too badly resulting in audible artifacts. I will add ABR mode and quality-based mode to make it better. Another issue is how to use codec options to turn them on, so Robert Swain can add profiles for them ;).

In related news: AAC decoder is slowly migrating to FFmpeg SVN, so I should be able to submit my encoder for review and inclusion as well.

A bit of AAC news

Sunday, July 20th, 2008

I’ve not abandoned work on AAC encoder completely.
For example, I think now my psy model calculates and handles bitrate better. Now the only goals I set to myself are:

  • Make encoder provide psy model lookahead samples for block switching
  • Finetune psy model, or more specifically:
    • block switching decision
    • finish M/S case handling (for now it does not update all psy model information and result in artifacts on several test samples)
    • adjust scalefactors to reduce quantisation distortion
    • some other tricks from 3GPP TS26.403?

After that there are several ways to go: improve quality until it beats other encoders (at least libfaac), implement SBR/PS encoding (the latter is easier to do), introduce multichannel coding.

I suspect that at least one person will suggest to do it all.

Troubles with Psy Model

Monday, July 14th, 2008

I’m battling with psychoacoustic model. 3GPP TS26.403 seemed clear at the start but then problems have begun.

The main problem is perceptual entropy estimation. Since MDCT coefficients differ by magnitude in FFmpeg and 3GPP, perceptual entropy estimated by formulae from 3GPP differs much from actual number of bits to code. Also 3GPP encoder always makes scalefactor lie in range 104…164, beats me why (and its center does not correspond to scale = 1.0 either).

I have to investigate further before continuing work on psy model. I also hope to see AAC decoder in FFmpeg SVN soon and push my work on encoder there as well.

AAC: Nachrichten pro Woche

Saturday, July 5th, 2008

Here is this week portion of AAC-related news:

  • I was working on psychoacoustic model and fixes for it. Now encoder should always produce correct files (i.e. decodable without bitstream errors). Sound quality may be low though.
  • There was a bug in MDCT calculation which resulted in wrong spectrum.
  • My test device for AAC has broken 🙁 Where I can find a decent pair of headphones that won’t break that easily? Especially in this country.

And just in case my mentor’s reading this, here are my plans:

  • Improve and finish 3GPP TS26.403-based psychoacoustic model.
  • Implement block switching.
  • Add sine windows.
  • Sync my encoder with current AAC decoder code (maybe it will be committed by then?)