Skip to main content

Module tile_encoder

Module tile_encoder 

Source
Expand description

Tile-based parallel frame encoding for OxiMedia codecs.

This module provides pixel-level infrastructure for splitting raw video frames into rectangular tiles, processing them concurrently, and reassembling the result into a complete frame.

Unlike crate::tile which works with crate::frame::VideoFrame and codec-level bitstream output, this module operates on raw &[u8] / Vec<u8> pixel buffers and is therefore codec-agnostic.

§Architecture

TileConfig  ─── tile grid parameters (cols, rows, frame size)
    │
    ▼
TileLayout  ─── pre-computed TileRegion grid (handles remainder pixels)
    │
    ▼
ParallelTileEncoder ─── split_frame → parallel encode_fn → merge_tiles

§Example

use oximedia_codec::tile_encoder::{TileConfig, ParallelTileEncoder};

let config = TileConfig::new()
    .tile_cols(2)
    .tile_rows(2)
    .frame_width(64)
    .frame_height(64);

let encoder = ParallelTileEncoder::new(config);

// Create a simple 64×64 RGB frame (3 channels).
let frame: Vec<u8> = (0u8..=255).cycle().take(64 * 64 * 3).collect();

let tiles = encoder.split_frame(&frame, 3);
assert_eq!(tiles.len(), 4);

let merged = ParallelTileEncoder::merge_tiles(&tiles, 64, 64, 3);
assert_eq!(merged, frame);

Structs§

ParallelTileEncoder
Splits a raw pixel frame into tiles, processes them in parallel, and reassembles the result.
TileBitBudget
Bit budget allocation for a single tile.
TileBuffer
Raw pixel data extracted from (or destined for) a single tile.
TileComplexity
Content complexity metric for a tile region.
TileConfig
Configuration for the tile grid and frame dimensions.
TileDependency
A dependency edge from one tile to another.
TileDependencyGraph
Dependency graph for a tile layout.
TileLayout
A grid of TileRegions computed from a TileConfig.
TileQualityMetrics
Per-tile quality metrics.
TileRegion
Pixel coordinates and dimensions of a single tile within a frame.
TileWorkItem
A work item for the tile encode queue.

Enums§

TileDependencyKind
The type of dependency one tile has on another.

Functions§

adaptive_tile_partition
Decides whether a tile should be split into sub-tiles based on complexity.
allocate_tile_bits
Allocate a total bit budget across tiles based on complexity.
analyse_frame_quality
Compute quality metrics for all tiles by comparing original and reconstructed frames.
analyse_tile_complexity
Analyse content complexity for each tile in a frame.
compute_tile_quality
Compute quality metrics between original and reconstructed tile buffers.
encode_tiles_wavefront
Encodes tiles in dependency-aware waves using Rayon.