[x265] [PATCH 2 of 3] improve duplicate MV check by reduce condition jump
chen
chenm003 at 163.com
Mon Jun 29 18:47:28 CEST 2015
Most compiler will do a good optimize on it, the && must generate jump since maybe side effect on previous operator.
this condition and above mvc[i].clipped(qmvmin, qmvmax) is highest component in MotionEstimate::motionEstimate
At 2015-06-30 00:42:48,"Deepthi Nandakumar" <deepthi at multicorewareinc.com> wrote:
Hmm, but arent the benefits very compiler dependent? Since this isnt the innermost loop, is the readability loss worth it?
On Jun 29, 2015 9:27 PM, "Steve Borho" <steve at borho.org> wrote:
It is avoiding the C short-circuit logic that is necessary for &&. With
& the compiler does not have to perform early-out jumps for each
condition. Instead it does all the & operations then does a single
conditional jump.
It can often be faster, but you have to take a lot of care that the
& does the right thing.
On 06/29, Deepthi Nandakumar wrote:
> Hi,
>
> How does this improve the generated asm code/cycles taken?
>
> On Sat, Jun 27, 2015 at 7:43 AM, Min Chen <chenm003 at 163.com> wrote:
>
> > # HG changeset patch
> > # User Min Chen <chenm003 at 163.com>
> > # Date 1435370055 25200
> > # Node ID a8198965fbf18d7ced2cd8e8acd07fcc4ee6a2b3
> > # Parent 229602ba850eb11c171d8c3cbb049dda4b41abda
> > improve duplicate MV check by reduce condition jump
> > ---
> > source/encoder/motion.cpp | 4 ++--
> > 1 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff -r 229602ba850e -r a8198965fbf1 source/encoder/motion.cpp
> > --- a/source/encoder/motion.cpp Fri Jun 26 18:54:13 2015 -0700
> > +++ b/source/encoder/motion.cpp Fri Jun 26 18:54:15 2015 -0700
> > @@ -645,7 +645,7 @@
> > for (int i = 0; i < numCandidates; i++)
> > {
> > MV m = mvc[i].clipped(qmvmin, qmvmax);
> > - if (m.notZero() && m != pmv && m != bestpre) // check already
> > measured
> > + if (m.notZero() & (m != pmv ? 1 : 0) & (m != bestpre ? 1 :
> > 0)) // check already measured
> > {
> > int cost = ref->lowresQPelCost(fenc, blockOffset, m, sad)
> > + mvcost(m);
> > if (cost < bprecost)
> > @@ -661,7 +661,7 @@
> > for (int i = 0; i < numCandidates; i++)
> > {
> > MV m = mvc[i].clipped(qmvmin, qmvmax);
> > - if (m.notZero() && m != pmv && m != bestpre) // check already
> > measured
> > + if (m.notZero() & (m != pmv ? 1 : 0) & (m != bestpre ? 1 :
> > 0)) // check already measured
> > {
> > int cost = subpelCompare(ref, m, sad) + mvcost(m);
> > if (cost < bprecost)
> >
> > _______________________________________________
> > x265-devel mailing list
> > x265-devel at videolan.org
> > https://mailman.videolan.org/listinfo/x265-devel
> >
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
--
Steve Borho
_______________________________________________
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/20150630/2929bb53/attachment.html>
More information about the x265-devel
mailing list