Make the tables const and keep a copy of the table in the SWelsFuncPtrList struct instead, where any modifications to the table only touch that individual instance of the codec.
Showing the changes to codec/encoder/core/src/mc.cpp (1 of 2 files). Show all
Unified · Split
| @@ -676,16 +676,16 @@ void EncMcChroma_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* · 675 unmodified lines | ||
| 676 | 676 | |
| 677 | 677 | typedef void (*PixelAvgFunc) (uint8_t*, int32_t, const uint8_t*, int32_t, const uint8_t*, int32_t, int32_t); |
| 678 | 678 | void WelsInitMcFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag) { |
| 679 | − static PixelAvgFunc pfPixAvgFunc[2] = {PixelAvgWidthEq8_c, PixelAvgWidthEq16_c}; | |
| 679 | + static const PixelAvgFunc pfPixAvgFunc[2] = {PixelAvgWidthEq8_c, PixelAvgWidthEq16_c}; | |
| 680 | 680 | |
| 681 | − static PWelsLumaQuarpelMcFunc pWelsMcFuncWidthEq16[16] = { //[y*4+x] | |
| 681 | + static const PWelsLumaQuarpelMcFunc pWelsMcFuncWidthEq16[16] = { //[y*4+x] | |
| 682 | 682 | McCopyWidthEq16_c, McHorVer10WidthEq16, McHorVer20WidthEq16_c, McHorVer30WidthEq16, |
| 683 | 683 | McHorVer01WidthEq16, McHorVer11WidthEq16, McHorVer21WidthEq16, McHorVer31WidthEq16, |
| 684 | 684 | McHorVer02WidthEq16_c, McHorVer12WidthEq16, McHorVer22WidthEq16_c, McHorVer32WidthEq16, |
| 685 | 685 | McHorVer03WidthEq16, McHorVer13WidthEq16, McHorVer23WidthEq16, McHorVer33WidthEq16 |
| 686 | 686 | }; |
| 687 | 687 | #if defined (X86_ASM) |
| 688 | − static PWelsLumaQuarpelMcFunc pWelsMcFuncWidthEq16_sse2[16] = { | |
| 688 | + static const PWelsLumaQuarpelMcFunc pWelsMcFuncWidthEq16_sse2[16] = { | |
| 689 | 689 | McCopyWidthEq16_sse2, McHorVer10WidthEq16, McHorVer20WidthEq16_sse2, McHorVer30WidthEq16, |
| 690 | 690 | McHorVer01WidthEq16, McHorVer11WidthEq16, McHorVer21WidthEq16, McHorVer31WidthEq16, |
| 691 | 691 | McHorVer02WidthEq16_sse2, McHorVer12WidthEq16, McHorVer22WidthEq16_sse2, McHorVer32WidthEq16, |
| @@ -693,7 +693,7 @@ void WelsInitMcFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag) { · 1 unmodified line | ||
| 693 | 693 | }; |
| 694 | 694 | #endif |
| 695 | 695 | #if defined(HAVE_NEON) |
| 696 | − static PWelsLumaQuarpelMcFunc pWelsMcFuncWidthEq16_neon[16] = { //[x][y] | |
| 696 | + static const PWelsLumaQuarpelMcFunc pWelsMcFuncWidthEq16_neon[16] = { //[x][y] | |
| 697 | 697 | McCopyWidthEq16_neon, McHorVer10WidthEq16_neon, McHorVer20WidthEq16_neon, McHorVer30WidthEq16_neon, |
| 698 | 698 | McHorVer01WidthEq16_neon, EncMcHorVer11_neon, EncMcHorVer21_neon, EncMcHorVer31_neon, |
| 699 | 699 | McHorVer02WidthEq16_neon, EncMcHorVer12_neon, McHorVer22WidthEq16_neon, EncMcHorVer32_neon, |
| @@ -701,7 +701,7 @@ void WelsInitMcFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag) { · 1 unmodified line | ||
| 701 | 701 | }; |
| 702 | 702 | #endif |
| 703 | 703 | #if defined(HAVE_NEON_AARCH64) |
| 704 | − static PWelsLumaQuarpelMcFunc pWelsMcFuncWidthEq16_AArch64_neon[16] = { //[x][y] | |
| 704 | + static const PWelsLumaQuarpelMcFunc pWelsMcFuncWidthEq16_AArch64_neon[16] = { //[x][y] | |
| 705 | 705 | McCopyWidthEq16_AArch64_neon, McHorVer10WidthEq16_AArch64_neon, McHorVer20WidthEq16_AArch64_neon, McHorVer30WidthEq16_AArch64_neon, |
| 706 | 706 | McHorVer01WidthEq16_AArch64_neon, EncMcHorVer11_AArch64_neon, EncMcHorVer21_AArch64_neon, EncMcHorVer31_AArch64_neon, |
| 707 | 707 | McHorVer02WidthEq16_AArch64_neon, EncMcHorVer12_AArch64_neon, McHorVer22WidthEq16_AArch64_neon, EncMcHorVer32_AArch64_neon, |
| @@ -711,7 +711,7 @@ void WelsInitMcFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag) { · 3 unmodified lines | ||
| 711 | 711 | pFuncList->sMcFuncs.pfLumaHalfpelHor = McHorVer20_c; |
| 712 | 712 | pFuncList->sMcFuncs.pfLumaHalfpelVer = McHorVer02_c; |
| 713 | 713 | pFuncList->sMcFuncs.pfLumaHalfpelCen = McHorVer22_c; |
| 714 | − pFuncList->sMcFuncs.pfSampleAveraging = pfPixAvgFunc; | |
| 714 | + memcpy (pFuncList->sMcFuncs.pfSampleAveraging, pfPixAvgFunc, sizeof (pfPixAvgFunc)); | |
| 715 | 715 | pFuncList->sMcFuncs.pfChromaMc = McChroma_c; |
| 716 | 716 | fpVerFilter = VerFilter_c; |
| 717 | 717 | fpHorFilter = HorFilter_c; |
| @@ -723,7 +723,7 @@ void WelsInitMcFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag) { · 5 unmodified lines | ||
| 723 | 723 | pfMcHorVer02WidthEq16 = McHorVer02WidthEq16_c; |
| 724 | 724 | pfMcHorVer20WidthEq16 = McHorVer20WidthEq16_c; |
| 725 | 725 | pfMcHorVer22WidthEq16 = McHorVer22WidthEq16_c; |
| 726 | − pFuncList->sMcFuncs.pfLumaQuarpelMc = pWelsMcFuncWidthEq16; | |
| 726 | + memcpy (pFuncList->sMcFuncs.pfLumaQuarpelMc, pWelsMcFuncWidthEq16, sizeof (pWelsMcFuncWidthEq16)); | |
| 727 | 727 | #if defined (X86_ASM) |
| 728 | 728 | if (uiCpuFlag & WELS_CPU_SSE2) { |
| 729 | 729 | pFuncList->sMcFuncs.pfLumaHalfpelHor = McHorVer20Width9Or17_sse2; |
| @@ -739,7 +739,7 @@ void WelsInitMcFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag) { · 9 unmodified lines | ||
| 739 | 739 | pfMcHorVer02WidthEq16 = McHorVer02WidthEq16_sse2; |
| 740 | 740 | pfMcHorVer20WidthEq16 = McHorVer20WidthEq16_sse2; |
| 741 | 741 | pfMcHorVer22WidthEq16 = McHorVer22WidthEq16_sse2; |
| 742 | − pFuncList->sMcFuncs.pfLumaQuarpelMc = pWelsMcFuncWidthEq16_sse2; | |
| 742 | + memcpy (pFuncList->sMcFuncs.pfLumaQuarpelMc, pWelsMcFuncWidthEq16_sse2, sizeof (pWelsMcFuncWidthEq16_sse2)); | |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | if (uiCpuFlag & WELS_CPU_SSSE3) { |
| @@ -750,7 +750,7 @@ void WelsInitMcFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag) { · 4 unmodified lines | ||
| 750 | 750 | |
| 751 | 751 | #if defined(HAVE_NEON) |
| 752 | 752 | if (uiCpuFlag & WELS_CPU_NEON) { |
| 753 | − pFuncList->sMcFuncs.pfLumaQuarpelMc = pWelsMcFuncWidthEq16_neon; | |
| 753 | + memcpy (pFuncList->sMcFuncs.pfLumaQuarpelMc, pWelsMcFuncWidthEq16_neon, sizeof (pWelsMcFuncWidthEq16_neon)); | |
| 754 | 754 | pFuncList->sMcFuncs.pfChromaMc = EncMcChroma_neon; |
| 755 | 755 | pFuncList->sMcFuncs.pfSampleAveraging[0] = PixStrideAvgWidthEq8_neon; |
| 756 | 756 | pFuncList->sMcFuncs.pfSampleAveraging[1] = PixStrideAvgWidthEq16_neon; |
| @@ -761,7 +761,8 @@ void WelsInitMcFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag) { · 4 unmodified lines | ||
| 761 | 761 | #endif |
| 762 | 762 | #if defined(HAVE_NEON_AARCH64) |
| 763 | 763 | if (uiCpuFlag & WELS_CPU_NEON) { |
| 764 | − pFuncList->sMcFuncs.pfLumaQuarpelMc = pWelsMcFuncWidthEq16_AArch64_neon; | |
| 764 | + memcpy (pFuncList->sMcFuncs.pfLumaQuarpelMc, pWelsMcFuncWidthEq16_AArch64_neon, | |
| 765 | + sizeof (pWelsMcFuncWidthEq16_AArch64_neon)); | |
| 765 | 766 | pFuncList->sMcFuncs.pfChromaMc = EncMcChroma_AArch64_neon; |
| 766 | 767 | pFuncList->sMcFuncs.pfSampleAveraging[0] = PixStrideAvgWidthEq8_AArch64_neon; |
| 767 | 768 | pFuncList->sMcFuncs.pfSampleAveraging[1] = PixStrideAvgWidthEq16_AArch64_neon; |