[x265] [PATCH 1 of 3] Introduce structure needed for Intra-refresh

santhoshini at multicorewareinc.com santhoshini at multicorewareinc.com
Mon Sep 7 14:30:28 CEST 2015


# HG changeset patch
# User Santhoshini Sekar<santhoshini at multicorewareinc.com>
# Date 1441619453 -19800
#      Mon Sep 07 15:20:53 2015 +0530
# Node ID 2ba81f60f111c12a8f668ece13b23123702f2582
# Parent  44cc2ce22c43ee04c67f669f2667a6e25747c4f9
Introduce structure needed for Intra-refresh

diff -r 44cc2ce22c43 -r 2ba81f60f111 source/common/framedata.cpp
--- a/source/common/framedata.cpp	Thu Sep 03 22:26:21 2015 +0530
+++ b/source/common/framedata.cpp	Mon Sep 07 15:20:53 2015 +0530
@@ -43,6 +43,7 @@
 
     CHECKED_MALLOC(m_cuStat, RCStatCU, sps.numCUsInFrame);
     CHECKED_MALLOC(m_rowStat, RCStatRow, sps.numCuInHeight);
+    CHECKED_MALLOC(m_pir, PeriodicIR, 1);
     reinit(sps);
     return true;
 
@@ -54,6 +55,7 @@
 {
     memset(m_cuStat, 0, sps.numCUsInFrame * sizeof(*m_cuStat));
     memset(m_rowStat, 0, sps.numCuInHeight * sizeof(*m_rowStat));
+    memset(m_pir, 0, sizeof(*m_pir));
 }
 
 void FrameData::destroy()
@@ -66,4 +68,5 @@
 
     X265_FREE(m_cuStat);
     X265_FREE(m_rowStat);
+    X265_FREE(m_pir);
 }
diff -r 44cc2ce22c43 -r 2ba81f60f111 source/common/framedata.h
--- a/source/common/framedata.h	Thu Sep 03 22:26:21 2015 +0530
+++ b/source/common/framedata.h	Mon Sep 07 15:20:53 2015 +0530
@@ -134,7 +134,16 @@
     RCStatCU*      m_cuStat;
     RCStatRow*     m_rowStat;
     FrameStats     m_frameStats; // stats of current frame for multi-pass encodes
+    /* data needed for periodic intra refresh */
+    struct PeriodicIR
+    {
+        double    position;
+        uint32_t       pirStartPelX;
+        uint32_t       pirEndPelX;
+        int       framesSinceLastPir;
+    };
 
+    PeriodicIR*    m_pir;
     double         m_avgQpRc;    /* avg QP as decided by rate-control */
     double         m_avgQpAq;    /* avg QP as decided by AQ in addition to rate-control */
     double         m_rateFactor; /* calculated based on the Frame QP */
diff -r 44cc2ce22c43 -r 2ba81f60f111 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Thu Sep 03 22:26:21 2015 +0530
+++ b/source/encoder/encoder.cpp	Mon Sep 07 15:20:53 2015 +0530
@@ -1517,6 +1517,7 @@
         p->rc.cuTree = 0;
         p->bEnableWeightedPred = 0;
         p->bEnableWeightedBiPred = 0;
+        p->bIntraRefresh = 0;
 
         /* SPSs shall have sps_max_dec_pic_buffering_minus1[ sps_max_sub_layers_minus1 ] equal to 0 only */
         p->maxNumReferences = 1;
@@ -1607,6 +1608,24 @@
 
     if (p->totalFrames && p->totalFrames <= 2 * ((float)p->fpsNum) / p->fpsDenom && p->rc.bStrictCbr)
         p->lookaheadDepth = p->totalFrames;
+    if (p->bIntraRefresh && p->maxNumReferences > 1)
+    {
+        x265_log(p,  X265_LOG_WARNING, "Max References > 1 + intra-refresh is not supported , setting max num references = 1\n");
+        p->maxNumReferences = 1;
+    }
+    if (p->bIntraRefresh && p->maxNumReferences == 1)
+    {
+        if (p->bBPyramid == 1 && p->bframes > 0)
+            x265_log(p,  X265_LOG_WARNING, "B pyramid cannot be enabled when max references is 1, Disabling B pyramid\n");
+        p->bBPyramid = 0;
+    }
+
+    if (p->bIntraRefresh && p->bOpenGOP)
+    {
+        x265_log(p,  X265_LOG_WARNING, "Open Gop disabled, Intra Refresh is not compatible with openGop\n");
+        p->bOpenGOP = 0;
+    }
+
 
     if (p->scalingLists && p->internalCsp == X265_CSP_I444)
     {
diff -r 44cc2ce22c43 -r 2ba81f60f111 source/x265.h
--- a/source/x265.h	Thu Sep 03 22:26:21 2015 +0530
+++ b/source/x265.h	Mon Sep 07 15:20:53 2015 +0530
@@ -702,6 +702,11 @@
      * should detect scene cuts. The default (40) is recommended. */
     int       scenecutThreshold;
 
+    /* Replace keyframes by using a column of intra blocks that move across the video
+     * from one side to the other, thereby "refreshing" the image. In effect, instead of a
+     * big keyframe, the keyframe is "spread" over many frames. */
+    int       bIntraRefresh;
+
     /*== Coding Unit (CU) definitions ==*/
 
     /* Maximum CU width and height in pixels.  The size must be 64, 32, or 16.


More information about the x265-devel mailing list