[x265] [PATCH] Enhance VBV lookahead of RADL pictures

aruna at multicorewareinc.com aruna at multicorewareinc.com
Thu Jul 26 10:58:29 CEST 2018


# HG changeset patch
# User Aruna Matheswaran <aruna at multicorewareinc.com>
# Date 1532078824 -19800
#      Fri Jul 20 14:57:04 2018 +0530
# Node ID 29345837cd2057dd2cfca837c1a36cab94e41bc4
# Parent  79c76e42cb28876d3fa3141f5f1f1a6b3973af0a
Enhance VBV lookahead of RADL pictures

This patch does the following,
1) Modifies the slice type enforcement flow to enhance VBV lookahead of RADL frames.
2) Update test CLI.

diff -r 79c76e42cb28 -r 29345837cd20 source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Wed Jul 25 14:40:47 2018 +0530
+++ b/source/encoder/slicetype.cpp	Fri Jul 20 14:57:04 2018 +0530
@@ -1147,14 +1147,6 @@
                     bframes--;
                 }
             }
-            if (m_param->radl && !m_param->bOpenGOP && list[bframes + 1])
-            {
-                if ((frm.frameNum - m_lastKeyframe) > (m_param->keyframeMax - m_param->radl - 1) && (frm.frameNum - m_lastKeyframe) < m_param->keyframeMax)
-                    frm.sliceType = X265_TYPE_B;
-                if ((frm.frameNum - m_lastKeyframe) == (m_param->keyframeMax - m_param->radl - 1))
-                    frm.sliceType = X265_TYPE_P;
-            }
-
             if (bframes == m_param->bframes || !list[bframes + 1])
             {
                 if (IS_X265_TYPE_B(frm.sliceType))
@@ -1538,6 +1530,7 @@
     int numBFrames = 0;
     int numAnalyzed = numFrames;
     bool isScenecut = scenecut(frames, 0, 1, true, origNumFrames);
+
     /* When scenecut threshold is set, use scenecut detection for I frame placements */
     if (m_param->scenecutThreshold && isScenecut)
     {
@@ -1645,14 +1638,28 @@
             frames[numFrames]->sliceType = X265_TYPE_P;
         }
 
-        /* Check scenecut on the first minigop. */
-        for (int j = 1; j < numBFrames + 1; j++)
+        bool bForceRADL = m_param->radl && !m_param->bOpenGOP;
+        bool bLastMiniGop = (framecnt >= m_param->bframes + 1) ? false : true;
+        int preRADL = m_lastKeyframe + m_param->keyframeMax - m_param->radl - 1; /*Frame preceeding RADL in POC order*/
+        if (bForceRADL && (frames[0]->frameNum == preRADL) && !bLastMiniGop)
         {
-            if (scenecut(frames, j, j + 1, false, origNumFrames))
+            int j = 1;
+            numBFrames = m_param->radl;
+            for (; j <= m_param->radl; j++)
+                frames[j]->sliceType = X265_TYPE_B;
+            frames[j]->sliceType = X265_TYPE_I;
+        }
+        else /* Check scenecut and RADL on the first minigop. */
+        {
+            for (int j = 1; j < numBFrames + 1; j++)
             {
-                frames[j]->sliceType = X265_TYPE_P;
-                numAnalyzed = j;
-                break;
+                if (scenecut(frames, j, j + 1, false, origNumFrames) || 
+                    (bForceRADL && (frames[j]->frameNum == preRADL)))
+                {
+                    frames[j]->sliceType = X265_TYPE_P;
+                    numAnalyzed = j;
+                    break;
+                }
             }
         }
         resetStart = bKeyframe ? 1 : X265_MIN(numBFrames + 2, numAnalyzed + 1);
diff -r 79c76e42cb28 -r 29345837cd20 source/test/regression-tests.txt
--- a/source/test/regression-tests.txt	Wed Jul 25 14:40:47 2018 +0530
+++ b/source/test/regression-tests.txt	Fri Jul 20 14:57:04 2018 +0530
@@ -149,7 +149,7 @@
 Kimono1_1920x1080_24_400.yuv,--preset veryslow --crf 4 --cu-lossless --slices 2 --limit-refs 3 --limit-modes
 Kimono1_1920x1080_24_400.yuv,--preset placebo --ctu 32 --max-tu-size 8 --limit-tu 2
 big_buck_bunny_360p24.y4m, --keyint 60 --min-keyint 40 --gop-lookahead 14
-BasketballDrive_1920x1080_50.y4m, --preset medium --no-open-gop --keyint 50 --min-keyint 50 --radl 2
+BasketballDrive_1920x1080_50.y4m, --preset medium --no-open-gop --keyint 50 --min-keyint 50 --radl 2 --vbv-maxrate 5000 --vbv-bufsize 5000
 
 # Main12 intraCost overflow bug test
 720p50_parkrun_ter.y4m,--preset medium
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265-clone.patch
Type: text/x-patch
Size: 3933 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20180726/5760ba92/attachment.bin>


More information about the x265-devel mailing list