<div dir="ltr">This patch looks OK</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 25, 2014 at 8:15 PM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Fri, Apr 25, 2014 at 2:05 AM, Satoshi Nakagawa <<a href="mailto:nakagawa424@oki.com">nakagawa424@oki.com</a>> wrote:<br>

> # HG changeset patch<br>
> # User Satoshi Nakagawa <<a href="mailto:nakagawa424@oki.com">nakagawa424@oki.com</a>><br>
> # Date 1398409064 -32400<br>
> #      Fri Apr 25 15:57:44 2014 +0900<br>
> # Node ID 9178bef9cb2b89befc082b42865ad85befe7db2b<br>
> # Parent  c630b0b393eec3a2e2bedf137fba0d56764672ef<br>
> fix: 4:2:2 rdLevel <= 1<br>
<br>
</div>Thanks Satoshi, this is being reviewed internally.  Hope to have some<br>
feedback on Monday<br>
<div class="HOEnZb"><div class="h5"><br>
> diff -r c630b0b393ee -r 9178bef9cb2b source/Lib/TLibEncoder/TEncSearch.cpp<br>
> --- a/source/Lib/TLibEncoder/TEncSearch.cpp     Thu Apr 24 15:59:05 2014 -0500<br>
> +++ b/source/Lib/TLibEncoder/TEncSearch.cpp     Fri Apr 25 15:57:44 2014 +0900<br>
> @@ -2812,6 +2812,8 @@<br>
>      assert(cu->getDepth(0) == cu->getDepth(absPartIdx));<br>
>      const uint32_t trMode = depth - cu->getDepth(0);<br>
>      const uint32_t trSizeLog2 = g_convertToBit[cu->getSlice()->getSPS()->getMaxCUSize() >> depth] + 2;<br>
> +    uint32_t  trSizeCLog2     = trSizeLog2 - m_hChromaShift;<br>
> +    const uint32_t setCbf     = 1 << trMode;<br>
>      int chFmt                 = cu->getChromaFormat();<br>
><br>
>      bool bSplitFlag = ((cu->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && cu->getPredictionMode(absPartIdx) == MODE_INTER && (cu->getPartitionSize(absPartIdx) != SIZE_2Nx2N));<br>

> @@ -2825,16 +2827,17 @@<br>
><br>
>      bool bCodeChroma = true;<br>
>      uint32_t trModeC = trMode;<br>
> -    uint32_t trSizeCLog2 = trSizeLog2 - 1;<br>
> -    if (trSizeLog2 == 2)<br>
> +    if ((trSizeLog2 == 2) && !(chFmt == CHROMA_444))<br>
>      {<br>
>          trSizeCLog2++;<br>
>          trModeC--;<br>
> -        uint32_t qpdiv = cu->getPic()->getNumPartInCU() >> ((cu->getDepth(0) + trModeC) << 1);<br>
> +        uint32_t qpdiv = cu->getPic()->getNumPartInCU() >> ((depth - 1) << 1);<br>
>          bCodeChroma = ((absPartIdx % qpdiv) == 0);<br>
>      }<br>
><br>
> -    const uint32_t setCbf = 1 << trMode;<br>
> +    const bool splitIntoSubTUs = (chFmt == CHROMA_422);<br>
> +    uint32_t absPartIdxStep = cu->getPic()->getNumPartInCU() >> ((cu->getDepth(0) +  trModeC) << 1);<br>
> +<br>
>      // code full block<br>
>      uint32_t absSumY = 0, absSumU = 0, absSumV = 0;<br>
>      int lastPosY = -1, lastPosU = -1, lastPosV = -1;<br>
> @@ -2847,18 +2850,12 @@<br>
>          coeff_t *coeffCurV = cu->getCoeffCr() + (numCoeffPerAbsPartIdxIncrement * absPartIdx >> (m_hChromaShift + m_vChromaShift));<br>
><br>
>          int trWidth = 0, trHeight = 0, trWidthC = 0, trHeightC = 0;<br>
> -        uint32_t absTUPartIdxC = absPartIdx;<br>
><br>
>          trWidth  = trHeight  = 1 << trSizeLog2;<br>
>          trWidthC = trHeightC = 1 << trSizeCLog2;<br>
>          cu->setTrIdxSubParts(depth - cu->getDepth(0), absPartIdx, depth);<br>
><br>
>          cu->setTransformSkipSubParts(0, TEXT_LUMA, absPartIdx, depth);<br>
> -        if (bCodeChroma)<br>
> -        {<br>
> -            cu->setTransformSkipSubParts(0, TEXT_CHROMA_U, absPartIdx, cu->getDepth(0) + trModeC);<br>
> -            cu->setTransformSkipSubParts(0, TEXT_CHROMA_V, absPartIdx, cu->getDepth(0) + trModeC);<br>
> -        }<br>
><br>
>          m_trQuant->setQPforQuant(cu->getQP(0), TEXT_LUMA, QP_BD_OFFSET, 0, chFmt);<br>
>          m_trQuant->selectLambda(TEXT_LUMA);<br>
> @@ -2868,25 +2865,6 @@<br>
><br>
>          cu->setCbfSubParts(absSumY ? setCbf : 0, TEXT_LUMA, absPartIdx, depth);<br>
><br>
> -        if (bCodeChroma)<br>
> -        {<br>
> -            int curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCbQpOffset() + cu->getSlice()->getSliceQpDeltaCb();<br>
> -            m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
> -<br>
> -            m_trQuant->selectLambda(TEXT_CHROMA);<br>
> -<br>
> -            absSumU = m_trQuant->transformNxN(cu, resiYuv->getCbAddr(absTUPartIdxC), resiYuv->m_cwidth, coeffCurU,<br>
> -                                              trWidthC, TEXT_CHROMA_U, absPartIdx, &lastPosU, false, curuseRDOQ);<br>
> -<br>
> -            curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();<br>
> -            m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
> -            absSumV = m_trQuant->transformNxN(cu, resiYuv->getCrAddr(absTUPartIdxC), resiYuv->m_cwidth, coeffCurV,<br>
> -                                              trWidthC, TEXT_CHROMA_V, absPartIdx, &lastPosV, false, curuseRDOQ);<br>
> -<br>
> -            cu->setCbfSubParts(absSumU ? setCbf : 0, TEXT_CHROMA_U, absPartIdx, cu->getDepth(0) + trModeC);<br>
> -            cu->setCbfSubParts(absSumV ? setCbf : 0, TEXT_CHROMA_V, absPartIdx, cu->getDepth(0) + trModeC);<br>
> -        }<br>
> -<br>
>          if (absSumY)<br>
>          {<br>
>              int16_t *curResiY = resiYuv->getLumaAddr(absTUPartIdx);<br>
> @@ -2903,49 +2881,84 @@<br>
>              assert(trWidth == trHeight);<br>
>              primitives.blockfill_s[(int)g_convertToBit[trWidth]](ptr, resiYuv->m_width, 0);<br>
>          }<br>
> +        cu->setCbfSubParts(absSumY ? setCbf : 0, TEXT_LUMA, absPartIdx, depth);<br>
><br>
>          if (bCodeChroma)<br>
>          {<br>
> -            if (absSumU)<br>
> +            TComTURecurse tuIterator;<br>
> +            initSection(&tuIterator, splitIntoSubTUs ? VERTICAL_SPLIT : DONT_SPLIT, absPartIdxStep, absPartIdx);<br>
> +<br>
> +            uint32_t widthC  = trWidthC;<br>
> +            uint32_t heightC = trWidthC;<br>
> +<br>
> +            do<br>
>              {<br>
> -                int16_t *pcResiCurrU = resiYuv->getCbAddr(absTUPartIdxC);<br>
> +                uint32_t absTUPartIdxC = tuIterator.m_absPartIdxTURelCU;<br>
> +                uint32_t subTUBufferOffset    = widthC * heightC * tuIterator.m_section;<br>
> +<br>
> +                cu->setTransformSkipPartRange(0, TEXT_CHROMA_U, absTUPartIdxC, tuIterator.m_absPartIdxStep);<br>
> +                cu->setTransformSkipPartRange(0, TEXT_CHROMA_V, absTUPartIdxC, tuIterator.m_absPartIdxStep);<br>
><br>
>                  int curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCbQpOffset() + cu->getSlice()->getSliceQpDeltaCb();<br>
>                  m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
><br>
> -                int scalingListType = 3 + TEXT_CHROMA_U;<br>
> -                assert(scalingListType < 6);<br>
> -                m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), REG_DCT, pcResiCurrU, resiYuv->m_cwidth, coeffCurU, trWidthC, scalingListType, false, lastPosU);<br>
> -            }<br>
> -            else<br>
> +                m_trQuant->selectLambda(TEXT_CHROMA);<br>
> +<br>
> +                absSumU = m_trQuant->transformNxN(cu, resiYuv->getCbAddr(absTUPartIdxC), resiYuv->m_cwidth, coeffCurU + subTUBufferOffset,<br>
> +                                                  trWidthC, TEXT_CHROMA_U, absTUPartIdxC, &lastPosU, false, curuseRDOQ);<br>
> +<br>
> +                curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();<br>
> +                m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
> +                absSumV = m_trQuant->transformNxN(cu, resiYuv->getCrAddr(absTUPartIdxC), resiYuv->m_cwidth, coeffCurV + subTUBufferOffset,<br>
> +                                                  trWidthC, TEXT_CHROMA_V, absTUPartIdxC, &lastPosV, false, curuseRDOQ);<br>
> +<br>
> +                cu->setCbfPartRange(absSumU ? setCbf : 0, TEXT_CHROMA_U, absTUPartIdxC, tuIterator.m_absPartIdxStep);<br>
> +                cu->setCbfPartRange(absSumV ? setCbf : 0, TEXT_CHROMA_V, absTUPartIdxC, tuIterator.m_absPartIdxStep);<br>
> +<br>
> +                if (absSumU)<br>
> +                {<br>
> +                    int16_t *pcResiCurrU = resiYuv->getCbAddr(absTUPartIdxC);<br>
> +<br>
> +                    curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCbQpOffset() + cu->getSlice()->getSliceQpDeltaCb();<br>
> +                    m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
> +<br>
> +                    int scalingListType = 3 + TEXT_CHROMA_U;<br>
> +                    assert(scalingListType < 6);<br>
> +                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absTUPartIdxC), REG_DCT, pcResiCurrU, resiYuv->m_cwidth, coeffCurU + subTUBufferOffset, trWidthC, scalingListType, false, lastPosU);<br>

