Showing the changes to codec/processing/src/downsample (3 of 9 files). Show all
Unified · Split
| @@ -53,6 +53,8 @@ void CDownsampling::InitDownsampleFuncs (SDownsampleFuncs& sDownsampleFunc, int · 52 unmodified lines | ||
| 53 | 53 | sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsampler_c; |
| 54 | 54 | sDownsampleFunc.pfHalfAverage[2] = DyadicBilinearDownsampler_c; |
| 55 | 55 | sDownsampleFunc.pfHalfAverage[3] = DyadicBilinearDownsampler_c; |
| 56 | + sDownsampleFunc.pfOneThirdDownsampler = DyadicBilinearOneThirdDownsampler_c; | |
| 57 | + sDownsampleFunc.pfQuarterDownsampler = DyadicBilinearQuarterDownsampler_c; | |
| 56 | 58 | sDownsampleFunc.pfGeneralRatioChroma = GeneralBilinearAccurateDownsampler_c; |
| 57 | 59 | sDownsampleFunc.pfGeneralRatioLuma = GeneralBilinearFastDownsampler_c; |
| 58 | 60 | #if defined(X86_ASM) |
| @@ -60,6 +62,7 @@ void CDownsampling::InitDownsampleFuncs (SDownsampleFuncs& sDownsampleFunc, int · 1 unmodified line | ||
| 60 | 62 | sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_sse; |
| 61 | 63 | sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_sse; |
| 62 | 64 | sDownsampleFunc.pfHalfAverage[2] = DyadicBilinearDownsamplerWidthx8_sse; |
| 65 | + sDownsampleFunc.pfQuarterDownsampler = DyadicBilinearQuarterDownsampler_sse; | |
| 63 | 66 | } |
| 64 | 67 | if (iCpuFlag & WELS_CPU_SSE2) { |
| 65 | 68 | sDownsampleFunc.pfGeneralRatioChroma = GeneralBilinearAccurateDownsamplerWrap_sse2; |
| @@ -68,10 +71,14 @@ void CDownsampling::InitDownsampleFuncs (SDownsampleFuncs& sDownsampleFunc, int · 2 unmodified lines | ||
| 68 | 71 | if (iCpuFlag & WELS_CPU_SSSE3) { |
| 69 | 72 | sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_ssse3; |
| 70 | 73 | sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_ssse3; |
| 74 | + sDownsampleFunc.pfOneThirdDownsampler = DyadicBilinearOneThirdDownsampler_ssse3; | |
| 75 | + sDownsampleFunc.pfQuarterDownsampler = DyadicBilinearQuarterDownsampler_ssse3; | |
| 71 | 76 | } |
| 72 | 77 | if (iCpuFlag & WELS_CPU_SSE41) { |
| 73 | 78 | sDownsampleFunc.pfHalfAverage[0] = DyadicBilinearDownsamplerWidthx32_sse4; |
| 74 | 79 | sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsamplerWidthx16_sse4; |
| 80 | + sDownsampleFunc.pfOneThirdDownsampler = DyadicBilinearOneThirdDownsampler_sse4; | |
| 81 | + sDownsampleFunc.pfQuarterDownsampler = DyadicBilinearQuarterDownsampler_sse4; | |
| 75 | 82 | } |
| 76 | 83 | #endif//X86_ASM |
| 77 | 84 | |
| @@ -81,6 +88,8 @@ void CDownsampling::InitDownsampleFuncs (SDownsampleFuncs& sDownsampleFunc, int · 3 unmodified lines | ||
| 81 | 88 | sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsampler_neon; |
| 82 | 89 | sDownsampleFunc.pfHalfAverage[2] = DyadicBilinearDownsampler_neon; |
| 83 | 90 | sDownsampleFunc.pfHalfAverage[3] = DyadicBilinearDownsampler_neon; |
| 91 | + sDownsampleFunc.pfOneThirdDownsampler = DyadicBilinearOneThirdDownsampler_neon; | |
| 92 | + sDownsampleFunc.pfQuarterDownsampler = DyadicBilinearQuarterDownsampler_neon; | |
| 84 | 93 | sDownsampleFunc.pfGeneralRatioChroma = GeneralBilinearAccurateDownsamplerWrap_neon; |
| 85 | 94 | sDownsampleFunc.pfGeneralRatioLuma = GeneralBilinearAccurateDownsamplerWrap_neon; |
| 86 | 95 | } |
| @@ -92,6 +101,8 @@ void CDownsampling::InitDownsampleFuncs (SDownsampleFuncs& sDownsampleFunc, int · 5 unmodified lines | ||
| 92 | 101 | sDownsampleFunc.pfHalfAverage[1] = DyadicBilinearDownsampler_AArch64_neon; |
| 93 | 102 | sDownsampleFunc.pfHalfAverage[2] = DyadicBilinearDownsampler_AArch64_neon; |
| 94 | 103 | sDownsampleFunc.pfHalfAverage[3] = DyadicBilinearDownsampler_AArch64_neon; |
| 104 | + sDownsampleFunc.pfOneThirdDownsampler = DyadicBilinearOneThirdDownsampler_AArch64_neon; | |
| 105 | + sDownsampleFunc.pfQuarterDownsampler = DyadicBilinearQuarterDownsampler_AArch64_neon; | |
| 95 | 106 | sDownsampleFunc.pfGeneralRatioChroma = GeneralBilinearAccurateDownsamplerWrap_AArch64_neon; |
| 96 | 107 | sDownsampleFunc.pfGeneralRatioLuma = GeneralBilinearAccurateDownsamplerWrap_AArch64_neon; |
| 97 | 108 | } |
| @@ -124,6 +135,28 @@ EResult CDownsampling::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pDs · 26 unmodified lines | ||
| 124 | 135 | (uint8_t*)pSrcPixMap->pPixel[1], pSrcPixMap->iStride[1], iSrcWidthUV, iSrcHeightUV); |
| 125 | 136 | m_pfDownsample.pfHalfAverage[iAlignIndex] ((uint8_t*)pDstPixMap->pPixel[2], pDstPixMap->iStride[2], |
| 126 | 137 | (uint8_t*)pSrcPixMap->pPixel[2], pSrcPixMap->iStride[2], iSrcWidthUV, iSrcHeightUV); |
| 138 | + } else if ((iSrcWidthY >> 2) == iDstWidthY && (iSrcHeightY >> 2) == iDstHeightY) { | |
| 139 | + | |
| 140 | + m_pfDownsample.pfQuarterDownsampler ((uint8_t*)pDstPixMap->pPixel[0], pDstPixMap->iStride[0], | |
| 141 | + (uint8_t*)pSrcPixMap->pPixel[0], pSrcPixMap->iStride[0], iSrcWidthY, iSrcHeightY); | |
| 142 | + | |
| 143 | + m_pfDownsample.pfQuarterDownsampler ((uint8_t*)pDstPixMap->pPixel[1], pDstPixMap->iStride[1], | |
| 144 | + (uint8_t*)pSrcPixMap->pPixel[1], pSrcPixMap->iStride[1], iSrcWidthUV, iSrcHeightUV); | |
| 145 | + | |
| 146 | + m_pfDownsample.pfQuarterDownsampler ((uint8_t*)pDstPixMap->pPixel[2], pDstPixMap->iStride[2], | |
| 147 | + (uint8_t*)pSrcPixMap->pPixel[2], pSrcPixMap->iStride[2], iSrcWidthUV, iSrcHeightUV); | |
| 148 | + | |
| 149 | + } else if ((iSrcWidthY / 3) == iDstWidthY && (iSrcHeightY / 3) == iDstHeightY) { | |
| 150 | + | |
| 151 | + m_pfDownsample.pfOneThirdDownsampler ((uint8_t*)pDstPixMap->pPixel[0], pDstPixMap->iStride[0], | |
| 152 | + (uint8_t*)pSrcPixMap->pPixel[0], pSrcPixMap->iStride[0], iSrcWidthY, iDstHeightY); | |
| 153 | + | |
| 154 | + m_pfDownsample.pfOneThirdDownsampler ((uint8_t*)pDstPixMap->pPixel[1], pDstPixMap->iStride[1], | |
| 155 | + (uint8_t*)pSrcPixMap->pPixel[1], pSrcPixMap->iStride[1], iSrcWidthUV, iDstHeightUV); | |
| 156 | + | |
| 157 | + m_pfDownsample.pfOneThirdDownsampler ((uint8_t*)pDstPixMap->pPixel[2], pDstPixMap->iStride[2], | |
| 158 | + (uint8_t*)pSrcPixMap->pPixel[2], pSrcPixMap->iStride[2], iSrcWidthUV, iDstHeightUV); | |
| 159 | + | |
| 127 | 160 | } else { |
| 128 | 161 | m_pfDownsample.pfGeneralRatioLuma ((uint8_t*)pDstPixMap->pPixel[0], pDstPixMap->iStride[0], iDstWidthY, iDstHeightY, |
| 129 | 162 | (uint8_t*)pSrcPixMap->pPixel[0], pSrcPixMap->iStride[0], iSrcWidthY, iSrcHeightY); |
| @@ -54,20 +54,29 @@ typedef void (HalveDownsampleFunc) (uint8_t* pDst, const int32_t kiDstStride, · 53 unmodified lines | ||
| 54 | 54 | uint8_t* pSrc, const int32_t kiSrcStride, |
| 55 | 55 | const int32_t kiSrcWidth, const int32_t kiSrcHeight); |
| 56 | 56 | |
| 57 | +typedef void (SpecificDownsampleFunc) (uint8_t* pDst, const int32_t kiDstStride, | |
| 58 | + uint8_t* pSrc, const int32_t kiSrcStride, | |
| 59 | + const int32_t kiSrcWidth, const int32_t kiHeight); | |
| 60 | + | |
| 57 | 61 | typedef void (GeneralDownsampleFunc) (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth, |
| 58 | 62 | const int32_t kiDstHeight, |
| 59 | 63 | uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight); |
| 60 | 64 | |
| 61 | 65 | typedef HalveDownsampleFunc* PHalveDownsampleFunc; |
| 66 | +typedef SpecificDownsampleFunc* PSpecificDownsampleFunc; | |
| 62 | 67 | typedef GeneralDownsampleFunc* PGeneralDownsampleFunc; |
| 63 | 68 | |
| 64 | −HalveDownsampleFunc DyadicBilinearDownsampler_c; | |
| 69 | +HalveDownsampleFunc DyadicBilinearDownsampler_c; | |
| 65 | 70 | GeneralDownsampleFunc GeneralBilinearFastDownsampler_c; |
| 66 | 71 | GeneralDownsampleFunc GeneralBilinearAccurateDownsampler_c; |
| 72 | +SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_c; | |
| 73 | +SpecificDownsampleFunc DyadicBilinearQuarterDownsampler_c; | |
| 67 | 74 | |
| 68 | 75 | typedef struct { |
| 69 | 76 | // align_index: 0 = x32; 1 = x16; 2 = x8; 3 = common case left; |
| 70 | 77 | PHalveDownsampleFunc pfHalfAverage[4]; |
| 78 | + PSpecificDownsampleFunc pfOneThirdDownsampler; | |
| 79 | + PSpecificDownsampleFunc pfQuarterDownsampler; | |
| 71 | 80 | PGeneralDownsampleFunc pfGeneralRatioLuma; |
| 72 | 81 | PGeneralDownsampleFunc pfGeneralRatioChroma; |
| 73 | 82 | } SDownsampleFuncs; |
| @@ -93,10 +102,19 @@ HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_sse4; · 19 unmodified lines | ||
| 93 | 102 | GeneralDownsampleFunc GeneralBilinearFastDownsamplerWrap_sse2; |
| 94 | 103 | GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_sse2; |
| 95 | 104 | |
| 105 | +SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_ssse3; | |
| 106 | +SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_sse4; | |
| 107 | +SpecificDownsampleFunc DyadicBilinearQuarterDownsampler_sse; | |
| 108 | +SpecificDownsampleFunc DyadicBilinearQuarterDownsampler_ssse3; | |
| 109 | +SpecificDownsampleFunc DyadicBilinearQuarterDownsampler_sse4; | |
| 110 | + | |
| 96 | 111 | void GeneralBilinearFastDownsampler_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth, |
| 97 | − const int32_t kiDstHeight, uint8_t* pSrc, const int32_t kiSrcStride, const uint32_t kuiScaleX, const uint32_t kuiScaleY); | |
| 112 | + const int32_t kiDstHeight, uint8_t* pSrc, const int32_t kiSrcStride, const uint32_t kuiScaleX, | |
| 113 | + const uint32_t kuiScaleY); | |
| 98 | 114 | void GeneralBilinearAccurateDownsampler_sse2 (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth, |
| 99 | − const int32_t kiDstHeight, uint8_t* pSrc, const int32_t kiSrcStride, const uint32_t kuiScaleX, const uint32_t kuiScaleY); | |
| 115 | + const int32_t kiDstHeight, uint8_t* pSrc, const int32_t kiSrcStride, const uint32_t kuiScaleX, | |
| 116 | + const uint32_t kuiScaleY); | |
| 117 | + | |
| 100 | 118 | WELSVP_EXTERN_C_END |
| 101 | 119 | #endif |
| 102 | 120 | |
| @@ -109,6 +127,10 @@ HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_neon; · 6 unmodified lines | ||
| 109 | 127 | |
| 110 | 128 | GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_neon; |
| 111 | 129 | |
| 130 | +SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_neon; | |
| 131 | + | |
| 132 | +SpecificDownsampleFunc DyadicBilinearQuarterDownsampler_neon; | |
| 133 | + | |
| 112 | 134 | void GeneralBilinearAccurateDownsampler_neon (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth, |
| 113 | 135 | const int32_t kiDstHeight, |
| 114 | 136 | uint8_t* pSrc, const int32_t kiSrcStride, const uint32_t kuiScaleX, const uint32_t kuiScaleY); |
| @@ -125,8 +147,13 @@ HalveDownsampleFunc DyadicBilinearDownsamplerWidthx32_AArch64_neon; · 10 unmodified lines | ||
| 125 | 147 | |
| 126 | 148 | GeneralDownsampleFunc GeneralBilinearAccurateDownsamplerWrap_AArch64_neon; |
| 127 | 149 | |
| 128 | −void GeneralBilinearAccurateDownsampler_AArch64_neon (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth, const int32_t kiDstHeight, | |
| 129 | − uint8_t* pSrc, const int32_t kiSrcStride, const uint32_t kuiScaleX, const uint32_t kuiScaleY); | |
| 150 | +SpecificDownsampleFunc DyadicBilinearOneThirdDownsampler_AArch64_neon; | |
| 151 | + | |
| 152 | +SpecificDownsampleFunc DyadicBilinearQuarterDownsampler_AArch64_neon; | |
| 153 | + | |
| 154 | +void GeneralBilinearAccurateDownsampler_AArch64_neon (uint8_t* pDst, const int32_t kiDstStride, | |
| 155 | + const int32_t kiDstWidth, const int32_t kiDstHeight, | |
| 156 | + uint8_t* pSrc, const int32_t kiSrcStride, const uint32_t kuiScaleX, const uint32_t kuiScaleY); | |
| 130 | 157 | |
| 131 | 158 | WELSVP_EXTERN_C_END |
| 132 | 159 | #endif |
| @@ -68,6 +68,53 @@ void DyadicBilinearDownsampler_c (uint8_t* pDst, const int32_t kiDstStride, · 67 unmodified lines | ||
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | +void DyadicBilinearQuarterDownsampler_c (uint8_t* pDst, const int32_t kiDstStride, | |
| 72 | + uint8_t* pSrc, const int32_t kiSrcStride, | |
| 73 | + const int32_t kiSrcWidth, const int32_t kiSrcHeight) | |
| 74 | + | |
| 75 | +{ | |
| 76 | + uint8_t* pDstLine = pDst; | |
| 77 | + uint8_t* pSrcLine = pSrc; | |
| 78 | + const int32_t kiSrcStridex4 = kiSrcStride << 2; | |
| 79 | + const int32_t kiDstWidth = kiSrcWidth >> 2; | |
| 80 | + const int32_t kiDstHeight = kiSrcHeight >> 2; | |
| 81 | + | |
| 82 | + for (int32_t j = 0; j < kiDstHeight; j ++) { | |
| 83 | + for (int32_t i = 0; i < kiDstWidth; i ++) { | |
| 84 | + const int32_t kiSrcX = i << 2; | |
| 85 | + const int32_t kiTempRow1 = (pSrcLine[kiSrcX] + pSrcLine[kiSrcX + 1] + 1) >> 1; | |
| 86 | + const int32_t kiTempRow2 = (pSrcLine[kiSrcX + kiSrcStride] + pSrcLine[kiSrcX + kiSrcStride + 1] + 1) >> 1; | |
| 87 | + | |
| 88 | + pDstLine[i] = (uint8_t) ((kiTempRow1 + kiTempRow2 + 1) >> 1); | |
| 89 | + } | |
| 90 | + pDstLine += kiDstStride; | |
| 91 | + pSrcLine += kiSrcStridex4; | |
| 92 | + } | |
| 93 | +} | |
| 94 | + | |
| 95 | +void DyadicBilinearOneThirdDownsampler_c (uint8_t* pDst, const int32_t kiDstStride, | |
| 96 | + uint8_t* pSrc, const int32_t kiSrcStride, | |
| 97 | + const int32_t kiSrcWidth, const int32_t kiDstHeight) | |
| 98 | + | |
| 99 | +{ | |
| 100 | + uint8_t* pDstLine = pDst; | |
| 101 | + uint8_t* pSrcLine = pSrc; | |
| 102 | + const int32_t kiSrcStridex3 = kiSrcStride * 3; | |
| 103 | + const int32_t kiDstWidth = kiSrcWidth / 3; | |
| 104 | + | |
| 105 | + for (int32_t j = 0; j < kiDstHeight; j ++) { | |
| 106 | + for (int32_t i = 0; i < kiDstWidth; i ++) { | |
| 107 | + const int32_t kiSrcX = i * 3; | |
| 108 | + const int32_t kiTempRow1 = (pSrcLine[kiSrcX] + pSrcLine[kiSrcX + 1] + 1) >> 1; | |
| 109 | + const int32_t kiTempRow2 = (pSrcLine[kiSrcX + kiSrcStride] + pSrcLine[kiSrcX + kiSrcStride + 1] + 1) >> 1; | |
| 110 | + | |
| 111 | + pDstLine[i] = (uint8_t) ((kiTempRow1 + kiTempRow2 + 1) >> 1); | |
| 112 | + } | |
| 113 | + pDstLine += kiDstStride; | |
| 114 | + pSrcLine += kiSrcStridex3; | |
| 115 | + } | |
| 116 | +} | |
| 117 | + | |
| 71 | 118 | void GeneralBilinearFastDownsampler_c (uint8_t* pDst, const int32_t kiDstStride, const int32_t kiDstWidth, |
| 72 | 119 | const int32_t kiDstHeight, |
| 73 | 120 | uint8_t* pSrc, const int32_t kiSrcStride, const int32_t kiSrcWidth, const int32_t kiSrcHeight) { |