Sync the kernel copy with the bed layout map and the stream path
This commit is contained in:
1 parent
9dca991e03
commit
b43ee8f685
17 files changed
+227
-26
No files matched your search
+2
-2
@@ -169,8 +169,8 @@ every container in the library, which is where the volume comes from.
|
|||||||
## Known limitations
|
## Known limitations
|
||||||
|
|
||||||
* ADM BWF output is not implemented.
|
* ADM BWF output is not implemented.
|
||||||
* Speaker layouts go up to 9.1.6 (16 channels), which is the renderer's own limit — there is no
|
* Speaker layouts go up to 9.1.6 (16 channels), the renderer's own output limit; see
|
||||||
22.2, see [Speaker layouts and channel order](#speaker-layouts-and-channel-order).
|
[Speaker layouts and channel order](#speaker-layouts-and-channel-order).
|
||||||
* A multichannel layout declares no speaker positions in Properties, and the per-chunk map used for
|
* A multichannel layout declares no speaker positions in Properties, and the per-chunk map used for
|
||||||
playback is only foobar2000's default for the channel count; output mapping is up to the user's
|
playback is only foobar2000's default for the channel count; output mapping is up to the user's
|
||||||
channel assignment (same section).
|
channel assignment (same section).
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ pwsh -File tools/package.ps1 # 两个架构,打包到 dist\*.fb2k-c
|
|||||||
## 已知限制
|
## 已知限制
|
||||||
|
|
||||||
* 不实现 ADM BWF 输出。
|
* 不实现 ADM BWF 输出。
|
||||||
* 扬声器布局到 9.1.6(16 声道)为止;内核输出上限就是 16 声道,没有 22.2,见
|
* 扬声器布局到 9.1.6(16 声道)为止;内核输出上限就是 16 声道,见
|
||||||
[扬声器布局与声道顺序](#扬声器布局与声道顺序)。
|
[扬声器布局与声道顺序](#扬声器布局与声道顺序)。
|
||||||
* 多声道布局在 Properties 里不声明扬声器位置,播放时的块内映射只是 foobar2000 对该声道数的
|
* 多声道布局在 Properties 里不声明扬声器位置,播放时的块内映射只是 foobar2000 对该声道数的
|
||||||
默认值;输出映射要按声道编号自行完成(同上)。
|
默认值;输出映射要按声道编号自行完成(同上)。
|
||||||
|
|||||||
@@ -175,6 +175,7 @@
|
|||||||
<ClCompile Include="src\io\process.cpp" />
|
<ClCompile Include="src\io\process.cpp" />
|
||||||
<ClCompile Include="src\io\wav_writer.cpp" />
|
<ClCompile Include="src\io\wav_writer.cpp" />
|
||||||
<ClCompile Include="src\io\zip_reader.cpp" />
|
<ClCompile Include="src\io\zip_reader.cpp" />
|
||||||
|
<ClCompile Include="src\joc_bitstream\bed_layout_map.cpp" />
|
||||||
<ClCompile Include="src\joc_bitstream\joc_parser.cpp" />
|
<ClCompile Include="src\joc_bitstream\joc_parser.cpp" />
|
||||||
<ClCompile Include="src\joc_core\objects16.cpp" />
|
<ClCompile Include="src\joc_core\objects16.cpp" />
|
||||||
<ClCompile Include="src\oamd\oamd_parser.cpp" />
|
<ClCompile Include="src\oamd\oamd_parser.cpp" />
|
||||||
@@ -250,6 +251,7 @@
|
|||||||
<ClInclude Include="src\io\process.h" />
|
<ClInclude Include="src\io\process.h" />
|
||||||
<ClInclude Include="src\io\wav_writer.h" />
|
<ClInclude Include="src\io\wav_writer.h" />
|
||||||
<ClInclude Include="src\io\zip_reader.h" />
|
<ClInclude Include="src\io\zip_reader.h" />
|
||||||
|
<ClInclude Include="src\joc_bitstream\bed_layout_map.h" />
|
||||||
<ClInclude Include="src\joc_bitstream\joc_huffman_tables.h" />
|
<ClInclude Include="src\joc_bitstream\joc_huffman_tables.h" />
|
||||||
<ClInclude Include="src\joc_bitstream\joc_parser.h" />
|
<ClInclude Include="src\joc_bitstream\joc_parser.h" />
|
||||||
<ClInclude Include="src\joc_core\objects16.h" />
|
<ClInclude Include="src\joc_core\objects16.h" />
|
||||||
|
|||||||
@@ -151,6 +151,14 @@ Status build_dbmd(std::uint32_t object_count, BinauralMode mode, std::string* ou
|
|||||||
for (std::size_t i = 5u + 262u; i < segment10.size(); ++i) {
|
for (std::size_t i = 5u + 262u; i < segment10.size(); ++i) {
|
||||||
segment10[i] = static_cast<char>(0x84);
|
segment10[i] = static_cast<char>(0x84);
|
||||||
}
|
}
|
||||||
|
// Nine 15-byte configuration trims start at byte 7; the first byte of each
|
||||||
|
// carries the auto-trim flag in bit 0 (1 = automatic, 0 = manual). The
|
||||||
|
// default is automatic, so a freshly rendered master opens with automatic
|
||||||
|
// trims in the renderer.
|
||||||
|
for (std::size_t layout = 0; layout < 9; ++layout) {
|
||||||
|
const std::size_t flag = 7u + 15u * layout;
|
||||||
|
segment10[flag] = static_cast<char>(static_cast<unsigned char>(segment10[flag]) | 0x01u);
|
||||||
|
}
|
||||||
const std::size_t object_modes = 4u + 2u + 1u + 9u * 15u + object_count;
|
const std::size_t object_modes = 4u + 2u + 1u + 9u * 15u + object_count;
|
||||||
for (std::uint32_t i = 10; i < std::min<std::uint32_t>(object_count, 10u + kObjectCount); ++i) {
|
for (std::uint32_t i = 10; i < std::min<std::uint32_t>(object_count, 10u + kObjectCount); ++i) {
|
||||||
const std::size_t index = object_modes + i;
|
const std::size_t index = object_modes + i;
|
||||||
|
|||||||
@@ -236,6 +236,9 @@ void TrajectoryBuilder::submit_frame(std::int64_t frame_index, const oamd::OamdU
|
|||||||
ramp_samples = static_cast<std::int64_t>(update->ramp_duration_samples);
|
ramp_samples = static_cast<std::int64_t>(update->ramp_duration_samples);
|
||||||
}
|
}
|
||||||
for (int object = 1; object <= kObjectCount; ++object) {
|
for (int object = 1; object <= kObjectCount; ++object) {
|
||||||
|
if (fixed_[object - 1]) {
|
||||||
|
continue; // 固定 bed 声道:位置由布局给出,不跟 OAMD 更新
|
||||||
|
}
|
||||||
double x = 0.0;
|
double x = 0.0;
|
||||||
double y = 0.0;
|
double y = 0.0;
|
||||||
double z = 0.0;
|
double z = 0.0;
|
||||||
@@ -260,6 +263,18 @@ Status TrajectoryBuilder::build(std::int64_t total_samples, TrajectoryMode mode,
|
|||||||
for (int object = 1; object <= kObjectCount; ++object) {
|
for (int object = 1; object <= kObjectCount; ++object) {
|
||||||
Track track;
|
Track track;
|
||||||
track.name = "JOC_Object_" + std::to_string(object);
|
track.name = "JOC_Object_" + std::to_string(object);
|
||||||
|
if (fixed_[object - 1]) {
|
||||||
|
Keyframe block;
|
||||||
|
block.rtime_samples = 0;
|
||||||
|
block.x = fixed_xyz_[object - 1][0];
|
||||||
|
block.y = fixed_xyz_[object - 1][1];
|
||||||
|
block.z = fixed_xyz_[object - 1][2];
|
||||||
|
block.duration_samples = total_samples;
|
||||||
|
block.interpolation_samples = 0;
|
||||||
|
track.blocks.push_back(block);
|
||||||
|
out->push_back(std::move(track));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const Status status =
|
const Status status =
|
||||||
(mode == TrajectoryMode::Compact)
|
(mode == TrajectoryMode::Compact)
|
||||||
? expand_compact(events_[object - 1], total_samples, rate_, block_,
|
? expand_compact(events_[object - 1], total_samples, rate_, block_,
|
||||||
|
|||||||
@@ -38,6 +38,18 @@ public:
|
|||||||
|
|
||||||
Status build(std::int64_t total_samples, TrajectoryMode mode, std::vector<Track>* out) const;
|
Status build(std::int64_t total_samples, TrajectoryMode mode, std::vector<Track>* out) const;
|
||||||
|
|
||||||
|
// bed 声道是固定通道:OAMD 不给位置,整片静止在声明的 bed 方位。
|
||||||
|
void set_fixed_position(int object_index, double x, double y, double z) {
|
||||||
|
if (object_index < 1 || object_index > kObjectCount) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const int slot = object_index - 1;
|
||||||
|
fixed_[slot] = true;
|
||||||
|
fixed_xyz_[slot][0] = x;
|
||||||
|
fixed_xyz_[slot][1] = y;
|
||||||
|
fixed_xyz_[slot][2] = z;
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<OamdEvent>& events(int object_index) const { return events_[object_index]; }
|
const std::vector<OamdEvent>& events(int object_index) const { return events_[object_index]; }
|
||||||
std::uint32_t rate() const { return rate_; }
|
std::uint32_t rate() const { return rate_; }
|
||||||
std::int64_t object_delay_samples() const { return object_delay_; }
|
std::int64_t object_delay_samples() const { return object_delay_; }
|
||||||
@@ -50,6 +62,8 @@ private:
|
|||||||
std::vector<OamdEvent> events_[kObjectCount];
|
std::vector<OamdEvent> events_[kObjectCount];
|
||||||
bool has_previous_[kObjectCount] = {};
|
bool has_previous_[kObjectCount] = {};
|
||||||
double previous_[kObjectCount][3] = {};
|
double previous_[kObjectCount][3] = {};
|
||||||
|
bool fixed_[kObjectCount] = {};
|
||||||
|
double fixed_xyz_[kObjectCount][3] = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
Status expand_compact(const std::vector<OamdEvent>& events, std::int64_t total_samples, std::uint32_t rate,
|
Status expand_compact(const std::vector<OamdEvent>& events, std::int64_t total_samples, std::uint32_t rate,
|
||||||
|
|||||||
@@ -72,6 +72,11 @@ public:
|
|||||||
std::size_t staged_samples() const { return staged_; }
|
std::size_t staged_samples() const { return staged_; }
|
||||||
const timeline::OamdPositionTimeline& timeline() const { return timeline_; }
|
const timeline::OamdPositionTimeline& timeline() const { return timeline_; }
|
||||||
|
|
||||||
|
// bed 声道是固定通道:OAMD 不给位置,方位由声明的 bed 布局给出。
|
||||||
|
void set_fixed_position(int object_index, const double position[3]) {
|
||||||
|
timeline_.set_fixed_position(object_index, position);
|
||||||
|
}
|
||||||
|
|
||||||
// finish_output_capacity as the reference computes it (plan 21.4).
|
// finish_output_capacity as the reference computes it (plan 21.4).
|
||||||
std::uint32_t finish_capacity(double tail_seconds) const;
|
std::uint32_t finish_capacity(double tail_seconds) const;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "joc_bitstream/joc_parser.h"
|
#include "joc_bitstream/joc_parser.h"
|
||||||
|
|
||||||
|
#include "joc_bitstream/bed_layout_map.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@@ -545,6 +547,26 @@ std::string position_name(Position position) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 核心声道位置 → bed 布局声道;返回 kCount 表示本标准表没有对应身份。
|
||||||
|
BedChannel bed_channel_for_position(Position position) {
|
||||||
|
switch (position) {
|
||||||
|
case Position::kLeft: return BedChannel::kLeft;
|
||||||
|
case Position::kRight: return BedChannel::kRight;
|
||||||
|
case Position::kCenter: return BedChannel::kCenter;
|
||||||
|
case Position::kLfe: return BedChannel::kLfe;
|
||||||
|
case Position::kLfe2: return BedChannel::kLfe2;
|
||||||
|
case Position::kLeftSurround: return BedChannel::kLeftSurround;
|
||||||
|
case Position::kRightSurround: return BedChannel::kRightSurround;
|
||||||
|
case Position::kLeftRearSurround: return BedChannel::kLeftRearSurround;
|
||||||
|
case Position::kRightRearSurround: return BedChannel::kRightRearSurround;
|
||||||
|
case Position::kVerticalHeightLeft: return BedChannel::kTopFrontLeft;
|
||||||
|
case Position::kVerticalHeightRight: return BedChannel::kTopFrontRight;
|
||||||
|
case Position::kTopSurroundLeft: return BedChannel::kTopSideLeft;
|
||||||
|
case Position::kTopSurroundRight: return BedChannel::kTopSideRight;
|
||||||
|
default: return BedChannel::kCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string position_list(const std::vector<Position>& positions) {
|
std::string position_list(const std::vector<Position>& positions) {
|
||||||
std::string text = "[";
|
std::string text = "[";
|
||||||
for (std::size_t index = 0; index < positions.size(); ++index) {
|
for (std::size_t index = 0; index < positions.size(); ++index) {
|
||||||
@@ -917,25 +939,24 @@ Status check_cross_layer(const joc_frame_params& params, const eac3::Frame* core
|
|||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bed_assignments != nullptr) {
|
if (bed_assignments != nullptr && !bed_assignments->empty()) {
|
||||||
static constexpr std::uint32_t kBedBitLeftRear = 1u << 4; // RC_LB/RC_RB
|
// OAMD 的 bed 掩码描述的是内容的 bed 布局,可以比核心子流实际编码的声道多
|
||||||
static constexpr std::uint32_t kBedBitTopFront = 1u << 5; // RC_TFL/RC_TFR
|
// (例如 9.1.6 bed 只编 5.1 核心)。只有核心声道在 bed 布局里找不到位置才是
|
||||||
std::vector<Position> declared_pair;
|
// 真正的不一致;多出来的 bed 声道是布局的一部分。
|
||||||
for (const oamd::BedAssignment& assignment : *bed_assignments) {
|
const BedLayout bed = resolve_bed_layout(*bed_assignments, true);
|
||||||
if (!assignment.standard || assignment.mask == 0u) {
|
if (bed.present && bed.complete) {
|
||||||
continue;
|
bool covered = true;
|
||||||
|
for (const Position position : core_positions) {
|
||||||
|
const BedChannel channel = bed_channel_for_position(position);
|
||||||
|
if (channel == BedChannel::kCount) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!bed_layout_has(bed, channel)) {
|
||||||
|
covered = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((assignment.mask & kBedBitLeftRear) != 0u) {
|
if (!covered && notes != nullptr) {
|
||||||
push_unique(&declared_pair, Position::kLeftRearSurround);
|
|
||||||
push_unique(&declared_pair, Position::kRightRearSurround);
|
|
||||||
}
|
|
||||||
if ((assignment.mask & kBedBitTopFront) != 0u) {
|
|
||||||
push_unique(&declared_pair, Position::kVerticalHeightLeft);
|
|
||||||
push_unique(&declared_pair, Position::kVerticalHeightRight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!declared_pair.empty() && declared_pair != wanted) {
|
|
||||||
if (notes != nullptr) {
|
|
||||||
notes->bed_mask_mismatch = true;
|
notes->bed_mask_mismatch = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,9 @@ bool variable_bits_max(bits::BitReader& reader, unsigned width, unsigned max_gro
|
|||||||
struct ProgramInfo {
|
struct ProgramInfo {
|
||||||
bool dynamic_object_only = false;
|
bool dynamic_object_only = false;
|
||||||
bool lfe_present = false;
|
bool lfe_present = false;
|
||||||
|
bool content_bed = false;
|
||||||
|
bool content_isf = false;
|
||||||
|
bool content_dynamic = false;
|
||||||
std::uint32_t num_bed_objects = 0;
|
std::uint32_t num_bed_objects = 0;
|
||||||
std::uint32_t num_isf_objects = 0;
|
std::uint32_t num_isf_objects = 0;
|
||||||
std::int32_t num_dynamic_objects = -1;
|
std::int32_t num_dynamic_objects = -1;
|
||||||
@@ -88,6 +91,9 @@ Status parse_program_assignment(bits::BitReader& reader, ProgramInfo* program) {
|
|||||||
if (reader.failed()) {
|
if (reader.failed()) {
|
||||||
return syntax("program_assignment truncated");
|
return syntax("program_assignment truncated");
|
||||||
}
|
}
|
||||||
|
program->content_bed = (mask & 0x1u) != 0u;
|
||||||
|
program->content_isf = (mask & 0x2u) != 0u;
|
||||||
|
program->content_dynamic = (mask & 0x4u) != 0u;
|
||||||
if ((mask & 0x1u) != 0u) {
|
if ((mask & 0x1u) != 0u) {
|
||||||
reader.read(1);
|
reader.read(1);
|
||||||
const std::uint32_t multi = reader.read(1);
|
const std::uint32_t multi = reader.read(1);
|
||||||
@@ -520,6 +526,9 @@ Status parse_id11_verbose(const std::uint8_t* payload, std::size_t payload_size,
|
|||||||
out->num_bed_objects = program.num_bed_objects;
|
out->num_bed_objects = program.num_bed_objects;
|
||||||
out->num_isf_objects = program.num_isf_objects;
|
out->num_isf_objects = program.num_isf_objects;
|
||||||
out->num_dynamic_objects = program.num_dynamic_objects;
|
out->num_dynamic_objects = program.num_dynamic_objects;
|
||||||
|
out->content_bed = program.content_bed;
|
||||||
|
out->content_isf = program.content_isf;
|
||||||
|
out->content_dynamic = program.content_dynamic;
|
||||||
|
|
||||||
if (trace != nullptr) {
|
if (trace != nullptr) {
|
||||||
trace->bed_assignments = program.bed_assignments;
|
trace->bed_assignments = program.bed_assignments;
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ struct OamdUpdate {
|
|||||||
std::uint32_t num_bed_objects = 0;
|
std::uint32_t num_bed_objects = 0;
|
||||||
std::uint32_t num_isf_objects = 0;
|
std::uint32_t num_isf_objects = 0;
|
||||||
std::int32_t num_dynamic_objects = -1;
|
std::int32_t num_dynamic_objects = -1;
|
||||||
|
// program_assignment() 的 content_description:bed / ISF / 动态对象三类内容。
|
||||||
|
bool content_bed = false;
|
||||||
|
bool content_isf = false;
|
||||||
|
bool content_dynamic = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OamdState {
|
class OamdState {
|
||||||
|
|||||||
@@ -37,6 +37,14 @@ Status step(SpeakerStep* context, const std::vector<float>& objects16_planar,
|
|||||||
|
|
||||||
std::uint16_t positions[oamd::kObjects][3] = {};
|
std::uint16_t positions[oamd::kObjects][3] = {};
|
||||||
context->state.object_positions_q15(positions);
|
context->state.object_positions_q15(positions);
|
||||||
|
for (int object = 0; object < oamd::kObjects; ++object) {
|
||||||
|
if (!context->bed_override[object]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int axis = 0; axis < oamd::kAxes; ++axis) {
|
||||||
|
positions[object][axis] = context->bed_positions[object][axis];
|
||||||
|
}
|
||||||
|
}
|
||||||
// A frame without OAMD must not touch the gains at all (no event), otherwise a
|
// A frame without OAMD must not touch the gains at all (no event), otherwise a
|
||||||
// pending ramp would snap - matching the reference exactly.
|
// pending ramp would snap - matching the reference exactly.
|
||||||
const std::uint32_t event_count = context->last_had_payload ? 1u : 0u;
|
const std::uint32_t event_count = context->last_had_payload ? 1u : 0u;
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ struct SpeakerStep {
|
|||||||
std::uint32_t last_ramp_duration = 0;
|
std::uint32_t last_ramp_duration = 0;
|
||||||
std::uint32_t last_object_count = 0;
|
std::uint32_t last_object_count = 0;
|
||||||
bool last_had_payload = false;
|
bool last_had_payload = false;
|
||||||
|
// bed 声道是固定通道:OAMD 不给位置,方位由声明的 bed 布局给出。这里存
|
||||||
|
// 对象槽 → Q15 方位;bed_override 为 false 的槽仍按 OAMD 坐标声像。
|
||||||
|
std::uint16_t bed_positions[oamd::kObjects][oamd::kAxes] = {};
|
||||||
|
bool bed_override[oamd::kObjects] = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
Status step(SpeakerStep* context, const std::vector<float>& objects16_planar,
|
Status step(SpeakerStep* context, const std::vector<float>& objects16_planar,
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
#include "io/process.h"
|
#include "io/process.h"
|
||||||
#include "io/wav_writer.h"
|
#include "io/wav_writer.h"
|
||||||
#include "joc_bitstream/joc_parser.h"
|
#include "joc_bitstream/joc_parser.h"
|
||||||
|
#include "joc_bitstream/bed_layout_map.h"
|
||||||
#include "joc_core/objects16.h"
|
#include "joc_core/objects16.h"
|
||||||
#include "oamd/oamd_parser.h"
|
#include "oamd/oamd_parser.h"
|
||||||
#include "speaker/speaker_step.h"
|
#include "speaker/speaker_step.h"
|
||||||
@@ -1322,6 +1323,7 @@ Status run(const joc_task_config& raw, const joc_event_sink* sink, joc_task_resu
|
|||||||
}
|
}
|
||||||
|
|
||||||
::joc::speaker::SpeakerStep speaker;
|
::joc::speaker::SpeakerStep speaker;
|
||||||
|
bool bed_positions_ready = false;
|
||||||
const bool speaker_enabled = cfg.operation == JOC_OP_SPEAKER;
|
const bool speaker_enabled = cfg.operation == JOC_OP_SPEAKER;
|
||||||
if (speaker_enabled) {
|
if (speaker_enabled) {
|
||||||
if (!::joc::speaker::layout_by_name(cfg.layout.c_str(), &speaker.layout)) {
|
if (!::joc::speaker::layout_by_name(cfg.layout.c_str(), &speaker.layout)) {
|
||||||
@@ -1745,6 +1747,58 @@ Status run(const joc_task_config& raw, const joc_event_sink* sink, joc_task_resu
|
|||||||
job.outer_offset = static_cast<std::int64_t>(payload->sample_offset);
|
job.outer_offset = static_cast<std::int64_t>(payload->sample_offset);
|
||||||
const Status bed_ok = ::joc::oamd::parse_id11_bed_assignments(
|
const Status bed_ok = ::joc::oamd::parse_id11_bed_assignments(
|
||||||
bytes.data(), bytes.size(), &group_bed_assignments);
|
bytes.data(), bytes.size(), &group_bed_assignments);
|
||||||
|
if (bed_ok.ok() && !bed_positions_ready &&
|
||||||
|
!group_bed_assignments.empty()) {
|
||||||
|
const ::joc::joc::BedLayout bed_layout =
|
||||||
|
::joc::joc::resolve_bed_layout(
|
||||||
|
group_bed_assignments,
|
||||||
|
job.update.content_bed && !job.update.content_isf &&
|
||||||
|
!job.update.content_dynamic);
|
||||||
|
if (bed_layout.present) {
|
||||||
|
bed_positions_ready = true;
|
||||||
|
bus.emit(JOC_EV_RENDERER_INITIALIZED, JOC_STAGE_RENDER,
|
||||||
|
JOC_LOG_INFO,
|
||||||
|
fmt("bed layout: %s (%u bed channels)",
|
||||||
|
bed_layout.name[0] != '\0'
|
||||||
|
? bed_layout.name : "custom",
|
||||||
|
static_cast<unsigned>(
|
||||||
|
bed_layout.channels.size())));
|
||||||
|
if (bed_layout.bed_only) {
|
||||||
|
// bed 声道是固定通道:OAMD 不给位置,方位由声明的 bed 布局给出。
|
||||||
|
for (std::size_t slot = 0;
|
||||||
|
slot < bed_layout.channels.size() &&
|
||||||
|
slot < static_cast<std::size_t>(::joc::oamd::kObjects);
|
||||||
|
++slot) {
|
||||||
|
const ::joc::joc::BedChannel channel =
|
||||||
|
bed_layout.channels[slot];
|
||||||
|
double xyz[3] = {0.0, 0.0, 0.0};
|
||||||
|
if (::joc::joc::bed_channel_adm_position(channel, xyz)) {
|
||||||
|
trajectory.set_fixed_position(
|
||||||
|
static_cast<int>(slot) + 1, xyz[0], xyz[1],
|
||||||
|
xyz[2]);
|
||||||
|
if (binaural_enabled) {
|
||||||
|
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 < ::joc::oamd::kAxes; ++axis) {
|
||||||
|
speaker.bed_positions[slot][axis] = q15[axis];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!bed_ok.ok()) {
|
if (!bed_ok.ok()) {
|
||||||
failures.record(produced, StageRank::kJoc, bed_ok.code(),
|
failures.record(produced, StageRank::kJoc, bed_ok.code(),
|
||||||
bed_ok.stage(), bed_ok.message());
|
bed_ok.stage(), bed_ok.message());
|
||||||
@@ -2039,11 +2093,6 @@ Status run(const joc_task_config& raw, const joc_event_sink* sink, joc_task_resu
|
|||||||
" audio frame(s): the chanmap declares a different extra pair than "
|
" audio frame(s): the chanmap declares a different extra pair than "
|
||||||
"joc_dmx_config_idx; the bed mapping follows the chanmap");
|
"joc_dmx_config_idx; the bed mapping follows the chanmap");
|
||||||
}
|
}
|
||||||
if (bed_mask_mismatch_frames != 0u) {
|
|
||||||
bus.warning(std::to_string(bed_mask_mismatch_frames) +
|
|
||||||
" audio frame(s): the OAMD bed mask declares a different extra pair than "
|
|
||||||
"joc_dmx_config_idx; the bed mask only affects metadata");
|
|
||||||
}
|
|
||||||
StageFailure recorded;
|
StageFailure recorded;
|
||||||
if (failures.earliest(&recorded)) {
|
if (failures.earliest(&recorded)) {
|
||||||
return finalize_with_error(recorded.code, recorded.stage_text, recorded.message);
|
return finalize_with_error(recorded.code, recorded.stage_text, recorded.message);
|
||||||
|
|||||||
@@ -114,6 +114,10 @@ Status OamdPositionTimeline::submit_update(const oamd::OamdUpdate& update,
|
|||||||
|
|
||||||
double targets[kTimelineObjects][3] = {};
|
double targets[kTimelineObjects][3] = {};
|
||||||
for (int index = 0; index < kTimelineObjects; ++index) {
|
for (int index = 0; index < kTimelineObjects; ++index) {
|
||||||
|
if (fixed_[index]) {
|
||||||
|
std::memcpy(targets[index], fixed_xyz_[index], sizeof(targets[index]));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
geometry::q_to_adm_xyz(state_.q(index + 1, 0), state_.q(index + 1, 1),
|
geometry::q_to_adm_xyz(state_.q(index + 1, 0), state_.q(index + 1, 1),
|
||||||
state_.q(index + 1, 2), &targets[index][0], &targets[index][1],
|
state_.q(index + 1, 2), &targets[index][0], &targets[index][1],
|
||||||
&targets[index][2]);
|
&targets[index][2]);
|
||||||
|
|||||||
@@ -49,6 +49,17 @@ public:
|
|||||||
// positions[15][3]; queries must be monotonically increasing.
|
// positions[15][3]; queries must be monotonically increasing.
|
||||||
Status positions_at(std::int64_t sample, double positions[kTimelineObjects][3]);
|
Status positions_at(std::int64_t sample, double positions[kTimelineObjects][3]);
|
||||||
|
|
||||||
|
// bed 声道是固定通道:OAMD 不给位置,方位由声明的 bed 布局给出。
|
||||||
|
void set_fixed_position(int object_index, const double position[3]) {
|
||||||
|
if (object_index < 1 || object_index > kTimelineObjects) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fixed_[object_index - 1] = true;
|
||||||
|
fixed_xyz_[object_index - 1][0] = position[0];
|
||||||
|
fixed_xyz_[object_index - 1][1] = position[1];
|
||||||
|
fixed_xyz_[object_index - 1][2] = position[2];
|
||||||
|
}
|
||||||
|
|
||||||
std::uint64_t payload_count() const { return payload_count_; }
|
std::uint64_t payload_count() const { return payload_count_; }
|
||||||
std::uint64_t transition_count() const { return transition_count_; }
|
std::uint64_t transition_count() const { return transition_count_; }
|
||||||
bool initialized() const { return initialized_; }
|
bool initialized() const { return initialized_; }
|
||||||
@@ -62,6 +73,8 @@ private:
|
|||||||
bool initialized_ = false;
|
bool initialized_ = false;
|
||||||
double previous_targets_[kTimelineObjects][3] = {};
|
double previous_targets_[kTimelineObjects][3] = {};
|
||||||
bool has_previous_[kTimelineObjects] = {};
|
bool has_previous_[kTimelineObjects] = {};
|
||||||
|
bool fixed_[kTimelineObjects] = {};
|
||||||
|
double fixed_xyz_[kTimelineObjects][3] = {};
|
||||||
std::uint64_t payload_count_ = 0;
|
std::uint64_t payload_count_ = 0;
|
||||||
std::uint64_t transition_count_ = 0;
|
std::uint64_t transition_count_ = 0;
|
||||||
std::int64_t last_coded_event_sample_ = -1;
|
std::int64_t last_coded_event_sample_ = -1;
|
||||||
|
|||||||
Reference in new issue
Block a user