# belabox/gstreamer-rockchip architecture

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

- Interactive diagram: https://gitdiagram.com/belabox/gstreamer-rockchip
- Repository: https://github.com/belabox/gstreamer-rockchip

## Overview

This repository is a GStreamer plugin collection for Rockchip hardware: it captures from KMS, decodes and encodes through Rockchip MPP, and renders video through an X11/KMS-backed sink. The main workflow is a GStreamer pipeline supplying encoded or raw video to MPP codec elements and consuming decoded or encoded frames; the sink and KMS source provide separate pipeline endpoints. The graph covers codec families and buffer/format support. Evidence is limited to the supplied excerpts and source index; unsampled implementation details are not asserted.

Main entry points: [`gst/rockchipmpp/gstmpp.c`](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmpp.c) (MPP plugin), [`gst/rkximage/ximagesink.c`](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rkximage/ximagesink.c) (X/KMS sink), [`gst/rockchipmpp/gstmppvideodec.c`](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppvideodec.c) (Video decoder), [`gst/rockchipmpp/gstmppenc.c`](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppenc.c) (Video encoder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture_display["Capture and display"]
  node_kms_source["KMS capture<br/>[gstkmssrc.c]"]
  node_video_sink["X/KMS sink<br/>[ximagesink.c]"]
end

subgraph group_mpp_codecs["MPP codecs"]
  node_mpp_plugin["MPP plugin<br/>[gstmpp.c]"]
  node_video_decode["Video decoder<br/>[gstmppvideodec.c]"]
  node_jpeg_decode["JPEG decoder<br/>[gstmppjpegdec.c]"]
  node_video_encode["Video encoder<br/>[gstmppenc.c]"]
  node_h264_encode["H.264 encoder<br/>[gstmpph264enc.c]"]
  node_h265_encode["H.265 encoder<br/>[gstmpph265enc.c]"]
  node_vp8_encode["VP8 encoder<br/>[gstmppvp8enc.c]"]
  node_jpeg_encode["JPEG encoder<br/>[gstmppjpegenc.c]"]
  node_alpha_decode["Alpha decode bin"]
  node_vpx_alpha_bin["VPx alpha bin"]
end

subgraph group_memory_formats["Memory and formats"]
  node_mpp_common["MPP formats and RGA<br/>[gstmpp.c]"]
  node_mpp_allocator["MPP allocator<br/>[gstmppallocator.c]"]
  node_kms_allocator["KMS allocator<br/>[gstkmsallocator.c]"]
  node_kms_pool["KMS buffer pool<br/>[gstkmsbufferpool.c]"]
  node_kms_utils["DRM video utilities<br/>[gstkmsutils.c]"]
end

node_pipeline(("GStreamer pipeline"))
node_rockchip_mpp["Rockchip MPP"]
node_display_stack["X11 and DRM/KMS"]

node_pipeline -->|"captures frames"| node_kms_source
node_pipeline -->|"renders frames"| node_video_sink
node_pipeline -->|"supplies encoded video"| node_video_decode
node_pipeline -->|"supplies raw video"| node_video_encode
node_mpp_plugin -->|"registers decoder"| node_video_decode
node_mpp_plugin -->|"registers decoder"| node_jpeg_decode
node_mpp_plugin -->|"registers encoder"| node_h264_encode
node_mpp_plugin -->|"registers encoder"| node_h265_encode
node_mpp_plugin -->|"registers encoder"| node_vp8_encode
node_mpp_plugin -->|"registers encoder"| node_jpeg_encode
node_mpp_plugin -->|"registers bin"| node_vpx_alpha_bin
node_vpx_alpha_bin -->|"uses base bin"| node_alpha_decode
node_video_decode -->|"uses buffers"| node_mpp_allocator
node_video_encode -->|"uses buffers"| node_mpp_allocator
node_video_decode -.->|"decodes with"| node_rockchip_mpp
node_video_encode -.->|"encodes with"| node_rockchip_mpp
node_mpp_common -->|"maps MPP formats"| node_rockchip_mpp
node_video_sink -->|"uses format helpers"| node_kms_utils
node_video_sink -->|"uses allocation"| node_kms_allocator
node_video_sink -->|"creates buffer pool"| node_kms_pool
node_kms_pool -->|"allocates memory"| node_kms_allocator
node_video_sink -->|"presents frames"| node_display_stack
node_kms_source -.->|"captures from KMS"| node_display_stack

click node_kms_source "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/kmssrc/gstkmssrc.c"
click node_video_sink "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rkximage/ximagesink.c"
click node_mpp_plugin "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmpp.c"
click node_video_decode "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppvideodec.c"
click node_jpeg_decode "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppjpegdec.c"
click node_video_encode "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppenc.c"
click node_h264_encode "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmpph264enc.c"
click node_h265_encode "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmpph265enc.c"
click node_vp8_encode "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppvp8enc.c"
click node_jpeg_encode "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppjpegenc.c"
click node_alpha_decode "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppalphadecodebin.c"
click node_vpx_alpha_bin "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppvpxalphadecodebin.c"
click node_mpp_common "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmpp.c"
click node_mpp_allocator "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppallocator.c"
click node_kms_allocator "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rkximage/gstkmsallocator.c"
click node_kms_pool "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rkximage/gstkmsbufferpool.c"
click node_kms_utils "https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rkximage/gstkmsutils.c"

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_kms_source,node_video_sink toneBlue
class node_mpp_plugin,node_video_decode,node_jpeg_decode,node_video_encode,node_h264_encode,node_h265_encode,node_vp8_encode,node_jpeg_encode,node_alpha_decode,node_vpx_alpha_bin toneAmber
class node_mpp_common,node_mpp_allocator,node_kms_allocator,node_kms_pool,node_kms_utils toneMint
class node_pipeline,node_rockchip_mpp,node_display_stack toneIndigo
```

## Components

### Capture and display

- [KMS capture](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/kmssrc/gstkmssrc.c): `gst/kmssrc/gstkmssrc.c`
- [X/KMS sink](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rkximage/ximagesink.c): `gst/rkximage/ximagesink.c`

### MPP codecs

- [MPP plugin](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmpp.c): `gst/rockchipmpp/gstmpp.c`
- [Video decoder](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppvideodec.c): `gst/rockchipmpp/gstmppvideodec.c`
- [JPEG decoder](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppjpegdec.c): `gst/rockchipmpp/gstmppjpegdec.c`
- [Video encoder](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppenc.c): `gst/rockchipmpp/gstmppenc.c`
- [H.264 encoder](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmpph264enc.c): `gst/rockchipmpp/gstmpph264enc.c`
- [H.265 encoder](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmpph265enc.c): `gst/rockchipmpp/gstmpph265enc.c`
- [VP8 encoder](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppvp8enc.c): `gst/rockchipmpp/gstmppvp8enc.c`
- [JPEG encoder](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppjpegenc.c): `gst/rockchipmpp/gstmppjpegenc.c`
- [Alpha decode bin](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppalphadecodebin.c): `gst/rockchipmpp/gstmppalphadecodebin.c`
- [VPx alpha bin](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppvpxalphadecodebin.c): `gst/rockchipmpp/gstmppvpxalphadecodebin.c`

### Memory and formats

- [MPP formats and RGA](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmpp.c): `gst/rockchipmpp/gstmpp.c`
- [MPP allocator](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rockchipmpp/gstmppallocator.c): `gst/rockchipmpp/gstmppallocator.c`
- [KMS allocator](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rkximage/gstkmsallocator.c): `gst/rkximage/gstkmsallocator.c`
- [KMS buffer pool](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rkximage/gstkmsbufferpool.c): `gst/rkximage/gstkmsbufferpool.c`
- [DRM video utilities](https://github.com/belabox/gstreamer-rockchip/blob/main/gst/rkximage/gstkmsutils.c): `gst/rkximage/gstkmsutils.c`

### Other components

- **GStreamer pipeline**
- **Rockchip MPP**
- **X11 and DRM/KMS**

## Connections

- GStreamer pipeline → KMS capture: captures frames (evidence: `gst/kmssrc/gstkmssrc.c`)
- GStreamer pipeline → X/KMS sink: renders frames (evidence: `gst/rkximage/ximagesink.c`)
- GStreamer pipeline → Video decoder: supplies encoded video
- GStreamer pipeline → Video encoder: supplies raw video (evidence: `gst/rockchipmpp/gstmppenc.c`)
- MPP plugin → Video decoder: registers decoder (evidence: `gst/rockchipmpp/gstmpp.c`)
- MPP plugin → JPEG decoder: registers decoder (evidence: `gst/rockchipmpp/gstmpp.c`)
- MPP plugin → H.264 encoder: registers encoder (evidence: `gst/rockchipmpp/gstmpp.c`)
- MPP plugin → H.265 encoder: registers encoder (evidence: `gst/rockchipmpp/gstmpp.c`)
- MPP plugin → VP8 encoder: registers encoder (evidence: `gst/rockchipmpp/gstmpp.c`)
- MPP plugin → JPEG encoder: registers encoder (evidence: `gst/rockchipmpp/gstmpp.c`)
- MPP plugin → VPx alpha bin: registers bin (evidence: `gst/rockchipmpp/gstmpp.c`)
- VPx alpha bin → Alpha decode bin: uses base bin (evidence: `gst/rockchipmpp/gstmppvpxalphadecodebin.c`)
- Video decoder → MPP allocator: uses buffers
- Video encoder → MPP allocator: uses buffers (evidence: `gst/rockchipmpp/gstmppenc.c`)
- Video decoder → Rockchip MPP: decodes with
- Video encoder → Rockchip MPP: encodes with
- MPP formats and RGA → Rockchip MPP: maps MPP formats (evidence: `gst/rockchipmpp/gstmpp.c`)
- X/KMS sink → DRM video utilities: uses format helpers (evidence: `gst/rkximage/ximagesink.c`)
- X/KMS sink → KMS allocator: uses allocation (evidence: `gst/rkximage/ximagesink.c`)
- X/KMS sink → KMS buffer pool: creates buffer pool (evidence: `gst/rkximage/ximagesink.c`)
- KMS buffer pool → KMS allocator: allocates memory (evidence: `gst/rkximage/gstkmsbufferpool.c`)
- X/KMS sink → X11 and DRM/KMS: presents frames (evidence: `gst/rkximage/ximagesink.c`)
- KMS capture → X11 and DRM/KMS: captures from KMS
