changeset 3845:7df7dab02f10

using slicetypes from lookahead
author Deepthi Devaki <deepthidevaki@multicorewareinc.com>
date Wed, 04 Sep 2013 16:35:21 +0530
parents 6b2797b588c7
children 43a27c6d551d
files source/Lib/TLibEncoder/TEncTop.cpp source/encoder/dpb.cpp source/encoder/frameencoder.cpp source/encoder/frameencoder.h source/encoder/slicetype.cpp
diffstat 5 files changed, 7 insertions(+-), 22 deletions(-) [+]
line wrap: on
line diff
--- a/source/Lib/TLibEncoder/TEncTop.cpp	Wed Sep 04 19:22:57 2013 +0800
+++ b/source/Lib/TLibEncoder/TEncTop.cpp	Wed Sep 04 16:35:21 2013 +0530
@@ -246,13 +246,9 @@ int TEncTop::encode(bool flush, const x2
         // pop a single frame from decided list, prepare, then provide to frame encoder
         // curEncoder is guaranteed to be idle at this point
         TComPic *fenc = m_lookahead->outputQueue.popFront();
-
         // Initialise slice in Frame Encoder
-        int pocCurr = fenc->getSlice()->getPOC();
-        bool forceIntra = m_dpb->m_cfg->param.keyframeMax == 1 || (pocCurr % m_dpb->m_cfg->param.keyframeMax == 0) || pocCurr == 0;
         int gopIdx = fenc->m_lowres.gopIdx;
-        curEncoder->initSlice(fenc, forceIntra, gopIdx);
-
+        curEncoder->initSlice(fenc,gopIdx);
         // determine references, set QP, etc
         m_dpb->prepareEncode(fenc, curEncoder);
         if (m_rateControl->rateControlMode == X265_RC_ABR)
--- a/source/encoder/dpb.cpp	Wed Sep 04 19:22:57 2013 +0800
+++ b/source/encoder/dpb.cpp	Wed Sep 04 16:35:21 2013 +0530
@@ -78,14 +78,8 @@ void DPB::prepareEncode(TComPic *pic, Fr
         m_lastIDR = pocCurr;
     }
     slice->setLastIDR(m_lastIDR);
-
-    if (slice->getSliceType() == B_SLICE && m_cfg->getGOPEntry(gopIdx).m_sliceType == 'P')
-    {
-        slice->setSliceType(P_SLICE);
-    }
     slice->setReferenced(slice->getSliceType() != B_SLICE);
     slice->setTemporalLayerNonReferenceFlag(!slice->isReferenced());
-
     // Set the nal unit type
     slice->setNalUnitType(getNalUnitType(pocCurr, m_lastIDR));
 
--- a/source/encoder/frameencoder.cpp	Wed Sep 04 19:22:57 2013 +0800
+++ b/source/encoder/frameencoder.cpp	Wed Sep 04 16:35:21 2013 +0530
@@ -209,8 +209,7 @@ int FrameEncoder::getStreamHeaders(Acces
     }
     return 0;
 }
-
-void FrameEncoder::initSlice(TComPic* pic, bool bForceISlice, int gopID)
+void FrameEncoder::initSlice(TComPic* pic, int gopID)
 {
     m_pic = pic;
     TComSlice* slice = pic->getSlice();
@@ -220,9 +219,8 @@ void FrameEncoder::initSlice(TComPic* pi
     slice->setPic(pic);
     slice->initSlice();
     slice->setPicOutputFlag(true);
-
-    // slice type
-    SliceType sliceType = bForceISlice ? I_SLICE : B_SLICE;
+    int type = pic->m_lowres.sliceType;
+    SliceType sliceType = IS_X265_TYPE_B(type)? B_SLICE : ((type == X265_TYPE_P) ? P_SLICE: I_SLICE );
     slice->setSliceType(sliceType);
     slice->setReferenced(true);
     slice->setScalingList(m_top->getScalingList());
--- a/source/encoder/frameencoder.h	Wed Sep 04 19:22:57 2013 +0800
+++ b/source/encoder/frameencoder.h	Wed Sep 04 16:35:21 2013 +0530
@@ -163,11 +163,8 @@ public:
         // Initialize global singletons (these should eventually be per-slice)
         m_sbacCoder.init((TEncBinIf*)&m_binCoderCABAC);
     }
-
     int getStreamHeaders(AccessUnit& accessUnitOut);
-
-    void initSlice(TComPic* pic, bool bForceISlice, int gopID);
-
+    void initSlice(TComPic* pic, int gopID);
     /* analyze / compress frame, can be run in parallel within reference constraints */
     void compressFrame(TComPic *pic);
 
--- a/source/encoder/slicetype.cpp	Wed Sep 04 19:22:57 2013 +0800
+++ b/source/encoder/slicetype.cpp	Wed Sep 04 16:35:21 2013 +0530
@@ -143,9 +143,9 @@ void Lookahead::slicetypeDecide()
         {
             iterPic++;
         }
-
         TComPic *pic = *iterPic;
-        pic->m_lowres.sliceType = cfg->getGOPEntry(i).m_sliceType;
+        bool forceIntra = cfg->param.keyframeMax == 1 || ( pic->getPOC() % cfg->param.keyframeMax == 0) || pic->getPOC() == 0;
+        pic->m_lowres.sliceType = forceIntra? X265_TYPE_I : (cfg->getGOPEntry(i).m_sliceType=='P')? X265_TYPE_P : X265_TYPE_B;
         pic->m_lowres.gopIdx = i;
         outputQueue.pushBack(pic);
         numDecided++;