[x265] [PATCH 1 of 2] slicetype: update the lowresCosts and intraCosts when cutree is enabled

Aarthi Priya Thirumalai aarthi at multicorewareinc.com
Wed May 7 08:27:40 CEST 2014


On Wed, May 7, 2014 at 1:36 AM, Steve Borho <steve at borho.org> wrote:

> On Tue, May 6, 2014 at 8:07 AM, Aarthi Priya Thirumalai
> <aarthi at multicorewareinc.com> wrote:
> > This is the correct patch.
> >
> > # HG changeset patch
> > # User Aarthi Thirumalai
> > # Date 1399381528 -19800
> > #      Tue May 06 18:35:28 2014 +0530
> > # Node ID 65cb5558ad4a474114aa95d45a7c155ea16f0008
> > # Parent  a6c7325e6ee60827142c18eaf4141e0eb4d6d98a
> > slicetype: update the lowresCosts and intraCosts when cutree is enabled
> >
> > diff -r a6c7325e6ee6 -r 65cb5558ad4a source/encoder/frameencoder.cpp
> > --- a/source/encoder/frameencoder.cpp Tue May 06 15:31:18 2014 +0530
> > +++ b/source/encoder/frameencoder.cpp Tue May 06 18:35:28 2014 +0530
> > @@ -1261,15 +1261,8 @@
> >                  qp_offset += qpoffs[idx];
> >              if (bIsVbv)
> >              {
> > -                uint16_t lowresCuCost =
> > m_pic->m_lowres.lowresCostForRc[idx] & LOWRES_COST_MASK;
> > -                uint16_t intraCuCost = m_pic->m_lowres.intraCost[idx];
> > -                if (m_cfg->param->rc.cuTree)
> > -                {
> > -                    lowresCuCost = (lowresCuCost *
> > x265_exp2fix8(qpoffs[idx]) + 128) >> 8;
> > -                    intraCuCost = (intraCuCost *
> x265_exp2fix8(qpoffs[idx])
> > + 128) >> 8;
> > -                }
> > -                m_pic->m_cuCostsForVbv[cuAddr] += lowresCuCost;
> > -                m_pic->m_intraCuCostsForVbv[cuAddr] += intraCuCost;
> > +                m_pic->m_cuCostsForVbv[cuAddr] +=
> > m_pic->m_lowres.lowresCostForRc[idx];
> > +                m_pic->m_intraCuCostsForVbv[cuAddr] +=
> > m_pic->m_lowres.intraCost[idx];
> >              }
> >              cnt++;
> >          }
> > diff -r a6c7325e6ee6 -r 65cb5558ad4a source/encoder/slicetype.cpp
> > --- a/source/encoder/slicetype.cpp Tue May 06 15:31:18 2014 +0530
> > +++ b/source/encoder/slicetype.cpp Tue May 06 18:35:28 2014 +0530
> > @@ -255,6 +255,7 @@
> >          uint32_t lowresRow = 0, lowresCol = 0, lowresCuIdx = 0, sum = 0;
> >          uint32_t scale = param->maxCUSize / (2 * X265_LOWRES_CU_SIZE);
> >          uint32_t widthInLowresCu = (uint32_t)widthInCU,
> heightInLowresCu =
> > (uint32_t)heightInCU;
> > +        double *qp_offset =frames[b]->sliceType == X265_TYPE_B ?
> > frames[b]->qpAqOffset : frames[b]->qpOffset;
> >
> >          for (uint32_t row = 0; row < pic->getFrameHeightInCU(); row++)
> >          {
> > @@ -265,9 +266,16 @@
> >                  lowresCuIdx = lowresRow * widthInLowresCu;
> >                  for (lowresCol = 0; lowresCol < widthInLowresCu;
> > lowresCol++, lowresCuIdx++)
> >                  {
> > -                    sum += pic->m_lowres.lowresCostForRc[lowresCuIdx] &
> > LOWRES_COST_MASK;
> > +                    uint16_t lowresCuCost =
> > pic->m_lowres.lowresCostForRc[lowresCuIdx] & LOWRES_COST_MASK;
> > +                    if (param->rc.cuTree)
> > +                    {
> > +                        lowresCuCost = (lowresCuCost *
> > x265_exp2fix8(qp_offset[lowresCuIdx]) + 128) >> 8;
> > +                        uint16_t intraCuCost =
> > pic->m_lowres.intraCost[lowresCuIdx];
> > +                        pic->m_lowres.intraCost[lowresCuIdx] =
> (intraCuCost
> > * x265_exp2fix8(qp_offset[lowresCuIdx]) + 128) >> 8;
> > +                    }
>
> shouldn't this adjustment also be performed for AQ w/o cuTree?
>
We are already doing this adjustments for aq within estimateCuCost :
            if (fenc->invQscaleFactor)   // this is available when Aq is
turned on.
                costEstAq += (bcost * fenc->invQscaleFactor[cuXY] + 128) >>
8;
        }
 when cutree is enabled, it might change the qpOffsets values
in cuTreeFinish(). So, we need to recalculate the frameCosts and cucCosts
with the new quantizer offsets.


> > +                    pic->m_lowres.lowresCostForRc[lowresCuIdx] =
> > lowresCuCost;
> > +                    sum += lowresCuCost;
> >                  }
> > -
> >                  pic->m_rowSatdForVbv[row] += sum;
> >              }
> >          }
> >
> >
> >
> > On Tue, May 6, 2014 at 5:15 PM, <aarthi at multicorewareinc.com> wrote:
> >>
> >> # HG changeset patch
> >> # User Aarthi Thirumalai
> >> # Date 1399375233 -19800
> >> #      Tue May 06 16:50:33 2014 +0530
> >> # Node ID a3a234d72841f94f605c6075a5531e93f06eaeb6
> >> # Parent  075705aa41a9144bb1a4d7f12d837169767630e1
> >> slicetype: update the lowresCosts and intraCosts when cutree is enabled.
> >>
> >> diff -r 075705aa41a9 -r a3a234d72841 source/encoder/frameencoder.cpp
> >> --- a/source/encoder/frameencoder.cpp   Mon May 05 23:26:59 2014 -0500
> >> +++ b/source/encoder/frameencoder.cpp   Tue May 06 16:50:33 2014 +0530
> >> @@ -1261,8 +1261,15 @@
> >>                  qp_offset += qpoffs[idx];
> >>              if (bIsVbv)
> >>              {
> >> -                m_pic->m_cuCostsForVbv[cuAddr] +=
> >> m_pic->m_lowres.lowresCostForRc[idx] & LOWRES_COST_MASK;
> >> -                m_pic->m_intraCuCostsForVbv[cuAddr] +=
> >> m_pic->m_lowres.intraCost[idx];
> >> +                uint16_t lowresCuCost =
> >> m_pic->m_lowres.lowresCostForRc[idx] & LOWRES_COST_MASK;
> >> +                uint16_t intraCuCost = m_pic->m_lowres.intraCost[idx];
> >> +                if (m_cfg->param->rc.cuTree)
> >> +                {
> >> +                    lowresCuCost = (lowresCuCost *
> >> x265_exp2fix8(qpoffs[idx]) + 128) >> 8;
> >> +                    intraCuCost = (intraCuCost *
> >> x265_exp2fix8(qpoffs[idx]) + 128) >> 8;
> >> +                }
> >> +                m_pic->m_cuCostsForVbv[cuAddr] += lowresCuCost;
> >> +                m_pic->m_intraCuCostsForVbv[cuAddr] += intraCuCost;
> >>              }
> >>              cnt++;
> >>          }
> >> diff -r 075705aa41a9 -r a3a234d72841 source/encoder/slicetype.cpp
> >> --- a/source/encoder/slicetype.cpp      Mon May 05 23:26:59 2014 -0500
> >> +++ b/source/encoder/slicetype.cpp      Tue May 06 16:50:33 2014 +0530
> >> @@ -1141,7 +1141,7 @@
> >>  {
> >>      int64_t score = 0;
> >>      int *rowSatd = frames[b]->rowSatds[b - p0][p1 - b];
> >> -    double *qp_offset = IS_X265_TYPE_B(frames[b]->sliceType) ?
> >> frames[b]->qpAqOffset : frames[b]->qpOffset;
> >> +    double *qp_offset =frames[b]->sliceType == X265_TYPE_B ?
> >> frames[b]->qpAqOffset : frames[b]->qpOffset;
> >>
> >>      x265_emms();
> >>      for (int cuy = heightInCU - 1; cuy >= 0; cuy--)
> >
> >
> >
> > _______________________________________________
> > 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/20140507/415b3eae/attachment.html>


More information about the x265-devel mailing list