[x265] [PATCH] motion.cpp: optimize 'X265_DIA_SEARCH' byeliminating costly branch instructions

praveen tiwari praveen at multicorewareinc.com
Wed Mar 9 03:37:28 CET 2016


Yes, this is for eliminating if...else so it's perform a conditional assignment for correctness of code. I will try to update macro definition. Thanks. 

-----Original Message-----
From: "chen" <chenm003 at 163.com>
Sent: ‎09-‎03-‎2016 05:52
To: "Development for x265" <x265-devel at videolan.org>
Subject: Re: [x265] [PATCH] motion.cpp: optimize 'X265_DIA_SEARCH' byeliminating costly branch instructions

I suggest you to modify macro
And this patch depends on side effect of conditional statment, it is bad code style.

At 2016-03-08 22:48:49,praveen at multicorewareinc.com wrote:
># HG changeset patch
># User Praveen Tiwari <praveen at multicorewareinc.com>
># Date 1457448163 -19800
>#      Tue Mar 08 20:12:43 2016 +0530
># Node ID 519441d72cf723dc3b279a91a6080f329729cb49
># Parent  0e1b6472c05e3a53538d8e064e502d8a7508eb6e
>motion.cpp: optimize 'X265_DIA_SEARCH' by eliminating costly branch instructions
>
>diff -r 0e1b6472c05e -r 519441d72cf7 source/encoder/motion.cpp
>--- a/source/encoder/motion.cpp	Tue Mar 08 19:08:57 2016 +0530
>+++ b/source/encoder/motion.cpp	Tue Mar 08 20:12:43 2016 +0530
>@@ -659,10 +659,10 @@
>         do
>         {
>             COST_MV_X4_DIR(0, -1, 0, 1, -1, 0, 1, 0, costs);
>-            COPY1_IF_LT(bcost, (costs[0] << 4) + 1);
>-            COPY1_IF_LT(bcost, (costs[1] << 4) + 3);
>-            COPY1_IF_LT(bcost, (costs[2] << 4) + 4);
>-            COPY1_IF_LT(bcost, (costs[3] << 4) + 12);
>+            (((costs[0] << 4) + 1) < bcost) && (bcost = ((costs[0] << 4) + 1));  // if ((y) < (x)) (x) = (y);
>+            (((costs[1] << 4) + 3) < bcost) && (bcost = ((costs[1] << 4) + 3));
>+            (((costs[2] << 4) + 4) < bcost) && (bcost = ((costs[2] << 4) + 4));
>+            (((costs[3] << 4) + 12) < bcost) && (bcost = ((costs[3] << 4) + 12));
>             if (!(bcost & 15))
>                 break;
>             bmv.x -= (bcost << 28) >> 30;
>_______________________________________________
>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/20160309/f91a3ab1/attachment-0001.html>


More information about the x265-devel mailing list