MCPcopy Create free account
hub / github.com/cisco/openh264 / PredictSad

Function PredictSad

codec/encoder/core/src/md.cpp:826–867  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

824}
825
826void PredictSad (int8_t* pRefIndexCache, int32_t* pSadCostCache, int32_t uiRef, int32_t* pSadPred) {
827 const int32_t kiRefB = pRefIndexCache[1];//top g_uiCache12_8x8RefIdx[0] - 4
828 int32_t iRefC = pRefIndexCache[5];//top-right g_uiCache12_8x8RefIdx[0] - 2
829 const int32_t kiRefA = pRefIndexCache[6];//left g_uiCache12_8x8RefIdx[0] - 1
830 const int32_t kiSadB = pSadCostCache[1];
831 int32_t iSadC = pSadCostCache[2];
832 const int32_t kiSadA = pSadCostCache[3];
833
834 int32_t iCount;
835
836 if (iRefC == REF_NOT_AVAIL) {
837 iRefC = pRefIndexCache[0];//top-left g_uiCache12_8x8RefIdx[0] - 4 - 1
838 iSadC = pSadCostCache[0];
839 }
840
841 if (kiRefB == REF_NOT_AVAIL && iRefC == REF_NOT_AVAIL && kiRefA != REF_NOT_AVAIL) {
842 * pSadPred = kiSadA;
843 } else {
844 iCount = (uiRef == kiRefA) << MB_LEFT_BIT;
845 iCount |= (uiRef == kiRefB) << MB_TOP_BIT;
846 iCount |= (uiRef == iRefC) << MB_TOPRIGHT_BIT;
847 switch (iCount) {
848 case LEFT_MB_POS:// A
849 *pSadPred = kiSadA;
850 break;
851 case TOP_MB_POS:// B
852 *pSadPred = kiSadB;
853 break;
854 case TOPRIGHT_MB_POS:// C or D
855 *pSadPred = iSadC;
856 break;
857 default:
858 *pSadPred = WelsMedian (kiSadA, kiSadB, iSadC);
859 break;
860 }
861 }
862
863#define REPLACE_SAD_MULTIPLY(x) ((x) - (x>>3) + (x >>5)) // it's 0.90625, very close with 0.9
864 iCount = (*pSadPred) << 6; // here *64 will not overflow. SAD range 0~ 255*256(max 2^16), int32_t is enough
865 *pSadPred = (REPLACE_SAD_MULTIPLY (iCount) + 32) >> 6;
866#undef REPLACE_SAD_MULTIPLY
867}
868
869
870void PredictSadSkip (int8_t* pRefIndexCache, bool* pMbSkipCache, int32_t* pSadCostCache, int32_t uiRef,

Callers 2

WelsMdInterMbFunction · 0.85

Calls 1

WelsMedianFunction · 0.85

Tested by

no test coverage detected