<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 2, 2018 at 7:37 PM, <span dir="ltr"><<a href="mailto:bhavna@multicorewareinc.com" target="_blank">bhavna@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Bhavna Hariharan <<a href="mailto:bhavna@multicorewareinc.com">bhavna@multicorewareinc.com</a>><br>
# Date 1530094711 -19800<br>
# Wed Jun 27 15:48:31 2018 +0530<br>
# Node ID 0a629ea6036b24d60d0a1bc8a7b2f6<wbr>d5cc476a02<br>
# Parent 289b8a3730ae108bbb9e4b295dc915<wbr>205ba2d0e9<br>
Avoid calling slicetypeDecide() routine when analysis-load is enabled.<br>
<br>
This patch does the following:<br>
1) Bypass slicetypeDecide() call for analysis-load<br>
2) Update params that must match between analysis save and load runs<br>
<br>
diff -r 289b8a3730ae -r 0a629ea6036b source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Fri Jun 22 11:47:36 2018 +0530<br>
+++ b/source/encoder/encoder.cpp Wed Jun 27 15:48:31 2018 +0530<br>
@@ -4105,6 +4105,7 @@<br>
int readValue = 0;<br>
int count = 0;<br>
<br>
+ X265_PARAM_VALIDATE(saveParam-<wbr>>intraRefresh, sizeof(int), 1, &m_param->bIntraRefresh, intra-refresh);<br>
X265_PARAM_VALIDATE(saveParam-<wbr>>maxNumReferences, sizeof(int), 1, &m_param->maxNumReferences, ref);<br>
X265_PARAM_VALIDATE(saveParam-<wbr>>analysisReuseLevel, sizeof(int), 1, &m_param->analysisReuseLevel, analysis-reuse-level);<br>
X265_PARAM_VALIDATE(saveParam-<wbr>>keyframeMax, sizeof(int), 1, &m_param->keyframeMax, keyint);<br>
@@ -4113,9 +4114,9 @@<br>
X265_PARAM_VALIDATE(saveParam-<wbr>>bframes, sizeof(int), 1, &m_param->bframes, bframes);<br>
X265_PARAM_VALIDATE(saveParam-<wbr>>bPyramid, sizeof(int), 1, &m_param->bBPyramid, bPyramid);<br>
X265_PARAM_VALIDATE(saveParam-<wbr>>minCUSize, sizeof(int), 1, &m_param->minCUSize, min - cu - size);<br>
- X265_PARAM_VALIDATE(saveParam-<wbr>>radl, sizeof(int), 1, &m_param->radl, radl);<br>
X265_PARAM_VALIDATE(saveParam-<wbr>>lookaheadDepth, sizeof(int), 1, &m_param->lookaheadDepth, rc - lookahead);<br>
- X265_PARAM_VALIDATE(saveParam-<wbr>>gopLookahead, sizeof(int), 1, &m_param->gopLookahead, gop - lookahead);<br>
+ X265_PARAM_VALIDATE(saveParam-<wbr>>chunkStart, sizeof(int), 1, &m_param->chunkStart, chunk-start);<br>
+ X265_PARAM_VALIDATE(saveParam-<wbr>>chunkEnd, sizeof(int), 1, &m_param->chunkEnd, chunk-end);<br>
<br>
int sourceHeight, sourceWidth;<br>
if (writeFlag)<br>
@@ -4133,8 +4134,8 @@<br>
int curSourceHeight = m_param->sourceHeight - m_conformanceWindow.<wbr>bottomOffset;<br>
int curSourceWidth = m_param->sourceWidth - m_conformanceWindow.<wbr>rightOffset;<br>
<br>
- X265_FREAD(&sourceWidth, sizeof(int), 1, m_analysisFileIn, &(saveParam->sourceHeight));<br>
- X265_FREAD(&sourceHeight, sizeof(int), 1, m_analysisFileIn, &(saveParam->sourceWidth));<br>
+ X265_FREAD(&sourceWidth, sizeof(int), 1, m_analysisFileIn, &(saveParam->sourceWidth));<br>
+ X265_FREAD(&sourceHeight, sizeof(int), 1, m_analysisFileIn, &(saveParam->sourceHeight));<br>
X265_FREAD(&readValue, sizeof(int), 1, m_analysisFileIn, &(saveParam->maxCUSize));<br>
<br>
bool isScaledRes = (2 * sourceHeight == curSourceHeight) && (2 * sourceWidth == curSourceWidth);<br>
diff -r 289b8a3730ae -r 0a629ea6036b source/encoder/slicetype.cpp<br>
--- a/source/encoder/slicetype.cpp Fri Jun 22 11:47:36 2018 +0530<br>
+++ b/source/encoder/slicetype.cpp Wed Jun 27 15:48:31 2018 +0530<br>
@@ -1088,86 +1088,105 @@<br>
}<br>
<br>
int bframes, brefs;<br>
- for (bframes = 0, brefs = 0;; bframes++)<br>
+ if (!m_param->analysisLoad)<br>
{<br>
- Lowres& frm = list[bframes]->m_lowres;<br>
-<br>
- if (frm.sliceType == X265_TYPE_BREF && !m_param->bBPyramid && brefs == m_param->bBPyramid)<br>
+ for (bframes = 0, brefs = 0;; bframes++)<br>
{<br>
- frm.sliceType = X265_TYPE_B;<br>
- x265_log(m_param, X265_LOG_WARNING, "B-ref at frame %d incompatible with B-pyramid\n",<br>
- frm.frameNum);<br>
- }<br>
+ Lowres& frm = list[bframes]->m_lowres;<br>
+<br>
+ if (frm.sliceType == X265_TYPE_BREF && !m_param->bBPyramid && brefs == m_param->bBPyramid)<br>
+ {<br>
+ frm.sliceType = X265_TYPE_B;<br>
+ x265_log(m_param, X265_LOG_WARNING, "B-ref at frame %d incompatible with B-pyramid\n",<br>
+ frm.frameNum);<br>
+ }<br>
<br>
- /* pyramid with multiple B-refs needs a big enough dpb that the preceding P-frame stays available.<br>
- * smaller dpb could be supported by smart enough use of mmco, but it's easier just to forbid it. */<br>
- else if (frm.sliceType == X265_TYPE_BREF && m_param->bBPyramid && brefs &&<br>
- m_param->maxNumReferences <= (brefs + 3))<br>
- {<br>
- frm.sliceType = X265_TYPE_B;<br>
- x265_log(m_param, X265_LOG_WARNING, "B-ref at frame %d incompatible with B-pyramid and %d reference frames\n",<br>
- frm.sliceType, m_param->maxNumReferences);<br>
+ /* pyramid with multiple B-refs needs a big enough dpb that the preceding P-frame stays available.<br>
+ * smaller dpb could be supported by smart enough use of mmco, but it's easier just to forbid it. */<br>
+ else if (frm.sliceType == X265_TYPE_BREF && m_param->bBPyramid && brefs &&<br>
+ m_param->maxNumReferences <= (brefs + 3))<br>
+ {<br>
+ frm.sliceType = X265_TYPE_B;<br>
+ x265_log(m_param, X265_LOG_WARNING, "B-ref at frame %d incompatible with B-pyramid and %d reference frames\n",<br>
+ frm.sliceType, m_param->maxNumReferences);<br>
+ }<br>
+ if (((!m_param->bIntraRefresh || frm.frameNum == 0) && frm.frameNum - m_lastKeyframe >= m_param->keyframeMax &&<br>
+ (!m_extendGopBoundary || frm.frameNum - m_lastKeyframe >= m_param->keyframeMax + m_param->gopLookahead)) ||<br>
+ (frm.frameNum == (m_param->chunkStart - 1)) || (frm.frameNum == m_param->chunkEnd))<br>
+ {<br>
+ if (frm.sliceType == X265_TYPE_AUTO || frm.sliceType == X265_TYPE_I)<br>
+ frm.sliceType = m_param->bOpenGOP && m_lastKeyframe >= 0 ? X265_TYPE_I : X265_TYPE_IDR;<br>
+ bool warn = frm.sliceType != X265_TYPE_IDR;<br>
+ if (warn && m_param->bOpenGOP)<br>
+ warn &= frm.sliceType != X265_TYPE_I;<br>
+ if (warn)<br>
+ {<br>
+ x265_log(m_param, X265_LOG_WARNING, "specified frame type (%d) at %d is not compatible with keyframe interval\n",<br>
+ frm.sliceType, frm.frameNum);<br>
+ frm.sliceType = m_param->bOpenGOP && m_lastKeyframe >= 0 ? X265_TYPE_I : X265_TYPE_IDR;<br>
+ }<br>
+ }<br>
+ if ((frm.sliceType == X265_TYPE_I && frm.frameNum - m_lastKeyframe >= m_param->keyframeMin) || (frm.frameNum == (m_param->chunkStart - 1)) || (frm.frameNum == m_param->chunkEnd))<br>
+ {<br>
+ if (m_param->bOpenGOP)<br>
+ {<br>
+ m_lastKeyframe = frm.frameNum;<br>
+ frm.bKeyframe = true;<br>
+ }<br>
+ else<br>
+ frm.sliceType = X265_TYPE_IDR;<br>
+ }<br>
+ if (frm.sliceType == X265_TYPE_IDR)<br>
+ {<br>
+ /* Closed GOP */<br>
+ m_lastKeyframe = frm.frameNum;<br>
+ frm.bKeyframe = true;<br>
+ if (bframes > 0 && !m_param->radl)<br>
+ {<br>
+ list[bframes - 1]->m_lowres.sliceType = X265_TYPE_P;<br>
+ bframes--;<br>
+ }<br>
+ }<br>
+ if (m_param->radl && !m_param->bOpenGOP && list[bframes + 1])<br>
+ {<br>
+ if ((frm.frameNum - m_lastKeyframe) > (m_param->keyframeMax - m_param->radl - 1) && (frm.frameNum - m_lastKeyframe) < m_param->keyframeMax)<br>
+ frm.sliceType = X265_TYPE_B;<br>
+ if ((frm.frameNum - m_lastKeyframe) == (m_param->keyframeMax - m_param->radl - 1))<br>
+ frm.sliceType = X265_TYPE_P;<br>
+ }<br>
+<br>
+ if (bframes == m_param->bframes || !list[bframes + 1])<br>
+ {<br>
+ if (IS_X265_TYPE_B(frm.sliceType)<wbr>)<br>
+ x265_log(m_param, X265_LOG_WARNING, "specified frame type is not compatible with max B-frames\n");<br>
+ if (frm.sliceType == X265_TYPE_AUTO || IS_X265_TYPE_B(frm.sliceType))<br>
+ frm.sliceType = X265_TYPE_P;<br>
+ }<br>
+ if (frm.sliceType == X265_TYPE_BREF)<br>
+ brefs++;<br>
+ if (frm.sliceType == X265_TYPE_AUTO)<br>
+ frm.sliceType = X265_TYPE_B;<br>
+ else if (!IS_X265_TYPE_B(frm.<wbr>sliceType))<br>
+ break;<br>
}<br>
- if (((!m_param->bIntraRefresh || frm.frameNum == 0) && frm.frameNum - m_lastKeyframe >= m_param->keyframeMax &&<br>
- (!m_extendGopBoundary || frm.frameNum - m_lastKeyframe >= m_param->keyframeMax + m_param->gopLookahead)) ||<br>
- (frm.frameNum == (m_param->chunkStart - 1)) || (frm.frameNum == m_param->chunkEnd))<br>
+ }<br>
+ else<br>
+ {<br>
+ for (bframes = 0, brefs = 0;; bframes++)<br>
{<br>
- if (frm.sliceType == X265_TYPE_AUTO || frm.sliceType == X265_TYPE_I)<br>
- frm.sliceType = m_param->bOpenGOP && m_lastKeyframe >= 0 ? X265_TYPE_I : X265_TYPE_IDR;<br>
- bool warn = frm.sliceType != X265_TYPE_IDR;<br>
- if (warn && m_param->bOpenGOP)<br>
- warn &= frm.sliceType != X265_TYPE_I;<br>
- if (warn)<br>
- {<br>
- x265_log(m_param, X265_LOG_WARNING, "specified frame type (%d) at %d is not compatible with keyframe interval\n",<br>
- frm.sliceType, frm.frameNum);<br>
- frm.sliceType = m_param->bOpenGOP && m_lastKeyframe >= 0 ? X265_TYPE_I : X265_TYPE_IDR;<br>
- }<br>
- }<br>
- if ((frm.sliceType == X265_TYPE_I && frm.frameNum - m_lastKeyframe >= m_param->keyframeMin) || (frm.frameNum == (m_param->chunkStart - 1)) || (frm.frameNum == m_param->chunkEnd))<br>
- {<br>
- if (m_param->bOpenGOP)<br>
+ Lowres& frm = list[bframes]->m_lowres;<br>
+ if (frm.sliceType == X265_TYPE_BREF)<br>
+ brefs++;<br>
+ if ((IS_X265_TYPE_I(frm.<wbr>sliceType) && frm.frameNum - m_lastKeyframe >= m_param->keyframeMin)<br>
+ || (frm.frameNum == (m_param->chunkStart - 1)) || (frm.frameNum == m_param->chunkEnd))<br>
{<br>
m_lastKeyframe = frm.frameNum;<br>
frm.bKeyframe = true;<br>
}<br>
- else<br>
- frm.sliceType = X265_TYPE_IDR;<br>
- }<br>
- if (frm.sliceType == X265_TYPE_IDR)<br>
- {<br>
- /* Closed GOP */<br>
- m_lastKeyframe = frm.frameNum;<br>
- frm.bKeyframe = true;<br>
- if (bframes > 0 && !m_param->radl)<br>
- {<br>
- list[bframes - 1]->m_lowres.sliceType = X265_TYPE_P;<br>
- bframes--;<br>
- }<br>
+ if (!IS_X265_TYPE_B(frm.<wbr>sliceType))<br>
+ break;<br>
}<br>
- if (m_param->radl && !m_param->bOpenGOP && list[bframes + 1])<br>
- {<br>
- if ((frm.frameNum - m_lastKeyframe) > (m_param->keyframeMax - m_param->radl - 1) && (frm.frameNum - m_lastKeyframe) < m_param->keyframeMax)<br>
- frm.sliceType = X265_TYPE_B;<br>
- if ((frm.frameNum - m_lastKeyframe) == (m_param->keyframeMax - m_param->radl - 1))<br>
- frm.sliceType = X265_TYPE_P;<br>
- }<br>
-<br>
- if (bframes == m_param->bframes || !list[bframes + 1])<br>
- {<br>
- if (IS_X265_TYPE_B(frm.sliceType)<wbr>)<br>
- x265_log(m_param, X265_LOG_WARNING, "specified frame type is not compatible with max B-frames\n");<br>
- if (frm.sliceType == X265_TYPE_AUTO || IS_X265_TYPE_B(frm.sliceType))<br>
- frm.sliceType = X265_TYPE_P;<br>
- }<br>
- if (frm.sliceType == X265_TYPE_BREF)<br>
- brefs++;<br>
- if (frm.sliceType == X265_TYPE_AUTO)<br>
- frm.sliceType = X265_TYPE_B;<br>
- else if (!IS_X265_TYPE_B(frm.<wbr>sliceType))<br>
- break;<br>
}<br>
-<br>
if (bframes)<br>
list[bframes - 1]->m_lowres.<wbr>bLastMiniGopBFrame = true;<br>
list[bframes]->m_lowres.<wbr>leadingBframes = bframes;<br>
diff -r 289b8a3730ae -r 0a629ea6036b source/x265.h<br>
--- a/source/x265.h Fri Jun 22 11:47:36 2018 +0530<br>
+++ b/source/x265.h Wed Jun 27 15:48:31 2018 +0530<br>
@@ -121,9 +121,10 @@<br>
int bPyramid;<br>
int maxCUSize;<br>
int minCUSize;<br>
- int radl;<br>
+ int intraRefresh;<br>
int lookaheadDepth;<br>
- int gopLookahead;<br>
+ int chunkStart;<br>
+ int chunkEnd;<br>
}x265_analysis_validate;<br>
<br>
/* Stores all analysis data for a single frame */<br>
<br>______________________________<wbr>_________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/<wbr>listinfo/x265-devel</a><br>
<br></blockquote></div><br></div><div class="gmail_extra">Pushed.</div></div>