This directory contains comprehensive architecture documentation and diagrams for the OpenIMP library.
- ARCHITECTURE.md: Complete architecture documentation with ASCII diagrams
- Data flow from hardware to user application
- Module architecture and responsibilities
- Threading model and synchronization
- Memory management with DMA
- Module binding via observer pattern
- Build system and testing
All .mmd files are Mermaid diagrams that can be rendered in various tools:
-
data-flow.mmd: End-to-end data flow diagram
- Shows complete pipeline from kernel driver to user application
- Includes all intermediate steps and data structures
- Color-coded by component type
-
module-architecture.mmd: Module relationship diagram
- Shows all 11 modules and their dependencies
- Distinguishes between core modules, infrastructure, and stubs
- Illustrates module registration and binding
-
threading-model.mmd: Threading and synchronization diagram
- Shows all thread types (frame capture, encoder, stream)
- Illustrates synchronization primitives (mutex, semaphore, condvar, eventfd)
- Thread lifecycle and creation/cancellation
-
memory-management.mmd: DMA allocation and buffer management
- Shows complete flow from IMP_Alloc to VBM frame buffers
- Kernel driver integration with ioctl and mmap
- Fallback mechanism for non-DMA systems
-
Mermaid Live Editor: https://mermaid.live/
- Copy/paste the
.mmdfile content - Interactive editing and rendering
- Export to PNG/SVG
- Copy/paste the
-
GitHub:
- GitHub automatically renders
.mmdfiles in markdown - View directly in the repository
- GitHub automatically renders
Install the "Mermaid Preview" extension:
code --install-extension bierner.markdown-mermaidThen open any .mmd file and use the preview pane.
Install mermaid-cli:
npm install -g @mermaid-js/mermaid-cliRender to PNG:
mmdc -i data-flow.mmd -o data-flow.pngRender to SVG:
mmdc -i data-flow.mmd -o data-flow.svg- Hardware Layer: Ingenic ISP and kernel drivers
- Kernel Interface: ioctl wrappers for /dev/framechan%d
- DMA Allocator: Physical memory allocation via /dev/mem
- VBM: Video buffer manager with frame pools
- FrameSource: Frame capture with polling thread
- Encoder: H.264/H.265 encoding with dual threads
- Codec: Parameter management and FIFO queuing
- System: Module registry and observer pattern
- Fifo: Thread-safe queue implementation
Hardware → Kernel Driver → Frame Capture Thread → VBM Pool
→ Observer Pattern → Encoder Thread → Codec Frame FIFO
→ Stream Thread → Codec Stream FIFO → User Application
- Frame Capture Threads: 1 per FrameSource channel (max 5)
- Encoder Threads: 1 per Encoder channel (max 9)
- Stream Threads: 1 per Encoder channel (max 9)
- Total: Up to 23 threads (5 + 9 + 9)
- DMA Buffers: Allocated via kernel driver with mmap
- VBM Pools: 0x180 + (bufcount * 0x428) bytes per pool
- VBM Frames: 0x428 bytes per frame
- Codec: 0x924 bytes per codec instance
- Channels: 0x2e8 bytes (FS) or 0x308 bytes (Encoder)
- Total Lines: 4,434 lines of C code
- Library Size: 125KB (static), 88KB (shared)
- Modules: 11 modules (8 core + 3 infrastructure)
- Functions: 105+ functions implemented
- Build Status: ✅ Compiles cleanly
- Hardware Encoder Integration: Connect to actual Ingenic hardware codec
- Complete Stream Handling: Full IMPEncoderStream structure
- Observer Management: Complete observer lifecycle
- Testing: Integration with prudynt-t on real hardware
- Performance: Optimize latency and throughput
- Binary: libimp.so v1.1.6 for T31 platform
- Decompiler: Binary Ninja MCP
- Target Application: prudynt-t (open-source camera streaming)
- Hardware: Ingenic T31/T40/T41 SoCs
This is a reverse-engineered implementation for educational and interoperability purposes.