1 /*! 2 * \copy 3 * Copyright (c) 2011-2013, Cisco Systems 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 * \file : vaacalculation.h 32 * 33 * \brief : pVaa calculation class of wels video processor class 34 * 35 * \date : 2011/03/18 36 * 37 * \description : 1. rewrite the package code of pVaa calculation class 38 * 39 ************************************************************************************* 40 */ 41 42 #ifndef WELSVP_VAACALCULATION_H 43 #define WELSVP_VAACALCULATION_H 44 45 #include "util.h" 46 #include "memory.h" 47 #include "WelsFrameWork.h" 48 #include "IWelsVP.h" 49 50 WELSVP_NAMESPACE_BEGIN 51 52 typedef void (VAACalcSadBgdFunc) (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, 53 int32_t iPicHeight, 54 int32_t iPicStride, 55 int32_t* pFrameSad, int32_t* pSad8x8, int32_t* pSd8x8, uint8_t* pMad8x8); 56 57 typedef void (VAACalcSadSsdBgdFunc) (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, 58 int32_t iPicHeight, 59 int32_t iPicStride, 60 int32_t* pFrameSad, int32_t* pSad8x8, int32_t* pSum16x16, int32_t* pSumSquare16x16, 61 int32_t* pSsd16x16, int32_t* pSd8x8, uint8_t* pMad8x8); 62 63 typedef void (VAACalcSadFunc) (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, int32_t iPicHeight, 64 int32_t iPicStride, 65 int32_t* pFrameSad, int32_t* pSad8x8); 66 67 typedef void (VAACalcSadVarFunc) (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, 68 int32_t iPicHeight, 69 int32_t iPicStride, 70 int32_t* pFrameSad, int32_t* pSad8x8, int32_t* pSum16x16, int32_t* pSumSquare16x16); 71 72 typedef void (VAACalcSadSsdFunc) (const uint8_t* pCurData, const uint8_t* pRefData, int32_t iPicWidth, 73 int32_t iPicHeight, 74 int32_t iPicStride, 75 int32_t* pFrameSad, int32_t* pSad8x8, int32_t* pSum16x16, int32_t* pSumSquare16x16, int32_t* pSsd16x16); 76 77 78 typedef VAACalcSadBgdFunc* PVAACalcSadBgdFunc; 79 typedef VAACalcSadSsdBgdFunc* PVAACalcSadSsdBgdFunc; 80 typedef VAACalcSadFunc* PVAACalcSadFunc; 81 typedef VAACalcSadVarFunc* PVAACalcSadVarFunc; 82 typedef VAACalcSadSsdFunc* PVAACalcSadSsdFunc; 83 84 typedef struct TagVaaFuncs { 85 PVAACalcSadBgdFunc pfVAACalcSadBgd; 86 PVAACalcSadSsdBgdFunc pfVAACalcSadSsdBgd; 87 PVAACalcSadFunc pfVAACalcSad; 88 PVAACalcSadVarFunc pfVAACalcSadVar; 89 PVAACalcSadSsdFunc pfVAACalcSadSsd; 90 } SVaaFuncs; 91 92 93 VAACalcSadBgdFunc VAACalcSadBgd_c; 94 VAACalcSadSsdBgdFunc VAACalcSadSsdBgd_c; 95 VAACalcSadFunc VAACalcSad_c; 96 VAACalcSadVarFunc VAACalcSadVar_c; 97 VAACalcSadSsdFunc VAACalcSadSsd_c; 98 99 100 #ifdef X86_ASM 101 WELSVP_EXTERN_C_BEGIN 102 VAACalcSadBgdFunc VAACalcSadBgd_sse2; 103 VAACalcSadSsdBgdFunc VAACalcSadSsdBgd_sse2; 104 VAACalcSadFunc VAACalcSad_sse2; 105 VAACalcSadVarFunc VAACalcSadVar_sse2; 106 VAACalcSadSsdFunc VAACalcSadSsd_sse2; 107 VAACalcSadBgdFunc VAACalcSadBgd_avx2; 108 VAACalcSadSsdBgdFunc VAACalcSadSsdBgd_avx2; 109 VAACalcSadFunc VAACalcSad_avx2; 110 VAACalcSadVarFunc VAACalcSadVar_avx2; 111 VAACalcSadSsdFunc VAACalcSadSsd_avx2; 112 WELSVP_EXTERN_C_END 113 #endif 114 115 #ifdef HAVE_NEON 116 WELSVP_EXTERN_C_BEGIN 117 VAACalcSadBgdFunc VAACalcSadBgd_neon; 118 VAACalcSadSsdBgdFunc VAACalcSadSsdBgd_neon; 119 VAACalcSadFunc VAACalcSad_neon; 120 VAACalcSadVarFunc VAACalcSadVar_neon; 121 VAACalcSadSsdFunc VAACalcSadSsd_neon; 122 WELSVP_EXTERN_C_END 123 #endif 124 125 #ifdef HAVE_NEON_AARCH64 126 WELSVP_EXTERN_C_BEGIN 127 VAACalcSadBgdFunc VAACalcSadBgd_AArch64_neon; 128 VAACalcSadSsdBgdFunc VAACalcSadSsdBgd_AArch64_neon; 129 VAACalcSadFunc VAACalcSad_AArch64_neon; 130 VAACalcSadVarFunc VAACalcSadVar_AArch64_neon; 131 VAACalcSadSsdFunc VAACalcSadSsd_AArch64_neon; 132 WELSVP_EXTERN_C_END 133 #endif 134 135 #ifdef HAVE_MMI 136 WELSVP_EXTERN_C_BEGIN 137 VAACalcSadBgdFunc VAACalcSadBgd_mmi; 138 VAACalcSadSsdBgdFunc VAACalcSadSsdBgd_mmi; 139 VAACalcSadFunc VAACalcSad_mmi; 140 VAACalcSadVarFunc VAACalcSadVar_mmi; 141 VAACalcSadSsdFunc VAACalcSadSsd_mmi; 142 WELSVP_EXTERN_C_END 143 #endif 144 145 #ifdef HAVE_LSX 146 WELSVP_EXTERN_C_BEGIN 147 VAACalcSadBgdFunc VAACalcSadBgd_lsx; 148 VAACalcSadFunc VAACalcSad_lsx; 149 WELSVP_EXTERN_C_END 150 #endif 151 152 #ifdef HAVE_LASX 153 WELSVP_EXTERN_C_BEGIN 154 VAACalcSadBgdFunc VAACalcSadBgd_lasx; 155 WELSVP_EXTERN_C_END 156 #endif 157 158 class CVAACalculation : public IStrategy { 159 public: 160 CVAACalculation (int32_t iCpuFlag); 161 ~CVAACalculation(); 162 163 EResult Process (int32_t iType, SPixMap* pCurPixMap, SPixMap* pRefPixMap); 164 EResult Set (int32_t iType, void* pParam); 165 166 private: 167 void InitVaaFuncs (SVaaFuncs& sVaaFunc, int32_t iCpuFlag); 168 169 private: 170 SVaaFuncs m_sVaaFuncs; 171 int32_t m_iCPUFlag; 172 SVAACalcParam m_sCalcParam; 173 }; 174 175 WELSVP_NAMESPACE_END 176 177 #endif 178