diff --git a/tests/benchmark_decode.py b/tests/benchmark_decode.py index 1018fe4..3f75010 100644 --- a/tests/benchmark_decode.py +++ b/tests/benchmark_decode.py @@ -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)") pipe_str = ( 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"! h264parse ! mp4mux ! filesink location={path}" ) @@ -151,6 +151,16 @@ def _run_benchmark( sink.set_property("max-buffers", 4) sink.set_property("drop", False) 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() @@ -180,7 +190,7 @@ def _run_benchmark( wall = t_wall_end - t_wall_start 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_wall = frame_times[-1] - frame_times[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 if av_ok: _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( "SW fakesink (avdec_h264 → discard)", video_path, pipe, is_appsink=False, Gst=Gst, GLib=GLib, @@ -265,7 +276,8 @@ def main() -> None: # 3. HW fakesink — pure MPP decode throughput if mpp_ok: _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( "HW fakesink (mppvideodec → discard)", video_path, pipe, is_appsink=False, Gst=Gst, GLib=GLib, diff --git a/tests/fixtures/test_fhd_h264.mp4 b/tests/fixtures/test_fhd_h264.mp4 index edb3080..bd853d0 100644 Binary files a/tests/fixtures/test_fhd_h264.mp4 and b/tests/fixtures/test_fhd_h264.mp4 differ