[x265] [PATCH] Backed out changeset: cad77d34fec1

Pradeep Ramachandran pradeep at multicorewareinc.com
Tue Jun 20 13:08:46 CEST 2017


# HG changeset patch
# User Pradeep Ramachandran <pradeep at multicorewareinc.com>
# Date 1497956900 -19800
#      Tue Jun 20 16:38:20 2017 +0530
# Node ID 4436e1ca6f3987292dea608c7ecb2780fdcfc4df
# Parent  93d4b824e9348ab66ecce291702062c262ecb6f4
Backed out changeset: cad77d34fec1

The luma QP offsets specified with this patch don't take frame-level variation
into account and therefore may result in poor visual quality when used without
AQ which balances frame-level bit allocation.

The chroma QP offsets are less harmful and can be applied even without AQ,
which is the default behavior.

diff -r 93d4b824e934 -r 4436e1ca6f39 doc/reST/cli.rst
--- a/doc/reST/cli.rst	Thu Jun 15 11:41:14 2017 +0530
+++ b/doc/reST/cli.rst	Tue Jun 20 16:38:20 2017 +0530
@@ -1961,7 +1961,6 @@
 
 	Add luma and chroma offsets for HDR/WCG content.
 	Input video should be 10 bit 4:2:0. Applicable for HDR content.
-	It is recommended to use this feature along with AQ mode.
 	Default disabled. **Experimental Feature**
 	
 .. option:: --dhdr10-info <filename>
