Archive for July, 2008

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.

Turtles All the Way

Sunday, July 20th, 2008

Just in time I though I’ve fully understood RV4 loop filter. It uses both coded block pattern and some other pattern. I thought it was CBP from the previous frame, but it turned out to be some special deblocking pattern calculated for each block in interframes after decoding that block. That calculation is easy – it just selects a set of subblocks to check, compare some values and if the difference is less than 3 then set a bit in deblock pattern. Now the only thing left is to find out is where those values come from.

Again and again on RV40 loop filter

Tuesday, July 15th, 2008

I’ve mostly understood how RV40 loop filter works.

Just not to forget main principles I document it here (this blog was created for such things after all).

  • CBPs from left, top and bottom neighbours are used in filter, and if frame type is interframe then CBPs for those blocks in that reference frame are used as well.
  • There are two actual filter types – weak and strong, both are described in H.264 drafts.
  • Edges in subblock are filtered in the next order: bottom, left, top. Top edge is filtered only for the subblocks in the first row.
  • There are many filter parameters passed: dither argument (for strong filter, depends on subblock position), two thresholds taken from ClipTable, threshold taken from alpha_tab, threshold taken from beta_tab and the same value multiplied by 3 or 4 (four is for Y plane filters in not extremely big pictures).
  • The problem was to determine what ClipTable parameters should be used, as it has an additional dimension, more on it below.

There are seven values taken from ClipTable total:

  1. ClipTable[0][current block quantiser]
  2. ClipTable[2][current block quantiser]
  3. ClipTable[2][global quantiser set in header]
  4. ClipTable[x][current block quantiser]
  5. ClipTable[x][top neighbour quantiser]
  6. ClipTable[x][left neighbour quantiser]
  7. ClipTable[x][bottom neighbour quantiser]

That x value is 2 for the intra block types and P-frame interblock with DCs coded separately, 1 otherwise.
As I understand, ClipTable[x][current block quantiser] is used by default and other valuer are used for corner cases (subblock on the side of the edge is uncoded, belongs to another macroblock or does not exist at all).

I should look at H.264 loop filter description (thanks to all who sent me the pointers to the book by Iain Richardson), it seems suspiciously similar.

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.

Again on RV40 loop filter

Thursday, July 10th, 2008

While work on AAC encoder is slowly progressing (now it’s mostly psychoacoustics left to do and maybe HE-AAC if somebody will convince me), I’m looking at side tasks to make my life a bit more colourful.
For now those tasks are writing SSE2 optimization for Monkey’s Audio decoder (and that is the first piece of SIMD assembly I’ve ever written) and working on RV40 loop filter.
To give people false hope, it’s more understandable by now. Only one function argument is not obvious. And Dark Shikari, you were wrong – RV40 is 99,5% alike with H264 draft (not 99% you said), as loop filter is suspiciously similar to H264 one.

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?)

AAC: weekly report

Tuesday, July 1st, 2008

I’m working on creating psychoacoustic model from recommendations presented in 3GPP TS26.403. Implementation is very rough but at least it can produce the files with desired bitrate (not quite that bitrate but ~2kbps around it).

Now the tasks are to eliminate noise from encoded material and add block switching. Maybe window switching as well.
Oh, and commit that all to FFmpeg SVN.