[x265] [PATCH] SAO: initialize bottom and right line numbers to be skipped for SAO statistics calculation only once

chen chenm003 at 163.com
Fri Nov 20 16:35:05 CET 2015









At 2015-11-20 15:33:19,"Ashok Kumar Mishra" <ashok at multicorewareinc.com> wrote:

Yes, this idea is from HM, but our SAO module is HM code only, except some asm code.
Here the bottom and right line numbers to be skipped is initialized once in SAO:create() function before the start of encoding.
So, in calculating SAO statistics for every CTU, we are just reading those values from a array. 


But in our existing SAO code which is the old HM version, we are repeatedly calculating the bottom and right line numbers  to be skipped
for every CTU as well as for every plane. And also checking the condition below for every CTU for all components and for all EO and BO classes.


        if (m_param->bSaoNonDeblocked)
        {
            skipB = 3;
            skipR = 4;
        }


In C code:
    int skipB = 4;
    int skipR = 5;


        if (m_param->bSaoNonDeblocked)
        {
            skipB = 3;
            skipR = 4;
        }


in pseudo asm code:
mov R0, 4
mov R1, 5
cmp bSaoNonDeblocked
cmove R0, 3
cmove R0, 4


In Memory format, we need more instructions to calculate 64-bits address, and in asm developer, we know data range is [3,5] before, but need assume range [0,4G] since it read from memory.




I believe all those things can be avoided by initializing those values before the start of encoding and that is only once. So when we are calculating SAO
statistics for every CTU, we can just read those values from that array. 



On Fri, Nov 20, 2015 at 12:33 AM, chen <chenm003 at 163.com> wrote:




