diff --git a/include/joc_version.h b/include/joc_version.h index 33bed7e..0c131d4 100644 --- a/include/joc_version.h +++ b/include/joc_version.h @@ -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 */ diff --git a/src/joc_core/eac3joc_core.cpp b/src/joc_core/eac3joc_core.cpp index 8a02c45..8a4cec4 100644 --- a/src/joc_core/eac3joc_core.cpp +++ b/src/joc_core/eac3joc_core.cpp @@ -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; diff --git a/tests/test_core.cpp b/tests/test_core.cpp index f8ef797..f171a9b 100644 --- a/tests/test_core.cpp +++ b/tests/test_core.cpp @@ -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(sample)] = + static_cast(0.2 * std::sin(static_cast(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();