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.
91 lines
3.8 KiB
C++
91 lines
3.8 KiB
C++
// Port of the metadata application path of src/speaker_renderer.py HEAD.
|
|
//
|
|
// The metadata path consumes the full per-object per-block OAMD frame state and
|
|
// schedules block targets frame by frame: object gain/inactive, zone/elevation,
|
|
// snap, divergence, size kernel fusion, priority size budget, ISF basis rows and
|
|
// bed channel distribution, with the same float64 gain ramps and block alignment
|
|
// as the reference renderer.
|
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "eac3joc_core.h"
|
|
#include "foundation/status.h"
|
|
#include "oamd/oamd_parser.h"
|
|
#include "speaker/speaker_layout_lookup.h"
|
|
#include "speaker/speaker_trim.h"
|
|
|
|
namespace joc::speaker {
|
|
|
|
// One metadata target matrix: object_count x layout channel_count in the
|
|
// renderer's internal channel order, before the ramp/timing stage.
|
|
struct MetadataTargets {
|
|
std::uint32_t object_count = 0;
|
|
std::uint32_t channel_count = 0;
|
|
std::vector<double> values; // object major
|
|
|
|
double at(std::uint32_t object, std::uint32_t channel) const {
|
|
return values[static_cast<std::size_t>(object) * channel_count + channel];
|
|
}
|
|
};
|
|
|
|
// Computes the metadata target matrix of one block of a parsed frame without
|
|
// touching renderer state: the reference's _init_meta validation plus
|
|
// _block_targets. ``trim`` carries the current programme trim (bypass flags),
|
|
// ``controls`` the derived per-layout controls, ``size_budget`` the priority
|
|
// budget (0 means unlimited, the production value).
|
|
Status metadata_block_targets(const LayoutInfo& layout, const oamd::OamdUpdate& update,
|
|
std::uint32_t block_index,
|
|
const ejoc_speaker_controls& controls,
|
|
const oamd::OamdTrim* trim, std::uint32_t size_budget,
|
|
MetadataTargets* out);
|
|
|
|
// Stateful metadata-path renderer. It owns the object target ramps and the
|
|
// cross-block pending schedule; the legacy point-renderer state stays in the
|
|
// C ABI renderer, which is used for the blocks of a frame that precede the first
|
|
// metadata targets (the reference renders those with its legacy block path).
|
|
class MetaRenderer {
|
|
public:
|
|
MetaRenderer();
|
|
~MetaRenderer();
|
|
MetaRenderer(MetaRenderer&&) noexcept;
|
|
MetaRenderer& operator=(MetaRenderer&&) noexcept;
|
|
MetaRenderer(const MetaRenderer&) = delete;
|
|
MetaRenderer& operator=(const MetaRenderer&) = delete;
|
|
|
|
// Binds the target layout. Must be called once before process_frame().
|
|
Status configure(const LayoutInfo& layout);
|
|
|
|
// Drops the ramp, schedule and metadata state (the layout stays bound).
|
|
Status reset();
|
|
|
|
bool configured() const;
|
|
// True once a metadata frame has been accepted (the reference's _meta_mode).
|
|
bool engaged() const;
|
|
|
|
const char* last_error() const;
|
|
|
|
Status process_frame(ejoc_speaker_renderer_handle legacy,
|
|
const float* objects16_interleaved, std::uint32_t sample_count,
|
|
const oamd::OamdUpdate* update, std::uint32_t metadata_offset,
|
|
const ejoc_speaker_controls& controls, const oamd::OamdTrim* trim,
|
|
std::uint32_t raw_trim_mode, std::uint32_t size_budget,
|
|
double* output_interleaved);
|
|
|
|
// Computes the target matrix of one block of ``update`` into ``out`` using a
|
|
// scratch context; unlike metadata_block_targets() this validates through
|
|
// the renderer's own state-independent path.
|
|
Status block_targets(const oamd::OamdUpdate& update, std::uint32_t block_index,
|
|
const ejoc_speaker_controls& controls, const oamd::OamdTrim* trim,
|
|
std::uint32_t size_budget, MetadataTargets* out) const;
|
|
|
|
private:
|
|
struct Impl;
|
|
std::unique_ptr<Impl> impl_;
|
|
};
|
|
|
|
} // namespace joc::speaker
|