# rockchip-linux/mpp architecture

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

- Interactive diagram: https://gitdiagram.com/rockchip-linux/mpp
- Repository: https://github.com/rockchip-linux/mpp

## Overview

Rockchip MPP is a media-processing framework exposing an MPI API for hardware-assisted video decoding, encoding, and video processing. The principal workflow is an application submitting packets or frames through MPI, MPP dispatching to a codec path, codec parsing or preparation feeding the hardware abstraction layer, and the device service communicating with codec hardware; results are exposed through MPP buffers, frames, and packets. The README documents broad codec and platform support. Internal wiring beyond the documented framework is represented conservatively because the sampled implementation excerpts cover only selected parsers and OSAL service code.

Main entry points: [`mpp/hal/mpp_hal.c`](https://github.com/rockchip-linux/mpp/blob/develop/mpp/hal/mpp_hal.c) (Hardware Abstraction), [`mpp/mpp.c`](https://github.com/rockchip-linux/mpp/blob/develop/mpp/mpp.c) (MPP Context), [`mpp/mpi.c`](https://github.com/rockchip-linux/mpp/blob/develop/mpp/mpi.c) (MPI Interface), [`mpp/codec/mpp_enc_impl.c`](https://github.com/rockchip-linux/mpp/blob/develop/mpp/codec/mpp_enc_impl.c) (Encoder Engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_mpi["MPI Interface<br/>[mpi.c]"]
  node_mppctx["MPP Context<br/>[mpp.c]"]
end

subgraph group_codec["Codec Processing"]
  node_decoder["Decoder Engine<br/>[mpp_dec.c]"]
  node_decoders["Codec Decoders"]
  node_encoder["Encoder Engine<br/>[mpp_enc_impl.c]"]
  node_encoders["Codec Encoders"]
  node_ratecontrol["Rate Control"]
  node_vproc["Video Processing"]
end

subgraph group_hardware["Hardware Access"]
  node_hal["Hardware Abstraction<br/>[mpp_hal.c]"]
  node_dec_hal["Decoder HALs"]
  node_enc_hal["Encoder HALs"]
  node_vpu_hal["VPU HALs"]
  node_device["Device Layer<br/>[mpp_device.c]"]
  node_mpp_service["MPP Service<br/>[mpp_service.c]"]
  node_vcodec_service["Vcodec Service<br/>[vcodec_service.c]"]
end

subgraph group_runtime["Shared Runtime"]
  node_buffers["Media Objects"]
  node_allocator["Memory Allocators"]
end

node_application(("Media Client"))
node_kernel_device["Kernel Codec Device"]

node_application -->|"submits media"| node_mpi
node_mpi -->|"creates and controls"| node_mppctx
node_mppctx -->|"dispatches decode"| node_decoder
node_mppctx -->|"dispatches encode"| node_encoder
node_mppctx -->|"dispatches processing"| node_vproc
node_decoder -->|"selects codec parser"| node_decoders
node_decoders -->|"provides syntax"| node_hal
node_encoder -->|"selects codec"| node_encoders
node_encoder -->|"configures rate"| node_ratecontrol
node_encoders -->|"prepares encode"| node_hal
node_hal -->|"dispatches decode"| node_dec_hal
node_hal -->|"dispatches encode"| node_enc_hal
node_hal -->|"dispatches VPU work"| node_vpu_hal
node_hal -->|"submits device work"| node_device
node_device -->|"uses service ioctl"| node_mpp_service
node_device -->|"uses VPU ioctl"| node_vcodec_service
node_mpp_service -->|"sends ioctl requests"| node_kernel_device
node_vcodec_service -->|"sends register ioctls"| node_kernel_device
node_mpi -->|"exchanges media objects"| node_buffers
node_buffers -->|"allocates storage"| node_allocator
node_hal -->|"uses frame buffers"| node_buffers

click node_mpi "https://github.com/rockchip-linux/mpp/blob/develop/mpp/mpi.c"
click node_mppctx "https://github.com/rockchip-linux/mpp/blob/develop/mpp/mpp.c"
click node_buffers "https://github.com/rockchip-linux/mpp/tree/develop/mpp/base"
click node_decoder "https://github.com/rockchip-linux/mpp/blob/develop/mpp/codec/mpp_dec.c"
click node_decoders "https://github.com/rockchip-linux/mpp/tree/develop/mpp/codec/dec"
click node_encoder "https://github.com/rockchip-linux/mpp/blob/develop/mpp/codec/mpp_enc_impl.c"
click node_encoders "https://github.com/rockchip-linux/mpp/tree/develop/mpp/codec/enc"
click node_ratecontrol "https://github.com/rockchip-linux/mpp/tree/develop/mpp/codec/rc"
click node_hal "https://github.com/rockchip-linux/mpp/blob/develop/mpp/hal/mpp_hal.c"
click node_dec_hal "https://github.com/rockchip-linux/mpp/tree/develop/mpp/hal/rkdec"
click node_enc_hal "https://github.com/rockchip-linux/mpp/tree/develop/mpp/hal/rkenc"
click node_vpu_hal "https://github.com/rockchip-linux/mpp/tree/develop/mpp/hal/vpu"
click node_device "https://github.com/rockchip-linux/mpp/blob/develop/osal/driver/mpp_device.c"
click node_mpp_service "https://github.com/rockchip-linux/mpp/blob/develop/osal/driver/mpp_service.c"
click node_vcodec_service "https://github.com/rockchip-linux/mpp/blob/develop/osal/driver/vcodec_service.c"
click node_allocator "https://github.com/rockchip-linux/mpp/tree/develop/osal/allocator"
click node_vproc "https://github.com/rockchip-linux/mpp/tree/develop/mpp/vproc"

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_mpi,node_mppctx,node_application toneBlue
class node_decoder,node_decoders,node_encoder,node_encoders,node_ratecontrol,node_vproc toneAmber
class node_hal,node_dec_hal,node_enc_hal,node_vpu_hal,node_device,node_mpp_service,node_vcodec_service toneMint
class node_buffers,node_allocator toneRose
class node_kernel_device toneIndigo
```

## Components

### Public API

- [MPI Interface](https://github.com/rockchip-linux/mpp/blob/develop/mpp/mpi.c): `mpp/mpi.c`
- [MPP Context](https://github.com/rockchip-linux/mpp/blob/develop/mpp/mpp.c): `mpp/mpp.c`

### Codec Processing

- [Decoder Engine](https://github.com/rockchip-linux/mpp/blob/develop/mpp/codec/mpp_dec.c): `mpp/codec/mpp_dec.c`
- [Codec Decoders](https://github.com/rockchip-linux/mpp/tree/develop/mpp/codec/dec): `mpp/codec/dec`
- [Encoder Engine](https://github.com/rockchip-linux/mpp/blob/develop/mpp/codec/mpp_enc_impl.c): `mpp/codec/mpp_enc_impl.c`
- [Codec Encoders](https://github.com/rockchip-linux/mpp/tree/develop/mpp/codec/enc): `mpp/codec/enc`
- [Rate Control](https://github.com/rockchip-linux/mpp/tree/develop/mpp/codec/rc): `mpp/codec/rc`
- [Video Processing](https://github.com/rockchip-linux/mpp/tree/develop/mpp/vproc): `mpp/vproc`

### Hardware Access

- [Hardware Abstraction](https://github.com/rockchip-linux/mpp/blob/develop/mpp/hal/mpp_hal.c): `mpp/hal/mpp_hal.c`
- [Decoder HALs](https://github.com/rockchip-linux/mpp/tree/develop/mpp/hal/rkdec): `mpp/hal/rkdec`
- [Encoder HALs](https://github.com/rockchip-linux/mpp/tree/develop/mpp/hal/rkenc): `mpp/hal/rkenc`
- [VPU HALs](https://github.com/rockchip-linux/mpp/tree/develop/mpp/hal/vpu): `mpp/hal/vpu`
- [Device Layer](https://github.com/rockchip-linux/mpp/blob/develop/osal/driver/mpp_device.c): `osal/driver/mpp_device.c`
- [MPP Service](https://github.com/rockchip-linux/mpp/blob/develop/osal/driver/mpp_service.c): `osal/driver/mpp_service.c`
- [Vcodec Service](https://github.com/rockchip-linux/mpp/blob/develop/osal/driver/vcodec_service.c): `osal/driver/vcodec_service.c`

### Shared Runtime

- [Media Objects](https://github.com/rockchip-linux/mpp/tree/develop/mpp/base): `mpp/base`
- [Memory Allocators](https://github.com/rockchip-linux/mpp/tree/develop/osal/allocator): `osal/allocator`

### Other components

- **Media Client**
- **Kernel Codec Device**

## Connections

- Media Client → MPI Interface: submits media
- MPI Interface → MPP Context: creates and controls
- MPP Context → Decoder Engine: dispatches decode
- MPP Context → Encoder Engine: dispatches encode
- MPP Context → Video Processing: dispatches processing
- Decoder Engine → Codec Decoders: selects codec parser
- Codec Decoders → Hardware Abstraction: provides syntax
- Encoder Engine → Codec Encoders: selects codec
- Encoder Engine → Rate Control: configures rate
- Codec Encoders → Hardware Abstraction: prepares encode
- Hardware Abstraction → Decoder HALs: dispatches decode
- Hardware Abstraction → Encoder HALs: dispatches encode
- Hardware Abstraction → VPU HALs: dispatches VPU work
- Hardware Abstraction → Device Layer: submits device work
- Device Layer → MPP Service: uses service ioctl
- Device Layer → Vcodec Service: uses VPU ioctl
- MPP Service → Kernel Codec Device: sends ioctl requests
- Vcodec Service → Kernel Codec Device: sends register ioctls
- MPI Interface → Media Objects: exchanges media objects
- Media Objects → Memory Allocators: allocates storage
- Hardware Abstraction → Media Objects: uses frame buffers
