Hold frames without JOC metadata in the middle of a stream
A frame without JOC metadata (status 8) used to select Passthrough in every state, the middle of a stream included. Passthrough replaces the object render with the delayed core planes, and the object synthesis restarts from silence on the next frame, so every such frame produced a step at the frame boundary and a second one when the metadata came back. Encoders that are not careful with the JOC EMDF container emit exactly those frames. Status 8 now follows the state machine like the other invalid statuses: state 0 (no valid frame rendered yet, i.e. plain E-AC-3 or before the first JOC frame) keeps Passthrough, state 3 (mid-stream) selects Hold and reuses the previous object matrices, so the bed and the objects stay continuous. The compatibility note at select_mode records the old and the new state machine and states that the choice is a concession for non-standard streams, not a normative reading. Bump JOC_VERSION to 1.3.1. The new renderer test covers both sides: a mid-stream frame without metadata holds the previous matrices, while a stream that has not rendered a valid frame yet still passes the core planes through.
This commit is contained in:
1 parent
abce8465f8
commit
836d68c354
3 files changed
+67
-3
No files matched your search
@@ -10,7 +10,7 @@
|
||||
|
||||
#define JOC_VERSION_MAJOR 1
|
||||
#define JOC_VERSION_MINOR 3
|
||||
#define JOC_VERSION_PATCH 0
|
||||
#define JOC_VERSION_STRING "1.3.0"
|
||||
#define JOC_VERSION_PATCH 1
|
||||
#define JOC_VERSION_STRING "1.3.1"
|
||||
|
||||
#endif /* JOC_VERSION_H */
|
||||
@@ -800,9 +800,35 @@ private:
|
||||
return pre_state;
|
||||
}
|
||||
|
||||
// Compatibility note for frames without JOC metadata (status 8).
|
||||
//
|
||||
// The state machine used to map status 8 to Passthrough unconditionally,
|
||||
// including in the middle of a stream. That is only meaningful before the
|
||||
// first valid JOC frame: a plain E-AC-3 stream (or a stream whose first JOC
|
||||
// frame comes late) has no object state yet, so the core planes are all
|
||||
// there is and the delayed core PCM is the right output. In the middle of
|
||||
// a JOC stream a frame without metadata is a damaged frame, not "no
|
||||
// objects": the Passthrough output replaces the object render with the core
|
||||
// planes, and the object synthesis restarts from silence on the next frame.
|
||||
// Every such frame therefore produced a step at the frame boundary and a
|
||||
// second one when the metadata came back; encoders that are not careful
|
||||
// with the JOC EMDF container emit exactly those frames.
|
||||
//
|
||||
// After the change status 8 follows the state machine like the other
|
||||
// invalid statuses: state 0 (no valid frame rendered yet) stays Passthrough,
|
||||
// and state 3 (mid-stream) selects Hold, which reuses the previous object
|
||||
// matrices and keeps the bed and object rendering continuous.
|
||||
//
|
||||
// This is a compatibility choice, not a claim about the normative reading
|
||||
// of the specification: a frame without metadata can be argued to be the
|
||||
// Passthrough case. It exists so that non-standard streams stay click-free;
|
||||
// if the reference behaviour is preferred, re-add the unconditional
|
||||
// Passthrough branch here.
|
||||
FrameMode select_mode(const uint32_t status) const noexcept {
|
||||
if (status == EJOC_FRAME_STATUS_NO_METADATA) {
|
||||
return FrameMode::Passthrough;
|
||||
// See the note above: only a stream that has not rendered a valid
|
||||
// frame yet has nothing to hold.
|
||||
return state_ == 0u ? FrameMode::Passthrough : FrameMode::Hold;
|
||||
}
|
||||
if (state_ == 4u) {
|
||||
return FrameMode::HardCut;
|
||||
|
||||
@@ -2138,6 +2138,43 @@ float object_peak(const FrameCase& frame, int object_channel) {
|
||||
return peak;
|
||||
}
|
||||
|
||||
void test_joc_no_metadata_midstream_holds() {
|
||||
// A frame without JOC metadata in the middle of a JOC stream is a damaged
|
||||
// frame, not "no objects": it holds the previous matrices instead of
|
||||
// publishing the core planes. Before the compatibility change every such
|
||||
// frame went through Passthrough, which produced a step at the frame
|
||||
// boundary and a second one when the metadata came back.
|
||||
{
|
||||
FrameCase frame;
|
||||
frame.create();
|
||||
for (int sample = 0; sample < EJOC_FRAME_SAMPLES; ++sample) {
|
||||
frame.bed[static_cast<std::size_t>(sample)] =
|
||||
static_cast<float>(0.2 * std::sin(static_cast<double>(sample) * 0.05));
|
||||
}
|
||||
configure_passthrough_object(&frame);
|
||||
CHECK(frame.render(EJOC_CORE_CHANNELS, EJOC_CORE_CHANNELS, 0u, 0u, true, 1u, 1.0));
|
||||
CHECK(object_peak(frame, 1) > 1.0e-3f);
|
||||
CHECK(frame.render(EJOC_CORE_CHANNELS, 0u, EJOC_FRAME_STATUS_NO_METADATA, 0u, false,
|
||||
0u, 1.0));
|
||||
// Held: the object slot keeps rendering from the previous matrix.
|
||||
CHECK(object_peak(frame, 1) > 1.0e-3f);
|
||||
// The next valid frame resumes normally.
|
||||
CHECK(frame.render(EJOC_CORE_CHANNELS, EJOC_CORE_CHANNELS, 0u, 1u, true, 1u, 1.0));
|
||||
CHECK(object_peak(frame, 1) > 1.0e-3f);
|
||||
}
|
||||
// A stream that has not rendered a valid frame yet keeps the passthrough:
|
||||
// the core planes are all there is (plain E-AC-3, or a late first JOC frame).
|
||||
{
|
||||
FrameCase frame;
|
||||
frame.create();
|
||||
fill_frame_bed(&frame, 0.1f, 0.25f);
|
||||
CHECK(frame.render(EJOC_CORE_CHANNELS, 0u, EJOC_FRAME_STATUS_NO_METADATA, 0u, false,
|
||||
0u, 1.0));
|
||||
CHECK(frame.silent_slots(8, EJOC_OUTPUT_CHANNELS - 1));
|
||||
CHECK(!frame.silent_slots(0, 7));
|
||||
}
|
||||
}
|
||||
|
||||
void test_joc_frame_state_machine() {
|
||||
// seq 0 on the first frame is not a hard cut, and a mismatch later is.
|
||||
{
|
||||
@@ -2403,6 +2440,7 @@ int main() {
|
||||
test_eac3_frame_truncated_joc_payload();
|
||||
test_joc_lfe_clipgain_ramp();
|
||||
test_joc_passthrough_8_plane_layout();
|
||||
test_joc_no_metadata_midstream_holds();
|
||||
test_joc_frame_state_machine();
|
||||
test_joc_truncated_frame_holds_previous_matrix();
|
||||
test_joc_no_previous_interpolation();
|
||||
|
||||
Reference in new issue
Block a user