[x265-commits] [x265] quant: fix for tskip

Steve Borho steve at borho.org
Tue Jul 29 21:08:13 CEST 2014


details:   http://hg.videolan.org/x265/rev/6b286f66cfab
branches:  
changeset: 7599:6b286f66cfab
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 23:34:07 2014 -0500
description:
quant: fix for tskip
Subject: [x265] cmake: ignore msvc warnings about forcing value to bool 'true' or 'false'

details:   http://hg.videolan.org/x265/rev/8bab5275baed
branches:  
changeset: 7600:8bab5275baed
user:      Steve Borho <steve at borho.org>
date:      Mon Jul 28 00:14:55 2014 -0500
description:
cmake: ignore msvc warnings about forcing value to bool 'true' or 'false'
Subject: [x265] scaling: use simple ints for small counters and int32_t for scales and coeffs

details:   http://hg.videolan.org/x265/rev/d66a3bd865e3
branches:  
changeset: 7601:d66a3bd865e3
user:      Steve Borho <steve at borho.org>
date:      Mon Jul 28 12:24:43 2014 -0500
description:
scaling: use simple ints for small counters and int32_t for scales and coeffs

This fixes a gcc warning and mostly makes the code more readable and avoids
some (int) casts
Subject: [x265] scaling: remove m_refMatrixId; it was only used to return an int

details:   http://hg.videolan.org/x265/rev/236df356402d
branches:  
changeset: 7602:236df356402d
user:      Steve Borho <steve at borho.org>
date:      Mon Jul 28 12:38:39 2014 -0500
description:
scaling: remove m_refMatrixId; it was only used to return an int

Only one value of the matrix was ever used at a time, so we can return thtat
index directly from checkPredMode
Subject: [x265] slicetype: compute frame satd cost for zero latency

details:   http://hg.videolan.org/x265/rev/eba786bbe4b5
branches:  
changeset: 7603:eba786bbe4b5
user:      Aarthi Thirumalai
date:      Mon Jul 28 16:32:40 2014 +0530
description:
slicetype: compute frame satd cost for zero latency
Subject: [x265] search: separate bSkipRes == true path

details:   http://hg.videolan.org/x265/rev/7eab256b60f0
branches:  
changeset: 7604:7eab256b60f0
user:      Satoshi Nakagawa <nakagawa424 at oki.com>
date:      Mon Jul 28 18:49:51 2014 +0900
description:
search: separate bSkipRes == true path
Subject: [x265] frameencoder: re-order compressFrame() to avoid dependency problem with HRD

details:   http://hg.videolan.org/x265/rev/71c023799f3d
branches:  
changeset: 7605:71c023799f3d
user:      Steve Borho <steve at borho.org>
date:      Mon Jul 28 17:24:57 2014 -0500
description:
frameencoder: re-order compressFrame() to avoid dependency problem with HRD

1. if --hrd is enabled, the buffer period SEI needs data set by rateControlStart
2. rateControlStart may block, so get compute heavy tasks done first, like
   weighted prediction analysis
3. hoist rateControlStart and QP setup back out of compressCTURows() and move
   other code into it that belonged there in the first place
4. move framefilter setup logic together
5. don't measure rateControlEnd() in frame wall time
Subject: [x265] frameencoder: nits

details:   http://hg.videolan.org/x265/rev/e84b28132be1
branches:  
changeset: 7606:e84b28132be1
user:      Steve Borho <steve at borho.org>
date:      Mon Jul 28 17:26:13 2014 -0500
description:
frameencoder: nits
Subject: [x265] slice: move m_bReferenced to picsym and rename for clarity

details:   http://hg.videolan.org/x265/rev/3c50a7e516ed
branches:  
changeset: 7607:3c50a7e516ed
user:      Steve Borho <steve at borho.org>
date:      Mon Jul 28 21:40:08 2014 -0500
description:
slice: move m_bReferenced to picsym and rename for clarity

