<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 7, 2014 at 1:36 AM, Steve Borho <span dir="ltr"><<a href="mailto:steve@borho.org" target="_blank">steve@borho.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">On Tue, May 6, 2014 at 8:07 AM, Aarthi Priya Thirumalai<br>

<<a href="mailto:aarthi@multicorewareinc.com">aarthi@multicorewareinc.com</a>> wrote:<br>
> This is the correct patch.<br>
><br>
> # HG changeset patch<br>
> # User Aarthi Thirumalai<br>
> # Date 1399381528 -19800<br>
> #      Tue May 06 18:35:28 2014 +0530<br>
> # Node ID 65cb5558ad4a474114aa95d45a7c155ea16f0008<br>
> # Parent  a6c7325e6ee60827142c18eaf4141e0eb4d6d98a<br>
> slicetype: update the lowresCosts and intraCosts when cutree is enabled<br>
><br>
> diff -r a6c7325e6ee6 -r 65cb5558ad4a source/encoder/frameencoder.cpp<br>
> --- a/source/encoder/frameencoder.cpp Tue May 06 15:31:18 2014 +0530<br>
> +++ b/source/encoder/frameencoder.cpp Tue May 06 18:35:28 2014 +0530<br>
> @@ -1261,15 +1261,8 @@<br>
>                  qp_offset += qpoffs[idx];<br>
>              if (bIsVbv)<br>
>              {<br>
> -                uint16_t lowresCuCost =<br>
> m_pic->m_lowres.lowresCostForRc[idx] & LOWRES_COST_MASK;<br>
> -                uint16_t intraCuCost = m_pic->m_lowres.intraCost[idx];<br>
> -                if (m_cfg->param->rc.cuTree)<br>
> -                {<br>
> -                    lowresCuCost = (lowresCuCost *<br>
> x265_exp2fix8(qpoffs[idx]) + 128) >> 8;<br>
> -                    intraCuCost = (intraCuCost * x265_exp2fix8(qpoffs[idx])<br>
> + 128) >> 8;<br>
> -                }<br>
> -                m_pic->m_cuCostsForVbv[cuAddr] += lowresCuCost;<br>
> -                m_pic->m_intraCuCostsForVbv[cuAddr] += intraCuCost;<br>
> +                m_pic->m_cuCostsForVbv[cuAddr] +=<br>
> m_pic->m_lowres.lowresCostForRc[idx];<br>
> +                m_pic->m_intraCuCostsForVbv[cuAddr] +=<br>
> m_pic->m_lowres.intraCost[idx];<br>
>              }<br>
>              cnt++;<br>
>          }<br>
> diff -r a6c7325e6ee6 -r 65cb5558ad4a source/encoder/slicetype.cpp<br>
> --- a/source/encoder/slicetype.cpp Tue May 06 15:31:18 2014 +0530<br>
> +++ b/source/encoder/slicetype.cpp Tue May 06 18:35:28 2014 +0530<br>
> @@ -255,6 +255,7 @@<br>
>          uint32_t lowresRow = 0, lowresCol = 0, lowresCuIdx = 0, sum = 0;<br>
>          uint32_t scale = param->maxCUSize / (2 * X265_LOWRES_CU_SIZE);<br>
>          uint32_t widthInLowresCu = (uint32_t)widthInCU, heightInLowresCu =<br>
> (uint32_t)heightInCU;<br>
> +        double *qp_offset =frames[b]->sliceType == X265_TYPE_B ?<br>
> frames[b]->qpAqOffset : frames[b]->qpOffset;<br>
><br>
>          for (uint32_t row = 0; row < pic->getFrameHeightInCU(); row++)<br>
>          {<br>
> @@ -265,9 +266,16 @@<br>
>                  lowresCuIdx = lowresRow * widthInLowresCu;<br>
>                  for (lowresCol = 0; lowresCol < widthInLowresCu;<br>
> lowresCol++, lowresCuIdx++)<br>
>                  {<br>
> -                    sum += pic->m_lowres.lowresCostForRc[lowresCuIdx] &<br>
> LOWRES_COST_MASK;<br>
> +                    uint16_t lowresCuCost =<br>
> pic->m_lowres.lowresCostForRc[lowresCuIdx] & LOWRES_COST_MASK;<br>
> +                    if (param->rc.cuTree)<br>
> +                    {<br>
> +                        lowresCuCost = (lowresCuCost *<br>
> x265_exp2fix8(qp_offset[lowresCuIdx]) + 128) >> 8;<br>
> +                        uint16_t intraCuCost =<br>
> pic->m_lowres.intraCost[lowresCuIdx];<br>
> +                        pic->m_lowres.intraCost[lowresCuIdx] = (intraCuCost<br>
> * x265_exp2fix8(qp_offset[lowresCuIdx]) + 128) >> 8;<br>
> +                    }<br>
<br>
</div></div>shouldn't this adjustment also be performed for AQ w/o cuTree?<br></blockquote><div>We are already doing this adjustments for aq within estimateCuCost :</div><div>            if (fenc->invQscaleFactor)   // this is available when Aq is turned on. </div>
<div>                costEstAq += (bcost * fenc->invQscaleFactor[cuXY] + 128) >> 8;</div><div>        } </div><div> 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. </div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div><div class="h5"><br>
> +                    pic->m_lowres.lowresCostForRc[lowresCuIdx] =<br>
> lowresCuCost;<br>
> +                    sum += lowresCuCost;<br>
>                  }<br>
> -<br>
>                  pic->m_rowSatdForVbv[row] += sum;<br>
>              }<br>
>          }<br>
><br>
><br>
><br>
> On Tue, May 6, 2014 at 5:15 PM, <<a href="mailto:aarthi@multicorewareinc.com">aarthi@multicorewareinc.com</a>> wrote:<br>
>><br>
>> # HG changeset patch<br>
>> # User Aarthi Thirumalai<br>
>> # Date 1399375233 -19800<br>
>> #      Tue May 06 16:50:33 2014 +0530<br>
>> # Node ID a3a234d72841f94f605c6075a5531e93f06eaeb6<br>
>> # Parent  075705aa41a9144bb1a4d7f12d837169767630e1<br>
>> slicetype: update the lowresCosts and intraCosts when cutree is enabled.<br>
>><br>
>> diff -r 075705aa41a9 -r a3a234d72841 source/encoder/frameencoder.cpp<br>
>> --- a/source/encoder/frameencoder.cpp   Mon May 05 23:26:59 2014 -0500<br>
>> +++ b/source/encoder/frameencoder.cpp   Tue May 06 16:50:33 2014 +0530<br>
>> @@ -1261,8 +1261,15 @@<br>
>>                  qp_offset += qpoffs[idx];<br>
>>              if (bIsVbv)<br>
>>              {<br>
>> -                m_pic->m_cuCostsForVbv[cuAddr] +=<br>
>> m_pic->m_lowres.lowresCostForRc[idx] & LOWRES_COST_MASK;<br>
>> -                m_pic->m_intraCuCostsForVbv[cuAddr] +=<br>
>> m_pic->m_lowres.intraCost[idx];<br>
>> +                uint16_t lowresCuCost =<br>
>> m_pic->m_lowres.lowresCostForRc[idx] & LOWRES_COST_MASK;<br>
>> +                uint16_t intraCuCost = m_pic->m_lowres.intraCost[idx];<br>
>> +                if (m_cfg->param->rc.cuTree)<br>
>> +                {<br>
>> +                    lowresCuCost = (lowresCuCost *<br>
>> x265_exp2fix8(qpoffs[idx]) + 128) >> 8;<br>
>> +                    intraCuCost = (intraCuCost *<br>
>> x265_exp2fix8(qpoffs[idx]) + 128) >> 8;<br>
>> +                }<br>
>> +                m_pic->m_cuCostsForVbv[cuAddr] += lowresCuCost;<br>
>> +                m_pic->m_intraCuCostsForVbv[cuAddr] += intraCuCost;<br>
>>              }<br>
>>              cnt++;<br>
>>          }<br>
>> diff -r 075705aa41a9 -r a3a234d72841 source/encoder/slicetype.cpp<br>
>> --- a/source/encoder/slicetype.cpp      Mon May 05 23:26:59 2014 -0500<br>
>> +++ b/source/encoder/slicetype.cpp      Tue May 06 16:50:33 2014 +0530<br>
>> @@ -1141,7 +1141,7 @@<br>
>>  {<br>
>>      int64_t score = 0;<br>
>>      int *rowSatd = frames[b]->rowSatds[b - p0][p1 - b];<br>
>> -    double *qp_offset = IS_X265_TYPE_B(frames[b]->sliceType) ?<br>
>> frames[b]->qpAqOffset : frames[b]->qpOffset;<br>
>> +    double *qp_offset =frames[b]->sliceType == X265_TYPE_B ?<br>
>> frames[b]->qpAqOffset : frames[b]->qpOffset;<br>
>><br>
>>      x265_emms();<br>
>>      for (int cuy = heightInCU - 1; cuy >= 0; cuy--)<br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> x265-devel mailing list<br>
> <a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
> <a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
><br>
<span class=""><font color="#888888"><br>
<br>
<br>
--<br>
Steve Borho<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</font></span></blockquote></div><br></div></div>