Commits

nandaku2 committed a7d2fb1

compress: save best bits, sad in xcomputeCostIntrainInter

  • Participants
  • Parent commits e0036ec

Comments (0)

Files changed (1)

source/encoder/compress.cpp

     Pel *aboveFiltered = m_search->refAboveFlt + width - 1;
     Pel *left          = m_search->refLeft     + width - 1;
     Pel *leftFiltered  = m_search->refLeftFlt  + width - 1;
-    int sad;
-    uint32_t bits, mode, bmode;
+    int sad, bsad;
+    uint32_t bits, bbits, mode, bmode;
     uint64_t cost, bcost;
 
     // 33 Angle modes once
 
     // DC
     primitives.intra_pred_dc[log2SizeMinus2](above + 1, left + 1, tmp, scaleStride, (scaleWidth <= 16));
-    sad = costMultiplier * sa8d(fenc, scaleStride, tmp, scaleStride);
+    bsad = costMultiplier * sa8d(fenc, scaleStride, tmp, scaleStride);
     bmode = mode = DC_IDX;
-    bits  = m_search->xModeBitsIntra(cu, mode, partOffset, depth, initTrDepth);
-    bcost = m_rdCost->calcRdSADCost(sad, bits);
+    bbits  = m_search->xModeBitsIntra(cu, mode, partOffset, depth, initTrDepth);
+    bcost = m_rdCost->calcRdSADCost(bsad, bbits);
 
     Pel *abovePlanar   = above;
     Pel *leftPlanar    = left;
     mode = PLANAR_IDX;
     bits = m_search->xModeBitsIntra(cu, mode, partOffset, depth, initTrDepth);
     cost = m_rdCost->calcRdSADCost(sad, bits);
-    COPY2_IF_LT(bcost, cost, bmode, mode);
+    COPY4_IF_LT(bcost, cost, bmode, mode, bsad, sad, bbits, bits);
 
     // Transpose NxN
     primitives.transpose[log2SizeMinus2](buf_trans, fenc, scaleStride);
         sad  = costMultiplier * sa8d(cmp, srcStride, &tmp[(mode - 2) * (scaleWidth * scaleWidth)], scaleWidth);
         bits = m_search->xModeBitsIntra(cu, mode, partOffset, depth, initTrDepth);
         cost = m_rdCost->calcRdSADCost(sad, bits);
-        COPY2_IF_LT(bcost, cost, bmode, mode);
+        COPY4_IF_LT(bcost, cost, bmode, mode, bsad, sad, bbits, bits);
     }
 
+    cu->m_totalBits = bbits;
+    cu->m_totalDistortion = bsad;
+    cu->m_totalCost = bcost;
+
     // generate predYuv for the best mode
     cu->setLumaIntraDirSubParts(bmode, partOffset, depth + initTrDepth);