[x265] [PATCH 5 of 5] zone: Add support for RADL pictures

Pooja Venkatesan pooja at multicorewareinc.com
Thu Dec 20 06:40:14 CET 2018


# HG changeset patch
# User Pooja Venkatesan <pooja at multicorewareinc.com>
# Date 1544770885 -19800
#      Fri Dec 14 12:31:25 2018 +0530
# Node ID d5d79e22bfddda8c103da2182a68137757340425
# Parent  1a62483c0b7549ef677ce2f343e9c7f1fcd45c44
zone: Add support for RADL pictures

diff -r 1a62483c0b75 -r d5d79e22bfdd source/common/param.cpp
--- a/source/common/param.cpp Fri Dec 14 12:28:56 2018 +0530
+++ b/source/common/param.cpp Fri Dec 14 12:31:25 2018 +0530
@@ -624,6 +624,7 @@
     OPT("amp") p->bEnableAMP = atobool(value);
     OPT("max-merge") p->maxNumMergeCand = (uint32_t)atoi(value);
     OPT("rd") p->rdLevel = atoi(value);
+    OPT("radl") p->radl = atoi(value);
     OPT2("rdoq", "rdoq-level")
     {
         int bval = atobool(value);
diff -r 1a62483c0b75 -r d5d79e22bfdd source/encoder/dpb.h
--- a/source/encoder/dpb.h Fri Dec 14 12:28:56 2018 +0530
+++ b/source/encoder/dpb.h Fri Dec 14 12:31:25 2018 +0530
@@ -52,6 +52,14 @@
         m_lastIDR = 0;
         m_pocCRA = 0;
         m_bhasLeadingPicture = param->radl;
+        for (int i = 0; i < param->rc.zonefileCount; i++)
+        {
+            if (param->rc.zones[i].zoneParam->radl)
+            {
+                m_bhasLeadingPicture = param->rc.zones[i].zoneParam->radl;
+                break;
+            }
+        }
         m_bRefreshPending = false;
         m_frameDataFreeList = NULL;
         m_bOpenGOP = param->bOpenGOP;
diff -r 1a62483c0b75 -r d5d79e22bfdd source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Fri Dec 14 12:28:56 2018 +0530
+++ b/source/encoder/encoder.cpp Fri Dec 14 12:31:25 2018 +0530
@@ -2652,6 +2652,7 @@
         p->rc.qp = zone->rc.qp;
         p->rc.aqMode = X265_AQ_NONE;
     }
+    p->radl = zone->radl;

     memcpy(zone, p, sizeof(x265_param));
 }
diff -r 1a62483c0b75 -r d5d79e22bfdd source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp Fri Dec 14 12:28:56 2018 +0530
+++ b/source/encoder/slicetype.cpp Fri Dec 14 12:31:25 2018 +0530
@@ -1117,7 +1117,9 @@
             }
             for (int i = 0; i < m_param->rc.zonefileCount; i++)
             {
-                if (m_param->rc.zones[i].startFrame == frm.frameNum)
+                int curZoneStart = m_param->rc.zones[i].startFrame;
+                curZoneStart += curZoneStart ?
m_param->rc.zones[i].zoneParam->radl : 0;
+                if (curZoneStart == frm.frameNum)
                     frm.sliceType = X265_TYPE_IDR;
             }
             if ((frm.sliceType == X265_TYPE_I && frm.frameNum -
m_lastKeyframe >= m_param->keyframeMin) || (frm.frameNum ==
(m_param->chunkStart - 1)) || (frm.frameNum == m_param->chunkEnd))
@@ -1135,7 +1137,20 @@
                 /* Closed GOP */
                 m_lastKeyframe = frm.frameNum;
                 frm.bKeyframe = true;
-                if (bframes > 0 && !m_param->radl)
+                int zoneRadl = 0;
+                for (int i = 0; i < m_param->rc.zonefileCount; i++)
+                {
+                    int zoneStart = m_param->rc.zones[i].startFrame;
+                    zoneStart += zoneStart ?
m_param->rc.zones[i].zoneParam->radl : 0;
+                    if (zoneStart == frm.frameNum)
+                    {
+                        zoneRadl = m_param->rc.zones[i].zoneParam->radl;
+                        m_param->radl = 0;
+                        m_param->rc.zones->zoneParam->radl = i <
m_param->rc.zonefileCount - 1? m_param->rc.zones[i + 1].zoneParam->radl : 0;
+                        break;
+                    }
+                }
+                if (bframes > 0 && !m_param->radl && !zoneRadl)
                 {
                     list[bframes - 1]->m_lowres.sliceType = X265_TYPE_P;
                     bframes--;
@@ -1423,6 +1438,14 @@
     }
     frames[framecnt + 1] = NULL;

+    for (int i = 0; i < m_param->rc.zonefileCount; i++)
+    {
+        int curZoneStart = m_param->rc.zones[i].startFrame, nextZoneStart
= 0;
+        curZoneStart += curZoneStart ?
m_param->rc.zones[i].zoneParam->radl : 0;
+        nextZoneStart += (i + 1 < m_param->rc.zonefileCount) ?
m_param->rc.zones[i + 1].startFrame + m_param->rc.zones[i +
1].zoneParam->radl : m_param->totalFrames;
+        if (curZoneStart <= frames[0]->frameNum && nextZoneStart >
frames[0]->frameNum)
+            m_param->keyframeMax = nextZoneStart - curZoneStart;
+    }
     int keylimit = m_param->keyframeMax;
     if (frames[0]->frameNum < m_param->chunkEnd)
     {
@@ -1632,14 +1655,16 @@
             frames[numFrames]->sliceType = X265_TYPE_P;
         }

-        bool bForceRADL = m_param->radl && !m_param->bOpenGOP;
+        int zoneRadl = m_param->rc.zonefileCount ?
m_param->rc.zones->zoneParam->radl : 0;
+        bool bForceRADL = (m_param->radl || zoneRadl) &&
!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*/
+        int radl = m_param->radl ? m_param->radl : zoneRadl;
+        int preRADL = m_lastKeyframe + m_param->keyframeMax - radl - 1;
/*Frame preceeding RADL in POC order*/
         if (bForceRADL && (frames[0]->frameNum == preRADL) &&
!bLastMiniGop)
         {
             int j = 1;
-            numBFrames = m_param->radl;
-            for (; j <= m_param->radl; j++)
+            numBFrames = m_param->radl ? m_param->radl : zoneRadl;
+            for (; j <= numBFrames; j++)
                 frames[j]->sliceType = X265_TYPE_B;
             frames[j]->sliceType = X265_TYPE_I;
         }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20181220/3078269a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265-clean-5 (1).patch
Type: application/octet-stream
Size: 5672 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20181220/3078269a/attachment-0001.obj>


More information about the x265-devel mailing list