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

ashok at multicorewareinc.com ashok at multicorewareinc.com
Fri Jan 3 14:02:22 CET 2014


# HG changeset patch
# User ashok at multicorewareinc.com
# Date 1388754124 -19800
#      Fri Jan 03 18:32:04 2014 +0530
# Node ID a30b08b84798ed73e90033d84ba71a7b7dd04c04
# Parent  c99bbc0c7adff095695278b016be6163c3fdb812
Modify TEncSampleAdaptiveOffset structure to support multiple color space formats

diff -r c99bbc0c7adf -r a30b08b84798 source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
--- a/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	Fri Jan 03 18:30:46 2014 +0530
+++ b/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	Fri Jan 03 18:32:04 2014 +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