Again and again on RV40 loop filter

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

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

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

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

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.

AAC: going to psychoacoustics

June 24th, 2008

Looks like Gabriel Bouvigne of mp3-tech.org (how many information I got from there!) and Lame fame took interest in AAC encoder. For now I’m following his advise and trying to implement psychoacoustic model after 3GPP TS 26.403 document. It should be simple yet effective enough.

In the other news: AAC decoder mutates to become fit for FFmpeg SVN inclusion. I hope that will happen soon. Keep going, Robert, and keep reviewing, Michael!

Update on AAC progress

June 16th, 2008

If you are interested in what happens with my encoder, here’s a piece of report.

Simple encoding works. That means you can encode files with it now and they can be played back and you’ll be able to recognize the sound. Also I’ve separated psychoacoustic model and encoder itself, so it calls model to ask what windowing to use and what scaling/coefficients to encode.
Can I say this concludes the task for this summer of code? Technically yes but there are few points I ought to finish.

Encoder side:

  • MDCT for the cases different from simple 1024-point window (8 short windows sequence and two transition windows)
  • correct bitstream writing for 8SS case
  • probably multichannel encoding (it’s useless until we have defined multichannel audio API though)

Psychoacoustic model(s) side:

  • good psychoacoustic model 🙂
  • quantizer which allows rate control
  • something else?

I can add some models after the work is complete too and probably tune it for my ears and music I like to listen to. Reading papers I got on psychoacoustic models should help.

Back to work then.

Some progress in AAC encoder

June 9th, 2008

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…

Still in Memphis…

June 4th, 2008

Although it’s no good to kick a dead horse discuss the work of governmental establishments, I still want to cry about total ineffectiveness of our customs.

Today I’ve received stored value card from Google sent on May 27. They have also sent a book. On May 15th. And it’s still not here.
Here is the log – see for yourselves: 1.png.
And something stops me from believing custom officers take their time reading that book.

Last year package sent by Mike took a whole month rest. Not mentioning $10 fee for those 12 recorded DVD+Rs.

Surprisingly, x86 box I’ve recently got was delivered in a week by Express Mail or something similar.

Good system architects optimize system performance by removing the biggest and most probable delay. If delivering a package takes a week and clearing at custom takes at least two then what makes the weakest, slowest and ugliest link? Where can I submit a patch to this process?

P.S. For those who don’t know the title origin – look here.

Year of AAC in FFmpeg

May 31st, 2008

I’ve started working on AAC encoder for FFmpeg. I’ve bricked (=made a dead-tree brick copy) a bit of standard (it’s really big) and have written a bit of code too. Hopefully we will have fully working AAC encoder to the end of summer. It’s time to get rid of libfaac and libfaad dependencies!

The phrase chosen as title was coined by Robert Swain, who works on bringing GSoC-2006 AAC decoder to FFmpeg and adding SBR support to it.