History

[Decoder] Use encoder x86 IDCT routines

Move asm routines to common. Delete obsolete decoder routines. Use wider routines where applicable. ~1.07x overall faster decode on a quick 720p30 4Mbps test on Haswell.

Sindre Aamås committed 10 years ago

Commit 98042f11 parent 48a520912 files · +1217 −1047Browse files

Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 12 files). Show all

Unified · Split

codec/decoder/core/src/decoder.cpp+27−1
@@ -848,6 +848,22 @@ void InitDecFuncs (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 847 unmodified lines
848848 DeblockingInit (&pCtx->sDeblockingFunc, uiCpuFlag);
849849 }
850850
851+namespace {
852+
853+template<void pfIdctResAddPred (uint8_t* pPred, int32_t iStride, int16_t* pRs)>
854+void IdctFourResAddPred_ (uint8_t* pPred, int32_t iStride, int16_t* pRs, const int8_t* pNzc) {
855+ if (pNzc[0] || pRs[0 * 16])
856+ pfIdctResAddPred (pPred + 0 * iStride + 0, iStride, pRs + 0 * 16);
857+ if (pNzc[1] || pRs[1 * 16])
858+ pfIdctResAddPred (pPred + 0 * iStride + 4, iStride, pRs + 1 * 16);
859+ if (pNzc[4] || pRs[2 * 16])
860+ pfIdctResAddPred (pPred + 4 * iStride + 0, iStride, pRs + 2 * 16);
861+ if (pNzc[5] || pRs[3 * 16])
862+ pfIdctResAddPred (pPred + 4 * iStride + 4, iStride, pRs + 3 * 16);
863+}
864+
865+} // anon ns
866+
851867 void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) {
852868 pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c;
853869 pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c;
@@ -896,12 +912,14 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 42 unmodified lines
896912 pCtx->pGetIChromaPredFunc[C_PRED_DC_128] = WelsIChromaPredDcNA_c;
897913
898914 pCtx->pIdctResAddPredFunc = IdctResAddPred_c;
915+ pCtx->pIdctFourResAddPredFunc = IdctFourResAddPred_<IdctResAddPred_c>;
899916
900917 pCtx->pIdctResAddPredFunc8x8 = IdctResAddPred8x8_c;
901918
902919 #if defined(HAVE_NEON)
903920 if (uiCpuFlag & WELS_CPU_NEON) {
904921 pCtx->pIdctResAddPredFunc = IdctResAddPred_neon;
922+ pCtx->pIdctFourResAddPredFunc = IdctFourResAddPred_<IdctResAddPred_neon>;
905923
906924 pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_neon;
907925 pCtx->pGetI16x16LumaPredFunc[I16_PRED_P] = WelsDecoderI16x16LumaPredPlane_neon;
@@ -927,6 +945,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 19 unmodified lines
927945 #if defined(HAVE_NEON_AARCH64)
928946 if (uiCpuFlag & WELS_CPU_NEON) {
929947 pCtx->pIdctResAddPredFunc = IdctResAddPred_AArch64_neon;
948+ pCtx->pIdctFourResAddPredFunc = IdctFourResAddPred_<IdctResAddPred_AArch64_neon>;
930949
931950 pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_AArch64_neon;
932951 pCtx->pGetI16x16LumaPredFunc[I16_PRED_P] = WelsDecoderI16x16LumaPredPlane_AArch64_neon;
@@ -957,6 +976,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 24 unmodified lines
957976 #if defined(X86_ASM)
958977 if (uiCpuFlag & WELS_CPU_MMXEXT) {
959978 pCtx->pIdctResAddPredFunc = IdctResAddPred_mmx;
979+ pCtx->pIdctFourResAddPredFunc = IdctFourResAddPred_<IdctResAddPred_mmx>;
960980
961981 ///////mmx code opt---
962982 pCtx->pGetIChromaPredFunc[C_PRED_H] = WelsDecoderIChromaPredH_mmx;
@@ -971,7 +991,9 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 8 unmodified lines
971991 pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL ] = WelsDecoderI4x4LumaPredVL_mmx;
972992 }
973993 if (uiCpuFlag & WELS_CPU_SSE2) {
974− /////////sse2 code opt---
994+ pCtx->pIdctResAddPredFunc = IdctResAddPred_sse2;
995+ pCtx->pIdctFourResAddPredFunc = IdctFourResAddPred_sse2;
996+
975997 pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_sse2;
976998 pCtx->pGetI16x16LumaPredFunc[I16_PRED_P] = WelsDecoderI16x16LumaPredPlane_sse2;
977999 pCtx->pGetI16x16LumaPredFunc[I16_PRED_H] = WelsDecoderI16x16LumaPredH_sse2;
@@ -983,6 +1005,10 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 5 unmodified lines
9831005 pCtx->pGetIChromaPredFunc[C_PRED_DC_T] = WelsDecoderIChromaPredDcTop_sse2;
9841006 pCtx->pGetI4x4LumaPredFunc[I4_PRED_H] = WelsDecoderI4x4LumaPredH_sse2;
9851007 }
1008+ if (uiCpuFlag & WELS_CPU_AVX2) {
1009+ pCtx->pIdctResAddPredFunc = IdctResAddPred_avx2;
1010+ pCtx->pIdctFourResAddPredFunc = IdctFourResAddPred_avx2;
1011+ }
9861012 #endif
9871013 }
9881014

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t