Complete VIDEO-001 through VIDEO-004 software video studies
This commit is contained in:
48
tests/test_video_001_compare.py
Normal file
48
tests/test_video_001_compare.py
Normal file
@@ -0,0 +1,48 @@
|
||||
"""Проверки измерителя VIDEO-001 без камеры, SDR и исходного ролика."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from tools.video_compare import fit_frame, h264_case, jpeg_case, peak_second, radio_screen
|
||||
|
||||
|
||||
def test_four_by_three_output_preserves_source_geometry() -> None:
|
||||
source = np.full((72, 128, 3), 128, dtype=np.uint8)
|
||||
result = fit_frame(source, 640, 480)
|
||||
assert result.shape == (480, 640, 3)
|
||||
assert np.all(result[:60] == 0)
|
||||
assert np.all(result[60:420] == 128)
|
||||
assert np.all(result[420:] == 0)
|
||||
|
||||
|
||||
def test_h264_restores_exact_decoding_at_next_reference_frame(tmp_path) -> None:
|
||||
frames = []
|
||||
for index in range(10):
|
||||
frame = np.zeros((96, 128, 3), dtype=np.uint8)
|
||||
frame[:, :, 1] = 30 + index * 12
|
||||
frame[30:60, index * 5:index * 5 + 30, 0] = 250
|
||||
frames.append(frame)
|
||||
result = h264_case(frames, 5, 160_000, tmp_path / "example")
|
||||
assert result["decoded_frame_count"] == 10
|
||||
assert result["unique_decoded_frames"] == 10
|
||||
assert len(result["keyframe_sizes_bytes"]) == 2
|
||||
assert result["loss_recovery"]["lost_reference"]["first_exact_frame"] == 5
|
||||
assert result["loss_recovery"]["lost_delta"]["first_exact_frame"] == 5
|
||||
|
||||
|
||||
def test_jpeg_restores_on_the_next_independent_frame(tmp_path) -> None:
|
||||
frames = [np.full((32, 32, 3), index * 25, dtype=np.uint8) for index in range(5)]
|
||||
result = jpeg_case(frames, 5, tmp_path / "jpeg")
|
||||
assert result["decoded_frame_count"] == 5
|
||||
assert result["loss_recovery"]["first_exact_frame"] == 1
|
||||
|
||||
|
||||
def test_packetization_and_one_second_peak_do_not_use_mean_bitrate() -> None:
|
||||
assert peak_second([100, 100, 1000, 100, 100, 100], 2) == 8_800
|
||||
small = radio_screen([244] * 5, 5)
|
||||
assert small["peak_packet_slots_per_second"] == 5
|
||||
assert small["fits_current_radio_budget"] == "NOT_ESTABLISHED_NO_SUSTAINED_GOODPUT_TEST"
|
||||
large = radio_screen([10_000] * 5, 5)
|
||||
assert large["peak_packet_slots_per_second"] == 205
|
||||
assert large["fits_current_radio_budget"] == "NO_ON_OBSERVED_BURST_SCREEN"
|
||||
Reference in New Issue
Block a user