> +                }<br>
> +                else<br>
> +                {<br>
> +                    int16_t *ptr = resiYuv->getCbAddr(absTUPartIdxC);<br>
> +                    assert(trWidthC == trHeightC);<br>
> +                    primitives.blockfill_s[(int)g_convertToBit[trWidthC]](ptr, resiYuv->m_cwidth, 0);<br>
> +                }<br>
> +                if (absSumV)<br>
> +                {<br>
> +                    int16_t *curResiV = resiYuv->getCrAddr(absTUPartIdxC);<br>
> +                    curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();<br>
> +                    m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
> +<br>
> +                    int scalingListType = 3 + TEXT_CHROMA_V;<br>
> +                    assert(scalingListType < 6);<br>
> +                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absTUPartIdxC), REG_DCT, curResiV, resiYuv->m_cwidth, coeffCurV + subTUBufferOffset, trWidthC, scalingListType, false, lastPosV);<br>

> +                }<br>
> +                else<br>
> +                {<br>
> +                    int16_t *ptr =  resiYuv->getCrAddr(absTUPartIdxC);<br>
> +                    assert(trWidthC == trHeightC);<br>
> +                    primitives.blockfill_s[(int)g_convertToBit[trWidthC]](ptr, resiYuv->m_cwidth, 0);<br>
> +                }<br>
> +                cu->setCbfPartRange(absSumU ? setCbf : 0, TEXT_CHROMA_U, absTUPartIdxC, tuIterator.m_absPartIdxStep);<br>
> +                cu->setCbfPartRange(absSumV ? setCbf : 0, TEXT_CHROMA_V, absTUPartIdxC, tuIterator.m_absPartIdxStep);<br>
> +            } while (isNextSection(&tuIterator));<br>
> +<br>
> +            if (splitIntoSubTUs)<br>
>              {<br>
> -                int16_t *ptr = resiYuv->getCbAddr(absTUPartIdxC);<br>
> -                assert(trWidthC == trHeightC);<br>
> -                primitives.blockfill_s[(int)g_convertToBit[trWidthC]](ptr, resiYuv->m_cwidth, 0);<br>
> -            }<br>
> -            if (absSumV)<br>
> -            {<br>
> -                int16_t *curResiV = resiYuv->getCrAddr(absTUPartIdxC);<br>
> -                int curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();<br>
> -                m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
> -<br>
> -                int scalingListType = 3 + TEXT_CHROMA_V;<br>
> -                assert(scalingListType < 6);<br>
> -                m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), REG_DCT, curResiV, resiYuv->m_cwidth, coeffCurV, trWidthC, scalingListType, false, lastPosV);<br>
> -            }<br>
> -            else<br>
> -            {<br>
> -                int16_t *ptr =  resiYuv->getCrAddr(absTUPartIdxC);<br>
> -                assert(trWidthC == trHeightC);<br>
> -                primitives.blockfill_s[(int)g_convertToBit[trWidthC]](ptr, resiYuv->m_cwidth, 0);<br>
> +                offsetSubTUCBFs(cu, TEXT_CHROMA_U, trMode, absPartIdx);<br>
> +                offsetSubTUCBFs(cu, TEXT_CHROMA_V, trMode, absPartIdx);<br>
>              }<br>
>          }<br>
> -        cu->setCbfSubParts(absSumY ? setCbf : 0, TEXT_LUMA, absPartIdx, depth);<br>
> -        if (bCodeChroma)<br>
> -        {<br>
> -            cu->setCbfSubParts(absSumU ? setCbf : 0, TEXT_CHROMA_U, absPartIdx, cu->getDepth(0) + trModeC);<br>
> -            cu->setCbfSubParts(absSumV ? setCbf : 0, TEXT_CHROMA_V, absPartIdx, cu->getDepth(0) + trModeC);<br>
> -        }<br>
> +        return;<br>
>      }<br>
><br>
>      // code sub-blocks<br>
> @@ -2976,15 +2989,6 @@<br>
>          }<br>
>          return;<br>
>      }<br>
> -<br>
> -    cu->setTrIdxSubParts(trMode, absPartIdx, depth);<br>
> -    cu->setCbfSubParts(absSumY ? setCbf : 0, TEXT_LUMA, absPartIdx, depth);<br>
> -<br>
> -    if (bCodeChroma)<br>
> -    {<br>
> -        cu->setCbfSubParts(absSumU ? setCbf : 0, TEXT_CHROMA_U, absPartIdx, cu->getDepth(0) + trModeC);<br>
> -        cu->setCbfSubParts(absSumV ? setCbf : 0, TEXT_CHROMA_V, absPartIdx, cu->getDepth(0) + trModeC);<br>
> -    }<br>
>  }<br>
><br>
>  void TEncSearch::xEstimateResidualQT(TComDataCU*    cu,<br>
> @@ -3001,7 +3005,7 @@<br>
>      assert(cu->getDepth(0) == cu->getDepth(absPartIdx));<br>
>      const uint32_t trMode = depth - cu->getDepth(0);<br>
>      const uint32_t trSizeLog2 = g_convertToBit[cu->getSlice()->getSPS()->getMaxCUSize() >> depth] + 2;<br>
> -    uint32_t  trSizeCLog2     = g_convertToBit[(cu->getSlice()->getSPS()->getMaxCUSize() >> m_hChromaShift) >> depth] + 2;<br>
> +    uint32_t  trSizeCLog2     = trSizeLog2 - m_hChromaShift;<br>
>      const uint32_t subTUDepth = trMode + 1;<br>
>      const uint32_t setCbf     = 1 << trMode;<br>
>      int chFmt                 = cu->getChromaFormat();<br>
> @@ -3777,7 +3781,7 @@<br>
>      const uint32_t trMode      = cu->getTransformIdx(absPartIdx);<br>
>      const bool     bSubdiv     = curTrMode != trMode;<br>
>      const uint32_t trSizeLog2  = g_convertToBit[cu->getSlice()->getSPS()->getMaxCUSize() >> depth] + 2;<br>
> -    uint32_t       trSizeCLog2 = g_convertToBit[(cu->getSlice()->getSPS()->getMaxCUSize() >> m_hChromaShift) >> depth] + 2;<br>
> +    uint32_t       trSizeCLog2 = trSizeLog2 - m_hChromaShift;<br>
>      int            chFmt       = cu->getChromaFormat();<br>
><br>
>      if (bSubdivAndCbf && trSizeLog2 <= cu->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() && trSizeLog2 > cu->getQuadtreeTULog2MinSizeInCU(absPartIdx))<br>
> @@ -3887,7 +3891,7 @@<br>
>      if (curTrMode == trMode)<br>
>      {<br>
>          const uint32_t trSizeLog2 = g_convertToBit[cu->getSlice()->getSPS()->getMaxCUSize() >> depth] + 2;<br>
> -        uint32_t  trSizeCLog2     = g_convertToBit[(cu->getSlice()->getSPS()->getMaxCUSize() >> cu->getHorzChromaShift()) >> depth] + 2;<br>
> +        uint32_t  trSizeCLog2     = trSizeLog2 - m_hChromaShift;<br>
>          const uint32_t qtlayer    = cu->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() - trSizeLog2;<br>
><br>
>          bool bCodeChroma = true;<br>
> diff -r c630b0b393ee -r 9178bef9cb2b source/encoder/compress.cpp<br>
> --- a/source/encoder/compress.cpp       Thu Apr 24 15:59:05 2014 -0500<br>
> +++ b/source/encoder/compress.cpp       Fri Apr 25 15:57:44 2014 +0900<br>
> @@ -498,7 +498,11 @@<br>
>                  if (outBestCU->getSlice()->getSliceType() == P_SLICE)<br>
>                  {<br>
>                      /*compute intra cost */<br>
> -                    bool bdoIntra = true;<br>
> +<br>
> +                    // TODO: residualQTIntrachroma is broken for 4:2:2<br>
> +                    bool bdoIntra = (m_param->internalCsp != X265_CSP_I422);<br>
> +                    // bool bdoIntra = true;<br>
> +<br>
>                      if (m_param->rdLevel > 2)<br>
>                      {<br>
>                          bdoIntra = (outBestCU->getCbf(0, TEXT_LUMA) ||  outBestCU->getCbf(0, TEXT_CHROMA_U) ||<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>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Steve Borho<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<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>
</div></div></blockquote></div><br></div>