<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 13, 2017 at 7:07 PM,  <span dir="ltr"><<a href="mailto:praveen@multicorewareinc.com" target="_blank">praveen@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 Praveen Tiwari <<a href="mailto:praveen@multicorewareinc.com">praveen@multicorewareinc.com</a>><br>
# Date 1510555850 -19800<br>
#      Mon Nov 13 12:20:50 2017 +0530<br>
# Node ID 65eff30eb192d836b52edb5c3e2e6d<wbr>eae06dabf7<br>
# Parent  563cbe1f4a21dcfe2117ccaa874b71<wbr>3d94434f92<br>
API: 'x265_set_analysis_data' to capture analysis information<br></blockquote><div><br></div><div>Please describe api functionality in documentation and resubmit patch after making it applicable on current tip; I had to push another critical patch before this that make this not apply on the current tip of default.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
diff -r 563cbe1f4a21 -r 65eff30eb192 source/CMakeLists.txt<br>
--- a/source/CMakeLists.txt     Wed Nov 08 17:08:18 2017 +0530<br>
+++ b/source/CMakeLists.txt     Mon Nov 13 12:20:50 2017 +0530<br>
@@ -29,7 +29,7 @@<br>
 option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)<br>
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)<br>
 # X265_BUILD must be incremented each time the public API is changed<br>
-set(X265_BUILD 143)<br>
+set(X265_BUILD 144)<br>
 configure_file("${PROJECT_<wbr>SOURCE_DIR}/<a href="http://x265.def.in" rel="noreferrer" target="_blank">x265.def.in</a>"<br>
                "${PROJECT_BINARY_DIR}/x265.<wbr>def")<br>
 configure_file("${PROJECT_<wbr>SOURCE_DIR}/<a href="http://x265_config.h.in" rel="noreferrer" target="_blank">x265_config.h.in</a>"<br>
diff -r 563cbe1f4a21 -r 65eff30eb192 source/encoder/api.cpp<br>
--- a/source/encoder/api.cpp    Wed Nov 08 17:08:18 2017 +0530<br>
+++ b/source/encoder/api.cpp    Mon Nov 13 12:20:50 2017 +0530<br>
@@ -365,6 +365,18 @@<br>
     return encoder->getRefFrameList((<wbr>PicYuv**)l0, (PicYuv**)l1, sliceType, poc);<br>
 }<br>
<br>
+int x265_set_analysis_data(x265_<wbr>encoder *enc, x265_analysis_data *analysis_data, int poc, uint32_t cuBytes)<br>
+{<br>
+    if (!enc)<br>
+        return -1;<br>
+<br>
+    Encoder *encoder = static_cast<Encoder*>(enc);<br>
+    if (!encoder->setAnalysisData(<wbr>analysis_data, poc, cuBytes))<br>
+        return 0;<br>
+<br>
+    return -1;<br>
+}<br>
+<br>
 void x265_cleanup(void)<br>
 {<br>
     BitCost::destroy();<br>
@@ -444,6 +456,7 @@<br>
     &x265_csvlog_frame,<br>
     &x265_csvlog_encode,<br>
     &x265_dither_image,<br>
+    &x265_set_analysis_data<br>
 };<br>
<br>
 typedef const x265_api* (*api_get_func)(int bitDepth);<br>
diff -r 563cbe1f4a21 -r 65eff30eb192 source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp        Wed Nov 08 17:08:18 2017 +0530<br>
+++ b/source/encoder/encoder.cpp        Mon Nov 13 12:20:50 2017 +0530<br>
@@ -576,6 +576,88 @@<br>
     return 0;<br>
 }<br>
