From 819f08fb8d397d12667be7bfb8025727c15bc731 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Wed, 23 Apr 2025 10:46:16 +0800 Subject: [PATCH] speccpu/x264: add a new function to disable `weight->i_scale` mul --- src/speccpu/x264.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/speccpu/x264.py b/src/speccpu/x264.py index 21dc6b2..7c725d6 100644 --- a/src/speccpu/x264.py +++ b/src/speccpu/x264.py @@ -48,6 +48,23 @@ class MCBuilder: return self + def with_disabled_iscale_mul(self): + """ + Disable the i_scale multiplication in the mc_weight function. + Find: "src[x] * weight->i_scale", replace it to src[x] + + >>> builder = MCBuilder() + >>> 'src[x] * weight->i_scale' in builder.mc_src + True + >>> builder = builder.with_disabled_iscale_mul() + >>> 'src[x] * weight->i_scale' in builder.mc_src + False + >>> 'src[x]' in builder.mc_src + True + """ + self.mc_src = self.mc_src.replace("src[x] * weight->i_scale", "src[x]") + return self + def build(self): return self.mc_src