46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
"""Небольшой H.264-контроль IQ → CRC → внешний FEC → показ кадров."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import numpy as np
|
|
import pytest
|
|
|
|
from tools.video005_video import VideoFixture, build_fixture, run_case
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def synthetic_video() -> VideoFixture:
|
|
rows, columns = np.mgrid[0:360, 0:640]
|
|
frames = [np.stack(((columns + index * 17) % 256,
|
|
(rows + index * 11) % 256,
|
|
(columns // 2 + rows // 3 + index * 29) % 256), axis=-1
|
|
).astype(np.uint8)
|
|
for index in range(3)]
|
|
return build_fixture(3, pixels_override=frames)
|
|
|
|
|
|
def test_clean_h264_from_raw_iq_displays_three_unique_frames(
|
|
synthetic_video: VideoFixture,
|
|
) -> None:
|
|
result = run_case(synthetic_video, "clean", decoder_backend="legacy")
|
|
video = result["video"]
|
|
assert result["exact_crc_packets"]
|
|
assert result["crc_valid_radio_packets"] == len(synthetic_video.transmissions)
|
|
assert video["displayed_frame_ids"] == [0, 1, 2]
|
|
assert video["displayed_fps"] == 10
|
|
assert video["max_frame_age_ms"] < 300
|
|
assert video["wrong_encoded_frames"] == video["wrong_decoded_frames"] == 0
|
|
assert not video["old_frame_replay"]
|
|
|
|
|
|
def test_corrupted_iq_packet_is_erased_before_h264(
|
|
synthetic_video: VideoFixture,
|
|
) -> None:
|
|
result = run_case(synthetic_video, "corrupt_packet", decoder_backend="legacy")
|
|
video = result["video"]
|
|
assert result["exact_crc_packets"]
|
|
assert result["crc_valid_radio_packets"] == len(synthetic_video.transmissions) - 1
|
|
assert video["recovered_fragments"] == 1
|
|
assert video["displayed_frame_ids"] == [0, 1, 2]
|
|
assert video["wrong_encoded_frames"] == video["wrong_decoded_frames"] == 0
|