At 2015-11-19 18:03:09,ashok at multicorewareinc.com wrote:
># HG changeset patch
># User Ashok Kumar Mishra<ashok at multicorewareinc.com>
># Date 1446119115 -19800
>#      Thu Oct 29 17:15:15 2015 +0530
># Node ID 4a273947c8d54b4de3c05e0e04c9c915f554e6e5
># Parent  f722fb55404bb80b26a55ba0a0a1b98d8f20b362
>SAO: initialize bottom and right line numbers to be skipped for SAO statistics calculation only once
>
>diff -r f722fb55404b -r 4a273947c8d5 source/encoder/frameencoder.cpp
>--- a/source/encoder/frameencoder.cpp	Wed Nov 18 12:28:03 2015 +0530
>+++ b/source/encoder/frameencoder.cpp	Thu Oct 29 17:15:15 2015 +0530
>@@ -1091,7 +1091,7 @@
> 
>         /* SAO parameter estimation using non-deblocked pixels for CTU bottom and right boundary areas */
>         if (m_param->bEnableSAO && m_param->bSaoNonDeblocked)
>-            m_frameFilter.m_sao.calcSaoStatsCu_BeforeDblk(m_frame, col, row);
>+            m_frameFilter.m_sao.calcPreDeblockSaoStatsCu(m_frame, col, row);
> 
>         if (m_param->bEnableWavefront && curRow.completed >= 2 && row < m_numRows - 1 &&
>             (!m_bAllRowsStop || intRow + 1 < m_vbvResetTriggerRow))
>diff -r f722fb55404b -r 4a273947c8d5 source/encoder/sao.cpp
>--- a/source/encoder/sao.cpp	Wed Nov 18 12:28:03 2015 +0530
>+++ b/source/encoder/sao.cpp	Thu Oct 29 17:15:15 2015 +0530
>@@ -138,6 +138,68 @@
>     CHECKED_MALLOC(m_countPreDblk, PerPlane, numCtu);
>     CHECKED_MALLOC(m_offsetOrgPreDblk, PerPlane, numCtu);
> 
>+    for (int typeIdc = 0; typeIdc < MAX_NUM_SAO_TYPE; typeIdc++)
>+    {
>+        m_skipLinesR[TEXT_LUMA][typeIdc] = 5;
>+        m_skipLinesR[TEXT_CHROMA_U][typeIdc] = m_skipLinesR[TEXT_CHROMA_V][typeIdc] = 3;
>+
>+        m_skipLinesB[TEXT_LUMA ][typeIdc] = 4;
>+        m_skipLinesB[TEXT_CHROMA_U][typeIdc] = m_skipLinesB[TEXT_CHROMA_V][typeIdc] = 2;
>+
>+        if (!m_param->bSaoNonDeblocked)
>+        {
>+            for (int typeIdc = 0; typeIdc < MAX_NUM_SAO_TYPE; typeIdc++)
>+            {
>+                m_skipLinesR[TEXT_LUMA][typeIdc] = 5;
>+                m_skipLinesR[TEXT_CHROMA_U][typeIdc] = m_skipLinesR[TEXT_CHROMA_V][typeIdc] = 3;
>+
>+                m_skipLinesB[TEXT_LUMA ][typeIdc] = 4;
>+                m_skipLinesB[TEXT_CHROMA_U][typeIdc] = m_skipLinesB[TEXT_CHROMA_V][typeIdc] = 2;
>+            }
>+        }
>+        else
>+        {
>+            for (int typeIdc = 0; typeIdc < MAX_NUM_SAO_TYPE; typeIdc++)
>+            {
>+                switch (typeIdc)
>+                {
>+                case SAO_EO_0:
>+                    m_skipLinesR[TEXT_LUMA ][typeIdc] = 5;
>+                    m_skipLinesR[TEXT_CHROMA_U][typeIdc] = m_skipLinesR[TEXT_CHROMA_V][typeIdc] = 3;
>+
>+                    m_skipLinesB[TEXT_LUMA ][typeIdc] = 3;
>+                    m_skipLinesB[TEXT_CHROMA_U][typeIdc] = m_skipLinesB[TEXT_CHROMA_V][typeIdc] = 1;
>+                    break;
>+                case SAO_EO_1:
>+                    m_skipLinesR[TEXT_LUMA][typeIdc] = 4;
>+                    m_skipLinesR[TEXT_CHROMA_U][typeIdc] = m_skipLinesR[TEXT_CHROMA_V][typeIdc] = 2;
>+
>+                    m_skipLinesB[TEXT_LUMA][typeIdc] = 4;
>+                    m_skipLinesB[TEXT_CHROMA_U][typeIdc] = m_skipLinesB[TEXT_CHROMA_V][typeIdc] = 2;
>+                    break;
>+                case SAO_EO_2:
>+                case SAO_EO_3:
>+                    m_skipLinesR[TEXT_LUMA][typeIdc] = 5;
>+                    m_skipLinesR[TEXT_CHROMA_U][typeIdc] = m_skipLinesR[TEXT_CHROMA_V][typeIdc] = 3;
>+
>+                    m_skipLinesB[TEXT_LUMA][typeIdc] = 4;
>+                    m_skipLinesB[TEXT_CHROMA_U][typeIdc] = m_skipLinesB[TEXT_CHROMA_V][typeIdc] = 2;
>+                    break;
>+                case SAO_BO:
>+                    m_skipLinesR[TEXT_LUMA][typeIdc] = 4;
>+                    m_skipLinesR[TEXT_CHROMA_U][typeIdc] = m_skipLinesR[TEXT_CHROMA_V][typeIdc] = 2;
>+
>+                    m_skipLinesB[TEXT_LUMA][typeIdc] = 3;
>+                    m_skipLinesB[TEXT_CHROMA_U][typeIdc] = m_skipLinesB[TEXT_CHROMA_V][typeIdc] = 1;
>+                    break;
>+                default:
>+                    X265_CHECK(0, "Not a supported 
type");
>+                    break;
>+                }
>+            }
>+        }
>+    }
>+
this idea from HM, it more clear but more memory operators and compiler difficult to optimize code, e.g. MOV+CMP+CMOV replace by series address calculate and memory loading operator



_______________________________________________
x265-devel mailing list
x265-devel at videolan.org
https://mailman.videolan.org/listinfo/x265-devel



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20151120/fc6227a9/attachment-0001.html>


More information about the x265-devel mailing list