# VB Demo

## Overview

This sample demonstrates the K230 VB (Video Buffer) module, which manages frame buffers and memory blocks for the media pipeline.

## Functional Description

### VB Functions

- VB initialization and configuration
- pool creation
- frame and block allocation and release
- supplement address queries
- VB statistics

### VB Pool Characteristics

- support for multiple pixel formats
- runtime allocation and release
- memory-pool reuse for performance
- reduced copy overhead in media pipelines
- DMA-friendly buffer handling

### Supported Pixel Formats

Typical VB use covers:

- RGB formats such as `RGB565`, `RGB888`, and `ARGB8888`
- YUV formats such as `YUV420`, `YUV422`, and `YUV444`
- compressed-buffer paths such as JPEG-related flows

### Main APIs

- `kd_mpi_vb_init()` / `kd_mpi_vb_deinit()`
- `kd_mpi_vb_set_config()`
- `kd_mpi_vb_create_pool()`
- `kd_mpi_vb_get_block()` / `kd_mpi_vb_release_block()`
- `kd_mpi_vb_get_supplement_addr()`

## Source Location

```bash
src/rtsmart/examples/mpp/sample_vb
```

## Usage

### Build Method

Enable the VB sample in `make menuconfig`, then rebuild the firmware.

### Run Example

```bash
./sample_vb
```

### Expected Result

The sample initializes the VB module, creates pools, allocates and releases frames or blocks, and prints statistics that can be used to validate the VB path.

### Usage Scenarios

VB is mainly used for:

- VI output buffers
- VDEC output buffers
- VENC input buffers
- VO input buffers
- AI inference input buffers

```{admonition} Tip
VB is a foundational multimedia subsystem module. Before using VI, VDEC, VENC, VO, and related modules, VB must be initialized first. For API details, refer to [MPP System Control API](../../api_reference/mpp/mpp_sys.md).
```
