<div dir="ltr">Please ignore this patch. I have sent an updated version which can be found in the link -  <a href="https://mailman.videolan.org/pipermail/x265-devel/2019-September/012662.html">https://mailman.videolan.org/pipermail/x265-devel/2019-September/012662.html</a>   <br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 10, 2019 at 11:08 AM <<a href="mailto:pooja@multicorewareinc.com">pooja@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"># HG changeset patch<br>
# User Soundariya Ranin Venkatesh <<a href="mailto:soundariya@multicorewareinc.com" target="_blank">soundariya@multicorewareinc.com</a>><br>
# Date 1567501320 -19800<br>
#      Tue Sep 03 14:32:00 2019 +0530<br>
# Node ID b1799841d3307237a741eb7d097cba2efd76f1eb<br>
# Parent  f6d9a0145c4fcd7ac0a2a776a4f99fc431f8fd4a<br>
Implement slice-level SAO filter.<br>
<br>
diff -r f6d9a0145c4f -r b1799841d330 source/encoder/frameencoder.cpp<br>
--- a/source/encoder/frameencoder.cpp   Tue Sep 03 14:25:44 2019 +0530<br>
+++ b/source/encoder/frameencoder.cpp   Tue Sep 03 14:32:00 2019 +0530<br>
@@ -634,14 +634,22 @@<br>
         if (!m_param->bEnableWavefront)<br>
             m_backupStreams = new Bitstream[numSubstreams];<br>
         m_substreamSizes = X265_MALLOC(uint32_t, numSubstreams);<br>
-        if (!m_param->enableSAO)<br>
+        if (!slice->m_bUseSao)<br>
+        {<br>
             for (uint32_t i = 0; i < numSubstreams; i++)<br>
                 m_rows[i].rowGoOnCoder.setBitstream(&m_outStreams[i]);<br>
+        }<br>
     }<br>
     else<br>
     {<br>
         for (uint32_t i = 0; i < numSubstreams; i++)<br>
+        {<br>
             m_outStreams[i].resetBits();<br>
+            if (!slice->m_bUseSao)<br>
+                m_rows[i].rowGoOnCoder.setBitstream(&m_outStreams[i]);<br>
+            else<br>
+                m_rows[i].rowGoOnCoder.setBitstream(NULL);<br>
+        }<br>
     }<br>
<br>
     m_rce.encodeOrder = m_frame->m_encodeOrder;<br>
@@ -981,7 +989,7 @@<br>
     m_entropyCoder.setBitstream(&m_bs);<br>
<br>
     // finish encode of each CTU row, only required when SAO is enabled<br>
-    if (m_param->enableSAO)<br>
+    if (slice->m_bUseSao)<br>
         encodeSlice(0);<br>
<br>
     m_entropyCoder.setBitstream(&m_bs);<br>
@@ -1221,7 +1229,7 @@<br>
     const uint32_t lastCUAddr = (slice->m_endCUAddr + m_param->num4x4Partitions - 1) / m_param->num4x4Partitions;<br>
     const uint32_t numSubstreams = m_param->bEnableWavefront ? slice->m_sps->numCuInHeight : 1;<br>
<br>
-    SAOParam* saoParam = slice->m_sps->bUseSAO ? m_frame->m_encData->m_saoParam : NULL;<br>
+    SAOParam* saoParam = slice->m_sps->bUseSAO && slice->m_bUseSao ? m_frame->m_encData->m_saoParam : NULL;<br>
     for (uint32_t cuAddr = sliceAddr; cuAddr < lastCUAddr; cuAddr++)<br>
     {<br>
         uint32_t col = cuAddr % widthInLCUs;<br>
@@ -1515,11 +1523,11 @@<br>
             curRow.bufferedEntropy.loadContexts(rowCoder);<br>
<br>
         /* SAO parameter estimation using non-deblocked pixels for CTU bottom and right boundary areas */<br>
-        if (m_param->enableSAO && m_param->bSaoNonDeblocked)<br>
+        if (slice->m_bUseSao && m_param->bSaoNonDeblocked)<br>
             m_frameFilter.m_parallelFilter[row].m_sao.calcSaoStatsCu_BeforeDblk(m_frame, col, row);<br>
<br>
         /* Deblock with idle threading */<br>
-        if (m_param->bEnableLoopFilter | m_param->enableSAO)<br>
+        if (m_param->bEnableLoopFilter | slice->m_bUseSao)<br>
         {<br>
             // NOTE: in VBV mode, we may reencode anytime, so we can't do Deblock stage-Horizon and SAO<br>
             if (!bIsVbv)<br>
@@ -1833,12 +1841,12 @@<br>
<br>
     /* flush row bitstream (if WPP and no SAO) or flush frame if no WPP and no SAO */<br>
     /* end_of_sub_stream_one_bit / end_of_slice_segment_flag */<br>
-    if (!m_param->enableSAO && (m_param->bEnableWavefront || bLastRowInSlice))<br>
-        rowCoder.finishSlice();<br>
+       if (!slice->m_bUseSao && (m_param->bEnableWavefront || bLastRowInSlice))<br>
+               rowCoder.finishSlice();<br>
<br>
<br>
     /* Processing left Deblock block with current threading */<br>
-    if ((m_param->bEnableLoopFilter | m_param->enableSAO) & (rowInSlice >= 2))<br>
+    if ((m_param->bEnableLoopFilter | slice->m_bUseSao) & (rowInSlice >= 2))<br>
     {<br>
         /* Check conditional to start previous row process with current threading */<br>
         if (m_frameFilter.m_parallelFilter[row - 2].m_lastDeblocked.get() == (int)numCols)<br>
diff -r f6d9a0145c4f -r b1799841d330 source/encoder/frameencoder.h<br>
--- a/source/encoder/frameencoder.h     Tue Sep 03 14:25:44 2019 +0530<br>
+++ b/source/encoder/frameencoder.h     Tue Sep 03 14:32:00 2019 +0530<br>
@@ -150,6 +150,7 @@<br>
     uint32_t                 m_filterRowDelay;<br>
     uint32_t                 m_filterRowDelayCus;<br>
     uint32_t                 m_refLagRows;<br>
+    bool                     m_bUseSao;<br>
<br>
     CTURow*                  m_rows;<br>
     uint16_t                 m_sliceAddrBits;<br>
</blockquote></div>