This flag was being used for two purposes and introducing race hazards:

1. determining if a picture in the DPB must be signaled in an RPS
2. determining if the slice type is referenced (non-b)

The m_bHasReferences variable on the picsym is used for the first purpose.
The macro IS_REFERENCED(slice) is used for the second purpose.

The m_isReferenced member variable on the frame encoder was removed and
it just checks the slice type directly.
Subject: [x265] dpb: cleanup

details:   http://hg.videolan.org/x265/rev/bc53f6dcda7f
branches:  
changeset: 7608:bc53f6dcda7f
user:      Steve Borho <steve at borho.org>
date:      Mon Jul 28 21:54:49 2014 -0500
description:
dpb: cleanup
Subject: [x265] rc: call getEstimatedPictureCost() from API thread, prevent race hazards

details:   http://hg.videolan.org/x265/rev/2bc34d32e6cc
branches:  
changeset: 7609:2bc34d32e6cc
user:      Steve Borho <steve at borho.org>
date:      Mon Jul 28 23:44:47 2014 -0500
description:
rc: call getEstimatedPictureCost() from API thread, prevent race hazards
Subject: [x265] rc,weight: nits

details:   http://hg.videolan.org/x265/rev/0308c9e187be
branches:  
changeset: 7610:0308c9e187be
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 00:08:29 2014 -0500
description:
rc,weight: nits
Subject: [x265] remove sign compare warnings from TLibEncoder, cleanup SAO

details:   http://hg.videolan.org/x265/rev/a021b541a2ef
branches:  
changeset: 7611:a021b541a2ef
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 00:48:32 2014 -0500
description:
remove sign compare warnings from TLibEncoder, cleanup SAO
Subject: [x265] frameencoder: fix for crash in frameencoder when AccessUnitDelimiter is on

details:   http://hg.videolan.org/x265/rev/47e6a51b943f
branches:  
changeset: 7612:47e6a51b943f
user:      Albert Wang
date:      Tue Jul 29 12:16:11 2014 +0800
description:
frameencoder: fix for crash in frameencoder when AccessUnitDelimiter is on

The m_entropyCoder need to set the bitstream first before calling codeAUD,
otherwise a crash will happen.
Subject: [x265] quant: delay getTUEntropyCodingParameters() until known necessary

details:   http://hg.videolan.org/x265/rev/2834687bcb51
branches:  
changeset: 7613:2834687bcb51
user:      Steve Borho <steve at borho.org>
date:      Mon Jul 28 22:52:51 2014 -0500
description:
quant: delay getTUEntropyCodingParameters() until known necessary
Subject: [x265] cmake: enable full warnings for remaining TLibEncoder files

details:   http://hg.videolan.org/x265/rev/3a1245fb52a4
branches:  
changeset: 7614:3a1245fb52a4
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 01:26:19 2014 -0500
description:
cmake: enable full warnings for remaining TLibEncoder files
Subject: [x265] sei: fix byte alignment following HRD SEI

details:   http://hg.videolan.org/x265/rev/dbec825c30ad
branches:  
changeset: 7615:dbec825c30ad
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 13:00:16 2014 -0500
description:
sei: fix byte alignment following HRD SEI
Subject: [x265] hrd: add a comment about when an APS is required, update SEI

details:   http://hg.videolan.org/x265/rev/2263fe1c05f1
branches:  
changeset: 7616:2263fe1c05f1
user:      Steve Borho <steve at borho.org>
date:      Tue Jul 29 13:13:11 2014 -0500
description:
hrd: add a comment about when an APS is required, update SEI
Subject: [x265] rc: fix crash in 2 pass for faster preset (ultrafast - faster)

details:   http://hg.videolan.org/x265/rev/a9678988dda2
branches:  
changeset: 7617:a9678988dda2
user:      Aarthi Thirumalai
date:      Tue Jul 29 23:14:42 2014 +0530
description:
rc: fix crash in 2 pass for faster preset (ultrafast - faster)

