[x265-commits] [x265] SEI: enable generation of recovery point SEI message for ...

Kavitha Sampath kavitha at multicorewareinc.com
Thu May 8 20:28:22 CEST 2014


details:   http://hg.videolan.org/x265/rev/8e64aa56d635
branches:  
changeset: 6830:8e64aa56d635
user:      Kavitha Sampath <kavitha at multicorewareinc.com>
date:      Thu May 08 11:01:04 2014 +0530
description:
SEI: enable generation of recovery point SEI message for keyframes

SEI recovery points are inserted for every keyframe which tells the decoder an
identifier of the recovery point from which perfectly valid pictures can be
displayed no matter what the starting point of decoding is. The SEI specifies
recovery_poc_cnt that counts the number of frames after which perfect video can
be displayed to the user. Pictures encoded after the CRA but precede it in
display order(leading) are ignored by the decoder and pictures following CRA in
POC order(trailing) do not reference pictures prior to the recent CRA and are
guaranteed to be displayable. Hence recovery_poc_cnt is zero.
Subject: [x265] slicetype: update the lowresCosts and intraCosts when aq/cutree is enabled

details:   http://hg.videolan.org/x265/rev/59a43a5cc704
branches:  
changeset: 6831:59a43a5cc704
user:      Aarthi Thirumalai
date:      Thu May 08 11:14:48 2014 +0530
description:
slicetype: update the lowresCosts and intraCosts when aq/cutree is enabled

diffstat:

 source/encoder/encoder.cpp      |   1 -
 source/encoder/encoder.h        |   1 -
 source/encoder/frameencoder.cpp |  13 ++++++++++---
 source/encoder/slicetype.cpp    |  32 +++++++++++++++++++++++++-------
 4 files changed, 35 insertions(+), 12 deletions(-)

diffs (133 lines):

diff -r fdce542171cb -r 59a43a5cc704 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Thu May 08 00:29:21 2014 -0500
+++ b/source/encoder/encoder.cpp	Thu May 08 11:14:48 2014 +0530
@@ -1420,7 +1420,6 @@ void Encoder::configure(x265_param *p)
 
     m_nonPackedConstraintFlag = false;
     m_frameOnlyConstraintFlag = false;
-    m_recoveryPointSEIEnabled = 0;
     m_bufferingPeriodSEIEnabled = 0;
     m_displayOrientationSEIAngle = 0;
     m_gradualDecodingRefreshInfoEnabled = 0;
diff -r fdce542171cb -r 59a43a5cc704 source/encoder/encoder.h
--- a/source/encoder/encoder.h	Thu May 08 00:29:21 2014 -0500
+++ b/source/encoder/encoder.h	Thu May 08 11:14:48 2014 +0530
@@ -157,7 +157,6 @@ public:
     bool               m_loopFilterAcrossTilesEnabledFlag;
 
     int                m_bufferingPeriodSEIEnabled;
-    int                m_recoveryPointSEIEnabled;
     int                m_displayOrientationSEIAngle;
     int                m_gradualDecodingRefreshInfoEnabled;
     int                m_decodingUnitInfoSEIEnabled;
diff -r fdce542171cb -r 59a43a5cc704 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Thu May 08 00:29:21 2014 -0500
+++ b/source/encoder/frameencoder.cpp	Thu May 08 11:14:48 2014 +0530
@@ -473,7 +473,7 @@ void FrameEncoder::compressFrame()
         slice->setNextSlice(true);
     }
 
-    if ((m_cfg->m_recoveryPointSEIEnabled) && (slice->getSliceType() == I_SLICE))
+    if (slice->getPic()->m_lowres.bKeyframe)
     {
         if (m_cfg->m_gradualDecodingRefreshInfoEnabled && !slice->getRapPicFlag())
         {
@@ -492,12 +492,19 @@ void FrameEncoder::compressFrame()
                 m_nalCount++;
             }
         }
-        // Recovery point SEI
+        // The recovery point SEI message assists a decoder in determining when the decoding
+        // process will produce acceptable pictures for display after the decoder initiates
+        // random access. The m_recoveryPocCnt is in units of POC(picture order count) which
+        // means pictures encoded after the CRA but precede it in display order(leading) are
+        // implicitly discarded after a random access seek regardless of the value of
+        // m_recoveryPocCnt. Our encoder does not use references prior to the most recent CRA,
+        // so all pictures following the CRA in POC order are guaranteed to be displayable,
+        // so m_recoveryPocCnt is always 0.
         OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
 
         SEIRecoveryPoint sei_recovery_point;
         sei_recovery_point.m_recoveryPocCnt    = 0;
