Skip to content

v0.0.7: image and audio

Choose a tag to compare

@fluxin fluxin released this 20 Oct 20:32
· 48 commits to main since this release

odecs now covers the suite's images and audio. stb_image and miniaudio can
go: image and audio decode everything they read, more accurately, and
mostly faster.

Breaking

  • movie is now video: import deps:odecs/video. The procedures and
    types are unchanged, but three Reader fields moved, because the reader now
    embeds an audio.Reader that owns the opened file:
    • r.container is now r.audio.container;
    • r.audio_index is now r.audio.track;
    • r.audio is an audio.Reader. Its description is r.audio.info, and
      r.audio.present, r.audio.sample_rate and the other fields still work
      through using.
      The demuxers are r.audio.demux and r.audio.webm.
  • Multichannel audio now uses WAVE order for every codec: FL, FR, FC,
    LFE, BL, BR, then side and centre pairs. This covers read_audio and
    write_audio. AAC, Opus and Vorbis surround were in their codec's own
    order before. Mono and stereo are unchanged.

New

image: PNG, JPEG, GIF, BMP, TGA, QOI and WebP to RGBA8, plus PNG
writing.

  • jpeg: our own baseline and progressive decoder. Its output is
    identical to libjpeg-turbo, and it runs as fast with -microarch:native
    (about 1.6× faster than stb_image).
  • gif: the first frame as stb_image gives it, or the animation
    composited as browsers show it (identical to Chromium). About 1.5× faster
    than stb_image.
  • bmp: decoding by stb_image's rules. Unlike core:image's BMP, it keeps
    alpha.
  • png/encoder: PNG writing, moved from ovg.

audio: any file's first audio track, in MP4/M4A/MOV, WebM/MKV, WAV,
FLAC, MP3 or Ogg. The codecs are AAC-LC, PCM, FLAC, MP3, Opus, ALAC and
Vorbis.

  • Output: interleaved f32 in WAVE order, with seeking (audio.Reader),
    or a whole file at once (audio.decode).
  • vorbis: our own Vorbis I decoder, written from the specification. It
    is within 135 dB of libvorbis and takes 0.66× libvorbis' time.
  • wav: writing as 16-bit PCM or 32-bit float.

Accuracy against what we replace:

  • WAV and FLAC are identical to miniaudio.
  • MP3 is within 122 dB of FFmpeg; miniaudio's dr_mp3 is 70 to 89 dB from it.
  • miniaudio decodes 5.1 Vorbis wrongly; odecs matches libvorbis and FFmpeg.

Licences and provenance

Everything stays MIT. The JPEG and Vorbis decoders are our own code.
libjpeg-turbo and libvorbis are pinned only as test oracles
(tools/fetch_third_party.sh); none of their code is used.

Known gaps

  • JPEG: arithmetic coding, 12-bit and lossless JPEG are not decoded.
  • WAV: ADPCM is not decoded. miniaudio decodes it.
  • FLAC: decoding takes about 1.5× miniaudio's time.
  • Not supported yet: HEIC, AVIF and TIFF.