changeset 3901:86603fe88df5

slicetype: B-frames analysis integrated
author Deepthi Devaki <deepthidevaki@multicorewareinc.com>
date Fri, 06 Sep 2013 15:44:22 +0530
parents 9c4c2b1c7fe0
children 66b3f3b38e84
files source/encoder/slicetype.cpp
diffstat 1 files changed, 12 insertions(+-), 3 deletions(-) [+]
line wrap: on
line diff
--- a/source/encoder/slicetype.cpp	Fri Sep 06 15:35:18 2013 +0530
+++ b/source/encoder/slicetype.cpp	Fri Sep 06 15:44:22 2013 +0530
@@ -112,21 +112,30 @@ void Lookahead::slicetypeDecide()
 #if 0
     slicetypeAnalyse(false);
 
-    // This will work only in all-P config
     int dframes;
+    TComPic* picsAnalysed[X265_LOOKAHEAD_MAX];  //Used for sorting the pics in encode order
+    int idx = 1;
+
     for (dframes = 0; (frames[dframes + 1] != NULL) && (frames[dframes + 1]->sliceType != X265_TYPE_AUTO); dframes++)
     {}
 
     TComPic *pic = NULL;
-    for (int i = 1; i <= dframes && i <= inputQueue.size(); i++)
+    for (int i = 1; i <= dframes && !inputQueue.empty(); i++)
     {
         pic = inputQueue.popFront();
-        outputQueue.pushBack(pic);
+        picsAnalysed[idx++] = pic;
         if ((pic->m_lowres.sliceType == X265_TYPE_I) && !(pic->getPOC() % cfg->param.keyframeMax))
         {
             lastKeyframe = pic->getPOC();
         }
     }
+    picsAnalysed[0] = pic;  //Move the P-frame following B-frames to the beginning
+
+    //Push pictures in encode order
+    for (int i = 0; i < dframes ; i++)
+    {
+        outputQueue.pushBack(picsAnalysed[i]);
+    }
     if (pic)
         frames[0] = &(pic->m_lowres); // last nonb