Resolve the declared bed layout on the streaming path
ci / ubuntu-latest (push) Failing after 11s
ci / macos-latest (push) Canceled after 0s
ci / windows-latest (push) Canceled after 0s
ci / release (push) Canceled after 0s

This commit is contained in:
TheM14 committed 2026-10-30 04:14:06 +08:00
1 parent 1227fd6bbb
commit 075ef60afa
2 files changed
+45

No files matched your search

+41
View File
@@ -9,6 +9,7 @@
#include "hrtf/jochrtf.h" #include "hrtf/jochrtf.h"
#include "hrtf/rosella_model.h" #include "hrtf/rosella_model.h"
#include "hrtf/sofa_cache.h" #include "hrtf/sofa_cache.h"
#include "joc_bitstream/bed_layout_map.h"
#include "joc_bitstream/joc_parser.h" #include "joc_bitstream/joc_parser.h"
#include "joc_core/objects16.h" #include "joc_core/objects16.h"
@@ -186,12 +187,52 @@ Status Stream::create(const Config& config) {
return Status::success(); return Status::success();
} }
void Stream::apply_bed_positions(const FrameMetadata& entry) {
if (bed_positions_ready_ || entry.bed_assignments.empty()) {
return;
}
const bool bed_only = entry.has_update && entry.update.content_bed &&
!entry.update.content_isf && !entry.update.content_dynamic;
const ::joc::joc::BedLayout bed = ::joc::joc::resolve_bed_layout(entry.bed_assignments, bed_only);
if (!bed.present) {
return;
}
bed_positions_ready_ = true;
if (!bed.bed_only) {
return;
}
for (std::size_t slot = 0; slot < bed.channels.size() &&
slot < static_cast<std::size_t>(oamd::kObjects);
++slot) {
const ::joc::joc::BedChannel channel = bed.channels[slot];
double xyz[3] = {0.0, 0.0, 0.0};
if (binaural_ready_ && ::joc::joc::bed_channel_adm_position(channel, xyz)) {
binaural_.set_fixed_position(static_cast<int>(slot) + 1, xyz);
}
if (!speaker_enabled_) {
continue;
}
std::uint16_t q15[3] = {0, 0, 0};
if (!::joc::joc::layout_bed_anchor(speaker_.layout.out_ch_config, channel, q15) &&
!::joc::joc::bed_channel_q15(channel, q15)) {
continue;
}
speaker_.bed_override[slot] = true;
for (int axis = 0; axis < oamd::kAxes; ++axis) {
speaker_.bed_positions[slot][axis] = q15[axis];
}
}
}
Status Stream::flush_pending_frame() { Status Stream::flush_pending_frame() {
if (pending_frame_.streams.empty()) { if (pending_frame_.streams.empty()) {
return Status::success(); return Status::success();
} }
FrameMetadata entry = pending_frame_; FrameMetadata entry = pending_frame_;
pending_frame_ = FrameMetadata(); pending_frame_ = FrameMetadata();
if (entry.has_joc) {
apply_bed_positions(entry);
}
if (entry.has_joc) { if (entry.has_joc) {
std::string error; std::string error;
joc::CrossLayerNotes notes; joc::CrossLayerNotes notes;
+4
View File
@@ -128,6 +128,9 @@ private:
return rosella_ready_ ? (rosella_pending_.size() - rosella_read_offset_) / 2u : 0u; return rosella_ready_ ? (rosella_pending_.size() - rosella_read_offset_) / 2u : 0u;
} }
void reset_state(); void reset_state();
// 声明的 bed 布局只在首帧解析一次:bed 声道在 OAMD 里没有位置字段,方位由布局
// 给出;流式路径和文件任务走同一套 SpeakerStep/双耳运行时,所以这里也要下发。
void apply_bed_positions(const FrameMetadata& entry);
// Drops the bed samples that have already been rendered, keeping the rest. // Drops the bed samples that have already been rendered, keeping the rest.
void compact_bed_pending(); void compact_bed_pending();
// Closes the audio frame currently being assembled and queues it. // Closes the audio frame currently being assembled and queues it.
@@ -173,6 +176,7 @@ private:
bool speaker_enabled_ = false; bool speaker_enabled_ = false;
bool binaural_enabled_ = false; bool binaural_enabled_ = false;
bool binaural_ready_ = false; bool binaural_ready_ = false;
bool bed_positions_ready_ = false;
bool rosella_ready_ = false; bool rosella_ready_ = false;
float gain_ = 1.0f; float gain_ = 1.0f;
}; };