[x265] [PATCH] lookahead: overloading addPicture() function

ashok at multicorewareinc.com ashok at multicorewareinc.com
Wed Aug 31 16:25:47 CEST 2016


# HG changeset patch
# User Ashok Kumar Mishra<ashok at multicorewareinc.com>
# Date 1470815778 -19800
#      Wed Aug 10 13:26:18 2016 +0530
# Node ID 0c6a83f3621ad21351b068927c5015af2a980520
# Parent  5a0e139e29386ecebafc9c555aedcd3e0f61c70c
lookahead: overloading addPicture() function

diff -r 5a0e139e2938 -r 0c6a83f3621a source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Fri Jul 22 13:13:42 2016 +0530
+++ b/source/encoder/slicetype.cpp	Wed Aug 10 13:26:18 2016 +0530
@@ -670,6 +670,31 @@
     m_inputLock.release();
 }
 
+void Lookahead::addPicture(Frame& curFrame)
+{
+    m_inputLock.acquire();
+    m_inputQueue.pushBack(curFrame);
+    m_inputLock.release();
+}
+
+void Lookahead::checkLookaheadQueue(int &frameCnt)
+{
+    /* determine if the lookahead is (over) filled enough for frames to begin to
+     * be consumed by frame encoders */
+    if (!m_filled)
+    {
+        if (!m_param->bframes & !m_param->lookaheadDepth)
+            m_filled = true; /* zero-latency */
+        else if (frameCnt >= m_param->lookaheadDepth + 2 + m_param->bframes)
+            m_filled = true; /* full capacity plus mini-gop lag */
+    }
+
+    m_inputLock.acquire();
+    if (m_pool && m_inputQueue.size() >= m_fullQueueSize)
+        tryWakeOne();
+    m_inputLock.release();
+}
+
 /* Called by API thread */
 void Lookahead::flush()
 {
diff -r 5a0e139e2938 -r 0c6a83f3621a source/encoder/slicetype.h
--- a/source/encoder/slicetype.h	Fri Jul 22 13:13:42 2016 +0530
+++ b/source/encoder/slicetype.h	Wed Aug 10 13:26:18 2016 +0530
@@ -144,6 +144,8 @@
     void    stopJobs();
 
     void    addPicture(Frame&, int sliceType);
+    void    addPicture(Frame& curFrame);
+    void    checkLookaheadQueue(int &frameCnt);
     void    flush();
     Frame*  getDecidedPicture();
 


More information about the x265-devel mailing list