Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

feat(audio): read-only IEC 61937 carrier probe for capture audio

Veyra Goal Agentc832cd68cbea
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2f2dea36..1c4acf12 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -573,6 +573,10 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avform
target_compile_features(veyra_avermedia_switch_tests PRIVATE cxx_std_20)
target_compile_definitions(veyra_avermedia_switch_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN UNICODE _UNICODE)
target_link_libraries(veyra_avermedia_switch_tests PRIVATE veyra_sources)
+ add_executable(veyra_iec61937_probe_tests tests/unit/Iec61937ProbeTests.cpp)
+ target_compile_features(veyra_iec61937_probe_tests PRIVATE cxx_std_20)
+ target_compile_definitions(veyra_iec61937_probe_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN UNICODE _UNICODE)
+ target_link_libraries(veyra_iec61937_probe_tests PRIVATE veyra_sinks)
if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavcodec/avcodec.h")
add_executable(veyra_bitstream_audio_test tools/bitstream_audio_test/main.cpp)
target_compile_features(veyra_bitstream_audio_test PRIVATE cxx_std_20)
diff --git a/docs/AVERMEDIA_5P1_SWITCH_IMPLEMENTATION_2026-09-17.md b/docs/AVERMEDIA_5P1_SWITCH_IMPLEMENTATION_2026-09-17.md
index 103b1997..eb966768 100644
--- a/docs/AVERMEDIA_5P1_SWITCH_IMPLEMENTATION_2026-09-17.md
+++ b/docs/AVERMEDIA_5P1_SWITCH_IMPLEMENTATION_2026-09-17.md
@@ -51,6 +51,29 @@ if (!formatOk) { state=Failed; detail="card not reached: getAudioFormat ret=..."
芯片返回 **20 (0x14)** 表示 HDMI 源正在发非 PCM(Dolby);其他值表示 PCM。
注意这是**源的当前格式**,不是"有没有武装成功"——用户在菜单里时它一样是 PCM。
+### 1.4 只读载体探针:`sink::Iec61937Probe`
+
+**为什么必须要它**:`chipFormat=20` 只说明"源在发 Dolby",它无法区分下面两种完全不同的现状——
+
+- 切换**没生效**:卡照旧把 Dolby 解成 2.0 PCM 送出来(今天用户听到的正常声音);
+- 切换**生效了**:卡把位流原样塞进一个**仍然自称 PCM** 的媒体类型(厂商插件正是靠"每次回调问一次
+ `IsAudioFormatNonPcm()`"来判断的,说明媒体类型本身不带这个信息)。
+
+这两种情况下 `device bitstream types` 都可能是 0,用耳朵也分不出来(后者是噪音,前者是正常游戏声)。
+唯一可靠的区别是**字节本身**:IEC 61937 的突发头是自同步的。
+
+所以新增一个小探针,挂在现有 PCM 回调上,**只读、不改路**:
+
+- 扫 `F8 72 4E 1F` → 读 data-type 与 payload 长度 → 要求**至少两个同类突发**才判定;
+- 上限 1 MiB,判定即停;跨回调只保留 8 字节尾巴(处理头被切断的情况);
+- 判定一次就写一行日志,之后不再参与任何逻辑。
+
+顺带把 data-type 映射做成可测的纯函数 `classifyIec61937DataType()`(0x01 AC-3 / 0x15 E-AC-3 /
+0x0B–0x0D DTS / 0x11 DTS-HD / 0x16 TrueHD),下一步真正接线时直接复用。
+
+**这一步刻意不做的事**:不把位流改道去解码。那条音频路径刚经过 20 ms 储备、10 ms 协商、
+欠载/漂移修复,没有真卡的情况下盲改,等于把现场问题换成新问题。先把事实拿到手。
+
---
## 2. 实测证据(全部来自本机,可复核)
@@ -132,6 +155,26 @@ DELIVERY SHORT GATE PASS (exit 0)
logs\delivery\084be258e4834f7d958efa997a0b40c1\result.json
```
+### 2.6 载体探针单测
+
+`tests/unit/Iec61937ProbeTests.cpp` → `veyra_iec61937_probe_tests.exe`(21 项全过):
+
+```
+ok data type 0x01/0x15/0x0B/0x0C/0x0D/0x11/0x16 映射正确
+ok an unknown data type is rejected / data type 0 is rejected
+[capture-audio-carrier] IEC 61937 detected on the PCM-labelled carrier: dataType=0x15 (E-AC-3/DD+) bursts=2
+ok two E-AC-3 bursts conclude the probe / are reported as IEC 61937
+ok a partial header alone does not conclude the probe
+ok bursts split across two feeds are still detected ← 头被切断的情况
+ok unknown data types are never accepted as a bitstream
+ok the probe reaches a verdict within its scan budget
+ok a single burst followed by PCM is rejected ← 反例:偶然命中 sync 不算证据
+ok 64 KB of PCM does not conclude the probe
+PASS (0 failures)
+```
+
+探针改动后重跑交付短测仍为 PASS:`logs\delivery\427e950eeb6f4db5b0b2273d9be87139\result.json`。
+
---
## 3. 用户侧怎么验收(这是唯一还没走完的一步)
@@ -145,13 +188,18 @@ logs\delivery\084be258e4834f7d958efa997a0b40c1\result.json
- `chipFormat=<其它>` → 组件在跑但源不是 Dolby;
- `card not reached: getAudioFormat ret=5` → 没插卡/被别的软件占着;
- `not installed` → 组件没找到(可用环境变量指路)。
-5. 紧接着看 `[capture-audio-bitstream] device bitstream types=?`:
- - **非 0** → 卡切换后真的换了媒体类型,现有"位流优先"链路直接吃下,5.1 应当立刻可用;
- - **仍然是 0** → 说明切换只改载荷不改媒体类型(调研报告 2.4 的推断成立),下一步要做的是
- 在 PCM 标签流上嗅探 IEC 61937 同步字 `F8 72 4E 1F` 并按 data-type 选解码器;**在那之前,
- 这种情况下的声音会是位流被当 PCM 播出来的噪音,不是正常的 2.0**。
-
-第 5 步是这次唯一无法在本机回答的问题——本机没有卡,也没有 5.1 源。
+5. 看 `[capture-audio-bitstream] device bitstream types=?`:
+ - **非 0** → 卡切换后真的换了媒体类型,现有"位流优先"链路直接吃下,5.1 立刻可用,收工;
+ - **仍然是 0** → 看下一行。
+6. 看 `[capture-audio-carrier]`:
+ - `IEC 61937 detected ... dataType=0x15 (E-AC-3/DD+)` → 切换生效,载荷确实是位流,
+ 而媒体类型没变。此时声音会是"位流当 PCM 播"的噪音;下一步就是把这条已验证的字节流
+ 接到现有 `BitstreamDecoder`(代码位置、判定条件都已经明确,改动小且可测)。
+ - `no IEC 61937 burst in the first N bytes ... treating it as linear PCM` → 切换没有改变载荷,
+ 听到的仍然是正常的 2.0,说明卡在这个固件/设置下没被切换过去。
+
+这三行日志就是这次唯一无法在本机回答的问题的答案——本机没有卡,也没有 5.1 源。
+无论落在哪一支,都不需要再靠"听起来对不对"来判断。
---
@@ -159,6 +207,8 @@ logs\delivery\084be258e4834f7d958efa997a0b40c1\result.json
- **真卡未验收**:本机没有 GC553G2,`SwitchDeviceThenDetectAudioFormat` 走到"找不到设备"就结束了;
真正把卡切到 non-PCM、以及切换后端点媒体类型是否变化,都还没有观测。
+- **载体探针只给结论,不改路**:它不会把位流送去解码。在"切换生效但媒体类型不变"这一支,
+ 用户会听到噪音——这是已知且刻意保留的状态,目的是先用一行日志把事实钉死。
- **只验证到组件加载与调用**:`initialize` 后的真实设备交互、`StartChecking` 线程在长时运行下的行为未验证。
- **退出不还原模式**:`stop()` 只 `StopChecking` + `closePort/uninitialize`,不调 `setNonPcmOnOff(0)`
——这与厂商插件行为一致(它也不还原)。副作用是:之后若用**没有**装插件的软件采集同一端点,
diff --git a/include/veyra/sink/BitstreamAudio.h b/include/veyra/sink/BitstreamAudio.h
index d68069e4..3816faa8 100644
--- a/include/veyra/sink/BitstreamAudio.h
+++ b/include/veyra/sink/BitstreamAudio.h
@@ -35,6 +35,46 @@ int bitstreamPreferenceOrder(BitstreamKind kind);
// be unwrapped before the codec parser sees them.
bool bitstreamIsIec61937(uint32_t subtypeData1);
+// IEC 61937 burst header: sync 0xF8724E1F, then a 16-bit data-type word and a
+// 16-bit payload length in bits. Mapping a data-type to a codec family is how a
+// compressed stream is recognised when the endpoint labels it as plain PCM:
+// the AVerMedia capture cards forward the Dolby stream on a 2-channel carrier
+// whose media type does not change (see AverMediaAudioSwitch.h).
+BitstreamKind classifyIec61937DataType(uint16_t dataType);
+
+// Read-only carrier probe.
+//
+// Some capture cards deliver an IEC 61937 compressed stream *inside* a media
+// type that still claims linear PCM. Guessing from the device's declared
+// format is not safe - the same card also downmixes Dolby to real 2.0 PCM when
+// passthrough is not armed - so the only reliable discriminator is the bytes
+// themselves. This probe scans for valid bursts, requires at least two of the
+// same data-type, and then stops; it never changes what is played.
+//
+// Bounded by design: scanning stops after kMaxScanBytes or on a verdict, and
+// only an 8-byte tail is retained between calls.
+class Iec61937Probe {
+public:
+ static constexpr size_t kMaxScanBytes = 1u << 20;
+
+ // Feed carrier bytes in arrival order. Thread-affine: call from the one
+ // thread that delivers samples. Logs its verdict exactly once.
+ void feed(const uint8_t* data, size_t bytes);
+
+ bool concluded() const;
+ bool detected() const;
+ uint16_t dataType() const;
+ size_t scannedBytes() const;
+ unsigned burstCount() const;
+
+private:
+ std::vector<uint8_t> tail_;
+ size_t scanned_ = 0;
+ uint16_t type_ = 0;
+ unsigned bursts_ = 0;
+ int verdict_ = 0; // 0 = undecided, 1 = IEC 61937, -1 = not IEC 61937
+};
+
class BitstreamDecoder {
public:
BitstreamDecoder();
diff --git a/src/sink/BitstreamAudio.cpp b/src/sink/BitstreamAudio.cpp
index d5e317a7..2b6c9edb 100644
--- a/src/sink/BitstreamAudio.cpp
+++ b/src/sink/BitstreamAudio.cpp
@@ -9,6 +9,7 @@ extern "C" {
}
#include <cstring>
+#include <format>
namespace veyra::sink {
namespace {
@@ -75,6 +76,77 @@ bool bitstreamIsIec61937(uint32_t subtypeData1) {
return subtypeData1 == 0x00000092u; // S/PDIF framed AC-3 carrier
}
+BitstreamKind classifyIec61937DataType(uint16_t dataType) {
+ switch (dataType) {
+ case 0x01: return BitstreamKind::Ac3;
+ case 0x15: return BitstreamKind::Eac3;
+ case 0x0B:
+ case 0x0C:
+ case 0x0D: return BitstreamKind::Dts;
+ case 0x11: return BitstreamKind::DtsHd;
+ case 0x16: return BitstreamKind::TrueHd;
+ default: return BitstreamKind::None;
+ }
+}
+
+void Iec61937Probe::feed(const uint8_t* data, size_t bytes) {
+ if (verdict_ != 0 || data == nullptr || bytes == 0) return;
+ if (scanned_ >= kMaxScanBytes) {
+ verdict_ = -1;
+ log::info("capture-audio-carrier", std::format(
+ "no IEC 61937 burst in the first {} bytes of the carrier; treating it as linear PCM", scanned_));
+ return;
+ }
+ tail_.insert(tail_.end(), data, data + bytes);
+ size_t cursor = 0;
+ const size_t size = tail_.size();
+ while (cursor + kIecHeader <= size) {
+ if (scanned_ + cursor >= kMaxScanBytes) break;
+ if (std::memcmp(tail_.data() + cursor, kIecSync, 4) != 0) {
+ ++cursor;
+ continue;
+ }
+ const uint16_t dataType = uint16_t(tail_[cursor + 4]) | (uint16_t(tail_[cursor + 5]) << 8);
+ const size_t payloadBits = size_t(tail_[cursor + 6]) | (size_t(tail_[cursor + 7]) << 8);
+ const bool plausible = payloadBits >= 8 && classifyIec61937DataType(dataType) != BitstreamKind::None;
+ if (plausible) {
+ if (bursts_ == 0) type_ = dataType;
+ if (dataType == type_) {
+ ++bursts_;
+ if (bursts_ >= 2) {
+ verdict_ = 1;
+ scanned_ += cursor + kIecHeader;
+ log::info("capture-audio-carrier", std::format(
+ "IEC 61937 detected on the PCM-labelled carrier: dataType=0x{:02X} ({}) bursts={} scannedBytes={}",
+ type_, bitstreamKindName(classifyIec61937DataType(type_)), bursts_, scanned_));
+ tail_.clear();
+ return;
+ }
+ }
+ }
+ // A false sync inside random PCM must not stall the scan.
+ cursor += 4;
+ }
+ scanned_ += cursor;
+ // Keep only what a burst header could still straddle.
+ if (cursor < size) tail_.erase(tail_.begin(), tail_.begin() + cursor);
+ else tail_.clear();
+ // Reaching the budget inside this call must be as final as reaching it on
+ // the next one, otherwise a single large delivery would leave the verdict
+ // pending forever.
+ if (verdict_ == 0 && scanned_ >= kMaxScanBytes) {
+ verdict_ = -1;
+ log::info("capture-audio-carrier", std::format(
+ "no IEC 61937 burst in the first {} bytes of the carrier; treating it as linear PCM", scanned_));
+ }
+}
+
+bool Iec61937Probe::concluded() const { return verdict_ != 0; }
+bool Iec61937Probe::detected() const { return verdict_ == 1; }
+uint16_t Iec61937Probe::dataType() const { return verdict_ == 1 ? type_ : 0; }
+size_t Iec61937Probe::scannedBytes() const { return scanned_; }
+unsigned Iec61937Probe::burstCount() const { return bursts_; }
+
struct BitstreamDecoder::Impl {
AVCodecContext* context = nullptr;
AVCodecParserContext* parser = nullptr;
diff --git a/src/source/CaptureCardSource.cpp b/src/source/CaptureCardSource.cpp
index 4eebaa63..8064e5ff 100644
--- a/src/source/CaptureCardSource.cpp
+++ b/src/source/CaptureCardSource.cpp
@@ -230,6 +230,11 @@ struct CaptureCardSource::Impl:ISampleGrabberCB {
std::shared_ptr<sink::BitstreamAudioSink> audioPassthrough;
bool audioSessionDeferred=false;
std::wstring audioBitstreamKind;
+ // Read-only IEC 61937 probe on the PCM carrier. AVerMedia cards can deliver
+ // the Dolby stream inside a media type that still says PCM, and the same
+ // card downmixes to real 2.0 when passthrough is not armed - only the bytes
+ // tell the two apart. Observational: it never changes what is played.
+ std::shared_ptr<sink::Iec61937Probe> carrierProbe;
// AVerMedia GC553G2 / GC553PRO / GC575 only forward compressed HDMI audio
// after the installed vendor component arms non-PCM passthrough. The
// component is loaded from the user's own OBS installation (never
@@ -783,9 +788,11 @@ if(audioTypes.empty()&&(!allowBitstream||bitstreamTypes.empty())){log::warn("cap
sink::WavePcmFormat parsed{};
if(type->formattype==FORMAT_WaveFormatEx&&type->pbFormat&&type->cbFormat>=sizeof(WAVEFORMATEX)&&sink::parseWavePcm(type->pbFormat,type->cbFormat,parsed)&&session->configure(parsed)){
auto* target=session.get();
- hr=createNativeAudioSink(*type,[target](IMediaSample* sample){
+ auto probe=std::make_shared<sink::Iec61937Probe>();
+ hr=createNativeAudioSink(*type,[target,probe](IMediaSample* sample){
BYTE* bytes=nullptr;REFERENCE_TIME begin=0,end=0;
if(FAILED(sample->GetPointer(&bytes))||FAILED(sample->GetTime(&begin,&end)))return VFW_E_SAMPLE_TIME_NOT_SET;
+ probe->feed(bytes,size_t(sample->GetActualDataLength()));
return target->push(bytes,size_t(sample->GetActualDataLength()),double(begin)/10000,sample->IsDiscontinuity()==S_OK)?S_OK:E_FAIL;
},candidate,terminal);
if(SUCCEEDED(hr))hr=p.graph->AddFilter(candidate.Get(),L"Veyra audio PCM");
@@ -794,7 +801,7 @@ if(audioTypes.empty()&&(!allowBitstream||bitstreamTypes.empty())){log::warn("cap
// Some devices reject this advisory API, so do not fail capture.
if(SUCCEEDED(hr))suggestCaptureAudioBuffering(audioPin.Get(),*reinterpret_cast<const WAVEFORMATEX*>(type->pbFormat));
if(SUCCEEDED(hr))hr=p.graph->ConnectDirect(audioPin.Get(),terminal.Get(),type);
- if(SUCCEEDED(hr)){p.audioSink=candidate;p.audioSession=std::move(session);connectedAudio=true;log::info("capture-audio",std::format("selected media type channels={} mask=0x{:X} rate={} containerBits={} validBits={} floating={}",parsed.layout.channels,parsed.layout.mask,parsed.wave.nSamplesPerSec,parsed.wave.wBitsPerSample,parsed.validBits,parsed.floating?1:0));}
+ if(SUCCEEDED(hr)){p.audioSink=candidate;p.audioSession=std::move(session);p.carrierProbe=probe;connectedAudio=true;log::info("capture-audio",std::format("selected media type channels={} mask=0x{:X} rate={} containerBits={} validBits={} floating={}",parsed.layout.channels,parsed.layout.mask,parsed.wave.nSamplesPerSec,parsed.wave.wBitsPerSample,parsed.validBits,parsed.floating?1:0));}
else if(candidate)p.graph->RemoveFilter(candidate.Get());
log::info("capture-audio",std::format("PCM ConnectDirect hr=0x{:X}",unsigned(hr)));
}
diff --git a/tests/unit/Iec61937ProbeTests.cpp b/tests/unit/Iec61937ProbeTests.cpp
new file mode 100644
index 00000000..c4b0a295
--- /dev/null
+++ b/tests/unit/Iec61937ProbeTests.cpp
@@ -0,0 +1,126 @@
+// Unit checks for the read-only IEC 61937 carrier probe.
+//
+// The probe exists because a capture card can deliver a compressed stream
+// inside a media type that still claims linear PCM, while the same card also
+// downmixes to real 2.0 when passthrough is not armed. These checks pin down
+// the two properties that make the diagnostic trustworthy: it confirms only on
+// repeated, consistent bursts, and it stays bounded and silent otherwise.
+
+#include "veyra/sink/BitstreamAudio.h"
+
+#include <cstdint>
+#include <cstdio>
+#include <vector>
+
+namespace {
+
+int failures = 0;
+
+void check(bool condition, const char* what) {
+ if (condition) {
+ std::printf("ok %s\n", what);
+ } else {
+ std::printf("FAIL %s\n", what);
+ ++failures;
+ }
+}
+
+// One IEC 61937 burst: 4-byte sync, 16-bit data type, 16-bit payload length in
+// bits, then the payload. Payload bytes are arbitrary here: the probe only
+// validates the header, and a real decoder never sees these fixtures.
+void appendBurst(std::vector<uint8_t>& out, uint16_t dataType, size_t payloadBytes) {
+ out.push_back(0xF8); out.push_back(0x72); out.push_back(0x4E); out.push_back(0x1F);
+ out.push_back(uint8_t(dataType & 0xFF));
+ out.push_back(uint8_t(dataType >> 8));
+ const uint16_t bits = uint16_t(payloadBytes * 8);
+ out.push_back(uint8_t(bits & 0xFF));
+ out.push_back(uint8_t(bits >> 8));
+ out.insert(out.end(), payloadBytes, 0x5A);
+}
+
+// Deterministic PCM-ish noise: no accidental sync word, exercises the
+// "never conclude early" path without depending on a random seed.
+void appendPcmNoise(std::vector<uint8_t>& out, size_t bytes) {
+ uint32_t state = 0x12345678u;
+ for (size_t i = 0; i < bytes; ++i) {
+ state = state * 1664525u + 1013904223u;
+ uint8_t value = uint8_t(state >> 24);
+ if (value == 0xF8) value = 0xF7; // keep the fixture free of sync bytes
+ out.push_back(value);
+ }
+}
+
+} // namespace
+
+int wmain() {
+ using veyra::sink::BitstreamKind;
+ using veyra::sink::Iec61937Probe;
+
+ check(veyra::sink::classifyIec61937DataType(0x01) == BitstreamKind::Ac3, "data type 0x01 maps to AC-3");
+ check(veyra::sink::classifyIec61937DataType(0x15) == BitstreamKind::Eac3, "data type 0x15 maps to E-AC-3");
+ check(veyra::sink::classifyIec61937DataType(0x0B) == BitstreamKind::Dts, "data type 0x0B maps to DTS");
+ check(veyra::sink::classifyIec61937DataType(0x0C) == BitstreamKind::Dts, "data type 0x0C maps to DTS");
+ check(veyra::sink::classifyIec61937DataType(0x0D) == BitstreamKind::Dts, "data type 0x0D maps to DTS");
+ check(veyra::sink::classifyIec61937DataType(0x11) == BitstreamKind::DtsHd, "data type 0x11 maps to DTS-HD");
+ check(veyra::sink::classifyIec61937DataType(0x16) == BitstreamKind::TrueHd, "data type 0x16 maps to TrueHD");
+ check(veyra::sink::classifyIec61937DataType(0x42) == BitstreamKind::None, "an unknown data type is rejected");
+ check(veyra::sink::classifyIec61937DataType(0x00) == BitstreamKind::None, "data type 0 is rejected");
+
+ { // Two consistent bursts in one buffer: confirmed.
+ std::vector<uint8_t> carrier;
+ appendBurst(carrier, 0x15, 384);
+ appendBurst(carrier, 0x15, 384);
+ Iec61937Probe probe;
+ probe.feed(carrier.data(), carrier.size());
+ check(probe.concluded(), "two E-AC-3 bursts conclude the probe");
+ check(probe.detected(), "two E-AC-3 bursts are reported as IEC 61937");
+ check(probe.dataType() == 0x15, "the reported data type is E-AC-3");
+ check(probe.burstCount() >= 2, "the burst count is recorded");
+ }
+
+ { // Bursts straddling a buffer boundary must still be found.
+ std::vector<uint8_t> carrier;
+ appendBurst(carrier, 0x01, 512);
+ appendBurst(carrier, 0x01, 512);
+ Iec61937Probe probe;
+ const size_t split = 5; // inside the first header
+ probe.feed(carrier.data(), split);
+ check(!probe.concluded(), "a partial header alone does not conclude the probe");
+ probe.feed(carrier.data() + split, carrier.size() - split);
+ check(probe.detected(), "bursts split across two feeds are still detected");
+ check(probe.dataType() == 0x01, "the split case reports AC-3");
+ }
+
+ { // A sync word followed by an unknown data type is not evidence.
+ std::vector<uint8_t> carrier;
+ appendBurst(carrier, 0x42, 384);
+ appendBurst(carrier, 0x42, 384);
+ Iec61937Probe probe;
+ probe.feed(carrier.data(), carrier.size());
+ check(!probe.detected(), "unknown data types are never accepted as a bitstream");
+ }
+
+ { // One burst is not enough, and the scan must terminate on its own.
+ std::vector<uint8_t> carrier;
+ appendBurst(carrier, 0x01, 512);
+ appendPcmNoise(carrier, Iec61937Probe::kMaxScanBytes);
+ Iec61937Probe probe;
+ probe.feed(carrier.data(), carrier.size());
+ check(probe.concluded(), "the probe reaches a verdict within its scan budget");
+ check(!probe.detected(), "a single burst followed by PCM is rejected");
+ check(probe.scannedBytes() <= Iec61937Probe::kMaxScanBytes + 64,
+ "scanning stays inside the documented budget");
+ }
+
+ { // Plain PCM must stay silent (no verdict) until the budget runs out.
+ std::vector<uint8_t> pcm;
+ appendPcmNoise(pcm, 64 * 1024);
+ Iec61937Probe probe;
+ probe.feed(pcm.data(), pcm.size());
+ check(!probe.concluded(), "64 KB of PCM does not conclude the probe");
+ check(!probe.detected(), "64 KB of PCM is not reported as a bitstream");
+ }
+
+ std::printf("%s (%d failure%s)\n", failures == 0 ? "PASS" : "FAIL", failures, failures == 1 ? "" : "s");
+ return failures == 0 ? 0 : 1;
+}