[x265] [PATCH 3 of 3] psy-rd chroma: Adjust chroma lambda based on QP offsets

deepthi at multicorewareinc.com deepthi at multicorewareinc.com
Wed Jun 25 02:22:16 CEST 2014


# HG changeset patch
# User Deepthi Nandakumar <deepthi at multicorewareinc.com>
# Date 1403608182 -19800
#      Tue Jun 24 16:39:42 2014 +0530
# Node ID 613bfe5cd169c3accb4646891f904735ba21290d
# Parent  20611feb4a45e27a868af9609220aa7d6faf64ca
psy-rd chroma: Adjust chroma lambda based on QP offsets.

This hurts PSNR but improves visual quality

diff -r 20611feb4a45 -r 613bfe5cd169 source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Tue Jun 24 16:14:49 2014 +0530
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Tue Jun 24 16:39:42 2014 +0530
@@ -152,8 +152,12 @@
     m_me.setQP(qp);
     m_trQuant->setLambdas(lambda2, lambdaCb, lambdaCr);
     m_rdCost->setLambda(lambda2, x265_lambda_tab[qp]);
-    m_rdCost->setCbDistortionWeight(1.0);
-    m_rdCost->setCrDistortionWeight(1.0);
+    int chroma_offset_idx = X265_MIN(qp - qpCb + 12, MAX_CHROMA_LAMBDA_OFFSET);
+    double lambdaOffset = m_rdCost->psyRdEnabled() ? x265_chroma_lambda2_offset_tab[chroma_offset_idx] : 256.0;
+    m_rdCost->setCbDistortionWeight(lambdaOffset);
+    chroma_offset_idx = X265_MIN(qp - qpCr + 12, MAX_CHROMA_LAMBDA_OFFSET);
+    lambdaOffset = m_rdCost->psyRdEnabled() ? x265_chroma_lambda2_offset_tab[chroma_offset_idx] : 256.0;
+    m_rdCost->setCrDistortionWeight(lambdaOffset);
 }
 
 void TEncSearch::xEncSubdivCbfQT(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, uint32_t absPartIdxStep, uint32_t width, uint32_t height, bool bLuma, bool bChroma)
diff -r 20611feb4a45 -r 613bfe5cd169 source/encoder/rdcost.h
--- a/source/encoder/rdcost.h	Tue Jun 24 16:14:49 2014 +0530
+++ b/source/encoder/rdcost.h	Tue Jun 24 16:39:42 2014 +0530
@@ -55,12 +55,12 @@
 
     void setCbDistortionWeight(double cbDistortionWeight)
     {
-        m_cbDistortionWeight = (uint64_t)floor(256.0 * cbDistortionWeight);
+        m_cbDistortionWeight = (uint64_t)floor(cbDistortionWeight);
     }
 
     void setCrDistortionWeight(double crDistortionWeight)
     {
-        m_crDistortionWeight = (uint64_t)floor(256.0 * crDistortionWeight);
+        m_crDistortionWeight = (uint64_t)floor(crDistortionWeight);
     }
 
     void setPsyRdScale(double scale)


More information about the x265-devel mailing list