Port the OAMD metadata rendering and the frame-level JOC core
ci / ubuntu-latest (push) Failing after 19s
ci / macos-latest (push) Canceled after 0s
ci / windows-latest (push) Canceled after 0s
ci / release (push) Canceled after 0s

The JOC bitstream reports a per-frame parse status instead of treating every
anomaly as an exception: an unsupported downmix configuration, a clamped
object count, an unknown parameter-band count, bad offset_ts values and
trailing bytes each get their own status. The raw 5-bit offset_ts values are
kept as coded and validated to be strictly increasing per object, and the
clipgain uses 2^(x-4) * (1 + y/32).

The JOC core gains a frame-level state machine. It keeps the per-object
previous matrix and its presence marker, the seq counter, the 8-plane
passthrough history, the LFE clipgain ramp start and the previous actual
core-channel count. Normal, hold, hard-cut and passthrough frames are
distinguished: a frame without a previous state interpolates per the
data-point rules, an object that disappears keeps publishing a zero matrix,
a frame without metadata passes the 8 core planes through to slots 0..7 with
the 1217-sample delay, and a declared core-channel-count change hard-cuts and
clears the LFE ring while the clipgain ramp state is kept. The core LFE
applies the full clipgain as a sample-wise ramp before its delay.

The OAMD parser exposes the full frame state: every object's state in every
position block, the programme assignment and the trim element, with multiple
blocks and up to 30 declared objects accepted. The speaker renderer applies
this state: per-block gain/inactive, zone/elevation, the size kernel, snap,
divergence, element 5 refinement, the priority size budget, ISF basis
matrices and bed channel distribution, scheduled on the 32-sample metadata
grid with block alignment and gain ramps. The size kernel, ISF basis
assembly, bed routing and compensation are computed in oamd_math from the
speaker layout geometry; bed labels and reference positions derive from the
layout tables. The six ISF configurations and twelve layout descriptors are
compiled in as static tables (oamd/isf_tables.h); the JSON loader and the
configure-time embedding are gone. The layout tables gain 6.0, and the layout
lookup, bed map and trim probe follow.

The binaural position timeline consumes the full frame state as well: every
position block is scheduled at its own offset and ramp, and its track list
grows with the declared object count, so multi-block and over-16-object
programmes are rendered instead of rejected. The JOC binaural input stays one
LFE plus fifteen object sources; the extra tracks are followed but not
panned.

The file task and the stream parse the full state for speaker and binaural,
while the ADM export keeps the 15-track single-block view. The public headers
carry the new status values, the frame-level entry point and the raw offset_ts
description; the internal ABI versions go to 6 (joc_core), 2 (frame params and
EMDF info) and 4 (eac3joc).

ctest covers the frame-level core (clipgain formula and LFE ramp, offset_ts
validation, frame statuses, the 8-plane passthrough, the seq state machine and
the no-previous-state interpolation), the OAMD parser state, the compiled-in
ISF tables and the binaural timeline. The READMEs and the mathematical notes
describe the 6.0 layout, the frame state machine, the metadata application and
the ISF lookup tables.
This commit is contained in:
TheM14 committed 2026-11-08 14:04:21 +08:00
1 parent a2760286b0
commit 0bb82e4115
41 files changed
+8182 -678

No files matched your search

+23 -5
View File
@@ -81,11 +81,13 @@ if(MSVC AND CMAKE_GENERATOR MATCHES "Ninja" AND NOT CMAKE_CL_SHOWINCLUDES_PREFIX
"messages in the language CMake probes for.")
endif()
# Verbatim copies of the upstream native library; see THIRD_PARTY_NOTICES.md.
# These files are never edited: they are the validated DSP kernels.
# Sources copied verbatim from the upstream native library; see
# THIRD_PARTY_NOTICES.md. binaural_renderer.cpp is still an unmodified copy and
# is never edited; the unchanged reused headers include/eac3joc_core.h and
# src/joc_bitstream/joc_huffman_tables.h belong to the same set. The JOC core,
# the speaker renderer and the remaining tables started as copies and are
# maintained in-tree now, so they are listed as internal sources below.
set(JOC_REUSED_SOURCES
src/joc_core/eac3joc_core.cpp
src/speaker/speaker_renderer.cpp
src/binaural/binaural_renderer.cpp
)
@@ -119,8 +121,12 @@ set(JOC_INTERNAL_SOURCES
src/io/zip_reader.cpp
src/joc_bitstream/bed_layout_map.cpp
src/joc_bitstream/joc_parser.cpp
src/joc_core/eac3joc_core.cpp
src/joc_core/objects16.cpp
src/oamd/oamd_math.cpp
src/oamd/oamd_params.cpp
src/oamd/oamd_parser.cpp
src/speaker/speaker_renderer.cpp
src/speaker/speaker_layout_lookup.cpp
src/speaker/speaker_step.cpp
src/speaker/speaker_trim.cpp
@@ -236,6 +242,12 @@ if(JOC_BUILD_TESTS OR JOC_BUILD_DEVTOOLS)
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src"
)
target_link_libraries(joc_core_impl PUBLIC Threads::Threads)
# The same sources back both the shared library and this static archive. In
# the archive the C entry points are plain definitions: EJOC_STATIC stops the
# kernel sources that carry their own EJOC_BUILD_DLL define from marking them
# as dllexports, which would collide with the DLL import library in a link
# that uses both libraries (the tests do).
target_compile_definitions(joc_core_impl PUBLIC EJOC_STATIC)
endif()
add_library(joc_core SHARED
@@ -291,6 +303,10 @@ if(JOC_BUILD_TESTS)
target_link_libraries(joc_rosella_filterbank_tests PRIVATE joc_core_impl)
target_include_directories(joc_rosella_filterbank_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
add_test(NAME rosella_filterbank COMMAND joc_rosella_filterbank_tests)
add_executable(joc_oamd_metadata_tests tests/test_oamd_metadata.cpp)
target_link_libraries(joc_oamd_metadata_tests PRIVATE joc_core_impl)
target_include_directories(joc_oamd_metadata_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
add_test(NAME oamd_metadata COMMAND joc_oamd_metadata_tests)
# The public headers must stay valid C and C++: these targets exist to prove it.
add_library(joc_headers_c OBJECT tests/test_headers.c)
target_include_directories(joc_headers_c PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
@@ -317,7 +333,8 @@ if(JOC_BUILD_TESTS OR JOC_BUILD_DEVTOOLS)
list(APPEND JOC_MSVC_TARGETS joc_core_impl)
endif()
if(JOC_BUILD_TESTS)
list(APPEND JOC_MSVC_TARGETS joc_tests joc_rosella_filterbank_tests joc_headers_c joc_headers_cpp)
list(APPEND JOC_MSVC_TARGETS joc_tests joc_rosella_filterbank_tests
joc_oamd_metadata_tests joc_headers_c joc_headers_cpp)
endif()
if(JOC_BUILD_DEVTOOLS)
endif()
@@ -358,6 +375,7 @@ target_sources(joc_core PRIVATE
include/eac3joc_core.h
src/joc_bitstream/joc_huffman_tables.h
src/joc_core/qmf_tables.h
src/oamd/oamd_parser.h
src/speaker/speaker_layouts.h
)