Short:        FLAC decoder library (68020+/68080)
Author:       Renaud Schweingruber, David Reid (dr_flac)
Uploader:     renaud schweingruber protonmail com (Renaud Schweingruber)
Type:         util/libs
Version:      1.0 (27.10.2026)
Requires:     68020
Architecture: m68k-amigaos >= 3.0
Distribution: Aminet

flacdec.library 1.0
===================

A shared library that decodes FLAC (Free Lossless Audio Codec) to
16-bit PCM for AmigaOS 3, bit for bit what the reference decoder
gives. Inside is dr_flac by David Reid, with its decoding loops
(LPC prediction, Rice residuals, stereo output) rewritten in 68020
assembler and tuned for the Apollo 68080.

Programs that use it: AmiPlexAmp (Plex client), and yours: the
interface is five functions (see Developer/).

Two builds
----------

  Libs/flacdec.library      any 68020 or better
  Libs/flacdec.library.080  Apollo 68080 (Vampire) only; refuses to
                            open on another CPU. With the FPU on, the
                            prediction of 24-bit files runs on it,
                            bit for bit the same

Copy one of them to LIBS:flacdec.library.

Speed on a Vampire V4 (68080, 99 MHz), CPU time in % of real time,
decoding only:

                              68080 build   FPU off
  44.1 kHz / 16-bit stereo       5.2 %       5.4 %
  96 kHz / 24-bit stereo        11.6 %      13.4 %

Formats: 4 to 32 bits per sample (16-bit output), 1 to 8 channels,
any sample rate, native FLAC (not Ogg FLAC). CRCs are not checked.
Seeking is supported. Input comes from a file or from your own I/O
hook (for example a file that is still being downloaded). Several
programs and tasks can decode at the same time. The 68020 build does
not use the FPU; the 68080 build uses it when it is on (checked for
every subframe: the V4 can switch it off).

For programmers
---------------

  Developer/doc/flacdec.doc               the autodoc
  Developer/include/libraries/flacdec.h   structures and constants
  Developer/include/clib, proto, inline   prototypes, GCC inlines
  Developer/fd/flacdec_lib.fd

  struct FLACDecInfo info;
  APTR dec = FLACDecOpenFile("song.flac", &info);
  LONG n;
  while ((n = FLACDecRead(dec, buffer, 4096)) > 0)
      ... n frames of info.fdi_Channels interleaved WORDs ...
  FLACDecClose(dec);

The functions use up to about 4.6 KB of the caller's stack: call them
with at least 8 KB free.

Tested
------

Against ffmpeg's decoder: 23 files (CD and 96 kHz/24-bit music,
ffmpeg compression levels 0 to 12, LPC orders up to 32, mono, 48 kHz,
every stereo mode, wasted bits), whole decodes and seeks at 7
positions each, both builds; the read hook; the stack use. The FPU
prediction against the integer one on 1152 cases and under constant
interrupts.

License
-------

flacdec.library is free to use and to redistribute in this unchanged
archive. (C) 2026 Renaud Schweingruber. dr_flac by David Reid is
public domain (or MIT-0), https://github.com/mackron/dr_libs.

History
-------

1.0  First release.
