<div style="font-family: -apple-system, system-ui; font-size: 14px; color: rgb(0, 0, 0); line-height: 1.43;">From ac54e3ab6b5cbbd44129c2c2087dc87f963cfdea Mon Sep 17 00:00:00 2001<br  />
From: Mr-Z-2697 <74594146+Mr-Z-2697@users.noreply.github.com><br  />
Date: Mon, 12 May 2025 01:58:02 +0800<br  />
Subject: [PATCH] Fix weighted prediction delta_chroma_offset non-conformance<br  />
<br  />
The calculation here is the same as final entropy coding.<br  />
Specification says the valid range is [-512, 511].<br  />
---<br  />
 source/encoder/weightPrediction.cpp | 6 +++++-<br  />
 1 file changed, 5 insertions(+), 1 deletion(-)<br  />
<br  />
diff --git a/source/encoder/weightPrediction.cpp b/source/encoder/weightPrediction.cpp<br  />
index bc842f173..fd010d032 100644<br  />
--- a/source/encoder/weightPrediction.cpp<br  />
+++ b/source/encoder/weightPrediction.cpp<br  />
@@ -466,7 +466,11 @@ void weightAnalyse(Slice& slice, Frame& frame, x265_param& param)<br  />
                 }<br  />
             }<br  />
 <br  />
-            if (!bFound || (minscale == (1 << mindenom) && minoff == 0) || (float)minscore / origscore > 0.998f)<br  />
+            int predTemp = (128 - ((128 * minscale) >> (mindenom)));<br  />
+            int deltaChromaTemp = minoff - predTemp;<br  />
+<br  />
+            if (!bFound || (minscale == (1 << mindenom) && minoff == 0) || (float)minscore / origscore > 0.998f ||<br  />
+                (plane && (deltaChromaTemp < -512 || deltaChromaTemp > 511)) )<br  />
             {<br  />
                 SET_WEIGHT(weights[plane], false, 1 << denom, denom, 0);<br  />
             }<br  />
-- <br  />
2.49.0<br  />
</div><div style="font-family: -apple-system, system-ui; font-size: 14px; color: rgb(0, 0, 0); line-height: 1.43;"><br  /></div>