diffstat:

 source/Lib/TLibCommon/TComPicSym.h                  |    2 +
 source/Lib/TLibCommon/TComTrQuant.cpp               |   10 +-
 source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp |  799 ++++++++-----------
 source/Lib/TLibEncoder/TEncSearch.cpp               |  238 ++---
 source/Lib/TLibEncoder/TEncSearch.h                 |    5 +-
 source/common/CMakeLists.txt                        |    3 +-
 source/common/scalinglist.cpp                       |  117 +-
 source/common/scalinglist.h                         |   25 +-
 source/common/slice.h                               |    4 +-
 source/encoder/CMakeLists.txt                       |   25 +-
 source/encoder/analysis.cpp                         |   38 +-
 source/encoder/dpb.cpp                              |   70 +-
 source/encoder/encoder.cpp                          |   21 +-
 source/encoder/entropy.cpp                          |   15 +-
 source/encoder/frameencoder.cpp                     |  188 ++--
 source/encoder/frameencoder.h                       |    1 -
 source/encoder/motion.cpp                           |    2 +-
 source/encoder/motion.h                             |    2 +-
 source/encoder/ratecontrol.cpp                      |   39 +-
 source/encoder/ratecontrol.h                        |    3 +-
 source/encoder/sei.h                                |   13 +-
 source/encoder/slicetype.cpp                        |   21 +-
 source/encoder/slicetype.h                          |    2 +-
 source/encoder/weightPrediction.cpp                 |    9 -
 24 files changed, 738 insertions(+), 914 deletions(-)

diffs (truncated from 3303 to 300 lines):

diff -r ea63a67164e5 -r a9678988dda2 source/Lib/TLibCommon/TComPicSym.h
--- a/source/Lib/TLibCommon/TComPicSym.h	Sun Jul 27 19:15:14 2014 -0500
+++ b/source/Lib/TLibCommon/TComPicSym.h	Tue Jul 29 23:14:42 2014 +0530
@@ -80,6 +80,8 @@ public:
     TComPicSym*   m_freeListNext;
     TComPicYuv*   m_reconPicYuv;
 
+    bool          m_bHasReferences; // used during DPB/RPS updates
+
     bool        create(x265_param *param);
     void        destroy();
 
