# videolan/x265 architecture

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

- Interactive diagram: https://gitdiagram.com/videolan/x265
- Repository: https://github.com/videolan/x265

## Overview

##### Project type and purpose
- This is x265, an open-source HEVC video encoder implemented in C/C++ with some inline assembly.
- It exposes a CLI (x265cli) and a library API for embedding into other applications.
- The project is focused on high-performance video encoding, with support for multiple architectures (x86, ARM, PPC, AArch64) and extensible features (dynamic HDR10, profiles, tuning).

##### File structure
- Top-level “source” directory holds all code, subdivided into functional modules:
- common: utilities, bitstream, framing, threading, platform abstractions, architecture-specific asm under common/{x86,arm,aarch64,ppc}
- input: parsers for YUV and Y4M input formats
- encoder: core encoding pipeline (analysis, motion estimation, rate control, entropy coding, in-loop filters, NAL generation)
- output: muxing/wrapping output into raw/YUV/Y4M/recon play bitstreams
- dynamicHDR10: optional HDR10+ metadata generation and injection
- profile: hooks for performance profiling (PPA, VTune)
- test: unit/regression harnesses for validating asm routines and encoding correctness
- Top-level also contains:
- x265cli.cpp/h: the command-line interface wrapping the library API
- abrEncApp: an example application for average-bitrate encoding
- CMakeLists.txt and cmake/ scripts for multi-platform builds and cross-compiling toolchains
- build/ folder with platform-specific makefiles and scripts (Linux, MSVC, Xcode, cross-compiles)
- doc/ for reST user/developer docs and intra-prediction reference tables

##### README for additional insights
- Confirms it is a GPL-licensed HEVC encoder with both CLI and library interfaces.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "CLI & Applications"
        cli["x265cli (CLI Front-End)"]:::cli
        abr["abrEncApp (Example ABR App)"]:::cli
    end

    subgraph "Library API & Modules"
        lib["Core Library API"]:::core
        inp["Input Module (YUV/Y4M)"]:::core
        enc["Encoder Core Pipeline"]:::core
        hdr["Dynamic HDR10 Module (optional)"]:::core
        out["Output Module"]:::core
        common["Common Utility Layer"]:::core
    end

    subgraph "Architecture-Specific Acceleration"
        x86["x86"]:::arch
        arm["ARM"]:::arch
        aarch["AArch64"]:::arch
        ppc["PPC"]:::arch
        vec["Vectorized Primitives"]:::arch
    end

    subgraph "Profiling & Build System"
        profile["Profiling Hooks"]:::profile
        build["Build System (CMake & Toolchains)"]:::profile
    end

    test["Test Harness"]:::cli

    cli -->|invokes| lib
    abr -->|invokes| lib
    lib -->|reads frames via| inp
    inp -->|passes raw frames to| enc
    enc -->|encodes frames through pipeline| hdr
    hdr -->|injects metadata into bitstream| out
    enc -->|uses utilities| common
    enc <-->|plugin selection| x86
    enc <-->|plugin selection| arm
    enc <-->|plugin selection| aarch
    enc <-->|plugin selection| ppc
    enc <-->|plugin selection| vec
    profile -->|instruments| lib
    profile -->|instruments| enc
    build -->|compiles| cli
    build -->|compiles| lib
    build -->|compiles| inp
    build -->|compiles| enc
    build -->|compiles| hdr
    build -->|compiles| out
    build -->|compiles| common
    build -->|compiles| x86
    build -->|compiles| arm
    build -->|compiles| aarch
    build -->|compiles| ppc
    build -->|compiles| vec
    build -->|compiles| profile
    test -->|validates| common
    test -->|validates| enc

    click cli "https://github.com/videolan/x265/blob/master/source/x265cli.cpp"
    click abr "https://github.com/videolan/x265/blob/master/source/abrEncApp.cpp"
    click lib "https://github.com/videolan/x265/blob/master/source/x265.cpp"
    click inp "https://github.com/videolan/x265/blob/master/source/input/input.cpp"
    click enc "https://github.com/videolan/x265/blob/master/source/encoder/encoder.cpp"
    click hdr "https://github.com/videolan/x265/blob/master/source/dynamicHDR10/api.cpp"
    click out "https://github.com/videolan/x265/blob/master/source/output/output.cpp"
    click common "https://github.com/videolan/x265/blob/master/source/common/bitstream.cpp"
    click x86 "https://github.com/videolan/x265/blob/master/source/common/x86/asm-primitives.cpp"
    click arm "https://github.com/videolan/x265/blob/master/source/common/arm/asm-primitives.cpp"
    click aarch "https://github.com/videolan/x265/blob/master/source/common/aarch64/asm-primitives.cpp"
    click ppc "https://github.com/videolan/x265/blob/master/source/common/ppc/dct_altivec.cpp"
    click vec "https://github.com/videolan/x265/blob/master/source/common/vec/vec-primitives.cpp"
    click profile "https://github.com/videolan/x265/blob/master/source/profile/PPA/ppa.cpp"
    click build "https://github.com/videolan/x265/blob/master/CMakeLists.txt"
    click test "https://github.com/videolan/x265/blob/master/source/test/testbench.cpp"

    classDef cli fill:#cce5ff,stroke:#3399ff
    classDef core fill:#d4edda,stroke:#28a745
    classDef arch fill:#fff3cd,stroke:#ffcc00
    classDef profile fill:#e2e3e5,stroke:#6c757d
```
