Complete VIDEO-001 through VIDEO-004 software video studies

This commit is contained in:
LittleSam129
2026-09-16 18:27:35 +03:00
parent af7c05f2da
commit 95f664076a
403 changed files with 392009 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
"""Побитовая эквивалентность JIT и исходного Витерби."""
from __future__ import annotations
import numpy as np
import pytest
pytest.importorskip("numba")
from protocol import punctured_fec
from protocol.video004_viterbi import decode_soft
from tools.video004_benchmark import load_fixture, decode_stream
@pytest.mark.parametrize("rate", ["1/2", "2/3", "3/4"])
@pytest.mark.parametrize("byte_count", [13, 256, 1012])
def test_jit_matches_legacy_under_noise(rate: str, byte_count: int) -> None:
generator = np.random.default_rng(4004 + byte_count)
bits = generator.integers(0, 2, byte_count * 8, dtype=np.uint8)
coded = punctured_fec.encode(bits, rate)
soft = 2.0 * coded.astype(np.float64) - 1.0
soft += generator.normal(0, 0.8, len(soft))
expected = punctured_fec.decode_soft(soft, len(bits), rate)
actual = decode_soft(soft, len(bits), rate)
assert np.array_equal(actual, expected)
def test_canonical_qpsk_decisions_fec_crc_and_packets_are_equal() -> None:
received, manifest = load_fixture()
before = decode_stream(received, "legacy")
after = decode_stream(received, "numba")
assert before == after
assert len(after) == 32
assert [row["packet_sha256"] for row in after] == manifest["expected_packet_sha256"]