Overview

FreeWorld OS includes comprehensive hardware-accelerated video decoding and encoding support through GPU video acceleration engines. This system provides efficient video processing for H.264, H.265/HEVC, VP8, VP9, AV1, MPEG-2, and VC-1 codecs using Intel Quick Sync Video, AMD VCE/UVD, and NVIDIA NVENC/NVDEC.

Note: Video acceleration operates at the kernel level, providing direct access to GPU video engines for maximum performance.

Supported Codecs

  • H.264/AVC - Decode and encode
  • H.265/HEVC - Decode and encode
  • VP8 - Decode
  • VP9 - Decode and encode
  • AV1 - Decode and encode (NVIDIA only, depends on GPU generation)
  • MPEG-2 - Decode
  • VC-1 - Decode

Hardware Support

Intel Quick Sync Video

  • Supported GPUs: Haswell+ (HD Graphics, Iris)
  • H.264: Decode and encode (Haswell+)
  • H.265: Decode and encode (Skylake+)
  • VP8: Decode
  • VP9: Decode and encode (Kaby Lake+)
  • MPEG-2: Decode
  • VC-1: Decode

AMD VCE/UVD

  • Supported GPUs: GCN, RDNA architectures
  • H.264: Decode (UVD) and encode (VCE)
  • H.265: Decode (UVD) and encode (VCE)
  • VP9: Decode (UVD)
  • MPEG-2: Decode (UVD)
  • VC-1: Decode (UVD)

NVIDIA NVENC/NVDEC

  • Supported GPUs: Kepler+ (NVENC), Maxwell+ (NVDEC)
  • H.264: Decode (NVDEC) and encode (NVENC)
  • H.265: Decode (NVDEC) and encode (NVENC)
  • VP8: Decode (NVDEC)
  • VP9: Decode (NVDEC)
  • AV1: Decode (NVDEC, Turing+) and encode (NVENC, Ada+)
  • MPEG-2: Decode (NVDEC)
  • VC-1: Decode (NVDEC)

API Functions

Initialization and Device Management

; Initialize video acceleration subsystem
video_accel_init() -> status

; Detect video acceleration devices
video_accel_detect_devices() -> device_count

; Create video acceleration device
video_accel_create_device(GPU_pointer, device_type) -> device_pointer

; Destroy video acceleration device
video_accel_destroy_device(device_pointer) -> status

; Query device capabilities
video_accel_query_capabilities(device_pointer, capability_buffer) -> status

Stream Management

; Create video stream
video_accel_create_stream(device_pointer, codec_type, operation, width, height, format, ...) -> stream_pointer

; Destroy video stream
video_accel_destroy_stream(stream_pointer) -> status

; Submit buffer to stream
video_accel_submit_buffer(stream_pointer, buffer_pointer, buffer_type) -> status

; Get completed buffer from stream
video_accel_get_buffer(stream_pointer, buffer_type) -> buffer_pointer

Video Processing

; Decode video frame
video_accel_decode_frame(stream_pointer, input_buffer, output_buffer) -> status

; Encode video frame
video_accel_encode_frame(stream_pointer, input_buffer, output_buffer) -> status

; Get supported format
video_accel_get_format(device_pointer, codec_type, format_buffer) -> status

; Set format for stream
video_accel_set_format(stream_pointer, format_buffer) -> status

Usage Example

; Initialize video acceleration
call video_accel_init

; Detect devices
call video_accel_detect_devices

; Create device (assuming Intel GPU)
mov rdi, intel_gpu_pointer
mov rsi, 0  ; Intel device type
call video_accel_create_device
mov [video_device], rax

; Create H.264 decode stream
mov rdi, [video_device]
mov rsi, CODEC_H264
mov rdx, OP_DECODE
mov rcx, 1920  ; Width
mov r8, 1080   ; Height
mov r9, FORMAT_NV12
push 30  ; Frame rate numerator
push 1   ; Frame rate denominator
push 0   ; Bitrate (not used for decode)
push 0   ; GOP size (not used for decode)
call video_accel_create_stream
mov [video_stream], rax

; Decode frame
mov rdi, [video_stream]
mov rsi, compressed_buffer
mov rdx, decoded_buffer
call video_accel_decode_frame

Data Structures

Video Device Structure (512 bytes)

  • Magic number and version
  • Device type (Intel, AMD, NVIDIA)
  • GPU pointer
  • Supported codecs (bitmask)
  • Maximum streams, width, height
  • Status flags

Video Stream Structure (1024 bytes)

  • Magic number and version
  • Stream ID and device ID
  • Codec type and operation (decode/encode)
  • Width, height, format
  • Frame rate, bitrate, GOP size
  • Buffer queues (input, output, reference)
  • Status flags

Integration

Video acceleration integrates with:

  • GPU Drivers - Uses Intel, AMD, NVIDIA GPU drivers
  • Memory Management - Allocates buffers for video data
  • Interrupt Handling - Handles video engine interrupts
  • User Space - Provides API for applications

Build System

Video acceleration components are built using the Makefile in kernel/video/:

cd kernel/video
make

This produces object files that are linked into the kernel:

  • video_accel_core.o - Core video acceleration framework
  • video_accel_intel.o - Intel Quick Sync Video support
  • video_accel_amd.o - AMD VCE/UVD support
  • video_accel_nvidia.o - NVIDIA NVENC/NVDEC support

Limits and Constraints

  • Maximum Video Devices: 16
  • Maximum Streams per Device: 32
  • Maximum Buffers per Stream: 64
  • Maximum Resolution: Depends on GPU (typically 4K-8K)
  • Frame Rate: Up to 120fps (depends on codec and GPU)