Sync the kernel copy with the OAMD frame-level core

The kernel copy follows the new kernel. The renderer has a frame-level state
machine (normal, hold, hard cut and passthrough, the 8-plane passthrough, the
LFE clipgain ramp and interpolation when no previous state exists), the OAMD
parser carries the complete frame state (several blocks, more than 16 objects)
and the speaker renderer applies the metadata (gain and inactive flags,
zone/elevation, size, snap, divergence, ISF and bed distribution). oamd_math and
oamd_params are new modules, the ISF tables are compiled in now that the
upstream data/ directory is gone, and the binaural timeline accepts a complete
frame state. joc_core.h moves to ABI 6 (frame parameters and EMDF payload info
at v2, JOC_FRAME_STATUS_*, raw 5-bit offset_ts) and eac3joc_core.h to EJOC ABI 4
(EJOC_FRAME_STATUS_*, ejoc_frame_input v1, ejoc_renderer_render_frame,
EJOC_CORE_OUT_CHANNELS and EJOC_LFE_SLOT; the old ejoc_renderer_process stays).
joc_stream.h and joc_version.h are unchanged.

joc_kernel.vcxproj lists the two new translation units and the four new
headers. The component's layout table gains the kernel's 6.0 layout (L R Ls Rs
Lrs Rrs) after 9.1.6, and layout_table_test expects twelve layouts, so the list
the preferences page shows and the list the renderer accepts are the same
again. README, THIRD_PARTY_NOTICES and the CI comment pin the copy to commit
3f0d5e87fe41b90d9350528d2dca2ca82a637a3f; tag v1.2.0 points at the older
a276028 and is not the sync baseline.

Builds Release-Static|x64 and |Win32 with no errors. The offline test tools
build and pass on both architectures: layout_table_test reports 12 layouts, and
channel_swap_test, log_rotation_test and long_path_test pass. scan_crosscheck
agrees with the core on the upstream test material, and the render harness
delivers 7.1.4 speaker output and binaural output on both architectures, with
the speaker-path WAV byte-identical between them.

The core is still vendored under kernel/; building it from the upstream
checkout at build time is a separate change.
This commit is contained in:
TheM14 committed 2026-11-08 16:11:57 +08:00
1 parent 5b41868e94
commit defe9538fe
39 files changed
+6714 -616

No files matched your search

+101
View File
@@ -0,0 +1,101 @@
// Port of src/oamd_math.py: float32 equations for the metadata application path.
//
// The routines implement the fixed float32 equations for the size tables, ISF
// basis assembly, bed channel routing and the position-dependent compensation.
// The size tables are generated from the region geometry with grouped equal-power
// panning, an S448 weight and a power sum; every operation is evaluated in
// float32 in a fixed order so the coefficients are reproducible.
//
// The caller passes the parameter mappings from oamd_params; this module does
// not read files itself.
#pragma once
#include <array>
#include <cstddef>
#include <cstdint>
#include <vector>
#include "oamd/oamd_params.h"
#include "speaker/speaker_layout_lookup.h"
#include "speaker/speaker_layouts.h"
namespace joc::oamd {
// The specified 2**x approximation used by the compensation kernels.
float exp2_approx(float value);
// The specified x**power approximation; power is a float32.
float pow_approx(float value, float power);
// Stable float32 normalisation with the tiny-norm floor.
std::vector<float> norm(const std::vector<float>& vector);
// One boundary weight of the size kernel.
float boundary(int axis, int edge, float position, float t);
// Maps a scalar size in [0, 1] to t on the size curve.
float size_curve_value(double size);
// Size kernel response in region-speaker order (the region point order).
std::vector<float> size_kernel(const ::ejoc::speaker_tables::RegionGeometry& region,
const float position[3], float t, bool height);
// Size-kernel target vector in layout channel order.
std::vector<float> size_targets(const MetadataParams& meta,
const ::ejoc::speaker_tables::LayoutGeometry& layout,
int region_index, const double position[3],
double size, bool height);
// One assembled ISF basis matrix (row_count x layout output_count, row major).
struct IsfBasis {
int rows = 0;
int columns = 0;
std::vector<float> values;
float at(int row, int column) const {
return values[static_cast<std::size_t>(row) * static_cast<std::size_t>(columns) +
static_cast<std::size_t>(column)];
}
};
// Assembles one ISF basis matrix from the compressed base tables.
IsfBasis assemble_isf(const MetadataParams& meta, const char* layout_key, int isf_idx);
// Returns the per-basis ISF compensation gain.
float isf_compensation(const MetadataParams& meta, const char* layout_key, int isf_idx,
int row, bool disabled);
// Per-label bed redistribution weight, in the reference-position index space
// used by the layout descriptors.
float bed_weight(int label, std::uint32_t mask, int target_label);
// The five height-candidate flags for one input bed label.
std::array<int, 5> bed_candidates(int label, std::uint32_t mask,
const std::vector<int>& output_labels);
// Route and weights for one input bed label. route == -1 means the returned
// weights are the target; otherwise route is the reference position used to
// synthesise a point source.
struct BedDistribution {
int route = -1;
std::vector<float> weights;
};
// Derives the bed routing of one input bed label from the target layout.
BedDistribution bed_distribution(const ::joc::speaker::LayoutInfo& layout, int label,
std::uint32_t mask, bool distribute);
// Returns the Q15 reference position used by the bed fallback path.
void bed_reference_position(int index, int q15[3]);
// Returns the bed path compensation gain for one input bed label. ``mode`` is
// the trim mode (0 automatic, 1 disabled, 2 explicit) and ``levels`` holds the
// surround, height and centre levels in dB.
float bed_compensation(const ::joc::speaker::LayoutInfo& layout, int label, int mode,
bool bypass, const double levels[3]);
// Automatic attenuation of a target layout in dB.
float bed_attenuation_db(const ::joc::speaker::LayoutInfo& layout);
} // namespace joc::oamd