Home /Modules/codecs/README.md

README.md

codecs/backends/flac_native/README.md · 63 line(s) · markdown

flac-native โ€” in-tree FLAC decode backend

A real, dependency-free decode backend for SLEELA_CODEC_FLAC. It turns FLAC from "recognized, no backend wired" into a codec that actually decodes a FLAC stream to interleaved signed 16-bit PCM โ€” with no libFLAC and no other third-party dependency.

It plugs into the existing codec architecture through the documented backend ABI (sleela_codec_backend in codecs/include/sleela_codec_plugin.h): the FLAC plugin's decode() already dispatches to whatever backend is registered for its id, and this adapter is that backend.

Use

#include "flac_native.h"

sleela_flac_native_register();            // register for SLEELA_CODEC_FLAC
// ... now sleela_codec_manager_decode(m, SLEELA_CODEC_FLAC, bytes, len, &pcm)
//     returns SLEELA_CODEC_OK with real samples ...
sleela_flac_native_unregister();          // clear it again

Coverage (honest scope)

Decoded, bit-exact, following the FLAC format specification (Xiph.Org):

Deliberately not decoded (reported as a clean SLEELA_CODEC_ERR_UNSUPPORTED, never mis-decoded):

This matches the project's codec principle: the management layer never fakes a successful decode, and capability reporting stays truthful.

Tests

codecs/tests/test_flac_native.c builds real FLAC streams byte by byte and decodes them through the public manager path, asserting:

  1. a VERBATIM stereo frame decodes to bit-exact interleaved L/R samples;
  2. a FIXED order-0 frame with a Rice-coded residual decodes bit-exact (exercising the unary+binary Rice decoder and the fixed filter);
  3. an LPC subframe is reported unsupported rather than mis-decoded;
  4. clearing the backend restores a clean unsupported result.

Run with make test in codecs/.