[x265] [PATCH] Modify TEncSampleAdaptiveOffset structure to support multiple color space formats

ashok at multicorewareinc.com ashok at multicorewareinc.com
Fri Dec 20 15:00:36 CET 2013


# HG changeset patch
# User ashok at multicorewareinc.com
# Date 1387548022 -19800
#      Fri Dec 20 19:30:22 2013 +0530
# Node ID b44bd26b4a1e5be57df7cc9b5de039cfec830d43
# Parent  d3b5560deafced44b0dae5520fe4b936f14d1cd3
Modify TEncSampleAdaptiveOffset structure to support multiple color space formats

diff -r d3b5560deafc -r b44bd26b4a1e source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
--- a/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	Fri Dec 20 19:29:00 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	Fri Dec 20 19:30:22 2013 +0530
@@ -832,25 +832,27 @@
     int32_t *tmp_swap;
 
     int iIsChroma = (yCbCr != 0) ? 1 : 0;
-    int numSkipLine = iIsChroma ? 2 : 4;
+    int numSkipLine = iIsChroma ? 4 - (2 * m_vChromaShift) : 4;
 
     if (m_saoLcuBasedOptimization == 0)
     {
         numSkipLine = 0;
     }
 
-    int numSkipLineRight = iIsChroma ? 3 : 5;
+    int numSkipLineRight = iIsChroma ? 5 - (2 * m_hChromaShift) : 5;
+
     if (m_saoLcuBasedOptimization == 0)
     {
         numSkipLineRight = 0;
     }
 
-    iPicWidthTmp  = m_picWidth  >> iIsChroma;
-    iPicHeightTmp = m_picHeight >> iIsChroma;
-    iLcuWidth     = iLcuWidth    >> iIsChroma;
-    iLcuHeight    = iLcuHeight   >> iIsChroma;
-    lpelx       = lpelx      >> iIsChroma;
-    tpely       = tpely      >> iIsChroma;
+    iPicWidthTmp  = (iIsChroma == 0) ? m_picWidth  : m_picWidth  >> m_hChromaShift;
+    iPicHeightTmp = (iIsChroma == 0) ? m_picHeight : m_picHeight >> m_vChromaShift;
+    iLcuWidth     = (iIsChroma == 0) ? iLcuWidth   : iLcuWidth   >> m_hChromaShift;
+    iLcuHeight    = (iIsChroma == 0) ? iLcuHeight  : iLcuHeight  >> m_vChromaShift;
+    lpelx         = (iIsChroma == 0) ? lpelx       : lpelx       >> m_hChromaShift;
+    tpely         = (iIsChroma == 0) ? tpely       : tpely       >> m_vChromaShift;
+
     rpelx       = lpelx + iLcuWidth;
     bpely       = tpely + iLcuHeight;
     rpelx       = rpelx > iPicWidthTmp  ? iPicWidthTmp  : rpelx;
@@ -864,8 +866,8 @@
     {
         if (m_saoLcuBasedOptimization && m_saoLcuBoundary)
         {
-            numSkipLine = iIsChroma ? 1 : 3;
-            numSkipLineRight = iIsChroma ? 2 : 4;
+            numSkipLine      = iIsChroma ? 3 - (2 * m_vChromaShift) : 3;
+            numSkipLineRight = iIsChroma ? 4 - (2 * m_hChromaShift) : 4;
         }
         iStats = m_offsetOrg[partIdx][SAO_BO];
         iCount = m_count[partIdx][SAO_BO];
@@ -905,8 +907,8 @@
         {
             if (m_saoLcuBasedOptimization && m_saoLcuBoundary)
             {
-                numSkipLine = iIsChroma ? 1 : 3;
-                numSkipLineRight = iIsChroma ? 3 : 5;
+                numSkipLine      = iIsChroma ? 3 - (2 * m_vChromaShift) : 3;
+                numSkipLineRight = iIsChroma ? 5 - (2 * m_hChromaShift) : 5;
             }
             iStats = m_offsetOrg[partIdx][SAO_EO_0];
             iCount = m_count[partIdx][SAO_EO_0];
@@ -938,8 +940,8 @@
         {
             if (m_saoLcuBasedOptimization && m_saoLcuBoundary)
             {
-                numSkipLine = iIsChroma ? 2 : 4;
-                numSkipLineRight = iIsChroma ? 2 : 4;
+                numSkipLine      = iIsChroma ? 4 - (2 * m_vChromaShift) : 4;
+                numSkipLineRight = iIsChroma ? 4 - (2 * m_hChromaShift) : 4;
             }
             iStats = m_offsetOrg[partIdx][SAO_EO_1];
             iCount = m_count[partIdx][SAO_EO_1];
@@ -981,8 +983,8 @@
         {
             if (m_saoLcuBasedOptimization && m_saoLcuBoundary)
             {
-                numSkipLine = iIsChroma ? 2 : 4;
-                numSkipLineRight = iIsChroma ? 3 : 5;
+                numSkipLine      = iIsChroma ? 4-(2*m_vChromaShift) : 4;
+                numSkipLineRight = iIsChroma ? 5-(2*m_hChromaShift) : 5;
             }
             iStats = m_offsetOrg[partIdx][SAO_EO_2];
             iCount = m_count[partIdx][SAO_EO_2];
@@ -1031,8 +1033,8 @@
         {
             if (m_saoLcuBasedOptimization && m_saoLcuBoundary)
             {
-                numSkipLine = iIsChroma ? 2 : 4;
-                numSkipLineRight = iIsChroma ? 3 : 5;
+                numSkipLine      = iIsChroma ? 4 - (2 * m_vChromaShift) : 4;
+                numSkipLineRight = iIsChroma ? 5 - (2 * m_hChromaShift) : 5;
             }
             iStats = m_offsetOrg[partIdx][SAO_EO_3];
             iCount = m_count[partIdx][SAO_EO_3];


More information about the x265-devel mailing list