[Ffmpeg-devel] FLAC encoder

Justin Ruggles jruggle
Sun May 28 06:32:36 CEST 2006


Here is an updated version of the encoder.
http://home.earthlink.net/~jruggle/flake/flake-01.tar.bz2

What I did:

Instead of doing brute-force bit counts and gradient search for the
optimal rice parameters, I used the log2(mean_residual_value).  This is
not 100% optimal for compression, but it's close, and it is much faster.
 First, the mean is calculated for each partition on the highest order
level. Then, each lower level mean is calculated by averaging each pair
of partitions from the level above.  In addition to calculating k, the
means are also used to estimate bit count.

One annoying result of the optimization above is that now my pre-defined
compression levels became way out-of-whack.  I had to do some more
benchmarking to find better level definitions.  Now the levels run from
0 to 8 like libFLAC.

I also did a fix for the WAV data endianness.  Although I cannot test
it, as I only have access to 1 machine which is little-endian.

I found some custom settings for libFLAC that make my encoder look not
quite as impressive... It still compresses better at the highest level
though.  flac with custom settings beats "flake -7" in both speed and
compression.  "flake -8" does better compression, but is slower.  My
results are below.

Benchmark Results:

flac:

custom level options: -P 0 -b 8192 -m -l 12 -q 0 -r 0,6

level   real time    bytes    ratio   kbps
-----  -----------  --------  -----  ------
  0     0m3.646s     2576805  0.487   687
  1     0m3.613s     2575619  0.487   687
  2     0m4.574s     2566283  0.485   684
  3     0m4.459s     2427988  0.459   647
  4     0m5.520s     2302891  0.435   614
  5     0m6.714s     2297406  0.434   613
  6     0m7.445s     2295607  0.434   612
  7    0m24.310s     2285184  0.432   609
  8    0m31.677s     2275745  0.430   607
custom  0m9.258s     2254534  0.426   601


flake:

level   real time    bytes    ratio   kbps
-----  -----------  --------  -----  ------
  0     0m4.950s     2790743  0.527   744
  1     0m5.699s     3108906  0.587   829
  2     0m5.908s     2617044  0.495   698
  3     0m6.277s     2365795  0.447   631
  4     0m6.765s     2351615  0.444   627
  5     0m7.684s     2333206  0.441   622
  6     0m9.002s     2326797  0.440   620
  7    0m12.315s     2263428  0.428   604
  8    0m13.858s     2189192  0.414   584

As a comparison, here is the same sample with the previous version:
 10    0m18.091s     2187875  0.413   583

It might be worth taking out one of the lower levels and adding the old
brute-force search back in as level 8.

So..now it's about time to try my hand at integrating with FFmpeg.  Good
thing I have tomorrow off work. :)

-Justin






More information about the ffmpeg-devel mailing list