tests: fix benchmark pipelines (decodebin + rank steering, LD_PRELOAD note)
This commit is contained in:
+22
-13
@@ -224,17 +224,26 @@ def main() -> None:
|
||||
size = os.path.getsize(video_path)
|
||||
print(f" Using existing: {video_path} ({size // 1024}KB)")
|
||||
|
||||
def _set_mpp_rank(rank: int) -> None:
|
||||
"""Temporarily set mppvideodec factory rank to steer decodebin selection."""
|
||||
factory = reg.find_feature("mppvideodec", Gst.ElementFactory.__gtype__)
|
||||
if factory:
|
||||
factory.set_rank(rank)
|
||||
|
||||
# --- benchmark runs -----------------------------------------------------
|
||||
_section("Benchmarks (sync=false, as fast as possible)")
|
||||
|
||||
results = []
|
||||
|
||||
# Pipeline note: qtdemux has dynamic src pads so we use decodebin.
|
||||
# decodebin rank manipulation steers it toward SW or HW decoder.
|
||||
GST_RANK_NONE = 0
|
||||
MPP_RANK_HIGH = 257 # above avdec_h264 (256)
|
||||
|
||||
# 1. SW fakesink — pure decode throughput
|
||||
if av_ok:
|
||||
pipe = (
|
||||
f"filesrc location={video_path} ! qtdemux ! h264parse "
|
||||
f"! avdec_h264 ! fakesink sync=false"
|
||||
)
|
||||
_set_mpp_rank(GST_RANK_NONE) # ensure avdec_h264 wins
|
||||
pipe = f"filesrc location={video_path} ! decodebin ! fakesink sync=false"
|
||||
results.append(_run_benchmark(
|
||||
"SW fakesink (avdec_h264 → discard)",
|
||||
video_path, pipe, is_appsink=False, Gst=Gst, GLib=GLib,
|
||||
@@ -242,10 +251,10 @@ def main() -> None:
|
||||
|
||||
# 2. SW appsink — full BGRA path (as used by app without HW decode)
|
||||
if av_ok:
|
||||
_set_mpp_rank(GST_RANK_NONE)
|
||||
pipe = (
|
||||
f"filesrc location={video_path} ! qtdemux ! h264parse "
|
||||
f"! avdec_h264 ! videoconvert "
|
||||
f"! video/x-raw,format=BGRA "
|
||||
f"filesrc location={video_path} ! decodebin "
|
||||
f"! videoconvert ! video/x-raw,format=BGRA "
|
||||
f"! appsink name=bench_sink"
|
||||
)
|
||||
results.append(_run_benchmark(
|
||||
@@ -255,10 +264,8 @@ def main() -> None:
|
||||
|
||||
# 3. HW fakesink — pure MPP decode throughput
|
||||
if mpp_ok:
|
||||
pipe = (
|
||||
f"filesrc location={video_path} ! qtdemux ! h264parse "
|
||||
f"! mppvideodec ! fakesink sync=false"
|
||||
)
|
||||
_set_mpp_rank(MPP_RANK_HIGH) # prefer mppvideodec
|
||||
pipe = f"filesrc location={video_path} ! decodebin ! fakesink sync=false"
|
||||
results.append(_run_benchmark(
|
||||
"HW fakesink (mppvideodec → discard)",
|
||||
video_path, pipe, is_appsink=False, Gst=Gst, GLib=GLib,
|
||||
@@ -266,9 +273,9 @@ def main() -> None:
|
||||
|
||||
# 4. HW appsink NV12 — full app path with HW + zero-copy SDL upload
|
||||
if mpp_ok:
|
||||
_set_mpp_rank(MPP_RANK_HIGH)
|
||||
pipe = (
|
||||
f"filesrc location={video_path} ! qtdemux ! h264parse "
|
||||
f"! mppvideodec "
|
||||
f"filesrc location={video_path} ! decodebin "
|
||||
f"! appsink name=bench_sink caps=video/x-raw,format=NV12"
|
||||
)
|
||||
results.append(_run_benchmark(
|
||||
@@ -276,6 +283,8 @@ def main() -> None:
|
||||
video_path, pipe, is_appsink=True, Gst=Gst, GLib=GLib,
|
||||
))
|
||||
|
||||
_set_mpp_rank(64) # restore default marginal rank
|
||||
|
||||
# --- summary table -------------------------------------------------------
|
||||
_section("Results")
|
||||
print(f" {'Path':<45} {'FPS':>6} {'CPU%':>5}")
|
||||
|
||||
Reference in New Issue
Block a user