# babitmf/bmf architecture

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

- Interactive diagram: https://gitdiagram.com/babitmf/bmf
- Repository: https://github.com/babitmf/bmf

## Overview

BMF is a cross-platform multimedia framework for building and running configurable media-processing graphs; BMFLite is its lightweight, client-side counterpart. The principal workflow is to define a graph through an API, configure modules and streams, schedule packet processing, and collect output. The repository also includes media codecs, GPU/data-conversion capabilities, and mobile algorithms and demos. Relationships below follow shown bindings, source references, or README statements; several runtime and mobile subsystems are represented at directory level because their implementation was not sampled.

Main entry points: [`bmf/python/py_engine.cpp`](https://github.com/babitmf/bmf/blob/master/bmf/python/py_engine.cpp) (Python Graph API), [`bmf/engine/c_engine/src/node.cpp`](https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/node.cpp) (Processing Node), [`bmf/engine/c_engine/src/graph.cpp`](https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/graph.cpp) (Graph Runtime), [`bmf/engine/c_engine/src/input_stream_manager.cpp`](https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/input_stream_manager.cpp) (Input Scheduling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Graph APIs"]
  node_python_api["Python Graph API<br/>[py_engine.cpp]"]
  node_connector["Engine Connector<br/>[connector.cpp]"]
end

subgraph group_runtime["Graph Runtime"]
  node_graph_config["Graph Configuration<br/>[graph_config.cpp]"]
  node_graph_runtime["Graph Runtime<br/>[graph.cpp]"]
  node_module_factory["Module Factory<br/>[module_factory.cpp]"]
  node_node["Processing Node<br/>[node.cpp]"]
  node_input_manager["Input Scheduling"]
  node_output_manager["Output Streams"]
  node_scheduler["Task Scheduler<br/>[scheduler.cpp]"]
end

subgraph group_media["Media Processing"]
  node_module_sdk["Module SDK<br/>[module_manager.cpp]"]
  node_ffmpeg_modules["FFmpeg Modules<br/>[ffmpeg_decoder.cpp]"]
  node_hmp["Heterogeneous Media<br/>[hmp_capi.cpp]"]
  node_gpu_filters["GPU Filters<br/>[rotate_gpu.py]"]
end

subgraph group_lite["BMFLite Clients"]
  node_lite_api["BMFLite Algorithms"]
  node_qnn_pipeline["QNN ControlNet"]
  node_lite_video_buffers[("Video Buffers")]
  node_ios_loader["Model Loader"]
  node_ios_pipeline["Diffusion Pipeline<br/>[Pipeline.swift]"]
  node_android_image["Image Playback"]
  node_android_render["Surface Renderer"]
  node_ohos_camera["Camera Capture<br/>[camera_manager.cpp]"]
end

node_developer(("Developer"))

node_developer -->|"defines graph"| node_python_api
node_python_api -->|"binds to"| node_connector
node_python_api -->|"accepts config"| node_graph_config
node_python_api -.->|"starts graph"| node_graph_runtime
node_graph_runtime -.->|"uses config"| node_graph_config
node_graph_runtime -.->|"creates modules"| node_module_factory
node_node -->|"uses inputs"| node_input_manager
node_input_manager -->|"schedules task"| node_node
node_node -.->|"publishes outputs"| node_output_manager
node_scheduler -.->|"dispatches work"| node_node
node_module_sdk -->|"enables custom modules"| node_developer
node_developer -->|"configures transcode"| node_ffmpeg_modules
node_developer -->|"configures filters"| node_gpu_filters
node_developer -->|"uses conversions"| node_hmp
node_developer -->|"uses client framework"| node_lite_api
node_qnn_pipeline -.->|"processes frames"| node_lite_video_buffers
node_ios_loader -->|"loads pipeline"| node_ios_pipeline
node_android_image -->|"renders through"| node_android_render
node_developer -.->|"captures media"| node_ohos_camera

click node_python_api "https://github.com/babitmf/bmf/blob/master/bmf/python/py_engine.cpp"
click node_connector "https://github.com/babitmf/bmf/blob/master/bmf/engine/connector/src/connector.cpp"
click node_graph_config "https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/graph_config.cpp"
click node_graph_runtime "https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/graph.cpp"
click node_module_factory "https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/module_factory.cpp"
click node_node "https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/node.cpp"
click node_input_manager "https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/input_stream_manager.cpp"
click node_output_manager "https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/output_stream_manager.cpp"
click node_scheduler "https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/scheduler.cpp"
click node_module_sdk "https://github.com/babitmf/bmf/blob/master/bmf/sdk/cpp_sdk/src/module_manager.cpp"
click node_ffmpeg_modules "https://github.com/babitmf/bmf/blob/master/bmf/c_modules/src/ffmpeg_decoder.cpp"
click node_hmp "https://github.com/babitmf/bmf/blob/master/bmf/hmp/src/hmp_capi.cpp"
click node_gpu_filters "https://github.com/babitmf/bmf/blob/master/bmf/python_modules/rotate_gpu/rotate_gpu.py"
click node_lite_api "https://github.com/babitmf/bmf/blob/master/bmf_lite/src/algorithm/bmf_algorithm_impl.cpp"
click node_qnn_pipeline "https://github.com/babitmf/bmf/blob/master/bmf_lite/src/algorithm/contrib_modules/QnnControlNet/QnnControlNetPipeLine.cpp"
click node_lite_video_buffers "https://github.com/babitmf/bmf/blob/master/bmf_lite/src/media/video_buffer/hardware_device_context.cpp"
click node_ios_loader "https://github.com/babitmf/bmf/blob/master/bmf_lite/iOS/bmf_demo/bmf_demo/contrib_module/ml_stable_diffusion/common/pipeline/PipelineLoader.swift"
click node_ios_pipeline "https://github.com/babitmf/bmf/blob/master/bmf_lite/iOS/bmf_demo/bmf_demo/contrib_module/ml_stable_diffusion/common/pipeline/Pipeline.swift"
click node_android_image "https://github.com/babitmf/bmf/blob/master/bmf_lite/android/app/src/main/java/com/bmf/lite/app/playctrl/ImagePlayerWrapper.java"
click node_android_render "https://github.com/babitmf/bmf/blob/master/bmf_lite/android/app/src/main/java/com/bmf/lite/app/render/GLSurfaceViewWrapper.java"
click node_ohos_camera "https://github.com/babitmf/bmf/blob/master/bmf_lite/ohos/entry/src/main/cpp/camera/camera_manager.cpp"

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_python_api,node_connector toneBlue
class node_graph_config,node_graph_runtime,node_module_factory,node_node,node_input_manager,node_output_manager,node_scheduler toneAmber
class node_module_sdk,node_ffmpeg_modules,node_hmp,node_gpu_filters toneMint
class node_lite_api,node_qnn_pipeline,node_lite_video_buffers,node_ios_loader,node_ios_pipeline,node_android_image,node_android_render,node_ohos_camera toneRose
class node_developer toneIndigo
```

## Components

### Graph APIs

- [Python Graph API](https://github.com/babitmf/bmf/blob/master/bmf/python/py_engine.cpp): `bmf/python/py_engine.cpp`
- [Engine Connector](https://github.com/babitmf/bmf/blob/master/bmf/engine/connector/src/connector.cpp): `bmf/engine/connector/src/connector.cpp`

### Graph Runtime

- [Graph Configuration](https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/graph_config.cpp): `bmf/engine/c_engine/src/graph_config.cpp`
- [Graph Runtime](https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/graph.cpp): `bmf/engine/c_engine/src/graph.cpp`
- [Module Factory](https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/module_factory.cpp): `bmf/engine/c_engine/src/module_factory.cpp`
- [Processing Node](https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/node.cpp): `bmf/engine/c_engine/src/node.cpp`
- [Input Scheduling](https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/input_stream_manager.cpp): `bmf/engine/c_engine/src/input_stream_manager.cpp`
- [Output Streams](https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/output_stream_manager.cpp): `bmf/engine/c_engine/src/output_stream_manager.cpp`
- [Task Scheduler](https://github.com/babitmf/bmf/blob/master/bmf/engine/c_engine/src/scheduler.cpp): `bmf/engine/c_engine/src/scheduler.cpp`

### Media Processing

- [Module SDK](https://github.com/babitmf/bmf/blob/master/bmf/sdk/cpp_sdk/src/module_manager.cpp): `bmf/sdk/cpp_sdk/src/module_manager.cpp`
- [FFmpeg Modules](https://github.com/babitmf/bmf/blob/master/bmf/c_modules/src/ffmpeg_decoder.cpp): `bmf/c_modules/src/ffmpeg_decoder.cpp`
- [Heterogeneous Media](https://github.com/babitmf/bmf/blob/master/bmf/hmp/src/hmp_capi.cpp): `bmf/hmp/src/hmp_capi.cpp`
- [GPU Filters](https://github.com/babitmf/bmf/blob/master/bmf/python_modules/rotate_gpu/rotate_gpu.py): `bmf/python_modules/rotate_gpu/rotate_gpu.py`

### BMFLite Clients

- [BMFLite Algorithms](https://github.com/babitmf/bmf/blob/master/bmf_lite/src/algorithm/bmf_algorithm_impl.cpp): `bmf_lite/src/algorithm/bmf_algorithm_impl.cpp`
- [QNN ControlNet](https://github.com/babitmf/bmf/blob/master/bmf_lite/src/algorithm/contrib_modules/QnnControlNet/QnnControlNetPipeLine.cpp): `bmf_lite/src/algorithm/contrib_modules/QnnControlNet/QnnControlNetPipeLine.cpp`
- [Video Buffers](https://github.com/babitmf/bmf/blob/master/bmf_lite/src/media/video_buffer/hardware_device_context.cpp): `bmf_lite/src/media/video_buffer/hardware_device_context.cpp`
- [Model Loader](https://github.com/babitmf/bmf/blob/master/bmf_lite/iOS/bmf_demo/bmf_demo/contrib_module/ml_stable_diffusion/common/pipeline/PipelineLoader.swift): `bmf_lite/iOS/bmf_demo/bmf_demo/contrib_module/ml_stable_diffusion/common/pipeline/PipelineLoader.swift`
- [Diffusion Pipeline](https://github.com/babitmf/bmf/blob/master/bmf_lite/iOS/bmf_demo/bmf_demo/contrib_module/ml_stable_diffusion/common/pipeline/Pipeline.swift): `bmf_lite/iOS/bmf_demo/bmf_demo/contrib_module/ml_stable_diffusion/common/pipeline/Pipeline.swift`
- [Image Playback](https://github.com/babitmf/bmf/blob/master/bmf_lite/android/app/src/main/java/com/bmf/lite/app/playctrl/ImagePlayerWrapper.java): `bmf_lite/android/app/src/main/java/com/bmf/lite/app/playctrl/ImagePlayerWrapper.java`
- [Surface Renderer](https://github.com/babitmf/bmf/blob/master/bmf_lite/android/app/src/main/java/com/bmf/lite/app/render/GLSurfaceViewWrapper.java): `bmf_lite/android/app/src/main/java/com/bmf/lite/app/render/GLSurfaceViewWrapper.java`
- [Camera Capture](https://github.com/babitmf/bmf/blob/master/bmf_lite/ohos/entry/src/main/cpp/camera/camera_manager.cpp): `bmf_lite/ohos/entry/src/main/cpp/camera/camera_manager.cpp`

### Other components

- **Developer**

## Connections

- Developer → Python Graph API: defines graph (evidence: `README.md`)
- Python Graph API → Engine Connector: binds to (evidence: `bmf/python/py_engine.cpp`)
- Python Graph API → Graph Configuration: accepts config (evidence: `bmf/python/py_engine.cpp`)
- Python Graph API → Graph Runtime: starts graph
- Graph Runtime → Graph Configuration: uses config
- Graph Runtime → Module Factory: creates modules
- Processing Node → Input Scheduling: uses inputs
- Input Scheduling → Processing Node: schedules task (evidence: `bmf/engine/c_engine/src/input_stream_manager.cpp`)
- Processing Node → Output Streams: publishes outputs
- Task Scheduler → Processing Node: dispatches work
- Module SDK → Developer: enables custom modules (evidence: `README.md`)
- Developer → FFmpeg Modules: configures transcode (evidence: `README.md`)
- Developer → GPU Filters: configures filters (evidence: `README.md`)
- Developer → Heterogeneous Media: uses conversions (evidence: `README.md`)
- Developer → BMFLite Algorithms: uses client framework (evidence: `README.md`)
- QNN ControlNet → Video Buffers: processes frames
- Model Loader → Diffusion Pipeline: loads pipeline (evidence: `bmf_lite/iOS/bmf_demo/bmf_demo/contrib_module/ml_stable_diffusion/common/pipeline/PipelineLoader.swift`)
- Image Playback → Surface Renderer: renders through (evidence: `bmf_lite/android/app/src/main/java/com/bmf/lite/app/playctrl/ImagePlayerWrapper.java`)
- Developer → Camera Capture: captures media
