Skip to content

audio: ffmpeg_dec: add ALAC decoder and FLAC/ALAC encoder support - #11427

Draft
lgirdwood wants to merge 3 commits into
thesofproject:mainfrom
lgirdwood:topic/ffmpeg-lossless
Draft

lgirdwood wants to merge 3 commits into
thesofproject:mainfrom
lgirdwood:topic/ffmpeg-lossless

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Add Phase 1 lossless compress playback and capture codecs to ffmpeg_dec using native fixed-point libavcodec implementations:

  • ALAC decoder (CONFIG_FFMPEG_DEC_ALAC, SND_AUDIOCODEC_ALAC):
    • Apple .caf container parser (kuki chunk 36-byte ALAC magic cookie extraction and data chunk framing) and inline 36-byte QuickTime 'alac' atom header support.
    • Self-delimiting unparsed frame consumption tracking via GetBitContext and partial-frame reassembly across LL period boundaries.
  • FLAC encoder (CONFIG_FFMPEG_ENC_FLAC, SND_AUDIOCODEC_FLAC):
    • Native libavcodec flac encoder configured with fixed integer LPC predictors (FF_LPC_TYPE_FIXED, compression_level = 1) for deterministic low-MCPS DSP encoding.
    • Prepends the 42-byte "fLaC" + STREAMINFO metadata block from avctx->extradata to produce a self-contained .flac stream.
    • Bounds FlacEncodeContext dimensions on a build-tree copy of flacenc.c (FLAC_MAX_BLOCKSIZE=1152, rc_sums[1], FLAC_MAX_CHANNELS=2), reducing context allocation 122x from 7.35 MiB to 43.5 KiB.
  • ALAC encoder (CONFIG_FFMPEG_ENC_ALAC, SND_AUDIOCODEC_ALAC):
    • Native libavcodec alac encoder configured with fixed LPC prediction (compression_level = 1) and planar S16 input conversion.
    • Prepends the 36-byte QuickTime 'alac' magic cookie from avctx->extradata.
  • Topologies & Base FW Capabilities:
    • Advertise SND_AUDIOCODEC_ALAC playback and SND_AUDIOCODEC_FLAC / SND_AUDIOCODEC_ALAC capture in IPC4_SOF_CODEC_INFO.
    • Add sof-hda-generic-ffmpeg-alac-compr, sof-hda-generic-ffmpeg-flac-enc-compr, and sof-hda-generic-ffmpeg-alac-enc-compr development topology targets.

Hardware Verification (Aphid PTL ACE 3.0 & Spider TGL CAVS 2.5)

Verified end-to-end on both Aphid (ptl) and Spider (tgl):

  • ALAC .caf playback (comprC0D50, codec_id=15)
  • FLAC capture encode (comprC0D51, codec_id=10) + round-trip playback (comprC0D50)
  • ALAC capture encode (comprC0D51, codec_id=15) + round-trip playback (comprC0D50)

…abilities

Advertise SND_AUDIOCODEC_ALAC playback when CONFIG_FFMPEG_DEC_ALAC is enabled, and SND_AUDIOCODEC_FLAC / SND_AUDIOCODEC_ALAC compress capture when CONFIG_FFMPEG_ENC_FLAC / CONFIG_FFMPEG_ENC_ALAC are enabled.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add Phase 1 lossless compress playback and capture codecs to ffmpeg_dec using native fixed-point libavcodec implementations:

- ALAC decoder (CONFIG_FFMPEG_DEC_ALAC, SND_AUDIOCODEC_ALAC):
  - Apple CAF container parser (kuki chunk 36-byte ALAC magic cookie extraction and data chunk framing) and inline 36-byte QuickTime 'alac' atom header support.
  - Self-delimiting unparsed frame consumption tracking via GetBitContext and partial-frame reassembly across LL period boundaries.
- FLAC encoder (CONFIG_FFMPEG_ENC_FLAC, SND_AUDIOCODEC_FLAC):
  - Native libavcodec flac encoder configured with fixed integer LPC predictors (FF_LPC_TYPE_FIXED, compression_level 1) for deterministic low-MCPS DSP encoding.
  - Prepends the 42-byte 'fLaC' + STREAMINFO metadata block from avctx->extradata to produce a self-contained .flac stream.
  - Bounds FlacEncodeContext dimensions on a build-tree copy of flacenc.c (FLAC_MAX_BLOCKSIZE=4096, MAX_PARTITIONS=16, FLAC_MAX_CHANNELS=2), reducing context allocation 122x from 7.35 MiB to 43.5 KiB.
- ALAC encoder (CONFIG_FFMPEG_ENC_ALAC, SND_AUDIOCODEC_ALAC):
  - Native libavcodec alac encoder configured with fixed LPC prediction (compression_level 1) and planar S16 input conversion.
  - Prepends the 36-byte QuickTime 'alac' magic cookie from avctx->extradata.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add development topology targets for ALAC compress playback (sof-hda-generic-ffmpeg-alac-compr) and FLAC/ALAC compress capture (sof-hda-generic-ffmpeg-flac-enc-compr, sof-hda-generic-ffmpeg-alac-enc-compr).

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants