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

ashok at multicorewareinc.com ashok at multicorewareinc.com
Fri Dec 20 15:04:02 CET 2013


# HG changeset patch
# User ashok at multicorewareinc.com
# Date 1387548229 -19800
#      Fri Dec 20 19:33:49 2013 +0530
# Node ID c17ea1b9325b6aa88f7bb4b3293abac395ed07f4
# Parent  ee5e76287a4858456dddcdbff0684dbe8569b6db
Modify FrameFilter structure to support multiple color space formats

diff -r ee5e76287a48 -r c17ea1b9325b source/encoder/framefilter.cpp
--- a/source/encoder/framefilter.cpp	Fri Dec 20 19:32:18 2013 +0530
+++ b/source/encoder/framefilter.cpp	Fri Dec 20 19:33:49 2013 +0530
@@ -64,6 +64,9 @@
     m_cfg = top;
     m_numRows = numRows;
 
+    m_hChromaShift = CHROMA_H_SHIFT(m_cfg->getColorFormat());
+    m_vChromaShift = CHROMA_V_SHIFT(m_cfg->getColorFormat());
+
     // NOTE: for sao only, I write this code because I want to exact match with HM's bug bitstream
     m_rdGoOnSbacCoderRow0 = rdGoOnSbacCoder;
 
@@ -77,7 +80,7 @@
         m_sao.setSaoLcuBoundary(top->param.saoLcuBoundary);
         m_sao.setSaoLcuBasedOptimization(top->param.saoLcuBasedOptimization);
         m_sao.setMaxNumOffsetsPerPic(top->getMaxNumOffsetsPerPic());
-        m_sao.create(top->param.sourceWidth, top->param.sourceHeight, g_maxCUWidth, g_maxCUHeight);
+        m_sao.create(top->param.sourceWidth, top->param.sourceHeight, g_maxCUWidth, g_maxCUHeight, m_cfg->getColorFormat());
         m_sao.createEncBuffer();
     }
 
@@ -222,8 +225,8 @@
 
     // Border extend Left and Right
     primitives.extendRowBorder(recon->getLumaAddr(lineStartCUAddr), recon->getStride(), recon->getWidth(), realH, recon->getLumaMarginX());
-    primitives.extendRowBorder(recon->getCbAddr(lineStartCUAddr), recon->getCStride(), recon->getWidth() >> 1, realH >> 1, recon->getChromaMarginX());
-    primitives.extendRowBorder(recon->getCrAddr(lineStartCUAddr), recon->getCStride(), recon->getWidth() >> 1, realH >> 1, recon->getChromaMarginX());
+    primitives.extendRowBorder(recon->getCbAddr(lineStartCUAddr), recon->getCStride(), recon->getWidth() >> m_hChromaShift, realH >> m_vChromaShift, recon->getChromaMarginX());
+    primitives.extendRowBorder(recon->getCrAddr(lineStartCUAddr), recon->getCStride(), recon->getWidth() >> m_hChromaShift, realH >> m_vChromaShift, recon->getChromaMarginX());
 
     // Border extend Top
     if (row == 0)
@@ -252,8 +255,8 @@
         const intptr_t stride = recon->getStride();
         const intptr_t strideC = recon->getCStride();
         pixel *pixY = recon->getLumaAddr(lineStartCUAddr) - recon->getLumaMarginX() + (realH - 1) * stride;
-        pixel *pixU = recon->getCbAddr(lineStartCUAddr) - recon->getChromaMarginX() + ((realH >> 1) - 1) * strideC;
-        pixel *pixV = recon->getCrAddr(lineStartCUAddr) - recon->getChromaMarginX() + ((realH >> 1) - 1) * strideC;
+        pixel *pixU = recon->getCbAddr(lineStartCUAddr) - recon->getChromaMarginX() + ((realH >> m_vChromaShift) - 1) * strideC;
+        pixel *pixV = recon->getCrAddr(lineStartCUAddr) - recon->getChromaMarginX() + ((realH >> m_vChromaShift) - 1) * strideC;
 
         for (int y = 0; y < recon->getLumaMarginY(); y++)
         {
@@ -290,8 +293,8 @@
 
         UInt64 ssdY = computeSSD(orig->getLumaAddr(cuAddr), recon->getLumaAddr(cuAddr), stride, width, height);
 
-        height >>= 1;
-        width  >>= 1;
+        height >>= m_vChromaShift;
+        width  >>= m_hChromaShift;
         stride = recon->getCStride();
 
         UInt64 ssdU = computeSSD(orig->getCbAddr(cuAddr), recon->getCbAddr(cuAddr), stride, width, height);
@@ -337,8 +340,8 @@
 
         updateMD5Plane(m_pic->m_state[0], recon->getLumaAddr(cuAddr), width, height, stride);
 
-        width >>= 1;
-        height >>= 1;
+        width  >>= m_hChromaShift;
+        height >>= m_vChromaShift;
         stride = recon->getCStride();
 
         updateMD5Plane(m_pic->m_state[1], recon->getCbAddr(cuAddr), width, height, stride);
@@ -356,8 +359,8 @@
         }
         updateCRC(recon->getLumaAddr(cuAddr), m_pic->m_crc[0], height, width, stride);
 
-        width >>= 1;
-        height >>= 1;
+        width  >>= m_hChromaShift;
+        height >>= m_vChromaShift;
         stride = recon->getCStride();
 
         updateCRC(recon->getCbAddr(cuAddr), m_pic->m_crc[1], height, width, stride);
@@ -374,10 +377,10 @@
             m_pic->m_checksum[0] = m_pic->m_checksum[1] = m_pic->m_checksum[2] = 0;
         }
         updateChecksum(recon->getLumaAddr(), m_pic->m_checksum[0], height, width, stride, row, cuHeight);
-        width >>= 1;
-        height >>= 1;
+        width  >>= m_hChromaShift;
+        height >>= m_vChromaShift;
         stride = recon->getCStride();
-        cuHeight >>= 1;
+        cuHeight >>= m_vChromaShift;
         updateChecksum(recon->getCbAddr(), m_pic->m_checksum[1], height, width, stride, row, cuHeight);
         updateChecksum(recon->getCrAddr(), m_pic->m_checksum[2], height, width, stride, row, cuHeight);
     }
diff -r ee5e76287a48 -r c17ea1b9325b source/encoder/framefilter.h
--- a/source/encoder/framefilter.h	Fri Dec 20 19:32:18 2013 +0530
+++ b/source/encoder/framefilter.h	Fri Dec 20 19:33:49 2013 +0530
@@ -59,6 +59,9 @@
     TEncCfg*                    m_cfg;
     TComPic*                    m_pic;
 
+    int                         m_hChromaShift;
+    int                         m_vChromaShift;
+
 public:
 
     TComLoopFilter              m_loopFilter;


More information about the x265-devel mailing list