948697ef0d
Adds test_idct_bitexact that exercises daedalus_decoder_flush_frame
end-to-end with random coefficients and compares every output byte
against an inline C reference of the H.264 §8.5.12.1 1D butterfly.
Closes the validation gap from the previous PR ("dispatch succeeds"
becomes "dispatch is bit-exact").
What's tested:
- 320×240 coded frame (300 MBs), enough to cover multiple workgroups
of the V3D shader (16 blocks/WG → ≥30 WGs)
- Per-MB → flat-raster block layout consistent with flush_frame
- Random coeffs in [-512, 511] (same range as daedalus-fourier
cycle-6 M1 gate)
- Inline C reference: H.264 §8.5.12.1 butterfly with column-major
block layout, +32 rounding, >>6, add-to-predicted (=0), clip255 —
mirrors daedalus-fourier tests/h264_idct4_ref.c
Verified on hertz (Pi 5 / V3D 7.1 / daedalus-fourier 0.1.0):
$ ctest --test-dir build --output-on-failure
Start 1: smoke
1/2 Test #1: smoke ............................ Passed 0.16 sec
Start 2: idct_bitexact
2/2 Test #2: idct_bitexact .................... Passed 0.03 sec
100% tests passed, 0 tests failed out of 2
Bit-exact PASS first try — daedalus-fourier's V3D IDCT 4x4 shader
produces identical pixels to the C reference for all 4800 blocks in
the test frame. Validates BOTH the shader correctness AND the
frame-batched-dispatch correctness (this is the first time
n_blocks > ~30 has been exercised at the recipe-dispatch layer; the
substitution arc only ever called with n_blocks=1).
What is NOT tested by this PR (deferred to follow-ons):
- Non-zero predicted pixels — flush_frame zero-initialises scratch_y,
so the IDCT-ADD reduces to clip255(IDCT). Real predicted comes
from Stage 2a intra prediction.
- Z-scan permutation between FFmpeg's per-MB coeffs layout and our
per-MB → flat raster — the test uses its own coefficient generator
that already matches our layout, so it doesn't exercise the
permutation. The libavcodec-intercept patch is where the
permutation lands and gets validated against real H.264 streams.
- Chroma 4×4 IDCT.
- IDCT 8×8 (High profile).
Stacked on noether/phase1-stage1-idct (PR #3, the frame-scaled
dispatch). Rebase on main after #3 lands; the diff is purely additive
(one new test file + 5 lines of CMake).
133 lines
4.7 KiB
CMake
133 lines
4.7 KiB
CMake
# SPDX-License-Identifier: BSD-2-Clause
|
|
#
|
|
# daedalus-decoder — frame-level GPU H.264 decoder for V3D7 (Pi 5).
|
|
# Phase 1 scaffold; see DESIGN.md for architecture.
|
|
#
|
|
# Build dependencies:
|
|
# - daedalus-fourier ≥ 0.1.0 (kernel pack, V3D primitives + recipe layer)
|
|
# resolved via pkg-config; install via the daedalus-fourier upstream
|
|
# `cmake --install` rule (PR #5 made the .pc relocatable, so any
|
|
# install prefix works as long as $PKG_CONFIG_PATH is set).
|
|
# - Vulkan headers + libvulkan (pulled in transitively via
|
|
# daedalus-fourier, listed here explicitly for the link order).
|
|
#
|
|
# Build:
|
|
# cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
|
|
# cmake --build build
|
|
# ctest --test-dir build
|
|
|
|
cmake_minimum_required(VERSION 3.20)
|
|
project(daedalus-decoder
|
|
VERSION 0.0.1
|
|
DESCRIPTION "Frame-level GPU H.264 decoder for Raspberry Pi 5 / V3D7"
|
|
LANGUAGES C)
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
set(CMAKE_C_EXTENSIONS OFF)
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
endif()
|
|
|
|
# Pi 5 is the only supported target. Other aarch64 SoCs (Pi 4 V3D4,
|
|
# RK3588 Mali, …) might work but would need explicit substrate +
|
|
# shader-pack validation per the daedalus-fourier architecture
|
|
# backlog. Don't pretend to support what we haven't validated.
|
|
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
|
|
message(WARNING
|
|
"daedalus-decoder is designed for aarch64 (Pi 5 BCM2712 / V3D7). "
|
|
"Build will proceed but is unlikely to function.")
|
|
endif()
|
|
|
|
add_compile_options(-Wall -Wextra -Wno-unused-parameter)
|
|
|
|
# ---- Dependencies --------------------------------------------------
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
# daedalus-fourier — find_package via pkg-config per the Phase 1
|
|
# decision §9.6. Minimum version 0.1.0 (the cycle 6-9 shaders + pool
|
|
# + recipe-flip baseline). PKG_CONFIG_PATH should point at the
|
|
# directory holding daedalus-fourier.pc (e.g. /usr/local/lib/pkgconfig
|
|
# or a custom install prefix).
|
|
pkg_check_modules(DAEDALUS_FOURIER REQUIRED daedalus-fourier>=0.1.0)
|
|
|
|
# Vulkan — daedalus-fourier already depends on this; we add it
|
|
# explicitly so the link order stays correct (daedalus-fourier static
|
|
# archive contains undefined vk* symbols that the loader resolves).
|
|
find_package(Vulkan REQUIRED)
|
|
|
|
# ---- Version string baked into the library ------------------------
|
|
|
|
# git rev tagged onto the version string for traceability; degrades
|
|
# gracefully to bare semver if git isn't available.
|
|
execute_process(
|
|
COMMAND git -C ${CMAKE_CURRENT_SOURCE_DIR} rev-parse --short=7 HEAD
|
|
OUTPUT_VARIABLE DAEDALUS_DECODER_GITREV
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
ERROR_QUIET)
|
|
if(DAEDALUS_DECODER_GITREV)
|
|
set(DAEDALUS_DECODER_VERSION "${PROJECT_VERSION}+g${DAEDALUS_DECODER_GITREV}")
|
|
else()
|
|
set(DAEDALUS_DECODER_VERSION "${PROJECT_VERSION}")
|
|
endif()
|
|
message(STATUS "daedalus-decoder version: ${DAEDALUS_DECODER_VERSION}")
|
|
|
|
# ---- Library ------------------------------------------------------
|
|
|
|
add_library(daedalus_decoder STATIC
|
|
src/daedalus_decoder.c
|
|
)
|
|
target_include_directories(daedalus_decoder
|
|
PUBLIC
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
$<INSTALL_INTERFACE:include>
|
|
PRIVATE
|
|
src
|
|
${DAEDALUS_FOURIER_INCLUDE_DIRS}
|
|
)
|
|
target_link_directories(daedalus_decoder
|
|
PUBLIC
|
|
${DAEDALUS_FOURIER_LIBRARY_DIRS}
|
|
)
|
|
target_link_libraries(daedalus_decoder
|
|
PUBLIC
|
|
# Order matters: daedalus-fourier static archive references
|
|
# vulkan symbols; the loader needs daedalus-fourier first then
|
|
# vulkan to resolve them.
|
|
${DAEDALUS_FOURIER_LIBRARIES}
|
|
Vulkan::Vulkan
|
|
)
|
|
target_compile_definitions(daedalus_decoder
|
|
PRIVATE
|
|
DAEDALUS_DECODER_VERSION="${DAEDALUS_DECODER_VERSION}"
|
|
)
|
|
target_compile_options(daedalus_decoder PRIVATE -O2)
|
|
|
|
# ---- Smoke test ---------------------------------------------------
|
|
|
|
enable_testing()
|
|
|
|
add_executable(test_smoke tests/test_smoke.c)
|
|
target_link_libraries(test_smoke PRIVATE daedalus_decoder)
|
|
target_compile_options(test_smoke PRIVATE -O2)
|
|
add_test(NAME smoke COMMAND test_smoke)
|
|
|
|
add_executable(test_idct_bitexact tests/test_idct_bitexact.c)
|
|
target_link_libraries(test_idct_bitexact PRIVATE daedalus_decoder)
|
|
target_compile_options(test_idct_bitexact PRIVATE -O2)
|
|
add_test(NAME idct_bitexact COMMAND test_idct_bitexact)
|
|
|
|
# ---- Install ------------------------------------------------------
|
|
#
|
|
# Library + public header. Stage 2/3 will add a pkg-config file and
|
|
# CMake config exports once the API stabilises; pre-0.1 the scaffold
|
|
# install just gives the static archive a home.
|
|
|
|
include(GNUInstallDirs)
|
|
install(TARGETS daedalus_decoder
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
install(FILES include/daedalus_decoder.h
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|