[x265] [PATCH 2 of 3] improve duplicate MV check by reduce condition jump

Steve Borho steve at borho.org
Mon Jun 29 17:57:50 CEST 2015


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


More information about the x265-devel mailing list