-        sei_recovery_point.m_exactMatchingFlag = (slice->getPOC() == 0) ? (true) : (false);
+        sei_recovery_point.m_exactMatchingFlag = true;
         sei_recovery_point.m_brokenLinkFlag    = false;
 
         m_seiWriter.writeSEImessage(nalu.m_bitstream, sei_recovery_point, slice->getSPS());
diff -r fdce542171cb -r 59a43a5cc704 source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Thu May 08 00:29:21 2014 -0500
+++ b/source/encoder/slicetype.cpp	Thu May 08 11:14:48 2014 +0530
@@ -255,6 +255,10 @@ int64_t Lookahead::getEstimatedPictureCo
         uint32_t lowresRow = 0, lowresCol = 0, lowresCuIdx = 0, sum = 0;
         uint32_t scale = param->maxCUSize / (2 * X265_LOWRES_CU_SIZE);
         uint32_t widthInLowresCu = (uint32_t)widthInCU, heightInLowresCu = (uint32_t)heightInCU;
+        double *qp_offset = 0;
+        /* Factor in qpoffsets based on Aq/Cutree in CU costs */
+        if (param->rc.aqMode)
+            qp_offset = (frames[b]->sliceType == X265_TYPE_B || !param->rc.cuTree) ? frames[b]->qpAqOffset : frames[b]->qpOffset;
 
         for (uint32_t row = 0; row < pic->getFrameHeightInCU(); row++)
         {
@@ -265,9 +269,16 @@ int64_t Lookahead::getEstimatedPictureCo
                 lowresCuIdx = lowresRow * widthInLowresCu;
                 for (lowresCol = 0; lowresCol < widthInLowresCu; lowresCol++, lowresCuIdx++)
                 {
-                    sum += pic->m_lowres.lowresCostForRc[lowresCuIdx] & LOWRES_COST_MASK;
+                    uint16_t lowresCuCost = pic->m_lowres.lowresCostForRc[lowresCuIdx] & LOWRES_COST_MASK;
+                    if (qp_offset)
+                    {
+                        lowresCuCost = (lowresCuCost * x265_exp2fix8(qp_offset[lowresCuIdx]) + 128) >> 8;
+                        uint16_t intraCuCost = pic->m_lowres.intraCost[lowresCuIdx]; 
+                        pic->m_lowres.intraCost[lowresCuIdx] = (intraCuCost * x265_exp2fix8(qp_offset[lowresCuIdx]) + 128) >> 8;
+                    }
+                    pic->m_lowres.lowresCostForRc[lowresCuIdx] = lowresCuCost;
+                    sum += lowresCuCost;
                 }
-
                 pic->m_rowSatdForVbv[row] += sum;
             }
         }
@@ -1651,17 +1662,20 @@ void EstimateRow::estimateCUCost(Lowres 
             if (cost < icost)
                 icost = cost;
         }
-
         const int intraPenalty = 5 * lookAheadLambda;
         icost += intraPenalty + lowresPenalty;
         fenc->intraCost[cuXY] = icost;
-        fenc->rowSatds[0][0][cuy] += icost;
+        int icostAq = icost;
         if (bFrameScoreCU)
         {
             costIntra += icost;
             if (fenc->invQscaleFactor)
-                costIntraAq += (icost * fenc->invQscaleFactor[cuXY] + 128) >> 8;
+            {
+                icostAq = (icost * fenc->invQscaleFactor[cuXY] + 128) >> 8;
+                costIntraAq += icostAq;
+            }
         }
+        fenc->rowSatds[0][0][cuy] += icostAq;
     }
     bcost += lowresPenalty;
     if (!bBidir)
@@ -1677,13 +1691,17 @@ void EstimateRow::estimateCUCost(Lowres 
     /* For I frames these costs were accumulated earlier */
     if (p0 != p1)
     {
-        fenc->rowSatds[b - p0][p1 - b][cuy] += bcost;
+        int bcostAq = bcost;
         if (bFrameScoreCU)
         {
             costEst += bcost;
             if (fenc->invQscaleFactor)
-                costEstAq += (bcost * fenc->invQscaleFactor[cuXY] + 128) >> 8;
+            {
+                bcostAq = (bcost * fenc->invQscaleFactor[cuXY] + 128) >> 8;
+                costEstAq += bcostAq;
+            }
         }
+        fenc->rowSatds[b - p0][p1 - b][cuy] += bcostAq;
     }
     fenc->lowresCosts[b - p0][p1 - b][cuXY] = (uint16_t)(X265_MIN(bcost, LOWRES_COST_MASK) | (listused << LOWRES_COST_SHIFT));
 }


More information about the x265-commits mailing list