[x265] [PATCH] Fix dts calculation when disabling lookahead in analysis load mode

Divya Manivannan divya at multicorewareinc.com
Wed Oct 4 09:40:10 CEST 2017


# HG changeset patch
# User Divya Manivannan <divya at multicorewareinc.com>
# Date 1506315677 -19800
#      Mon Sep 25 10:31:17 2017 +0530
# Node ID 623fd118479831744b7b114bdce3f0026c006f68
# Parent  30998ebc3a3b7503f62e9ed520d7c67acca92b33
Fix dts calculation when disabling lookahead in analysis load mode

diff -r 30998ebc3a3b -r 623fd1184798 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Tue Oct 03 19:54:22 2017 +0530
+++ b/source/encoder/encoder.cpp	Mon Sep 25 10:31:17 2017 +0530
@@ -911,6 +911,7 @@
                         if (m_param->scaleFactor)
                             factor = m_param->scaleFactor * 2;
                         pic_out->analysisData.numCuInHeight = outFrame->m_analysisData.numCuInHeight;
+                        pic_out->analysisData.lookahead.dts = outFrame->m_dts;
                         pic_out->analysisData.satdCost *= factor;
                         pic_out->analysisData.lookahead.keyframe = outFrame->m_lowres.bKeyframe;
                         pic_out->analysisData.lookahead.lastMiniGopBFrame = outFrame->m_lowres.bLastMiniGopBFrame;
@@ -1099,6 +1100,7 @@
             }
             if (m_param->analysisReuseMode == X265_ANALYSIS_LOAD && m_param->bDisableLookahead)
             {
+                frameEnc->m_dts = frameEnc->m_analysisData.lookahead.dts;
                 for (uint32_t index = 0; index < frameEnc->m_analysisData.numCuInHeight; index++)
                 {
                     frameEnc->m_encData->m_rowStat[index].intraSatdForVbv = frameEnc->m_analysisData.lookahead.intraSatdForVbv[index];
@@ -1162,16 +1164,19 @@
             frameEnc->m_encData->m_slice->m_iNumRPSInSPS = m_sps.spsrpsNum;
 
             curEncoder->m_rce.encodeOrder = frameEnc->m_encodeOrder = m_encodedFrameNum++;
-            if (m_bframeDelay)
+            if (m_param->analysisReuseMode != X265_ANALYSIS_LOAD || !m_param->bDisableLookahead)
             {
-                int64_t *prevReorderedPts = m_prevReorderedPts;
-                frameEnc->m_dts = m_encodedFrameNum > m_bframeDelay
-                    ? prevReorderedPts[(m_encodedFrameNum - m_bframeDelay) % m_bframeDelay]
-                    : frameEnc->m_reorderedPts - m_bframeDelayTime;
-                prevReorderedPts[m_encodedFrameNum % m_bframeDelay] = frameEnc->m_reorderedPts;
+                if (m_bframeDelay)
+                {
+                    int64_t *prevReorderedPts = m_prevReorderedPts;
+                    frameEnc->m_dts = m_encodedFrameNum > m_bframeDelay
+                        ? prevReorderedPts[(m_encodedFrameNum - m_bframeDelay) % m_bframeDelay]
+                        : frameEnc->m_reorderedPts - m_bframeDelayTime;
+                    prevReorderedPts[m_encodedFrameNum % m_bframeDelay] = frameEnc->m_reorderedPts;
+                }
+                else
+                    frameEnc->m_dts = frameEnc->m_reorderedPts;
             }
-            else
-                frameEnc->m_dts = frameEnc->m_reorderedPts;
 
             /* Allocate analysis data before encode in save mode. This is allocated in frameEnc */
             if (m_param->analysisReuseMode == X265_ANALYSIS_SAVE)
diff -r 30998ebc3a3b -r 623fd1184798 source/x265.h
--- a/source/x265.h	Tue Oct 03 19:54:22 2017 +0530
+++ b/source/x265.h	Mon Sep 25 10:31:17 2017 +0530
@@ -100,6 +100,7 @@
     int       keyframe;
     int       lastMiniGopBFrame;
     int       plannedType[X265_LOOKAHEAD_MAX + 1];
+    int64_t   dts;
 } x265_lookahead_data;
 
 /* Stores all analysis data for a single frame */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265-clone.patch
Type: text/x-patch
Size: 3527 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20171004/ae3e3533/attachment.bin>


More information about the x265-devel mailing list