tests: fix benchmark (yuv420p fixture, identity probe frame counter)
This commit is contained in:
@@ -77,7 +77,7 @@ def _generate_test_video(path: str, Gst, GLib) -> None:
|
|||||||
print(f" (duration={GENERATE_DURATION}s, size=1920x1080, rate={GENERATE_FPS}/1)")
|
print(f" (duration={GENERATE_DURATION}s, size=1920x1080, rate={GENERATE_FPS}/1)")
|
||||||
pipe_str = (
|
pipe_str = (
|
||||||
f"videotestsrc num-buffers={GENERATE_DURATION * GENERATE_FPS} "
|
f"videotestsrc num-buffers={GENERATE_DURATION * GENERATE_FPS} "
|
||||||
f"! video/x-raw,width=1920,height=1080,framerate={GENERATE_FPS}/1 "
|
f"! video/x-raw,width=1920,height=1080,framerate={GENERATE_FPS}/1,format=I420 "
|
||||||
f"! avenc_h264 bitrate=4000000 "
|
f"! avenc_h264 bitrate=4000000 "
|
||||||
f"! h264parse ! mp4mux ! filesink location={path}"
|
f"! h264parse ! mp4mux ! filesink location={path}"
|
||||||
)
|
)
|
||||||
@@ -151,6 +151,16 @@ def _run_benchmark(
|
|||||||
sink.set_property("max-buffers", 4)
|
sink.set_property("max-buffers", 4)
|
||||||
sink.set_property("drop", False)
|
sink.set_property("drop", False)
|
||||||
sink.connect("new-sample", on_new_sample)
|
sink.connect("new-sample", on_new_sample)
|
||||||
|
else:
|
||||||
|
# fakesink path: count frames via identity handoff signal
|
||||||
|
probe = pipeline.get_by_name("probe")
|
||||||
|
if probe:
|
||||||
|
def on_handoff(elem, buf, pad):
|
||||||
|
n = frame_count[0]
|
||||||
|
frame_count[0] = n + 1
|
||||||
|
if n >= WARMUP_FRAMES:
|
||||||
|
frame_times.append(time.monotonic())
|
||||||
|
probe.connect("handoff", on_handoff)
|
||||||
|
|
||||||
loop = GLib.MainLoop()
|
loop = GLib.MainLoop()
|
||||||
|
|
||||||
@@ -180,7 +190,7 @@ def _run_benchmark(
|
|||||||
wall = t_wall_end - t_wall_start
|
wall = t_wall_end - t_wall_start
|
||||||
cpu_pct = _cpu_percent(*cpu_before, *cpu_after)
|
cpu_pct = _cpu_percent(*cpu_before, *cpu_after)
|
||||||
|
|
||||||
if is_appsink and len(frame_times) >= 2:
|
if len(frame_times) >= 2:
|
||||||
measure_frames = len(frame_times)
|
measure_frames = len(frame_times)
|
||||||
measure_wall = frame_times[-1] - frame_times[0]
|
measure_wall = frame_times[-1] - frame_times[0]
|
||||||
fps = (measure_frames - 1) / measure_wall if measure_wall > 0 else 0
|
fps = (measure_frames - 1) / measure_wall if measure_wall > 0 else 0
|
||||||
@@ -243,7 +253,8 @@ def main() -> None:
|
|||||||
# 1. SW fakesink — pure decode throughput
|
# 1. SW fakesink — pure decode throughput
|
||||||
if av_ok:
|
if av_ok:
|
||||||
_set_mpp_rank(GST_RANK_NONE) # ensure avdec_h264 wins
|
_set_mpp_rank(GST_RANK_NONE) # ensure avdec_h264 wins
|
||||||
pipe = f"filesrc location={video_path} ! decodebin ! fakesink sync=false"
|
pipe = (f"filesrc location={video_path} ! decodebin "
|
||||||
|
f"! identity name=probe signal-handoffs=true ! fakesink sync=false")
|
||||||
results.append(_run_benchmark(
|
results.append(_run_benchmark(
|
||||||
"SW fakesink (avdec_h264 → discard)",
|
"SW fakesink (avdec_h264 → discard)",
|
||||||
video_path, pipe, is_appsink=False, Gst=Gst, GLib=GLib,
|
video_path, pipe, is_appsink=False, Gst=Gst, GLib=GLib,
|
||||||
@@ -265,7 +276,8 @@ def main() -> None:
|
|||||||
# 3. HW fakesink — pure MPP decode throughput
|
# 3. HW fakesink — pure MPP decode throughput
|
||||||
if mpp_ok:
|
if mpp_ok:
|
||||||
_set_mpp_rank(MPP_RANK_HIGH) # prefer mppvideodec
|
_set_mpp_rank(MPP_RANK_HIGH) # prefer mppvideodec
|
||||||
pipe = f"filesrc location={video_path} ! decodebin ! fakesink sync=false"
|
pipe = (f"filesrc location={video_path} ! decodebin "
|
||||||
|
f"! identity name=probe signal-handoffs=true ! fakesink sync=false")
|
||||||
results.append(_run_benchmark(
|
results.append(_run_benchmark(
|
||||||
"HW fakesink (mppvideodec → discard)",
|
"HW fakesink (mppvideodec → discard)",
|
||||||
video_path, pipe, is_appsink=False, Gst=Gst, GLib=GLib,
|
video_path, pipe, is_appsink=False, Gst=Gst, GLib=GLib,
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
Reference in New Issue
Block a user