Showing the changes to codec/decoder/core/src/mc.cpp (1 of 308 files). Show all
Unified · Split
| @@ -0,0 +1,757 @@ | ||
| 1 | +/*! | |
| 2 | + * \copy | |
| 3 | + * Copyright (c) 2009-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 | + * | |
| 32 | + * \file mc.c | |
| 33 | + * | |
| 34 | + * \brief Interfaces implementation for motion compensation | |
| 35 | + * | |
| 36 | + * \date 03/17/2009 Created | |
| 37 | + * | |
| 38 | + ************************************************************************************* | |
| 39 | + */ | |
| 40 | + | |
| 41 | +#include "as264_common.h" | |
| 42 | +#include "mc.h" | |
| 43 | + | |
| 44 | +#include "cpu_core.h" | |
| 45 | + | |
| 46 | +namespace WelsDec { | |
| 47 | + | |
| 48 | +/*------------------weight for chroma fraction pixel interpolation------------------*/ | |
| 49 | +//iA = (8 - dx) * (8 - dy); | |
| 50 | +//iB = dx * (8 - dy); | |
| 51 | +//iC = (8 - dx) * dy; | |
| 52 | +//iD = dx * dy | |
| 53 | +static const uint8_t g_kuiABCD[8][8][4] = //g_kA[dy][dx], g_kB[dy][dx], g_kC[dy][dx], g_kD[dy][dx] | |
| 54 | +{ | |
| 55 | + { | |
| 56 | + {64, 0, 0, 0},{56, 8, 0, 0},{48, 16, 0, 0},{40, 24, 0, 0}, | |
| 57 | + {32, 32, 0, 0},{24, 40, 0, 0},{16, 48, 0, 0},{8, 56, 0, 0} | |
| 58 | + }, | |
| 59 | + { | |
| 60 | + {56, 0, 8, 0},{49, 7, 7, 1},{42, 14, 6, 2},{35, 21, 5, 3}, | |
| 61 | + {28, 28, 4, 4},{21, 35, 3, 5},{14, 42, 2, 6},{7, 49, 1, 7} | |
| 62 | + }, | |
| 63 | + { | |
| 64 | + {48, 0, 16, 0},{42, 6, 14, 2},{36, 12, 12, 4},{30, 18, 10, 6}, | |
| 65 | + {24, 24, 8, 8},{18, 30, 6, 10},{12, 36, 4, 12},{6, 42, 2, 14} | |
| 66 | + }, | |
| 67 | + { | |
| 68 | + {40, 0, 24, 0},{35, 5, 21, 3},{30, 10, 18, 6},{25, 15, 15, 9}, | |
| 69 | + {20, 20, 12, 12},{15, 25, 9, 15},{10, 30, 6, 18},{5, 35, 3, 21} | |
| 70 | + }, | |
| 71 | + { | |
| 72 | + {32, 0, 32, 0},{28, 4, 28, 4},{24, 8, 24, 8},{20, 12, 20, 12}, | |
| 73 | + {16, 16, 16, 16},{12, 20, 12, 20},{8, 24, 8, 24},{4, 28, 4, 28} | |
| 74 | + }, | |
| 75 | + { | |
| 76 | + {24, 0, 40, 0},{21, 3, 35, 5},{18, 6, 30, 10},{15, 9, 25, 15}, | |
| 77 | + {12, 12, 20, 20},{9, 15, 15, 25},{6, 18, 10, 30},{3, 21, 5, 35} | |
| 78 | + }, | |
| 79 | + { | |
| 80 | + {16, 0, 48, 0},{14, 2, 42, 6},{12, 4, 36, 12},{10, 6, 30, 18}, | |
| 81 | + {8, 8, 24, 24},{6, 10, 18, 30},{4, 12, 12, 36},{2, 14, 6, 42} | |
| 82 | + }, | |
| 83 | + { | |
| 84 | + {8, 0, 56, 0},{7, 1, 49, 7},{6, 2, 42, 14},{5, 3, 35, 21}, | |
| 85 | + {4, 4, 28, 28},{3, 5, 21, 35},{2, 6, 14, 42},{1, 7, 7, 49} | |
| 86 | + } | |
| 87 | +}; | |
| 88 | + | |
| 89 | +typedef void_t (*PWelsMcWidthHeightFunc)(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight); | |
| 90 | + | |
| 91 | +//***************************************************************************// | |
| 92 | +// C code implementation // | |
| 93 | +//***************************************************************************// | |
| 94 | +static inline void_t McCopyWidthEq2_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight) | |
| 95 | +{ | |
| 96 | + int32_t i; | |
| 97 | + for (i = 0; i < iHeight; i++)// iWidth == 2 only for chroma | |
| 98 | + { | |
| 99 | + ST16(pDst, LD16(pSrc)); | |
| 100 | + pDst += iDstStride; | |
| 101 | + pSrc += iSrcStride; | |
| 102 | + } | |
| 103 | +} | |
| 104 | + | |
| 105 | +static inline void_t McCopyWidthEq4_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight) | |
| 106 | +{ | |
| 107 | + int32_t i; | |
| 108 | + for (i = 0; i < iHeight; i++) | |
| 109 | + { | |
| 110 | + ST32(pDst, LD32(pSrc)); | |
| 111 | + pDst += iDstStride; | |
| 112 | + pSrc += iSrcStride; | |
| 113 | + } | |
| 114 | +} | |
| 115 | + | |
| 116 | +static inline void_t McCopyWidthEq8_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight) | |
| 117 | +{ | |
| 118 | + int32_t i; | |
| 119 | + for (i = 0; i < iHeight; i++) | |
| 120 | + { | |
| 121 | + ST64(pDst, LD64(pSrc)); | |
| 122 | + pDst += iDstStride; | |
| 123 | + pSrc += iSrcStride; | |
| 124 | + } | |
| 125 | +} | |
| 126 | + | |
| 127 | +static inline void_t McCopyWidthEq16_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iHeight) | |
| 128 | +{ | |
| 129 | + int32_t i; | |
| 130 | + for (i = 0; i < iHeight; i++) | |
| 131 | + { | |
| 132 | + ST64(pDst , LD64(pSrc)); | |
| 133 | + ST64(pDst+8, LD64(pSrc+8)); | |
| 134 | + pDst += iDstStride; | |
| 135 | + pSrc += iSrcStride; | |
| 136 | + } | |
| 137 | +} | |
| 138 | + | |
| 139 | +//--------------------Luma sample MC------------------// | |
| 140 | + | |
| 141 | +static inline int32_t HorFilterInput16bit_c(int16_t* pSrc) | |
| 142 | +{ | |
| 143 | + int32_t iPix05 = pSrc[-2] + pSrc[3]; | |
| 144 | + int32_t iPix14 = pSrc[-1] + pSrc[2]; | |
| 145 | + int32_t iPix23 = pSrc[ 0] + pSrc[1]; | |
| 146 | + | |
| 147 | + return (iPix05 - ((iPix14<<2)+iPix14) + (iPix23<<4) + (iPix23<<2)); | |
| 148 | +} | |
| 149 | +// h: iOffset=1 / v: iOffset=iSrcStride | |
| 150 | +static inline int32_t FilterInput8bitWithStride_c(uint8_t* pSrc, const int32_t kiOffset) | |
| 151 | +{ | |
| 152 | + const int32_t kiOffset1 = kiOffset; | |
| 153 | + const int32_t kiOffset2 = (kiOffset << 1); | |
| 154 | + const int32_t kiOffset3 = kiOffset + kiOffset2; | |
| 155 | + const uint32_t kuiPix05 = *(pSrc - kiOffset2) + *(pSrc + kiOffset3); | |
| 156 | + const uint32_t kuiPix14 = *(pSrc - kiOffset1) + *(pSrc + kiOffset2); | |
| 157 | + const uint32_t kuiPix23 = *(pSrc ) + *(pSrc + kiOffset1); | |
| 158 | + | |
| 159 | + return (kuiPix05 - ((kuiPix14<<2)+kuiPix14) + (kuiPix23<<4) + (kuiPix23<<2)); | |
| 160 | +} | |
| 161 | + | |
| 162 | +static inline void_t PixelAvg_c(uint8_t* pDst, int32_t iDstStride, uint8_t* pSrcA, int32_t iSrcAStride, | |
| 163 | + uint8_t* pSrcB, int32_t iSrcBStride, int32_t iWidth, int32_t iHeight) | |
| 164 | +{ | |
| 165 | + int32_t i, j; | |
| 166 | + for (i = 0; i < iHeight; i++) | |
| 167 | + { | |
| 168 | + for (j = 0; j < iWidth; j++) | |
| 169 | + { | |
| 170 | + pDst[j] = (pSrcA[j] + pSrcB[j] + 1) >> 1; | |
| 171 | + } | |
| 172 | + pDst += iDstStride; | |
| 173 | + pSrcA += iSrcAStride; | |
| 174 | + pSrcB += iSrcBStride; | |
| 175 | + } | |
| 176 | +} | |
| 177 | +static inline void_t McCopy_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 178 | +{ | |
| 179 | + if (iWidth == 16) | |
| 180 | + McCopyWidthEq16_c(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 181 | + else if(iWidth == 8) | |
| 182 | + McCopyWidthEq8_c(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 183 | + else if(iWidth == 4) | |
| 184 | + McCopyWidthEq4_c(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 185 | + else //here iWidth == 2 | |
| 186 | + McCopyWidthEq2_c(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 187 | +} | |
| 188 | + | |
| 189 | +static inline void_t McHorVer20_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 190 | +{ | |
| 191 | + int32_t i, j; | |
| 192 | + for (i = 0; i < iHeight; i++) | |
| 193 | + { | |
| 194 | + for (j = 0; j < iWidth; j++) | |
| 195 | + { | |
| 196 | + pDst[j] = WELS_CLIP1((FilterInput8bitWithStride_c(pSrc+j,1)+16)>>5); | |
| 197 | + } | |
| 198 | + pDst += iDstStride; | |
| 199 | + pSrc += iSrcStride; | |
| 200 | + } | |
| 201 | +} | |
| 202 | + | |
| 203 | +static inline void_t McHorVer02_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 204 | +{ | |
| 205 | + int32_t i, j; | |
| 206 | + for (i = 0; i < iHeight; i++) | |
| 207 | + { | |
| 208 | + for (j = 0; j < iWidth; j++) | |
| 209 | + { | |
| 210 | + pDst[j] = WELS_CLIP1((FilterInput8bitWithStride_c(pSrc+j, iSrcStride)+16)>>5); | |
| 211 | + } | |
| 212 | + pDst += iDstStride; | |
| 213 | + pSrc += iSrcStride; | |
| 214 | + } | |
| 215 | +} | |
| 216 | + | |
| 217 | +static inline void_t McHorVer22_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 218 | +{ | |
| 219 | + int16_t iTmp[16+5] = {0}; //16 | |
| 220 | + int32_t i, j, k; | |
| 221 | + | |
| 222 | + for (i = 0; i < iHeight; i++) | |
| 223 | + { | |
| 224 | + for (j = 0; j < iWidth + 5; j++) | |
| 225 | + { | |
| 226 | + iTmp[j] = FilterInput8bitWithStride_c(pSrc-2+j, iSrcStride); | |
| 227 | + } | |
| 228 | + for (k = 0; k < iWidth; k++) | |
| 229 | + { | |
| 230 | + pDst[k] = WELS_CLIP1((HorFilterInput16bit_c(&iTmp[2+k])+512)>>10); | |
| 231 | + } | |
| 232 | + pSrc += iSrcStride; | |
| 233 | + pDst += iDstStride; | |
| 234 | + } | |
| 235 | +} | |
| 236 | + | |
| 237 | +/////////////////////luma MC////////////////////////// | |
| 238 | +static inline void_t McHorVer01_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 239 | +{ | |
| 240 | + uint8_t uiTmp[256] = { 0 }; | |
| 241 | + McHorVer02_c(pSrc, iSrcStride, uiTmp, 16, iWidth, iHeight); | |
| 242 | + PixelAvg_c(pDst, iDstStride, pSrc, iSrcStride, uiTmp, 16, iWidth, iHeight); | |
| 243 | +} | |
| 244 | +static inline void_t McHorVer03_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 245 | +{ | |
| 246 | + uint8_t uiTmp[256] = { 0 }; | |
| 247 | + McHorVer02_c(pSrc, iSrcStride, uiTmp, 16, iWidth, iHeight); | |
| 248 | + PixelAvg_c(pDst, iDstStride, pSrc+iSrcStride, iSrcStride, uiTmp, 16, iWidth, iHeight); | |
| 249 | +} | |
| 250 | +static inline void_t McHorVer10_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 251 | +{ | |
| 252 | + uint8_t uiTmp[256] = { 0 }; | |
| 253 | + McHorVer20_c(pSrc, iSrcStride, uiTmp, 16, iWidth, iHeight); | |
| 254 | + PixelAvg_c(pDst, iDstStride, pSrc, iSrcStride, uiTmp, 16,iWidth, iHeight); | |
| 255 | +} | |
| 256 | +static inline void_t McHorVer11_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 257 | +{ | |
| 258 | + uint8_t uiHorTmp[256] = { 0 }; | |
| 259 | + uint8_t uiVerTmp[256] = { 0 }; | |
| 260 | + McHorVer20_c(pSrc, iSrcStride, uiHorTmp, 16, iWidth, iHeight); | |
| 261 | + McHorVer02_c(pSrc, iSrcStride, uiVerTmp, 16, iWidth, iHeight); | |
| 262 | + PixelAvg_c(pDst, iDstStride, uiHorTmp, 16, uiVerTmp, 16, iWidth, iHeight); | |
| 263 | +} | |
| 264 | +static inline void_t McHorVer12_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 265 | +{ | |
| 266 | + uint8_t uiVerTmp[256] = { 0 }; | |
| 267 | + uint8_t uiCtrTmp[256] = { 0 }; | |
| 268 | + McHorVer02_c(pSrc, iSrcStride, uiVerTmp, 16, iWidth, iHeight); | |
| 269 | + McHorVer22_c(pSrc, iSrcStride, uiCtrTmp, 16, iWidth, iHeight); | |
| 270 | + PixelAvg_c(pDst, iDstStride, uiVerTmp, 16, uiCtrTmp, 16, iWidth, iHeight); | |
| 271 | +} | |
| 272 | +static inline void_t McHorVer13_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 273 | +{ | |
| 274 | + uint8_t uiHorTmp[256] = { 0 }; | |
| 275 | + uint8_t uiVerTmp[256] = { 0 }; | |
| 276 | + McHorVer20_c(pSrc+iSrcStride, iSrcStride, uiHorTmp, 16, iWidth, iHeight); | |
| 277 | + McHorVer02_c(pSrc, iSrcStride, uiVerTmp, 16, iWidth, iHeight); | |
| 278 | + PixelAvg_c(pDst, iDstStride, uiHorTmp, 16, uiVerTmp, 16, iWidth, iHeight); | |
| 279 | +} | |
| 280 | +static inline void_t McHorVer21_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 281 | +{ | |
| 282 | + uint8_t uiHorTmp[256] = { 0 }; | |
| 283 | + uint8_t uiCtrTmp[256] = { 0 }; | |
| 284 | + McHorVer20_c(pSrc, iSrcStride, uiHorTmp, 16, iWidth, iHeight); | |
| 285 | + McHorVer22_c(pSrc, iSrcStride, uiCtrTmp, 16, iWidth, iHeight); | |
| 286 | + PixelAvg_c(pDst, iDstStride, uiHorTmp, 16, uiCtrTmp, 16, iWidth, iHeight); | |
| 287 | +} | |
| 288 | +static inline void_t McHorVer23_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 289 | +{ | |
| 290 | + uint8_t uiHorTmp[256] = { 0 }; | |
| 291 | + uint8_t uiCtrTmp[256] = { 0 }; | |
| 292 | + McHorVer20_c(pSrc+iSrcStride, iSrcStride, uiHorTmp, 16, iWidth, iHeight); | |
| 293 | + McHorVer22_c(pSrc, iSrcStride, uiCtrTmp, 16, iWidth, iHeight); | |
| 294 | + PixelAvg_c(pDst, iDstStride, uiHorTmp, 16, uiCtrTmp, 16, iWidth, iHeight); | |
| 295 | +} | |
| 296 | +static inline void_t McHorVer30_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 297 | +{ | |
| 298 | + uint8_t uiHorTmp[256] = { 0 }; | |
| 299 | + McHorVer20_c(pSrc, iSrcStride, uiHorTmp, 16, iWidth, iHeight); | |
| 300 | + PixelAvg_c(pDst, iDstStride, pSrc+1, iSrcStride, uiHorTmp, 16, iWidth, iHeight); | |
| 301 | +} | |
| 302 | +static inline void_t McHorVer31_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 303 | +{ | |
| 304 | + uint8_t uiHorTmp[256] = { 0 }; | |
| 305 | + uint8_t uiVerTmp[256] = { 0 }; | |
| 306 | + McHorVer20_c(pSrc, iSrcStride, uiHorTmp, 16, iWidth, iHeight); | |
| 307 | + McHorVer02_c(pSrc+1, iSrcStride, uiVerTmp, 16, iWidth, iHeight); | |
| 308 | + PixelAvg_c(pDst, iDstStride, uiHorTmp, 16, uiVerTmp, 16, iWidth, iHeight); | |
| 309 | +} | |
| 310 | +static inline void_t McHorVer32_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 311 | +{ | |
| 312 | + uint8_t uiVerTmp[256] = { 0 }; | |
| 313 | + uint8_t uiCtrTmp[256] = { 0 }; | |
| 314 | + McHorVer02_c(pSrc+1, iSrcStride, uiVerTmp, 16, iWidth, iHeight); | |
| 315 | + McHorVer22_c(pSrc, iSrcStride, uiCtrTmp, 16, iWidth, iHeight); | |
| 316 | + PixelAvg_c(pDst, iDstStride, uiVerTmp, 16, uiCtrTmp, 16, iWidth, iHeight); | |
| 317 | +} | |
| 318 | +static inline void_t McHorVer33_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 319 | +{ | |
| 320 | + uint8_t uiHorTmp[256] = { 0 }; | |
| 321 | + uint8_t uiVerTmp[256] = { 0 }; | |
| 322 | + McHorVer20_c(pSrc+iSrcStride, iSrcStride, uiHorTmp, 16, iWidth, iHeight); | |
| 323 | + McHorVer02_c(pSrc+1, iSrcStride, uiVerTmp, 16, iWidth, iHeight); | |
| 324 | + PixelAvg_c(pDst, iDstStride, uiHorTmp, 16, uiVerTmp, 16, iWidth, iHeight); | |
| 325 | +} | |
| 326 | + | |
| 327 | +void_t McLuma_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, | |
| 328 | + int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight) | |
| 329 | + //pSrc has been added the offset of mv | |
| 330 | +{ | |
| 331 | + PWelsMcWidthHeightFunc pWelsMcFunc[4][4] = //[x][y] | |
| 332 | + { | |
| 333 | + {McCopy_c, McHorVer01_c, McHorVer02_c, McHorVer03_c}, | |
| 334 | + {McHorVer10_c, McHorVer11_c, McHorVer12_c, McHorVer13_c}, | |
| 335 | + {McHorVer20_c, McHorVer21_c, McHorVer22_c, McHorVer23_c}, | |
| 336 | + {McHorVer30_c, McHorVer31_c, McHorVer32_c, McHorVer33_c}, | |
| 337 | + }; | |
| 338 | + | |
| 339 | + pWelsMcFunc[iMvX&0x03][iMvY&0x03](pSrc, iSrcStride, pDst, iDstStride, iWidth, iHeight); | |
| 340 | +} | |
| 341 | + | |
| 342 | +static inline void_t McChromaWithFragMv_c( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight ) | |
| 343 | +{ | |
| 344 | + int32_t i, j; | |
| 345 | + int32_t iA, iB, iC, iD; | |
| 346 | + uint8_t* pSrcNext = pSrc + iSrcStride; | |
| 347 | + const uint32_t kuiABCD = *((uint32_t *)g_kuiABCD[iMvY&0x07][iMvX&0x07]); | |
| 348 | + iA = (kuiABCD ) & 0xff; | |
| 349 | + iB = (kuiABCD >> 8) & 0xff; | |
| 350 | + iC = (kuiABCD >> 16) & 0xff; | |
| 351 | + iD = (kuiABCD >> 24) & 0xff; | |
| 352 | + for (i = 0; i < iHeight; i++) | |
| 353 | + { | |
| 354 | + for (j = 0; j < iWidth; j++) | |
| 355 | + { | |
| 356 | + pDst[j] = (iA * pSrc[j] + iB * pSrc[j+1] + iC * pSrcNext[j] + iD * pSrcNext[j+1] + 32) >> 6; | |
| 357 | + } | |
| 358 | + pDst += iDstStride; | |
| 359 | + pSrc = pSrcNext; | |
| 360 | + pSrcNext += iSrcStride; | |
| 361 | + } | |
| 362 | +} | |
| 363 | + | |
| 364 | +void_t McChroma_c(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, | |
| 365 | + int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight) | |
| 366 | + //pSrc has been added the offset of mv | |
| 367 | +{ | |
| 368 | + const int32_t kiD8x = iMvX&0x07; | |
| 369 | + const int32_t kiD8y = iMvY&0x07; | |
| 370 | + if (0 == kiD8x && 0 == kiD8y) | |
| 371 | + McCopy_c(pSrc, iSrcStride, pDst, iDstStride, iWidth, iHeight); | |
| 372 | + else | |
| 373 | + McChromaWithFragMv_c(pSrc, iSrcStride, pDst, iDstStride, iMvX, iMvY, iWidth, iHeight); | |
| 374 | +} | |
| 375 | + | |
| 376 | +#if defined(X86_ASM) | |
| 377 | +//***************************************************************************// | |
| 378 | +// SSE2 implement // | |
| 379 | +//***************************************************************************// | |
| 380 | +static inline void_t McHorVer22WidthEq8_sse2( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight ) | |
| 381 | +{ | |
| 382 | + ENFORCE_STACK_ALIGN_2D(int16_t, iTap, 21, 8, 16) | |
| 383 | + McHorVer22Width8HorFirst_sse2(pSrc-2, iSrcStride, (uint8_t *)iTap,16,iHeight+5); | |
| 384 | + McHorVer22VerLast_sse2((uint8_t *)iTap,16, pDst, iDstStride, 8, iHeight); | |
| 385 | +} | |
| 386 | + | |
| 387 | +static inline void_t McHorVer02WidthEq16_sse2( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight ) | |
| 388 | +{ | |
| 389 | + McHorVer02WidthEq8_sse2( pSrc, iSrcStride, pDst, iDstStride, iHeight ); | |
| 390 | + McHorVer02WidthEq8_sse2( &pSrc[8], iSrcStride, &pDst[8], iDstStride, iHeight ); | |
| 391 | +} | |
| 392 | + | |
| 393 | +static inline void_t McHorVer22WidthEq16_sse2( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, int32_t iHeight ) | |
| 394 | +{ | |
| 395 | + McHorVer22WidthEq8_sse2( pSrc, iSrcStride, pDst, iDstStride, iHeight ); | |
| 396 | + McHorVer22WidthEq8_sse2( &pSrc[8], iSrcStride, &pDst[8], iDstStride, iHeight ); | |
| 397 | +} | |
| 398 | + | |
| 399 | +static inline void_t McCopy_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 400 | +{ | |
| 401 | + if (iWidth == 16) | |
| 402 | + McCopyWidthEq16_sse2(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 403 | + else if(iWidth == 8) | |
| 404 | + McCopyWidthEq8_mmx(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 405 | + else if(iWidth ==4) | |
| 406 | + McCopyWidthEq4_mmx(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 407 | + else | |
| 408 | + McCopyWidthEq2_c(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 409 | +} | |
| 410 | + | |
| 411 | +static inline void_t McHorVer20_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 412 | +{ | |
| 413 | + if (iWidth == 16) | |
| 414 | + McHorVer20WidthEq16_sse2(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 415 | + else if(iWidth == 8) | |
| 416 | + McHorVer20WidthEq8_sse2(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 417 | + else | |
| 418 | + McHorVer20WidthEq4_mmx(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 419 | +} | |
| 420 | + | |
| 421 | +static inline void_t McHorVer02_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 422 | +{ | |
| 423 | + if (iWidth == 16) | |
| 424 | + McHorVer02WidthEq16_sse2(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 425 | + else if(iWidth == 8) | |
| 426 | + McHorVer02WidthEq8_sse2(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 427 | + else | |
| 428 | + McHorVer02_c(pSrc,iSrcStride,pDst,iDstStride, 4, iHeight); | |
| 429 | +} | |
| 430 | + | |
| 431 | +static inline void_t McHorVer22_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 432 | +{ | |
| 433 | + if (iWidth == 16) | |
| 434 | + McHorVer22WidthEq16_sse2(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 435 | + else if(iWidth == 8) | |
| 436 | + McHorVer22WidthEq8_sse2(pSrc,iSrcStride,pDst,iDstStride,iHeight); | |
| 437 | + else | |
| 438 | + McHorVer22_c(pSrc,iSrcStride,pDst,iDstStride,4, iHeight); | |
| 439 | +} | |
| 440 | + | |
| 441 | +static inline void_t McHorVer01_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 442 | +{ | |
| 443 | + FORCE_STACK_ALIGN_1D( uint8_t, pTmp, 256, 16 ); | |
| 444 | + if (iWidth == 16) | |
| 445 | + { | |
| 446 | + McHorVer02WidthEq16_sse2(pSrc, iSrcStride, pTmp, 16, iHeight); | |
| 447 | + PixelAvgWidthEq16_sse2(pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight); | |
| 448 | + } | |
| 449 | + else if(iWidth == 8) | |
| 450 | + { | |
| 451 | + McHorVer02WidthEq8_sse2(pSrc, iSrcStride, pTmp, 16, iHeight); | |
| 452 | + PixelAvgWidthEq8_mmx(pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight); | |
| 453 | + } | |
| 454 | + else | |
| 455 | + { | |
| 456 | + McHorVer02_c(pSrc, iSrcStride, pTmp, 16, 4, iHeight); | |
| 457 | + PixelAvgWidthEq4_mmx(pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight); | |
| 458 | + } | |
| 459 | +} | |
| 460 | +static inline void_t McHorVer03_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 461 | +{ | |
| 462 | + FORCE_STACK_ALIGN_1D( uint8_t, pTmp, 256, 16 ); | |
| 463 | + if (iWidth == 16) | |
| 464 | + { | |
| 465 | + McHorVer02WidthEq16_sse2(pSrc, iSrcStride, pTmp, 16, iHeight); | |
| 466 | + PixelAvgWidthEq16_sse2(pDst, iDstStride, pSrc+iSrcStride, iSrcStride, pTmp, 16, iHeight); | |
| 467 | + } | |
| 468 | + else if(iWidth == 8) | |
| 469 | + { | |
| 470 | + McHorVer02WidthEq8_sse2(pSrc, iSrcStride, pTmp, 16, iHeight); | |
| 471 | + PixelAvgWidthEq8_mmx(pDst, iDstStride, pSrc+iSrcStride, iSrcStride, pTmp, 16, iHeight); | |
| 472 | + } | |
| 473 | + else | |
| 474 | + { | |
| 475 | + McHorVer02_c(pSrc, iSrcStride, pTmp, 16, 4, iHeight); | |
| 476 | + PixelAvgWidthEq4_mmx(pDst, iDstStride, pSrc+iSrcStride, iSrcStride, pTmp, 16, iHeight); | |
| 477 | + } | |
| 478 | +} | |
| 479 | +static inline void_t McHorVer10_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 480 | +{ | |
| 481 | + FORCE_STACK_ALIGN_1D( uint8_t, pTmp, 256, 16 ); | |
| 482 | + if (iWidth == 16) | |
| 483 | + { | |
| 484 | + McHorVer20WidthEq16_sse2(pSrc, iSrcStride, pTmp, 16, iHeight); | |
| 485 | + PixelAvgWidthEq16_sse2(pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight); | |
| 486 | + } | |
| 487 | + else if(iWidth == 8) | |
| 488 | + { | |
| 489 | + McHorVer20WidthEq8_sse2(pSrc, iSrcStride, pTmp, 16, iHeight); | |
| 490 | + PixelAvgWidthEq8_mmx(pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight); | |
| 491 | + } | |
| 492 | + else | |
| 493 | + { | |
| 494 | + McHorVer20WidthEq4_mmx(pSrc, iSrcStride, pTmp, 16, iHeight); | |
| 495 | + PixelAvgWidthEq4_mmx(pDst, iDstStride, pSrc, iSrcStride, pTmp, 16, iHeight); | |
| 496 | + } | |
| 497 | +} | |
| 498 | +static inline void_t McHorVer11_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 499 | +{ | |
| 500 | + FORCE_STACK_ALIGN_1D( uint8_t, pHorTmp, 256, 16 ); | |
| 501 | + FORCE_STACK_ALIGN_1D( uint8_t, pVerTmp, 256, 16 ); | |
| 502 | + if (iWidth == 16) | |
| 503 | + { | |
| 504 | + McHorVer20WidthEq16_sse2(pSrc, iSrcStride, pHorTmp, 16, iHeight); | |
| 505 | + McHorVer02WidthEq16_sse2(pSrc, iSrcStride, pVerTmp, 16, iHeight); | |
| 506 | + PixelAvgWidthEq16_sse2 (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight); | |
| 507 | + } | |
| 508 | + else if(iWidth == 8) | |
| 509 | + { | |
| 510 | + McHorVer20WidthEq8_sse2(pSrc, iSrcStride, pHorTmp, 16, iHeight); | |
| 511 | + McHorVer02WidthEq8_sse2(pSrc, iSrcStride, pVerTmp, 16, iHeight); | |
| 512 | + PixelAvgWidthEq8_mmx(pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight); | |
| 513 | + } | |
| 514 | + else | |
| 515 | + { | |
| 516 | + McHorVer20WidthEq4_mmx(pSrc, iSrcStride, pHorTmp, 16, iHeight); | |
| 517 | + McHorVer02_c (pSrc, iSrcStride, pVerTmp, 16, 4, iHeight); | |
| 518 | + PixelAvgWidthEq4_mmx (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight); | |
| 519 | + } | |
| 520 | +} | |
| 521 | +static inline void_t McHorVer12_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 522 | +{ | |
| 523 | + FORCE_STACK_ALIGN_1D( uint8_t, pVerTmp, 256, 16 ); | |
| 524 | + FORCE_STACK_ALIGN_1D( uint8_t, pCtrTmp, 256, 16 ); | |
| 525 | + if (iWidth == 16) | |
| 526 | + { | |
| 527 | + McHorVer02WidthEq16_sse2(pSrc, iSrcStride, pVerTmp, 16, iHeight); | |
| 528 | + McHorVer22WidthEq16_sse2(pSrc, iSrcStride, pCtrTmp, 16, iHeight); | |
| 529 | + PixelAvgWidthEq16_sse2 (pDst, iDstStride, pVerTmp, 16, pCtrTmp, 16, iHeight); | |
| 530 | + } | |
| 531 | + else if(iWidth == 8) | |
| 532 | + { | |
| 533 | + McHorVer02WidthEq8_sse2(pSrc, iSrcStride, pVerTmp, 16, iHeight); | |
| 534 | + McHorVer22WidthEq8_sse2(pSrc, iSrcStride, pCtrTmp, 16, iHeight); | |
| 535 | + PixelAvgWidthEq8_mmx(pDst, iDstStride, pVerTmp, 16, pCtrTmp, 16, iHeight); | |
| 536 | + } | |
| 537 | + else | |
| 538 | + { | |
| 539 | + McHorVer02_c (pSrc, iSrcStride, pVerTmp, 16, 4, iHeight); | |
| 540 | + McHorVer22_c (pSrc, iSrcStride, pCtrTmp, 16, 4, iHeight); | |
| 541 | + PixelAvgWidthEq4_mmx(pDst, iDstStride, pVerTmp, 16, pCtrTmp, 16, iHeight); | |
| 542 | + } | |
| 543 | +} | |
| 544 | +static inline void_t McHorVer13_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 545 | +{ | |
| 546 | + FORCE_STACK_ALIGN_1D( uint8_t, pHorTmp, 256, 16 ); | |
| 547 | + FORCE_STACK_ALIGN_1D( uint8_t, pVerTmp, 256, 16 ); | |
| 548 | + if (iWidth ==16) | |
| 549 | + { | |
| 550 | + McHorVer20WidthEq16_sse2(pSrc+iSrcStride, iSrcStride, pHorTmp, 16, iHeight); | |
| 551 | + McHorVer02WidthEq16_sse2(pSrc, iSrcStride, pVerTmp, 16, iHeight); | |
| 552 | + PixelAvgWidthEq16_sse2 (pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight); | |
| 553 | + } | |
| 554 | + else if(iWidth == 8) | |
| 555 | + { | |
| 556 | + McHorVer20WidthEq8_sse2(pSrc+iSrcStride, iSrcStride, pHorTmp, 16, iHeight); | |
| 557 | + McHorVer02WidthEq8_sse2(pSrc, iSrcStride, pVerTmp, 16, iHeight); | |
| 558 | + PixelAvgWidthEq8_mmx(pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight); | |
| 559 | + } | |
| 560 | + else | |
| 561 | + { | |
| 562 | + McHorVer20WidthEq4_mmx(pSrc+iSrcStride, iSrcStride, pHorTmp, 16, iHeight); | |
| 563 | + McHorVer02_c (pSrc, iSrcStride, pVerTmp, 16, 4 ,iHeight); | |
| 564 | + PixelAvgWidthEq4_mmx(pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight); | |
| 565 | + } | |
| 566 | +} | |
| 567 | +static inline void_t McHorVer21_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 568 | +{ | |
| 569 | + FORCE_STACK_ALIGN_1D( uint8_t, pHorTmp, 256, 16 ); | |
| 570 | + FORCE_STACK_ALIGN_1D( uint8_t, pCtrTmp, 256, 16 ); | |
| 571 | + if (iWidth == 16) | |
| 572 | + { | |
| 573 | + McHorVer20WidthEq16_sse2(pSrc, iSrcStride, pHorTmp, 16, iHeight); | |
| 574 | + McHorVer22WidthEq16_sse2(pSrc, iSrcStride, pCtrTmp, 16, iHeight); | |
| 575 | + PixelAvgWidthEq16_sse2(pDst, iDstStride, pHorTmp, 16, pCtrTmp, 16, iHeight); | |
| 576 | + } | |
| 577 | + else if(iWidth == 8) | |
| 578 | + { | |
| 579 | + McHorVer20WidthEq8_sse2(pSrc, iSrcStride, pHorTmp, 16, iHeight); | |
| 580 | + McHorVer22WidthEq8_sse2(pSrc, iSrcStride, pCtrTmp, 16, iHeight); | |
| 581 | + PixelAvgWidthEq8_mmx(pDst, iDstStride, pHorTmp, 16, pCtrTmp, 16, iHeight); | |
| 582 | + } | |
| 583 | + else | |
| 584 | + { | |
| 585 | + McHorVer20WidthEq4_mmx(pSrc, iSrcStride, pHorTmp, 16, iHeight); | |
| 586 | + McHorVer22_c (pSrc, iSrcStride, pCtrTmp, 16, 4, iHeight); | |
| 587 | + PixelAvgWidthEq4_mmx(pDst, iDstStride, pHorTmp, 16, pCtrTmp, 16, iHeight); | |
| 588 | + } | |
| 589 | +} | |
| 590 | +static inline void_t McHorVer23_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 591 | +{ | |
| 592 | + FORCE_STACK_ALIGN_1D( uint8_t, pHorTmp, 256, 16 ); | |
| 593 | + FORCE_STACK_ALIGN_1D( uint8_t, pCtrTmp, 256, 16 ); | |
| 594 | + if (iWidth == 16) | |
| 595 | + { | |
| 596 | + McHorVer20WidthEq16_sse2(pSrc+iSrcStride, iSrcStride, pHorTmp, 16, iHeight); | |
| 597 | + McHorVer22WidthEq16_sse2(pSrc, iSrcStride, pCtrTmp, 16, iHeight); | |
| 598 | + PixelAvgWidthEq16_sse2(pDst, iDstStride, pHorTmp, 16, pCtrTmp, 16, iHeight); | |
| 599 | + } | |
| 600 | + else if(iWidth == 8) | |
| 601 | + { | |
| 602 | + McHorVer20WidthEq8_sse2(pSrc+iSrcStride, iSrcStride, pHorTmp, 16, iHeight); | |
| 603 | + McHorVer22WidthEq8_sse2(pSrc, iSrcStride, pCtrTmp, 16, iHeight); | |
| 604 | + PixelAvgWidthEq8_mmx(pDst, iDstStride, pHorTmp, 16, pCtrTmp, 16, iHeight); | |
| 605 | + } | |
| 606 | + else | |
| 607 | + { | |
| 608 | + McHorVer20WidthEq4_mmx(pSrc+iSrcStride, iSrcStride, pHorTmp, 16, iHeight); | |
| 609 | + McHorVer22_c (pSrc, iSrcStride, pCtrTmp, 16, 4, iHeight); | |
| 610 | + PixelAvgWidthEq4_mmx(pDst, iDstStride, pHorTmp, 16, pCtrTmp, 16, iHeight); | |
| 611 | + } | |
| 612 | +} | |
| 613 | +static inline void_t McHorVer30_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 614 | +{ | |
| 615 | + FORCE_STACK_ALIGN_1D( uint8_t, pHorTmp, 256, 16 ); | |
| 616 | + if (iWidth == 16) | |
| 617 | + { | |
| 618 | + McHorVer20WidthEq16_sse2(pSrc, iSrcStride, pHorTmp, 16, iHeight); | |
| 619 | + PixelAvgWidthEq16_sse2(pDst, iDstStride, pSrc+1, iSrcStride, pHorTmp, 16, iHeight); | |
| 620 | + } | |
| 621 | + else if(iWidth == 8) | |
| 622 | + { | |
| 623 | + McHorVer20WidthEq8_sse2(pSrc, iSrcStride, pHorTmp, 16, iHeight); | |
| 624 | + PixelAvgWidthEq8_mmx(pDst, iDstStride, pSrc+1, iSrcStride, pHorTmp, 16, iHeight); | |
| 625 | + } | |
| 626 | + else | |
| 627 | + { | |
| 628 | + McHorVer20WidthEq4_mmx(pSrc, iSrcStride, pHorTmp, 16, iHeight); | |
| 629 | + PixelAvgWidthEq4_mmx(pDst, iDstStride, pSrc+1, iSrcStride, pHorTmp, 16, iHeight); | |
| 630 | + } | |
| 631 | +} | |
| 632 | +static inline void_t McHorVer31_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 633 | +{ | |
| 634 | + FORCE_STACK_ALIGN_1D( uint8_t, pHorTmp, 256, 16 ); | |
| 635 | + FORCE_STACK_ALIGN_1D( uint8_t, pVerTmp, 256, 16 ); | |
| 636 | + if (iWidth == 16) | |
| 637 | + { | |
| 638 | + McHorVer20WidthEq16_sse2(pSrc, iSrcStride, pHorTmp, 16, iHeight); | |
| 639 | + McHorVer02WidthEq16_sse2(pSrc+1, iSrcStride, pVerTmp, 16, iHeight); | |
| 640 | + PixelAvgWidthEq16_sse2(pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight); | |
| 641 | + } | |
| 642 | + else if(iWidth == 8) | |
| 643 | + { | |
| 644 | + McHorVer20WidthEq8_sse2(pSrc, iSrcStride, pHorTmp, 16, iHeight); | |
| 645 | + McHorVer02WidthEq8_sse2(pSrc+1, iSrcStride, pVerTmp, 16, iHeight); | |
| 646 | + PixelAvgWidthEq8_mmx(pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight); | |
| 647 | + } | |
| 648 | + else | |
| 649 | + { | |
| 650 | + McHorVer20WidthEq4_mmx(pSrc, iSrcStride, pHorTmp, 16, iHeight); | |
| 651 | + McHorVer02_c(pSrc+1, iSrcStride, pVerTmp, 16, 4, iHeight); | |
| 652 | + PixelAvgWidthEq4_mmx(pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight); | |
| 653 | + } | |
| 654 | +} | |
| 655 | +static inline void_t McHorVer32_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 656 | +{ | |
| 657 | + FORCE_STACK_ALIGN_1D( uint8_t, pVerTmp, 256, 16 ); | |
| 658 | + FORCE_STACK_ALIGN_1D( uint8_t, pCtrTmp, 256, 16 ); | |
| 659 | + if (iWidth ==16) | |
| 660 | + { | |
| 661 | + McHorVer02WidthEq16_sse2(pSrc+1, iSrcStride, pVerTmp, 16, iHeight); | |
| 662 | + McHorVer22WidthEq16_sse2(pSrc, iSrcStride, pCtrTmp, 16, iHeight); | |
| 663 | + PixelAvgWidthEq16_sse2(pDst, iDstStride, pVerTmp, 16, pCtrTmp, 16, iHeight); | |
| 664 | + } | |
| 665 | + else if(iWidth == 8) | |
| 666 | + { | |
| 667 | + McHorVer02WidthEq8_sse2(pSrc+1, iSrcStride, pVerTmp, 16, iHeight); | |
| 668 | + McHorVer22WidthEq8_sse2(pSrc, iSrcStride, pCtrTmp, 16, iHeight); | |
| 669 | + PixelAvgWidthEq8_mmx(pDst, iDstStride, pVerTmp, 16, pCtrTmp, 16, iHeight); | |
| 670 | + } | |
| 671 | + else | |
| 672 | + { | |
| 673 | + McHorVer02_c(pSrc+1, iSrcStride, pVerTmp, 16, 4, iHeight); | |
| 674 | + McHorVer22_c(pSrc, iSrcStride, pCtrTmp, 16, 4, iHeight); | |
| 675 | + PixelAvgWidthEq4_mmx(pDst, iDstStride, pVerTmp, 16, pCtrTmp, 16, iHeight); | |
| 676 | + } | |
| 677 | +} | |
| 678 | +static inline void_t McHorVer33_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth, int32_t iHeight) | |
| 679 | +{ | |
| 680 | + FORCE_STACK_ALIGN_1D( uint8_t, pHorTmp, 256, 16 ); | |
| 681 | + FORCE_STACK_ALIGN_1D( uint8_t, pVerTmp, 256, 16 ); | |
| 682 | + if (iWidth == 16) | |
| 683 | + { | |
| 684 | + McHorVer20WidthEq16_sse2(pSrc+iSrcStride, iSrcStride, pHorTmp, 16, iHeight); | |
| 685 | + McHorVer02WidthEq16_sse2(pSrc+1, iSrcStride, pVerTmp, 16, iHeight); | |
| 686 | + PixelAvgWidthEq16_sse2(pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight); | |
| 687 | + } | |
| 688 | + else if(iWidth == 8) | |
| 689 | + { | |
| 690 | + McHorVer20WidthEq8_sse2(pSrc+iSrcStride, iSrcStride, pHorTmp, 16, iHeight); | |
| 691 | + McHorVer02WidthEq8_sse2(pSrc+1, iSrcStride, pVerTmp, 16, iHeight); | |
| 692 | + PixelAvgWidthEq8_mmx(pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight); | |
| 693 | + } | |
| 694 | + else | |
| 695 | + { | |
| 696 | + McHorVer20WidthEq4_mmx(pSrc+iSrcStride, iSrcStride, pHorTmp, 16, iHeight); | |
| 697 | + McHorVer02_c (pSrc+1, iSrcStride, pVerTmp, 16, 4, iHeight); | |
| 698 | + PixelAvgWidthEq4_mmx(pDst, iDstStride, pHorTmp, 16, pVerTmp, 16, iHeight); | |
| 699 | + } | |
| 700 | +} | |
| 701 | + | |
| 702 | +void_t McLuma_sse2(uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, | |
| 703 | + int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight) | |
| 704 | + //pSrc has been added the offset of mv | |
| 705 | +{ | |
| 706 | + PWelsMcWidthHeightFunc pWelsMcFunc[4][4] = //[x][y] | |
| 707 | + { | |
| 708 | + {McCopy_sse2, McHorVer01_sse2, McHorVer02_sse2, McHorVer03_sse2}, | |
| 709 | + {McHorVer10_sse2, McHorVer11_sse2, McHorVer12_sse2, McHorVer13_sse2}, | |
| 710 | + {McHorVer20_sse2, McHorVer21_sse2, McHorVer22_sse2, McHorVer23_sse2}, | |
| 711 | + {McHorVer30_sse2, McHorVer31_sse2, McHorVer32_sse2, McHorVer33_sse2}, | |
| 712 | + }; | |
| 713 | + | |
| 714 | + pWelsMcFunc[iMvX&0x03][iMvY&0x03](pSrc, iSrcStride, pDst, iDstStride, iWidth, iHeight); | |
| 715 | +} | |
| 716 | + | |
| 717 | +void_t McChroma_sse2( uint8_t *pSrc, int32_t iSrcStride, uint8_t *pDst, int32_t iDstStride, | |
| 718 | + int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight ) | |
| 719 | +{ | |
| 720 | + static const PMcChromaWidthExtFunc kpMcChromaWidthFuncs[2] = | |
| 721 | + { | |
| 722 | + McChromaWidthEq4_mmx, | |
| 723 | + McChromaWidthEq8_sse2 | |
| 724 | + }; | |
| 725 | + const int32_t kiD8x = iMvX&0x07; | |
| 726 | + const int32_t kiD8y = iMvY&0x07; | |
| 727 | + if (kiD8x ==0 && kiD8y ==0) | |
| 728 | + { | |
| 729 | + McCopy_sse2(pSrc, iSrcStride, pDst, iDstStride, iWidth, iHeight); | |
| 730 | + return; | |
| 731 | + } | |
| 732 | + if (iWidth != 2) | |
| 733 | + { | |
| 734 | + kpMcChromaWidthFuncs[iWidth>>3](pSrc, iSrcStride, pDst, iDstStride, g_kuiABCD[kiD8y][kiD8x], iHeight); | |
| 735 | + } | |
| 736 | + else | |
| 737 | + McChromaWithFragMv_c(pSrc, iSrcStride, pDst, iDstStride, iMvX, iMvY, iWidth, iHeight); | |
| 738 | +} | |
| 739 | + | |
| 740 | + | |
| 741 | +#endif //X86_ASM | |
| 742 | + | |
| 743 | +void_t InitMcFunc(SMcFunc *pMcFunc, int32_t iCpu) | |
| 744 | +{ | |
| 745 | + pMcFunc->pMcLumaFunc = McLuma_c; | |
| 746 | + pMcFunc->pMcChromaFunc = McChroma_c; | |
| 747 | + | |
| 748 | +#if defined (X86_ASM) | |
| 749 | + if ( iCpu & WELS_CPU_SSE2 ) | |
| 750 | + { | |
| 751 | + pMcFunc->pMcLumaFunc = McLuma_sse2; | |
| 752 | + pMcFunc->pMcChromaFunc = McChroma_sse2; | |
| 753 | + } | |
| 754 | +#endif //(X86_ASM) | |
| 755 | +} | |
| 756 | + | |
| 757 | +} // namespace WelsDec | |