diff -r 93d4b824e934 -r 4436e1ca6f39 source/common/frame.cpp
--- a/source/common/frame.cpp	Thu Jun 15 11:41:14 2017 +0530
+++ b/source/common/frame.cpp	Tue Jun 20 16:38:20 2017 +0530
@@ -78,7 +78,7 @@
     }
 
     if (m_fencPic->create(param->sourceWidth, param->sourceHeight, param->internalCsp) &&
-        m_lowres.create(m_fencPic, param->bframes, !!param->rc.aqMode || !!param->bAQMotion || !!param->bHDROpt, param->rc.qgSize))
+        m_lowres.create(m_fencPic, param->bframes, !!param->rc.aqMode || !!param->bAQMotion, param->rc.qgSize))
     {
         X265_CHECK((m_reconColCount == NULL), "m_reconColCount was initialized");
         m_numRows = (m_fencPic->m_picHeight + g_maxCUSize - 1)  / g_maxCUSize;
diff -r 93d4b824e934 -r 4436e1ca6f39 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Thu Jun 15 11:41:14 2017 +0530
+++ b/source/encoder/encoder.cpp	Tue Jun 20 16:38:20 2017 +0530
@@ -2058,7 +2058,7 @@
 {
     bool bIsVbv = m_param->rc.vbvBufferSize > 0 && m_param->rc.vbvMaxBitrate > 0;
 
-    if (!m_param->bLossless && (m_param->rc.aqMode || bIsVbv || m_param->bAQMotion || m_param->bHDROpt))
+    if (!m_param->bLossless && (m_param->rc.aqMode || bIsVbv || m_param->bAQMotion))
     {
         pps->bUseDQP = true;
         pps->maxCuDQPDepth = g_log2Size[m_param->maxCUSize] - g_log2Size[m_param->rc.qgSize];
@@ -2438,7 +2438,7 @@
         x265_log(p, X265_LOG_WARNING, "limit-tu disabled, requires tu-inter-depth > 1\n");
     }
     bool bIsVbv = m_param->rc.vbvBufferSize > 0 && m_param->rc.vbvMaxBitrate > 0;
-    if (!m_param->bLossless && (m_param->rc.aqMode || bIsVbv || m_param->bAQMotion || m_param->bHDROpt))
+    if (!m_param->bLossless && (m_param->rc.aqMode || bIsVbv || m_param->bAQMotion))
     {
         if (p->rc.qgSize < X265_MAX(8, p->minCUSize))
         {
diff -r 93d4b824e934 -r 4436e1ca6f39 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Thu Jun 15 11:41:14 2017 +0530
+++ b/source/encoder/ratecontrol.cpp	Tue Jun 20 16:38:20 2017 +0530
@@ -2592,7 +2592,7 @@
     int64_t actualBits = bits;
     Slice *slice = curEncData.m_slice;
 
-    if (m_param->rc.aqMode || m_isVbv || m_param->bAQMotion || m_param->bHDROpt)
+    if (m_param->rc.aqMode || m_isVbv || m_param->bAQMotion)
     {
         if (m_isVbv && !(m_2pass && m_param->rc.rateControlMode == X265_RC_CRF))
         {
@@ -2606,7 +2606,7 @@
             rce->qpaRc = curEncData.m_avgQpRc;
         }
 
-        if (m_param->rc.aqMode || m_param->bAQMotion || m_param->bHDROpt)
+        if (m_param->rc.aqMode || m_param->bAQMotion)
         {
             double avgQpAq = 0;
             /* determine actual avg encoded QP, after AQ/cutree adjustments */
diff -r 93d4b824e934 -r 4436e1ca6f39 source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Thu Jun 15 11:41:14 2017 +0530
+++ b/source/encoder/slicetype.cpp	Tue Jun 20 16:38:20 2017 +0530
@@ -243,6 +243,29 @@
                     qp_adj = strength * (X265_LOG2(X265_MAX(energy, 1)) - (modeOneConst + 2 * (X265_DEPTH - 8)));
                 }
 
+                if (param->bHDROpt)
+                {
+                    uint32_t sum = lumaSumCu(curFrame, blockX, blockY, param->rc.qgSize);
+                    uint32_t lumaAvg = sum / (loopIncr * loopIncr);
+                    if (lumaAvg < 301)
+                        qp_adj += 3;
+                    else if (lumaAvg >= 301 && lumaAvg < 367)
+                        qp_adj += 2;
+                    else if (lumaAvg >= 367 && lumaAvg < 434)
+                        qp_adj += 1;
+                    else if (lumaAvg >= 501 && lumaAvg < 567)
+                        qp_adj -= 1;
+                    else if (lumaAvg >= 567 && lumaAvg < 634)
+                        qp_adj -= 2;
+                    else if (lumaAvg >= 634 && lumaAvg < 701)
+                        qp_adj -= 3;
+                    else if (lumaAvg >= 701 && lumaAvg < 767)
+                        qp_adj -= 4;
+                    else if (lumaAvg >= 767 && lumaAvg < 834)
+                        qp_adj -= 5;
+                    else if (lumaAvg >= 834)
+                        qp_adj -= 6;
+                }
                 if (quantOffsets != NULL)
                     qp_adj += quantOffsets[blockXY];
                 curFrame->m_lowres.qpAqOffset[blockXY] = qp_adj;
@@ -253,43 +276,6 @@
         }
     }
 
-    if (param->bHDROpt)
-    {
-        double qp_adj;
-        blockXY = 0;
-        for (blockY = 0; blockY < maxRow; blockY += loopIncr)
-        {
-            for (blockX = 0; blockX < maxCol; blockX += loopIncr)
-            {
-                qp_adj = 0;
-                uint32_t sum = lumaSumCu(curFrame, blockX, blockY, param->rc.qgSize);
-                uint32_t lumaAvg = sum / (loopIncr * loopIncr);
-                if (lumaAvg < 301)
-                    qp_adj = 3;
-                else if (lumaAvg >= 301 && lumaAvg < 367)
-                    qp_adj = 2;
-                else if (lumaAvg >= 367 && lumaAvg < 434)
-                    qp_adj = 1;
-                else if (lumaAvg >= 501 && lumaAvg < 567)
-                    qp_adj = -1;
-                else if (lumaAvg >= 567 && lumaAvg < 634)
-                    qp_adj = -2;
-                else if (lumaAvg >= 634 && lumaAvg < 701)
-                    qp_adj = -3;
-                else if (lumaAvg >= 701 && lumaAvg < 767)
-                    qp_adj = -4;
-                else if (lumaAvg >= 767 && lumaAvg < 834)
-                    qp_adj = -5;
-                else if (lumaAvg >= 834)
-                    qp_adj = -6;
-                curFrame->m_lowres.qpAqOffset[blockXY] += qp_adj;
-                curFrame->m_lowres.qpCuTreeOffset[blockXY] += qp_adj;
-                curFrame->m_lowres.invQscaleFactor[blockXY] = x265_exp2fix8(curFrame->m_lowres.qpAqOffset[blockXY]);
-                blockXY++;
-            }
-        }
-    }
-
     if (param->rc.qgSize == 8)
     {
         for (int cuY = 0; cuY < heightInCU; cuY++)
@@ -616,7 +602,7 @@
     m_lastKeyframe = -m_param->keyframeMax;
     m_sliceTypeBusy = false;
     m_fullQueueSize = X265_MAX(1, m_param->lookaheadDepth);
-    m_bAdaptiveQuant = m_param->rc.aqMode || m_param->bEnableWeightedPred || m_param->bEnableWeightedBiPred || m_param->bAQMotion || m_param->bHDROpt;
+    m_bAdaptiveQuant = m_param->rc.aqMode || m_param->bEnableWeightedPred || m_param->bEnableWeightedBiPred || m_param->bAQMotion;
 
     /* If we have a thread pool and are using --b-adapt 2, it is generally
      * preferable to perform all motion searches for each lowres frame in large
@@ -925,7 +911,7 @@
         uint32_t widthInLowresCu = (uint32_t)m_8x8Width, heightInLowresCu = (uint32_t)m_8x8Height;
         double *qp_offset = 0;
         /* Factor in qpoffsets based on Aq/Cutree in CU costs */
-        if (m_param->rc.aqMode || m_param->bAQMotion || m_param->bHDROpt)
+        if (m_param->rc.aqMode || m_param->bAQMotion)
             qp_offset = (frames[b]->sliceType == X265_TYPE_B || !m_param->rc.cuTree) ? frames[b]->qpAqOffset : frames[b]->qpCuTreeOffset;
 
         for (uint32_t row = 0; row < numCuInHeight; row++)
@@ -1319,7 +1305,7 @@
     CostEstimateGroup estGroup(*this, frames);
     int64_t cost = estGroup.singleCost(p0, p1, b);
 
-    if (m_param->rc.aqMode || m_param->bAQMotion || m_param->bHDROpt)
+    if (m_param->rc.aqMode || m_param->bAQMotion)
     {
         if (m_param->rc.cuTree)
             return frameCostRecalculate(frames, p0, p1, b);
diff -r 93d4b824e934 -r 4436e1ca6f39 source/x265cli.h
--- a/source/x265cli.h	Thu Jun 15 11:41:14 2017 +0530
+++ b/source/x265cli.h	Tue Jun 20 16:38:20 2017 +0530
@@ -502,7 +502,7 @@
     H0("                                    format: G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)\n");
     H0("   --max-cll <string>            Emit content light level info SEI as \"cll,fall\" (HDR)\n");
     H0("   --[no-]hdr                    Control dumping of HDR SEI packet. If max-cll or master-display has non-zero values, this is enabled. Default %s\n", OPT(param->bEmitHDRSEI));
-    H0("   --[no-]hdr-opt                Add luma and chroma offsets for HDR/WCG content. Recommended to use this along with AQ Mode. Default %s\n", OPT(param->bHDROpt));
+    H0("   --[no-]hdr-opt                Add luma and chroma offsets for HDR/WCG content. Default %s\n", OPT(param->bHDROpt));
     H0("   --min-luma <integer>          Minimum luma plane value of input source picture\n");
     H0("   --max-luma <integer>          Maximum luma plane value of input source picture\n");
     H0("\nBitstream options:\n");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265.patch
Type: text/x-patch
Size: 9603 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20170620/23fe7f5f/attachment.bin>


More information about the x265-devel mailing list