-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integrity tests that compare source and output files for st20p and st30p. In st20p the files are compared by frame checksums, in st30p the files are compared by bytes.
- Loading branch information
Showing
8 changed files
with
285 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright(c) 2024-2025 Intel Corporation | ||
|
||
import hashlib | ||
import re | ||
from math import floor | ||
|
||
from tests.Engine.execute import log_fail | ||
|
||
|
||
def check_st20p_integrity(src_url: str, out_url: str, frame_size: int): | ||
src_chunk_sums = [] | ||
|
||
with open(src_url, "rb") as f: | ||
while chunk := f.read(frame_size): | ||
chunk_sum = hashlib.md5(chunk).hexdigest() | ||
src_chunk_sums.append(chunk_sum) | ||
|
||
out_chunk_sums = [] | ||
|
||
with open(out_url, "rb") as f: | ||
while chunk := f.read(frame_size): | ||
chunk_sum = hashlib.md5(chunk).hexdigest() | ||
out_chunk_sums.append(chunk_sum) | ||
|
||
if len(src_chunk_sums) < len(out_chunk_sums): | ||
for i in range(len(src_chunk_sums)): | ||
if src_chunk_sums[i] != out_chunk_sums[i]: | ||
log_fail(f"Received frame {i} is invalid") | ||
return False | ||
else: | ||
for i in range(len(out_chunk_sums)): | ||
if out_chunk_sums[i] != src_chunk_sums[i]: | ||
log_fail(f"Received frame {i} is invalid") | ||
return False | ||
|
||
return True | ||
|
||
|
||
def calculate_yuv_frame_size(width: int, height: int, file_format: str): | ||
match file_format: | ||
case "YUV422RFC4175PG2BE10": | ||
pixel_size = 2.5 | ||
case "YUV422PLANAR10LE": | ||
pixel_size = 4 | ||
case _: | ||
log_fail(f"Size of {file_format} pixel is not known") | ||
|
||
return int(width * height * pixel_size) | ||
|
||
|
||
def check_st30p_integrity(src_url: str, out_url: str, size: int): | ||
src_chunks = [] | ||
|
||
with open(src_url, "rb") as f: | ||
while chunk := f.read(size): | ||
src_chunks.append(chunk) | ||
|
||
out_chunks = [] | ||
|
||
with open(out_url, "rb") as f: | ||
while chunk := f.read(size): | ||
out_chunks.append(chunk) | ||
|
||
if len(src_chunks) < len(out_chunks): | ||
for i in range(len(src_chunks)): | ||
if src_chunks[i] != out_chunks[i]: | ||
log_fail(f"Received frame {i} is invalid") | ||
return False | ||
else: | ||
for i in range(len(out_chunks)): | ||
if out_chunks[i] != src_chunks[i]: | ||
log_fail(f"Received frame {i} is invalid") | ||
return False | ||
|
||
return True | ||
|
||
|
||
def calculate_st30p_framebuff_size( | ||
format: str, ptime: str, sampling: str, channel: str | ||
): | ||
match format: | ||
case "PCM8": | ||
sample_size = 1 | ||
case "PCM16": | ||
sample_size = 2 | ||
case "PCM24": | ||
sample_size = 3 | ||
|
||
match sampling: | ||
case "48kHz": | ||
match ptime: | ||
case "1": | ||
sample_num = 48 | ||
case "0.12": | ||
sample_num = 6 | ||
case "0.25": | ||
sample_num = 12 | ||
case "0.33": | ||
sample_num = 16 | ||
case "4": | ||
sample_num = 192 | ||
case "96kHz": | ||
match ptime: | ||
case "1": | ||
sample_num = 96 | ||
case "0.12": | ||
sample_num = 12 | ||
case "0.25": | ||
sample_num = 24 | ||
case "0.33": | ||
sample_num = 32 | ||
case "4": | ||
sample_num = 384 | ||
|
||
match channel: | ||
case "M": | ||
channel_num = 1 | ||
case "DM" | "ST" | "LtRt" | "AES3": | ||
channel_num = 2 | ||
case "51": | ||
channel_num = 6 | ||
case "71": | ||
channel_num = 8 | ||
case "222": | ||
channel_num = 24 | ||
case "SGRP": | ||
channel_num = 4 | ||
case _: | ||
match = re.match(r"^U(\d{2})$", channel) | ||
|
||
if match: | ||
channel_num = int(match.group(1)) | ||
|
||
packet_size = sample_size * sample_num * channel_num | ||
|
||
match ptime: | ||
case "1": | ||
packet_time = 1_000_000 * 1 | ||
case "0.12": | ||
packet_time = 1_000_000 * 0.125 | ||
case "0.25": | ||
packet_time = 1_000_000 * 0.25 | ||
case "0.33": | ||
packet_time = 1_000_000 * 1 / 3 | ||
case "4": | ||
packet_time = 1_000_000 * 4 | ||
|
||
desired_frame_time = 10_000_000 | ||
|
||
packet_per_frame = 1 | ||
|
||
if desired_frame_time > packet_time: | ||
packet_per_frame = floor(desired_frame_time / packet_time) | ||
|
||
return packet_per_frame * packet_size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,6 +189,7 @@ | |
"measure_latency": False, | ||
"display": False, | ||
"enable_rtcp": False, | ||
"st20p_url": "", | ||
} | ||
|
||
# st22p | ||
|
Empty file.
55 changes: 55 additions & 0 deletions
55
tests/validation/tests/single/st20p/integrity/test_integrity.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright(c) 2024-2025 Intel Corporation | ||
|
||
import os | ||
|
||
import pytest | ||
import tests.Engine.RxTxApp as rxtxapp | ||
from tests.Engine.execute import log_info | ||
from tests.Engine.integrity import calculate_yuv_frame_size, check_st20p_integrity | ||
from tests.Engine.logging import LOG_FOLDER | ||
from tests.Engine.media_files import yuv_files_422p10le, yuv_files_422rfc10 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"st20p_file, fps", | ||
[ | ||
(yuv_files_422rfc10["Penguin_720p"], "p25"), | ||
(yuv_files_422rfc10["Penguin_1080p"], "p25"), | ||
(yuv_files_422p10le["Penguin_720p"], "p25"), | ||
(yuv_files_422p10le["Penguin_1080p"], "p25"), | ||
], | ||
) | ||
def test_integrity(build, media, nic_port_list, test_time, st20p_file, fps): | ||
st20p_file_url = os.path.join(media, st20p_file["filename"]) | ||
|
||
out_file_url = os.path.join(os.getcwd(), LOG_FOLDER, "latest", "out.yuv") | ||
|
||
config = rxtxapp.create_empty_config() | ||
config = rxtxapp.add_st20p_sessions( | ||
config=config, | ||
nic_port_list=nic_port_list, | ||
test_mode="unicast", | ||
height=st20p_file["height"], | ||
width=st20p_file["width"], | ||
fps=fps, | ||
input_format=st20p_file["file_format"], | ||
transport_format=st20p_file["format"], | ||
output_format=st20p_file["file_format"], | ||
st20p_url=st20p_file_url, | ||
out_url=out_file_url, | ||
) | ||
|
||
rxtxapp.execute_test(config=config, build=build, test_time=test_time) | ||
|
||
frame_size = calculate_yuv_frame_size( | ||
st20p_file["width"], st20p_file["height"], st20p_file["file_format"] | ||
) | ||
result = check_st20p_integrity( | ||
src_url=st20p_file_url, out_url=out_file_url, frame_size=frame_size | ||
) | ||
|
||
if result: | ||
log_info("INTEGRITY PASS") | ||
else: | ||
log_info("INTEGRITY FAIL") |
Empty file.
Oops, something went wrong.