# cherry-embedded/cherryavp architecture

> Architecture diagram of the GitHub repository cherry-embedded/cherryavp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cherry-embedded/cherryavp
- Repository: https://github.com/cherry-embedded/cherryavp

## Overview

CherryAVP is a low-memory audio/video processing library for MCUs. Its documented audio workflow parses a container to identify stream data and decoder configuration, then decodes complete audio frames to PCM; callers can further convert sample rate, channels, or bit depth. Separate capabilities include audio front-end processing, effects, and MFCC extraction. The tree also contains container muxing and video-related format support, while the README recommends hardware video codecs. Several codec and format implementations are present in the tree but were not sampled, so their internal call links are not inferred.

Main entry points: [`avformat/src/audio_stream_demux.c`](https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/audio_stream_demux.c) (Stream demux), [`avcodec/src/audio_decode.c`](https://github.com/cherry-embedded/cherryavp/blob/master/avcodec/src/audio_decode.c) (Frame decoder API), [`avformat/src/mp4_demux.c`](https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/mp4_demux.c) (MP4 demux), [`avcodec/inc/audio_codec_common.h`](https://github.com/cherry-embedded/cherryavp/blob/master/avcodec/inc/audio_codec_common.h) (Audio frame contract)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_formats["Containers and streams"]
  node_stream_demux["Stream demux"]
  node_wav_demux["WAV demux<br/>[wav_demux.c]"]
  node_m4a_demux["M4A demux<br/>[m4a_demux.c]"]
  node_mp4_demux["MP4 demux<br/>[mp4_demux.c]"]
  node_avi_demux["AVI demux<br/>[avi_demux.c]"]
  node_ogg_demux["OGG demux<br/>[ogg_demux.c]"]
  node_wav_mux["WAV mux<br/>[wav_mux.c]"]
end

subgraph group_codecs["Audio codecs"]
  node_decoder_api["Frame decoder API<br/>[audio_decode.c]"]
  node_aac_decode["AAC decoder<br/>[aac_decode.c]"]
  node_flac_decode["FLAC decoder<br/>[flac_decode.c]"]
  node_g722_decode["G.722 decoder<br/>[g722_decode.c]"]
  node_other_decoders["Other audio decoders"]
  node_audio_contract["Audio frame contract"]
end

subgraph group_processing["Audio processing"]
  node_swr["Format conversion<br/>[avp_swr.c]"]
  node_afe_3a["3A front end<br/>[avp_afe_3a.c]"]
  node_howling["Howling suppression<br/>[avp_afe_howling.c]"]
  node_effects["Audio effects"]
  node_mfcc["MFCC extraction<br/>[avp_mfcc.c]"]
end

subgraph group_core["Shared runtime"]
  node_io["I/O abstraction<br/>[avp_io.c]"]
  node_packet["Packet utilities<br/>[avp_packet.c]"]
  node_bitreader["Bit reader<br/>[avp_bitreader.h]"]
  node_common["Shared utilities<br/>[avp_common.h]"]
end

node_caller(("Application"))
node_hardware_video["Hardware video codecs"]

node_caller -->|"opens stream"| node_stream_demux
node_caller -->|"decodes frames"| node_decoder_api
node_stream_demux -.->|"parses formats"| node_wav_demux
node_stream_demux -.->|"parses formats"| node_m4a_demux
node_stream_demux -.->|"parses formats"| node_mp4_demux
node_stream_demux -.->|"parses formats"| node_avi_demux
node_stream_demux -.->|"parses formats"| node_ogg_demux
node_stream_demux -->|"provides configuration"| node_decoder_api
node_decoder_api -.->|"uses frame contract"| node_audio_contract
node_caller -->|"converts PCM"| node_swr
node_caller -->|"processes audio"| node_afe_3a
node_caller -->|"suppresses howling"| node_howling
node_caller -->|"applies effects"| node_effects
node_caller -->|"extracts features"| node_mfcc
node_caller -->|"writes WAV"| node_wav_mux
node_caller -->|"uses hardware codecs"| node_hardware_video
node_mp4_demux -->|"reads bits"| node_bitreader
node_audio_contract -->|"references packet type"| node_packet

click node_stream_demux "https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/audio_stream_demux.c"
click node_wav_demux "https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/wav_demux.c"
click node_m4a_demux "https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/m4a_demux.c"
click node_mp4_demux "https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/mp4_demux.c"
click node_avi_demux "https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/avi_demux.c"
click node_ogg_demux "https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/ogg_demux.c"
click node_wav_mux "https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/wav_mux.c"
click node_decoder_api "https://github.com/cherry-embedded/cherryavp/blob/master/avcodec/src/audio_decode.c"
click node_aac_decode "https://github.com/cherry-embedded/cherryavp/blob/master/avcodec/src/aac_decode.c"
click node_flac_decode "https://github.com/cherry-embedded/cherryavp/blob/master/avcodec/src/flac_decode.c"
click node_g722_decode "https://github.com/cherry-embedded/cherryavp/blob/master/avcodec/src/g722_decode.c"
click node_other_decoders "https://github.com/cherry-embedded/cherryavp/tree/master/avcodec/src"
click node_audio_contract "https://github.com/cherry-embedded/cherryavp/blob/master/avcodec/inc/audio_codec_common.h"
click node_swr "https://github.com/cherry-embedded/cherryavp/blob/master/avswresample/src/avp_swr.c"
click node_afe_3a "https://github.com/cherry-embedded/cherryavp/blob/master/avfilter/src/avp_afe_3a.c"
click node_howling "https://github.com/cherry-embedded/cherryavp/blob/master/avfilter/src/avp_afe_howling.c"
click node_effects "https://github.com/cherry-embedded/cherryavp/tree/master/avfilter/src"
click node_mfcc "https://github.com/cherry-embedded/cherryavp/blob/master/avmfcc/src/avp_mfcc.c"
click node_io "https://github.com/cherry-embedded/cherryavp/blob/master/avutil/src/avp_io.c"
click node_packet "https://github.com/cherry-embedded/cherryavp/blob/master/avutil/src/avp_packet.c"
click node_bitreader "https://github.com/cherry-embedded/cherryavp/blob/master/avutil/inc/avp_bitreader.h"
click node_common "https://github.com/cherry-embedded/cherryavp/blob/master/avutil/inc/avp_common.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_stream_demux,node_wav_demux,node_m4a_demux,node_mp4_demux,node_avi_demux,node_ogg_demux,node_wav_mux toneBlue
class node_decoder_api,node_aac_decode,node_flac_decode,node_g722_decode,node_other_decoders,node_audio_contract toneAmber
class node_swr,node_afe_3a,node_howling,node_effects,node_mfcc toneMint
class node_io,node_packet,node_bitreader,node_common toneRose
class node_caller,node_hardware_video toneIndigo
```

## Components

### Containers and streams

- [Stream demux](https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/audio_stream_demux.c): `avformat/src/audio_stream_demux.c`
- [WAV demux](https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/wav_demux.c): `avformat/src/wav_demux.c`
- [M4A demux](https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/m4a_demux.c): `avformat/src/m4a_demux.c`
- [MP4 demux](https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/mp4_demux.c): `avformat/src/mp4_demux.c`
- [AVI demux](https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/avi_demux.c): `avformat/src/avi_demux.c`
- [OGG demux](https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/ogg_demux.c): `avformat/src/ogg_demux.c`
- [WAV mux](https://github.com/cherry-embedded/cherryavp/blob/master/avformat/src/wav_mux.c): `avformat/src/wav_mux.c`

### Audio codecs

- [Frame decoder API](https://github.com/cherry-embedded/cherryavp/blob/master/avcodec/src/audio_decode.c): `avcodec/src/audio_decode.c`
- [AAC decoder](https://github.com/cherry-embedded/cherryavp/blob/master/avcodec/src/aac_decode.c): `avcodec/src/aac_decode.c`
- [FLAC decoder](https://github.com/cherry-embedded/cherryavp/blob/master/avcodec/src/flac_decode.c): `avcodec/src/flac_decode.c`
- [G.722 decoder](https://github.com/cherry-embedded/cherryavp/blob/master/avcodec/src/g722_decode.c): `avcodec/src/g722_decode.c`
- [Other audio decoders](https://github.com/cherry-embedded/cherryavp/tree/master/avcodec/src): `avcodec/src`
- [Audio frame contract](https://github.com/cherry-embedded/cherryavp/blob/master/avcodec/inc/audio_codec_common.h): `avcodec/inc/audio_codec_common.h`

### Audio processing

- [Format conversion](https://github.com/cherry-embedded/cherryavp/blob/master/avswresample/src/avp_swr.c): `avswresample/src/avp_swr.c`
- [3A front end](https://github.com/cherry-embedded/cherryavp/blob/master/avfilter/src/avp_afe_3a.c): `avfilter/src/avp_afe_3a.c`
- [Howling suppression](https://github.com/cherry-embedded/cherryavp/blob/master/avfilter/src/avp_afe_howling.c): `avfilter/src/avp_afe_howling.c`
- [Audio effects](https://github.com/cherry-embedded/cherryavp/tree/master/avfilter/src): `avfilter/src`
- [MFCC extraction](https://github.com/cherry-embedded/cherryavp/blob/master/avmfcc/src/avp_mfcc.c): `avmfcc/src/avp_mfcc.c`

### Shared runtime

- [I/O abstraction](https://github.com/cherry-embedded/cherryavp/blob/master/avutil/src/avp_io.c): `avutil/src/avp_io.c`
- [Packet utilities](https://github.com/cherry-embedded/cherryavp/blob/master/avutil/src/avp_packet.c): `avutil/src/avp_packet.c`
- [Bit reader](https://github.com/cherry-embedded/cherryavp/blob/master/avutil/inc/avp_bitreader.h): `avutil/inc/avp_bitreader.h`
- [Shared utilities](https://github.com/cherry-embedded/cherryavp/blob/master/avutil/inc/avp_common.h): `avutil/inc/avp_common.h`

### Other components

- **Application**
- **Hardware video codecs**

## Connections

- Application → Stream demux: opens stream (evidence: `README.md`)
- Application → Frame decoder API: decodes frames (evidence: `README.md`)
- Stream demux → WAV demux: parses formats
- Stream demux → M4A demux: parses formats
- Stream demux → MP4 demux: parses formats
- Stream demux → AVI demux: parses formats
- Stream demux → OGG demux: parses formats
- Stream demux → Frame decoder API: provides configuration (evidence: `README.md`)
- Frame decoder API → Audio frame contract: uses frame contract
- Application → Format conversion: converts PCM (evidence: `README.md`)
- Application → 3A front end: processes audio (evidence: `README.md`)
- Application → Howling suppression: suppresses howling (evidence: `README.md`)
- Application → Audio effects: applies effects (evidence: `README.md`)
- Application → MFCC extraction: extracts features (evidence: `README.md`)
- Application → WAV mux: writes WAV (evidence: `README.md`)
- Application → Hardware video codecs: uses hardware codecs (evidence: `README.md`)
- MP4 demux → Bit reader: reads bits (evidence: `avformat/src/mp4_demux.c`)
- Audio frame contract → Packet utilities: references packet type (evidence: `avcodec/inc/audio_codec_common.h`)
