52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
"""Повторные фиксированные затравки для выбора защиты NORMAL 640×360/10."""
|
||
|
||
from __future__ import annotations
|
||
|
||
import argparse
|
||
import json
|
||
from pathlib import Path
|
||
|
||
from tools.video004_transport import (
|
||
BASELINE_160, BASELINE_320, CODEC_RESULTS, OUTPUT, _frames, simulate,
|
||
)
|
||
|
||
|
||
DEFAULT_OUTPUT = OUTPUT.with_name("normal_seed_sweep.json")
|
||
SEEDS = tuple(range(20260916, 20260921))
|
||
VARIANTS = (("2/3", 8, 1, False), ("2/3", 8, 1, True),
|
||
("2/3", 8, 2, False), ("3/4", 8, 1, False),
|
||
("3/4", 8, 1, True), ("3/4", 8, 2, False))
|
||
|
||
|
||
def run() -> dict:
|
||
codec = json.loads(CODEC_RESULTS.read_text(encoding="utf-8"))
|
||
baseline = json.loads(BASELINE_320.read_text(encoding="utf-8"))
|
||
baseline_160 = json.loads(BASELINE_160.read_text(encoding="utf-8"))
|
||
cases = []
|
||
for window in baseline["windows"]:
|
||
combined, _ = _frames("NORMAL", 640, 360, 10, window, codec, baseline_160)
|
||
frames = [frame for frame in combined if frame.stream_id == 0x56303334]
|
||
for rate, k, r, boost in VARIANTS:
|
||
for loss in (1, 5, 10):
|
||
for seed in SEEDS:
|
||
item = simulate(frames, 10, rate, k, r, ("random", loss),
|
||
keyframe_boost=boost, seed=seed)
|
||
item["window"] = window["name"]
|
||
cases.append(item)
|
||
return {"source_sha256": codec["source_sha256"], "seeds": list(SEEDS),
|
||
"cases": cases, "rf_tx": 0}
|
||
|
||
|
||
def main() -> None:
|
||
parser = argparse.ArgumentParser(description=__doc__)
|
||
parser.add_argument("--output", type=Path, default=DEFAULT_OUTPUT)
|
||
args = parser.parse_args()
|
||
result = run()
|
||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||
args.output.write_text(json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8")
|
||
print(f"NORMAL: {len(result['cases'])} случаев, {len(SEEDS)} затравок; {args.output}")
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|