<br>
+int Encoder::setAnalysisData(x265_<wbr>analysis_data *analysis_data, int poc, uint32_t cuBytes)<br>
+{<br>
+    uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;<br>
+    uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;<br>
+<br>
+    Frame* curFrame = m_dpb->m_picList.getPOC(poc);<br>
+    if (curFrame != NULL)<br>
+    {<br>
+        curFrame->m_analysisData = (*analysis_data);<br>
+        curFrame->m_analysisData.<wbr>numCUsInFrame = widthInCU * heightInCU;<br>
+        curFrame->m_analysisData.<wbr>numPartitions = m_param->num4x4Partitions;<br>
+        allocAnalysis(&curFrame->m_<wbr>analysisData);<br>
+        if (m_param->maxCUSize == 16)<br>
+        {<br>
+            if (analysis_data->sliceType == X265_TYPE_IDR || analysis_data->sliceType == X265_TYPE_I)<br>
+            {<br>
+                curFrame->m_analysisData.<wbr>sliceType = X265_TYPE_I;<br>
+                if (m_param->analysisReuseLevel < 2)<br>
+                    return -1;<br>
+<br>
+                curFrame->m_analysisData.<wbr>numPartitions = m_param->num4x4Partitions;<br>
+                size_t count = 0;<br>
+                analysis_intra_data * currIntraData = (analysis_intra_data *)curFrame->m_analysisData.<wbr>intraData;<br>
+                analysis_intra_data * intraData = (analysis_intra_data *)analysis_data->intraData;<br>
+                for (uint32_t d = 0; d < cuBytes; d++)<br>
+                {<br>
+                    int bytes = curFrame->m_analysisData.<wbr>numPartitions >> ((intraData)->depth[d] * 2);<br>
+                    memset(&(currIntraData)-><wbr>depth[count], (intraData)->depth[d], bytes);<br>
+                    memset(&(currIntraData)-><wbr>chromaModes[count], (intraData)->chromaModes[d], bytes);<br>
+                    memset(&(currIntraData)-><wbr>partSizes[count], (intraData)->partSizes[d], bytes);<br>
+                    memset(&(currIntraData)-><wbr>partSizes[count], (intraData)->partSizes[d], bytes);<br>
+                    count += bytes;<br>
+                }<br>
+                memcpy(&(currIntraData)-><wbr>modes, (intraData)->modes, curFrame->m_analysisData.<wbr>numPartitions * analysis_data->numCUsInFrame);<br>
+            }<br>
+            else<br>
+            {<br>
+                uint32_t numDir = analysis_data->sliceType == X265_TYPE_P ? 1 : 2;<br>
+                if (m_param->analysisReuseLevel < 2)<br>
+                    return -1;<br>
+<br>
+                curFrame->m_analysisData.<wbr>numPartitions = m_param->num4x4Partitions;<br>
+                size_t count = 0;<br>
+                analysis_inter_data * currInterData = (analysis_inter_data *)curFrame->m_analysisData.<wbr>interData;<br>
+                analysis_inter_data * interData = (analysis_inter_data *)analysis_data->interData;<br>
+                for (uint32_t d = 0; d < cuBytes; d++)<br>
+                {<br>
+                    int bytes = curFrame->m_analysisData.<wbr>numPartitions >> ((interData)->depth[d] * 2);<br>
+                    memset(&(currInterData)-><wbr>depth[count], (interData)->depth[d], bytes);<br>
+                    memset(&(currInterData)-><wbr>modes[count], (interData)->modes[d], bytes);<br>
+                    if (m_param->analysisReuseLevel > 4)<br>
+                    {<br>
+                        memset(&(currInterData)-><wbr>partSize[count], (interData)->partSize[d], bytes);<br>
+                        int numPU = nbPartsTable[(currInterData)-><wbr>partSize[d]];<br>
+                        for (int pu = 0; pu < numPU; pu++, d++)<br>
+                        {<br>
+                            (currInterData)->mergeFlag[<wbr>count + pu] = (interData)->mergeFlag[d];<br>
+                            if (m_param->analysisReuseLevel >= 7)<br>
+                            {<br>
+                                (currInterData)->interDir[<wbr>count + pu] = (interData)->interDir[d];<br>
+                                for (uint32_t i = 0; i < numDir; i++)<br>
+                                {<br>
+                                    (currInterData)->mvpIdx[i][<wbr>count + pu] = (interData)->mvpIdx[i][d];<br>
+                                    (currInterData)->refIdx[i][<wbr>count + pu] = (interData)->refIdx[i][d];<br>
+                                    memcpy(&(currInterData)->mv[i]<wbr>[count + pu], &(interData)->mv[i][d], sizeof(MV));<br>
+                                }<br>
+                            }<br>
+                        }<br>
+                    }<br>
+                    count += bytes;<br>
+                }<br>
+            }<br>
+        }<br>
+        else<br>
+            setAnalysisDataAfterZScan(<wbr>analysis_data, curFrame);<br>
+<br>
+        curFrame->m_copyMVType.<wbr>trigger();<br>
+        return 0;<br>
+    }<br>
+    return -1;<br>
+}<br>
+<br>
 void Encoder::destroy()<br>
 {<br>
 #if ENABLE_HDR10_PLUS<br>
diff -r 563cbe1f4a21 -r 65eff30eb192 source/encoder/encoder.h<br>
--- a/source/encoder/encoder.h  Wed Nov 08 17:08:18 2017 +0530<br>
+++ b/source/encoder/encoder.h  Mon Nov 13 12:20:50 2017 +0530<br>
@@ -212,6 +212,8 @@<br>
<br>
     int setAnalysisDataAfterZScan(<wbr>x265_analysis_data *analysis_data, Frame* curFrame);<br>
<br>
+    int setAnalysisData(x265_analysis_<wbr>data *analysis_data, int poc, uint32_t cuBytes);<br>
+<br>
     void getStreamHeaders(NALList& list, Entropy& sbacCoder, Bitstream& bs);<br>
<br>
     void fetchStats(x265_stats* stats, size_t statsSizeBytes);<br>
diff -r 563cbe1f4a21 -r 65eff30eb192 source/<a href="http://x265.def.in" rel="noreferrer" target="_blank">x265.def.in</a><br>
--- a/source/<a href="http://x265.def.in" rel="noreferrer" target="_blank">x265.def.in</a>        Wed Nov 08 17:08:18 2017 +0530<br>
+++ b/source/<a href="http://x265.def.in" rel="noreferrer" target="_blank">x265.def.in</a>        Mon Nov 13 12:20:50 2017 +0530<br>
@@ -30,3 +30,4 @@<br>
 x265_csvlog_frame<br>
 x265_csvlog_encode<br>
 x265_dither_image<br>
+x265_set_analysis_data<br>
diff -r 563cbe1f4a21 -r 65eff30eb192 source/x265.h<br>
--- a/source/x265.h     Wed Nov 08 17:08:18 2017 +0530<br>
+++ b/source/x265.h     Mon Nov 13 12:20:50 2017 +0530<br>
@@ -1743,6 +1743,11 @@<br>
  *     This API must be called after(poc >= lookaheadDepth + bframes + 2) condition check */<br>
 int x265_get_ref_frame_list(x265_<wbr>encoder *encoder, x265_picyuv**, x265_picyuv**, int, int);<br>
<br>
+/* x265_set_analysis_data:<br>
+ *     set the analysis data,<br>
+ *     returns negative on error, 0 access unit were output. */<br>
+int x265_set_analysis_data(x265_<wbr>encoder *encoder, x265_analysis_data *analysis_data, int poc, uint32_t cuBytes);<br>
+<br>
 void x265_cleanup(void);<br>
<br>
 /* Open a CSV log file. On success it returns a file handle which must be passed<br>
@@ -1816,6 +1821,7 @@<br>
     void          (*csvlog_frame)(const x265_param&, const x265_picture&);<br>
     void          (*csvlog_encode)(x265_encoder*<wbr>, const x265_stats&, int, char**);<br>
     void          (*dither_image)(x265_picture&, int, int, int16_t*, int);<br>
+    int           (*set_analysis_data)(x265_<wbr>encoder *encoder, x265_analysis_data *analysis_data, int poc, uint32_t cuBytes);<br>
     /* add new pointers to the end, or increment X265_MAJOR_VERSION */<br>
 } x265_api;<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>
</blockquote></div><br></div></div>