# kevmo314/codec-from-scratch architecture

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

- Interactive diagram: https://gitdiagram.com/kevmo314/codec-from-scratch
- Repository: https://github.com/kevmo314/codec-from-scratch

## Overview

Key Components to Include:

##### Input Processing Layer
- Raw RGB24 video input stream
- Stdin input mechanism

##### Encoding Pipeline
a. RGB24 to YUV420P Conversion
b. Run-Length Encoding (RLE)
c. DEFLATE Compression

##### Output Layer
- Compressed video output
- Performance metrics output

##### Component Representation
- Use rectangles for processing stages
- Use parallelograms for input/output data
- Data size reduction percentages at each stage

##### Specific Elements

**[Raw Video Input (RGB24)] → [RGB24 to YUV420P Converter]**
- ↓
- [RLE Compression]
- ↓
- [DEFLATE Compression]
- ↓
- [Compressed Output]

##### Additional Details
- Compression ratio annotations at each stage
- Memory footprint indicators
- Stdin/stdout flow

##### Technical Specifications
- Go runtime environment
- Single-threaded processing flow
- Buffer sizes and data formats

##### Performance Metrics
- YUV420P: 50% of original
- RLE: 25.17% of original
- DEFLATE: 10.11% of original

Key Considerations:
- Data transformation pipeline
- Compression achievements
- Sequential nature of the processing

- Data formats (RGB24, YUV420P)
- Compression algorithms (RLE, DEFLATE)
- Size reduction indicators
- I/O mechanisms

Remember to include a note about potential extensibility points where modern video codec features could be added, as mentioned in the README.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Define styles
    classDef input fill:#90EE90,stroke:#333,stroke-width:2px
    classDef process fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef output fill:#FFA500,stroke:#333,stroke-width:2px
    classDef data fill:#F0F0F0,stroke:#333,stroke-width:2px

    %% Input Layer
    input["Raw Video Input (RGB24)"]:::input
    click input "https://github.com/kevmo314/codec-from-scratch/blob/main/video.rgb24"

    %% Processing Layer
    conv["RGB24 to YUV420P Converter\n(50% size reduction)"]:::process
    rle["RLE Compression\n(25.17% size reduction)"]:::process
    deflate["DEFLATE Compression\n(10.11% size reduction)"]:::process
    click conv "https://github.com/kevmo314/codec-from-scratch/blob/main/main.go"
    click rle "https://github.com/kevmo314/codec-from-scratch/blob/main/main.go"
    click deflate "https://github.com/kevmo314/codec-from-scratch/blob/main/main.go"

    %% Output Layer
    output["Compressed Video Output"]:::output

    %% Data Flow
    input --> |"stdin"| conv
    conv --> |"YUV420P data"| rle
    rle --> |"RLE encoded"| deflate
    deflate --> |"stdout"| output

    %% Performance Metrics
    metrics["Performance Metrics\nSize Reduction: 89.89%"]:::data

    %% Connections to Metrics
    deflate -.-> metrics

    %% Legend
    subgraph Legend
        l1["Input Stage"]:::input
        l2["Processing Stage"]:::process
        l3["Output Stage"]:::output
        l4["Metrics"]:::data
    end
```