diff -r ea63a67164e5 -r a9678988dda2 source/Lib/TLibCommon/TComTrQuant.cpp
--- a/source/Lib/TLibCommon/TComTrQuant.cpp	Sun Jul 27 19:15:14 2014 -0500
+++ b/source/Lib/TLibCommon/TComTrQuant.cpp	Tue Jul 29 23:14:42 2014 +0530
@@ -223,8 +223,6 @@ uint32_t TComTrQuant::signBitHidingHDQ(c
 
 uint32_t TComTrQuant::quant(TComDataCU* cu, coeff_t* qCoef, uint32_t log2TrSize, TextType ttype, uint32_t absPartIdx)
 {
-    TUEntropyCodingParameters codingParameters;
-    getTUEntropyCodingParameters(cu, codingParameters, absPartIdx, log2TrSize, ttype);
     int deltaU[32 * 32];
 
     int scalingListType = (cu->isIntra(absPartIdx) ? 0 : 3) + ttype;
@@ -234,15 +232,18 @@ uint32_t TComTrQuant::quant(TComDataCU* 
     int32_t *quantCoeff = m_scalingList->m_quantCoef[log2TrSize - 2][scalingListType][rem];
 
     int transformShift = MAX_TR_DYNAMIC_RANGE - X265_DEPTH - log2TrSize; // Represents scaling through forward transform
-
     int qbits = QUANT_SHIFT + per + transformShift;
     int add = (cu->m_slice->m_sliceType == I_SLICE ? 171 : 85) << (qbits - 9);
+    int numCoeff = 1 << log2TrSize * 2;
 
-    int numCoeff = 1 << log2TrSize * 2;
     uint32_t numSig = primitives.quant(m_resiDctCoeff, quantCoeff, deltaU, qCoef, qbits, add, numCoeff);
 
     if (numSig >= 2 && cu->m_slice->m_pps->bSignHideEnabled)
+    {
+        TUEntropyCodingParameters codingParameters;
+        getTUEntropyCodingParameters(cu, codingParameters, absPartIdx, log2TrSize, ttype);
         return signBitHidingHDQ(qCoef, m_resiDctCoeff, deltaU, numSig, codingParameters);
+    }
     else
         return numSig;
 }
@@ -343,6 +344,7 @@ void TComTrQuant::invtransformNxN(bool t
     if (useTransformSkip)
     {
         int trSize = 1 << log2TrSize;
+        shift = transformShift;
 
         if (shift > 0)
             primitives.cvt32to16_shr(residual, m_resiDctCoeff, stride, shift, trSize);
diff -r ea63a67164e5 -r a9678988dda2 source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
--- a/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	Sun Jul 27 19:15:14 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	Tue Jul 29 23:14:42 2014 +0530
@@ -41,9 +41,6 @@
 
 using namespace x265;
 
-//! \ingroup TLibEncoder
-//! \{
-
 TEncSampleAdaptiveOffset::TEncSampleAdaptiveOffset()
     : m_entropyCoder(NULL)
     , m_count(NULL)
@@ -79,41 +76,24 @@ TEncSampleAdaptiveOffset::TEncSampleAdap
 TEncSampleAdaptiveOffset::~TEncSampleAdaptiveOffset()
 {}
 
-// ====================================================================================================================
-// Static
-// ====================================================================================================================
-
-// ====================================================================================================================
-// Constants
-// ====================================================================================================================
-
-// ====================================================================================================================
-// Tables
-// ====================================================================================================================
-
 #if HIGH_BIT_DEPTH
-inline double xRoundIbdi2(double x)
+inline double roundIDBI2(double x)
 {
     return ((x) > 0) ? (int)(((int)(x) + (1 << (X265_DEPTH - 8 - 1))) / (1 << (X265_DEPTH - 8))) : ((int)(((int)(x) - (1 << (X265_DEPTH - 8 - 1))) / (1 << (X265_DEPTH - 8))));
 }
-
 #endif
 
-/** rounding with IBDI
- * \param  x
- */
-inline double xRoundIbdi(double x)
+/* rounding with IBDI */
+inline double roundIDBI(double x)
 {
 #if HIGH_BIT_DEPTH
-    return X265_DEPTH > 8 ? xRoundIbdi2(x) : ((x) >= 0 ? ((int)((x) + 0.5)) : ((int)((x) - 0.5)));
+    return X265_DEPTH > 8 ? roundIDBI2(x) : ((x) >= 0 ? ((int)((x) + 0.5)) : ((int)((x) - 0.5)));
 #else
     return (x) >= 0 ? ((int)((x) + 0.5)) : ((int)((x) - 0.5));
 #endif
 }
 
-/** process SAO for one partition
- * \param  *psQTPart, partIdx, lambda
- */
+/** process SAO for one partition */
 void TEncSampleAdaptiveOffset::rdoSaoOnePart(SAOQTPart *psQTPart, int partIdx, double lambda, int yCbCr)
 {
     int typeIdx;
@@ -163,9 +143,7 @@ void TEncSampleAdaptiveOffset::rdoSaoOne
                     }
 
                     if (rx == onePart->startCUX)
-                    {
                         saoLcuParamRdo.mergeLeftFlag = 0;
-                    }
 
                     m_entropyCoder->codeSaoUnitInterleaving(yCbCr, 1, rx, ry,  &saoLcuParamRdo, 1,  1,  allowMergeLeft, allowMergeUp);
                 }
@@ -183,10 +161,8 @@ void TEncSampleAdaptiveOffset::rdoSaoOne
                 for (int i = 0; i < SAO_MAX_BO_CLASSES - SAO_BO_LEN + 1; i++)
                 {
                     currentRDCost = 0.0;
-                    for (uint32_t uj = i; uj < i + SAO_BO_LEN; uj++)
-                    {
-                        currentRDCost += currentRdCostTableBo[uj];
-                    }
+                    for (int j = i; j < i + SAO_BO_LEN; j++)
+                        currentRDCost += currentRdCostTableBo[j];
 
                     if (currentRDCost < bestRDCostTableBo)
                     {
@@ -198,9 +174,7 @@ void TEncSampleAdaptiveOffset::rdoSaoOne
                 // Re code all Offsets
                 // Code Center
                 for (classIdx = bestClassTableBo; classIdx < bestClassTableBo + SAO_BO_LEN; classIdx++)
-                {
                     estDist += currentDistortionTableBo[classIdx];
-                }
             }
 
             for (int ry = onePart->startCUY; ry <= onePart->endCUY; ry++)
@@ -219,23 +193,17 @@ void TEncSampleAdaptiveOffset::rdoSaoOne
                     saoLcuParamRdo.mergeLeftFlag = 1;
 
                     if (ry == onePart->startCUY)
-                    {
                         saoLcuParamRdo.mergeUpFlag = 0;
-                    }
 
                     if (rx == onePart->startCUX)
-                    {
                         saoLcuParamRdo.mergeLeftFlag = 0;
-                    }
 
                     // set type and offsets
                     saoLcuParamRdo.typeIdx = typeIdx;
                     saoLcuParamRdo.subTypeIdx = (typeIdx == SAO_BO) ? bestClassTableBo : 0;
                     saoLcuParamRdo.length = m_numClass[typeIdx];
                     for (classIdx = 0; classIdx < saoLcuParamRdo.length; classIdx++)
-                    {
                         saoLcuParamRdo.offset[classIdx] = (int)m_offset[partIdx][typeIdx][classIdx + saoLcuParamRdo.subTypeIdx + 1];
-                    }
 
                     m_entropyCoder->codeSaoUnitInterleaving(yCbCr, 1, rx, ry, &saoLcuParamRdo, 1, 1, allowMergeLeft, allowMergeUp);
                 }
@@ -271,9 +239,9 @@ void TEncSampleAdaptiveOffset::rdoSaoOne
     onePart->minRate   = (int)(m_typePartBest[partIdx] >= 0 ? m_rate[partIdx][m_typePartBest[partIdx]] : 0);
     onePart->minCost   = onePart->minDist + lambda * onePart->minRate;
     onePart->bestType  = m_typePartBest[partIdx];
+
     if (onePart->bestType != -1)
     {
-        // pOnePart->bEnableFlag =  1;
         onePart->length = m_numClass[onePart->bestType];
         int minIndex = 0;
         if (onePart->bestType == SAO_BO)
@@ -282,55 +250,41 @@ void TEncSampleAdaptiveOffset::rdoSaoOne
             minIndex = onePart->subTypeIdx;
         }
         for (int i = 0; i < onePart->length; i++)
-        {
             onePart->offset[i] = (int)m_offset[partIdx][onePart->bestType][minIndex + i + 1];
-        }
     }
     else
-    {
-        // pOnePart->bEnableFlag = 0;
         onePart->length     = 0;
-    }
 }
 
-/** Run partition tree disable
- */
+/* Run partition tree disable */
 void TEncSampleAdaptiveOffset::disablePartTree(SAOQTPart *psQTPart, int partIdx)
 {
     SAOQTPart* pOnePart = &(psQTPart[partIdx]);
 
-    pOnePart->bSplit     = false;
-    pOnePart->length     =  0;
-    pOnePart->bestType   = -1;
+    pOnePart->bSplit   = false;
+    pOnePart->length   =  0;
+    pOnePart->bestType = -1;
 
-    if (pOnePart->partLevel < m_maxSplitLevel)
+    if (pOnePart->partLevel < (int)m_maxSplitLevel)
     {
         for (int i = 0; i < NUM_DOWN_PART; i++)
-        {
             disablePartTree(psQTPart, pOnePart->downPartsIdx[i]);
-        }
     }
 }
 
-/** Run quadtree decision function
- * \param  partIdx, pcPicOrg, pcPicDec, pcPicRest, &costFinal
- */
+/** Run quadtree decision function */
 void TEncSampleAdaptiveOffset::runQuadTreeDecision(SAOQTPart *qtPart, int partIdx, double &costFinal, int maxLevel, double lambda, int yCbCr)
 {
     SAOQTPart* onePart = &(qtPart[partIdx]);
 
     uint32_t nextDepth = onePart->partLevel + 1;
 
-    if (partIdx == 0)
-    {
+    if (!partIdx)
         costFinal = 0;
-    }
 
     // SAO for this part
     if (!onePart->bProcessed)
-    {
         rdoSaoOnePart(qtPart, partIdx, lambda, yCbCr);
-    }
 
     // SAO for sub 4 parts
     if (onePart->partLevel < maxLevel)
@@ -340,14 +294,11 @@ void TEncSampleAdaptiveOffset::runQuadTr
 
         for (int i = 0; i < NUM_DOWN_PART; i++)
         {
-            if (0 == i) //initialize RD with previous depth buffer
-            {
+            if (i) //initialize RD with previous depth buffer
+                m_rdEntropyCoders[nextDepth][CI_CURR_BEST].load(m_rdEntropyCoders[nextDepth][CI_NEXT_BEST]);
+            else
                 m_rdEntropyCoders[nextDepth][CI_CURR_BEST].load(m_rdEntropyCoders[onePart->partLevel][CI_CURR_BEST]);
-            }
-            else
-            {
-                m_rdEntropyCoders[nextDepth][CI_CURR_BEST].load(m_rdEntropyCoders[nextDepth][CI_NEXT_BEST]);
-            }
+
             runQuadTreeDecision(qtPart, onePart->downPartsIdx[i], costFinal, maxLevel, lambda, yCbCr);
             costSplit += costFinal;
             m_rdEntropyCoders[nextDepth][CI_NEXT_BEST].load(m_rdEntropyCoders[nextDepth][CI_TEMP_BEST]);
@@ -366,17 +317,13 @@ void TEncSampleAdaptiveOffset::runQuadTr
             costFinal = costNotSplit;
             onePart->bSplit = false;
             for (int i = 0; i < NUM_DOWN_PART; i++)
-            {
                 disablePartTree(qtPart, onePart->downPartsIdx[i]);
-            }
 
             m_rdEntropyCoders[onePart->partLevel][CI_NEXT_BEST].load(m_rdEntropyCoders[onePart->partLevel][CI_TEMP_BEST]);
         }
     }
     else
-    {
         costFinal = onePart->minCost;
-    }
 }
 
 /** delete allocated memory of TEncSampleAdaptiveOffset class.
@@ -426,9 +373,7 @@ void TEncSampleAdaptiveOffset::destroyEn
     m_offsetOrgPreDblk = NULL;
 }
 
-/** create Encoder Buffer for SAO
- * \param
- */
+/* create Encoder Buffer for SAO */
 void TEncSampleAdaptiveOffset::createEncBuffer()
 {
     m_distOrg = X265_MALLOC(int64_t, m_numTotalParts);
@@ -461,16 +406,15 @@ void TEncSampleAdaptiveOffset::createEnc
         }
     }
 
-    int numLcu = m_numCuInWidth * m_numCuInHeight;
-    if (m_countPreDblk == NULL)
+    if (!m_countPreDblk)
     {


More information about the x265-commits mailing list