[x265] [PATCH] Improve all_angs_pred_c by remove unnecessary transpose

chen chenm003 at 163.com
Mon Nov 4 09:23:32 CET 2019


From 7e495390396d6a55f95ad4649e46b56fd7d2ef1c Mon Sep 17 00:00:00 2001
From: Min Chen <chenmin at kuaishou.com>
Date: Mon, 4 Nov 2019 16:21:20 +0800
Subject: [PATCH] Improve all_angs_pred_c by remove unnecessary transpose


---
 source/common/intrapred.cpp | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)


diff --git a/source/common/intrapred.cpp b/source/common/intrapred.cpp
index 0b65ccf..2fb4eb5 100644
--- a/source/common/intrapred.cpp
+++ b/source/common/intrapred.cpp
@@ -99,7 +99,7 @@ void planar_pred_c(pixel* dst, intptr_t dstStride, const pixel* srcPix, int /*di
             dst[y * dstStride + x] = (pixel) (((blkSize - 1 - x) * left[y] + (blkSize - 1 -y) * above[x] + (x + 1) * topRight + (y + 1) * bottomLeft + blkSize) >> (log2Size + 1));
 }
 
-template<int width>
+template<int width, bool disableTranspose = false>
 void intra_pred_ang_c(pixel* dst, intptr_t dstStride, const pixel *srcPix0, int dirMode, int bFilter)
 {
     int width2 = width << 1;
@@ -189,7 +189,7 @@ void intra_pred_ang_c(pixel* dst, intptr_t dstStride, const pixel *srcPix0, int
     }
 
     // Flip for horizontal.
-    if (horMode)
+    if (!disableTranspose && horMode)
     {
         for (int y = 0; y < width - 1; y++)
         {
@@ -212,24 +212,8 @@ void all_angs_pred_c(pixel *dest, pixel *refPix, pixel *filtPix, int bLuma)
         pixel *srcPix  = (g_intraFilterFlags[mode] & size ? filtPix  : refPix);
         pixel *out = dest + ((mode - 2) << (log2Size * 2));
 
-        intra_pred_ang_c<size>(out, size, srcPix, mode, bLuma);
-
         // Optimize code don't flip buffer
-        bool modeHor = (mode < 18);
-
-        // transpose the block if this is a horizontal mode
-        if (modeHor)
-        {
-            for (int k = 0; k < size - 1; k++)
-            {
-                for (int l = k + 1; l < size; l++)
-                {
-                    pixel tmp         = out[k * size + l];
-                    out[k * size + l] = out[l * size + k];
-                    out[l * size + k] = tmp;
-                }
-            }
-        }
+        intra_pred_ang_c<size, true>(out, size, srcPix, mode, bLuma);
     }
 }
 }
-- 
2.9.0.windows.1

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20191104/dc1e5201/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Improve-all_angs_pred_c-by-remove-unnecessary-transp.patch
Type: application/octet-stream
Size: 2188 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20191104/dc1e5201/attachment.obj>


More information about the x265-devel mailing list