[x265] [PATCH] Fix chroma qp offsets for non-YUV444 inputs
Richard
ccc7922 at foxmail.com
Sat Mar 28 01:01:45 UTC 2026
From: Mr-Z-2697 <74594146+Mr-Z-2697 at users.noreply.github.com>
This reverts commit 2d01af69c4757b5087274e36e27b660b08244010
and removes the m_psyRd ternary check.
The removal of the m_psyRd check diverges from the x264 code, but if the check is in place, the offsets seem to be broken when psy-rd=0 (x264 doesn't have this issue).
When psy-rd=0, the offsets have stronger effect than x264, but is more close to "6 in QP is double/half the quality/bitrate".
---
source/encoder/rdcost.h | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/source/encoder/rdcost.h b/source/encoder/rdcost.h
index 1bd4dd696..acdbb3e01 100644
--- a/source/encoder/rdcost.h
+++ b/source/encoder/rdcost.h
@@ -76,18 +76,13 @@ public:
qpCr = x265_clip3(QP_MIN, QP_MAX_SPEC, qp + slice.m_pps->chromaQpOffset[1] + slice.m_chromaQpOffset[1]);
}
- if (slice.m_sps->chromaFormatIdc == X265_CSP_I444)
- {
- int chroma_offset_idx = X265_MIN(qp - qpCb + 12, MAX_CHROMA_LAMBDA_OFFSET);
- uint16_t lambdaOffset = m_psyRd ? x265_chroma_lambda2_offset_tab[chroma_offset_idx] : 256;
- m_chromaDistWeight[0] = lambdaOffset;
+ int chroma_offset_idx = X265_MIN(qp - qpCb + 12, MAX_CHROMA_LAMBDA_OFFSET);
+ uint16_t lambdaOffset = x265_chroma_lambda2_offset_tab[chroma_offset_idx];
+ m_chromaDistWeight[0] = lambdaOffset;
- chroma_offset_idx = X265_MIN(qp - qpCr + 12, MAX_CHROMA_LAMBDA_OFFSET);
- lambdaOffset = m_psyRd ? x265_chroma_lambda2_offset_tab[chroma_offset_idx] : 256;
- m_chromaDistWeight[1] = lambdaOffset;
- }
- else
- m_chromaDistWeight[0] = m_chromaDistWeight[1] = 256;
+ chroma_offset_idx = X265_MIN(qp - qpCr + 12, MAX_CHROMA_LAMBDA_OFFSET);
+ lambdaOffset = x265_chroma_lambda2_offset_tab[chroma_offset_idx];
+ m_chromaDistWeight[1] = lambdaOffset;
}
void setLambda(double lambda2, double lambda)
--
2.53.0.windows.2
More information about the x265-devel
mailing list