[x265] [PATCH 4 of 4] Do not wait until all the frames in a stream are flushed, return to API as soon as one frame is flushed
santhoshini at multicorewareinc.com
santhoshini at multicorewareinc.com
Tue Nov 7 07:52:41 CET 2017
# HG changeset patch
# User Santhoshini Sekar <santhoshini at multicorewareinc.com>
# Date 1502275399 -19800
# Wed Aug 09 16:13:19 2017 +0530
# Node ID e5d68466150ca6d68e8222e346614c8e5a97f77f
# Parent 82708090cf1d29c4a81ff99acbb5945c86b81185
Do not wait until all the frames in a stream are flushed, return to API as soon as one frame is flushed.
In few cases it is better to flush only one frame in x265-lib and return to API. The
application should flush the remaining frames in the stream in these situations. This is
especially useful when the application wants to retrieve information from the lib.
diff --git a/source/encoder/api.cpp b/source/encoder/api.cpp
--- a/source/encoder/api.cpp
+++ b/source/encoder/api.cpp
@@ -257,7 +257,9 @@
{
numEncoded = encoder->encode(pic_in, pic_out);
}
- while (numEncoded == 0 && !pic_in && encoder->m_numDelayedPic && !encoder->m_latestParam->forceFlush);
+ while ((numEncoded == 0 && !pic_in && encoder->m_numDelayedPic && !encoder->m_latestParam->forceFlush) && !encoder->m_externalFlush);
+ if (numEncoded)
+ encoder->m_externalFlush = false;
// do not allow reuse of these buffers for more than one picture. The
// encoder now owns these analysisData buffers.
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -2342,6 +2342,10 @@
void Encoder::configure(x265_param *p)
{
this->m_param = p;
+ if (p->bMVType == AVC_INFO)
+ this->m_externalFlush = true;
+ else
+ this->m_externalFlush = false;
if (p->keyframeMax < 0)
{
/* A negative max GOP size indicates the user wants only one I frame at
diff --git a/source/encoder/encoder.h b/source/encoder/encoder.h
--- a/source/encoder/encoder.h
+++ b/source/encoder/encoder.h
@@ -138,6 +138,7 @@
RateControl* m_rateControl;
Lookahead* m_lookahead;
+ bool m_externalFlush;
/* Collect statistics globally */
EncStats m_analyzeAll;
EncStats m_analyzeI;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265-4.patch
Type: text/x-patch
Size: 2105 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20171107/7742c333/attachment-0001.bin>
More information about the x265-devel
mailing list