Skip to main content
Topic: Optimized FLAC encoder (Read 78441 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Optimized FLAC encoder

While playing with MPEG ALS I also studyed currently existing compressors a bit, to see if they had optimizations or tricks that could be of interest for ALS.

In the FLAC code, I found some things that looked like  bugs/oversights. I did some attempts to fix that, and the result appears to be positive.

This Windows binary should compress tighter than the reference encoder at all settings almost all of the time:

http://sjeng.org/ftp/lossless/flac.exe


Optimized FLAC encoder

Reply #2
The worst case is identical to the reference encoder.

The average case may be different - I did not investigate that.

Given that likely the player stutters when encountering the worst case, I think it should work fine. The files are fully FLAC-standard-compliant.

Optimized FLAC encoder

Reply #3
Looks good here.  I did a quick comparison with -8:

Code: [Select]
File:                                                   Size 1.1.2:     Size 1.1.2.1:   % Decrease:

04-Aly_And_AJ-Something_More.flac                          29357707          29270378         0.297
04-Fanny_Hamlin_and_Adam_Appel-Ready_For_Love.flac         21187038          21080676         0.502
04-McFly-That_Girl.flac                                    25878788          25767410         0.430
04-NSync-Merry_Christmas_Happy_Holidays.flac               32022324          31892606         0.405
04-Opeth-The_Drapery_Falls.flac                            85449229          84950401         0.584
06-BBMak-I_Can_Tell.flac                                   30068568          29973771         0.315
06-McFly-Too_Close_For_Comfort.flac                        36072742          35855022         0.604
08-Dream_Theater-Home.flac                                 97724239          97071027         0.668
09-Play-Another_Love_Story.flac                            25598417          25544604         0.210
10-Utopia_Banished-Forshadowing_The_Endless_Quest.flac     57122311          56928830         0.339

(Total)                                                   440481363         438334725         0.487

And the CRC of the decompressed files are all correct of course.

EDIT: Improved table alignment.

Optimized FLAC encoder

Reply #4
Quote
In the FLAC code, I found some things that looked like  bugs/oversights. I did some attempts to fix that, and the result appears to be positive.[a href="index.php?act=findpost&pid=355783"][{POST_SNAPBACK}][/a]

Thanks Garf, but what exactly changed? We lready know the decoding speed might have been affected, but was the compression ratio improved at all? Could you be more specific?

Edit (Garf): Uh, sorry, I'm tired and I accidentally edited your post instead of making a new one.

Optimized FLAC encoder

Reply #5
I tested it on my old machine (Intel P4 1.5GHz "Williamette") and -7 and -8 doesn't work here. The encoder freezes at 98%.
But here is my comparison with the "original" flac 1.1.2:
(tested with my own testsample provided here: http://www.megaupload.com/de/?d=O6WOVNJ8
replaygained with foobar2000 to a today's usual dynamic of 96dB)

Code: [Select]
Testsystem:

CPU:      1.5GHz P4 "Williamette"
RAM:      512 MB SD-RAM PC133
HDD:      WD 80GB 7.200upm
OS:      WinXP SP2
Programm:    foobar2000 0.8.3 (decoding: speed-meter)

=================================================================================


MODE        SPEED x
   ENCODE    DECODE        RATIO

FLAC 1.1.2
-0     25,95  40,43     68,06%
-1     25,43  39,60     66,55%
-2     23,13  40,00     65,89%
-3     21,94  36,56     66,43%
-4     19,90  35,88     64,80%
-5     17,94  36,58     64,30%
-6     17,60  36,23     64,21%
-7      7,82  36,92     64,09%
-8      6,20  35,88     64,05%

FLAC 1.1.2.1 optimized by Garf
-0     26,85  41,29     68,06%
-1     26,47  40,00     66,55%
-2     22,72  40,84     65,90%
-3     22.32  34,90     66,27%
-4     20,00  35,90     64,71%
-5     17,29  36,92     64,17%
-6     15,17  37,26     64,07%
-7     FREEZES PC AT 98%----
-8     FREEZES PC AT 98%----


Optimized FLAC encoder

Reply #7
Are you going to make the code or at least an overview of the changes available in case Josh wants to use your changes?

Optimized FLAC encoder

Reply #8
@Garf
Yes, flac_msvc is working, but it encodes a little bit slower than the other.

EDIT: (new test with the new flac_msvc)
Code: [Select]
Testsystem:

CPU:      1.5GHz P4 "Williamette"
RAM:      512 MB SD-RAM PC133
HDD:      WD 80GB 7.200upm
OS:       WinXP SP2
Programm: foobar2000 0.8.3 (decoded: speed-meter)

=================================================================================


MODE        SPEED x
       ENCODE DECODE   RATIO

FLAC 1.1.2
-0      25,95   40,43   68,06%
-1      25,43   39,60   66,55%
-2      23,13   40,00   65,89%
-3      21,94   36,56   66,43%
-4      19,90   35,88   64,80%
-5      17,94   36,58   64,30%
-6      17,60   36,23   64,21%
-7       7,82   36,92   64,09%
-8       6,20   35,88   64,05%

FLAC_MSVC 1.1.2.1 optimized by Garf
-0      24,93   41,29   68,06%
-1      24,45   40,00   66,55%
-2      19,90   40,84   65,90%
-3      21,33   37,29   66,27%
-4      18,28   35,88   64,71%
-5      16,33   36,92   64,17%
-6      12,92   36,92   64,07%
-7       3,75   36,92   63,91%
-8       2,91   36,23   63,87%

Seems to be a slight improvement in compression ratio from -3 up to -8, without any real effect on decoding speed.

Optimized FLAC encoder

Reply #9
Great! So you submitted this to Josh, right? *me hopes for a OS X build*
"Facts do not cease to exist just because they are ignored."
—Aldous Huxley

Optimized FLAC encoder

Reply #10
I'd be interested to see it.


Optimized FLAC encoder

Reply #12
Quote
http://sjeng.org/ftp/lossless/flac.exe

what's this? version is 1.1.2.1... different from flac_msvc.exe?
[a href="index.php?act=findpost&pid=356120"][{POST_SNAPBACK}][/a]

That's the original one he posted compiled with Intel compiler, later replaced with a MSVC compile due to the bug tedgo found.

Optimized FLAC encoder

Reply #13
Quote
Quote
http://sjeng.org/ftp/lossless/flac.exe

what's this? version is 1.1.2.1... different from flac_msvc.exe?
[a href="index.php?act=findpost&pid=356120"][{POST_SNAPBACK}][/a]

That's the original one he posted compiled with Intel compiler, later replaced with a MSVC compile due to the bug tedgo found.
[a href="index.php?act=findpost&pid=356132"][{POST_SNAPBACK}][/a]


thx. i understand 

Optimized FLAC encoder

Reply #14
Updated. Again better compression, though improvement is quite small :-P

I also replaced the binaries, now just one MSVC binary that is hopefully bugfree.

Optimized FLAC encoder

Reply #15
There seems to be something wrong with this new flac.exe, because I get this:
D:\Temp>flac.exe
The system cannot execute the specified program.

WinXp SP2

Optimized FLAC encoder

Reply #16
It works fine on my system (used it in foobar2000).

Compression ratio is between 0.02 and 0.04% worse than the flac_msvc-build... But with a slight speed improvement.

EDIT:
Have i downloaded the wrong binary? Its stated as "20060107" in the files properties.

Optimized FLAC encoder

Reply #17
Wanna make an optimized version of the wavpack encoder? That would be really great.

Optimized FLAC encoder

Reply #18
Btw, where's the source?

Optimized FLAC encoder

Reply #19
Quote
There seems to be something wrong with this new flac.exe, because I get this:
D:\Temp>flac.exe
The system cannot execute the specified program.

WinXp SP2[a href="index.php?act=findpost&pid=356625"][{POST_SNAPBACK}][/a]


Very same problem here...

ASUS P5P800, Intel Pentium 4 Prescott 640, 2xDDR-SDRAM PC3200 - 512 MBytes, Windows XP Professional SP2 fully updated.

Sergio
Sergio
M-Audio Delta AP + Revox B150 + (JBL 4301B | Sennheiser Amperior | Sennheiser HD598)

Optimized FLAC encoder

Reply #20
well, it works here. do you have a msvcr80.dll C runtime library?


http://www.dependencywalker.com/

Optimized FLAC encoder

Reply #21
Quote
well, it works here. do you have a mcvcr80.dll C runtime library?


http://www.dependencywalker.com/
[a href="index.php?act=findpost&pid=356654"][{POST_SNAPBACK}][/a]


Bingo! It is missing!

What is it? Where can I get it? Can't it be statically loaded?

Many thanks!

Sergio

Edit: BTW, very nice tool, the one you pointed to!
Sergio
M-Audio Delta AP + Revox B150 + (JBL 4301B | Sennheiser Amperior | Sennheiser HD598)

Optimized FLAC encoder

Reply #22
The flac.exe works fine on my system and i don't have a mcvcr80.dll.
Or did you meant a ms[/u]vcr80.dll?

Optimized FLAC encoder

Reply #23
Quote
The flac.exe works fine on my system and i don't have a mcvcr80.dll.
Or did you meant a ms[/u]vcr80.dll?
[a href="index.php?act=findpost&pid=356657"][{POST_SNAPBACK}][/a]


Oh, yes! It is msvcr80.dll!
Sergio
M-Audio Delta AP + Revox B150 + (JBL 4301B | Sennheiser Amperior | Sennheiser HD598)

Optimized FLAC encoder

Reply #24
Quote
Compression ratio is between 0.02 and 0.04% worse than the flac_msvc-build... But with a slight speed improvement.

The new one is worse for me also when comparing to the original build.  Out of the 10 files I tested, only 2 were better with the newer one, the other 8 were worse.  The overall size of all 10 files came out worse with the new one.

 
SimplePortal 1.0.0 RC1 © 2008-2019