[x265] [PATCH 1 of 2] Fixed slicetypeAnalyse() for no-B config

shazeb at multicorewareinc.com shazeb at multicorewareinc.com
Mon Sep 2 12:49:22 CEST 2013


# HG changeset patch
# User Shazeb Nawaz Khan <shazeb at multicorewareinc.com>
# Date 1378118617 -19800
#      Mon Sep 02 16:13:37 2013 +0530
# Node ID e2d93166e034040d61c897264e1dfe7aeeb3d661
# Parent  3ea029900ab3ee58ed6b16c5c5a0a89975ba8c03
Fixed slicetypeAnalyse() for no-B config

diff -r 3ea029900ab3 -r e2d93166e034 source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Mon Sep 02 12:40:15 2013 +0530
+++ b/source/encoder/slicetype.cpp	Mon Sep 02 16:13:37 2013 +0530
@@ -105,13 +105,12 @@
         pic->m_lowres.gopIdx = 0;
         outputQueue.pushBack(pic);
         numDecided++;
+        lastKeyframe = 0;
         return;
     }
 
 #if 0
     slicetypeAnalyse(false);
-#else
-    // Fake lookahead using HM's fixed GOP structure
 
     int batchSize = cfg->getGOPSize();
     for (int i = 0; i < batchSize; i++)
@@ -140,7 +139,8 @@
         {
             inputQueue.popFront();
         }
-#endif
+
+#endif // if 0
 }
 
 // Called by RateControl to get the estimated SATD cost for a given picture.
@@ -153,6 +153,7 @@
     int poc = pic->getSlice()->getPOC();
     int l0poc = pic->getSlice()->getRefPOC(REF_PIC_LIST_0, 0);
     int l1poc = pic->getSlice()->getRefPOC(REF_PIC_LIST_1, 0);
+
     switch (pic->getSlice()->getSliceType())
     {
     case I_SLICE:
@@ -171,8 +172,8 @@
             d1 = l1poc - poc;
             frames[0] = &pic->getSlice()->getRefPic(REF_PIC_LIST_0, 0)->m_lowres;
             frames[d0] = &pic->m_lowres;
-            frames[d0+d1] = &pic->getSlice()->getRefPic(REF_PIC_LIST_1, 0)->m_lowres;
-            return estimateFrameCost(0, d0+d1, d0, false);
+            frames[d0 + d1] = &pic->getSlice()->getRefPic(REF_PIC_LIST_1, 0)->m_lowres;
+            return estimateFrameCost(0, d0 + d1, d0, false);
         }
         else
         {
@@ -404,12 +405,13 @@
     int vbv_lookahead = 0;
 
     TComList<TComPic*>::iterator iterPic = inputQueue.begin();
-    for (framecnt = 0; framecnt < maxSearch; framecnt++)
+    for (framecnt = 0; (framecnt < maxSearch) && (framecnt < inputQueue.size()); framecnt++)
     {
-        frames[framecnt] = &((*iterPic++)->m_lowres);
+        frames[framecnt + 1] = &((*iterPic++)->m_lowres);
+        frames[framecnt + 1]->sliceType = X265_TYPE_AUTO;
     }
 
-    keyint_limit = cfg->param.keyframeMax - frames[0]->frameNum + lastKeyframe - 1;
+    keyint_limit = cfg->param.keyframeMax - frames[1]->frameNum + lastKeyframe;
     origNumFrames = num_frames = X265_MIN(framecnt, keyint_limit);
 
     /* This is important psy-wise: if we have a non-scenecut keyframe,
@@ -545,6 +547,12 @@
 
     // TODO if rc.b_mb_tree Enabled the need to call  x264_macroblock_tree currently Ignored the call
 
+    for (int j = keyint_limit + 1; j <= num_frames; j += cfg->param.keyframeMax)
+    {
+        frames[j]->sliceType = X265_TYPE_I;
+        reset_start = X265_MIN(reset_start, j + 1);
+    }
+
     /* Restore frametypes for all frames that haven't actually been decided yet. */
     for (int j = reset_start; j <= num_frames; j++)
     {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265-1.patch
Type: text/x-patch
Size: 3026 bytes
Desc: not available
URL: <https://mailman.videolan.org/private/x265-devel/attachments/20130902/ea6a9a4e/attachment.bin>


More information about the x265-devel mailing list