media/libyuv/source/row_any.cc

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /*
michael@0 2 * Copyright 2012 The LibYuv Project Authors. All rights reserved.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license
michael@0 5 * that can be found in the LICENSE file in the root of the source
michael@0 6 * tree. An additional intellectual property rights grant can be found
michael@0 7 * in the file PATENTS. All contributing project authors may
michael@0 8 * be found in the AUTHORS file in the root of the source tree.
michael@0 9 */
michael@0 10
michael@0 11 #include "libyuv/row.h"
michael@0 12
michael@0 13 #include "libyuv/basic_types.h"
michael@0 14
michael@0 15 #ifdef __cplusplus
michael@0 16 namespace libyuv {
michael@0 17 extern "C" {
michael@0 18 #endif
michael@0 19
michael@0 20 // TODO(fbarchard): Consider 'any' functions handling any quantity of pixels.
michael@0 21 // TODO(fbarchard): Consider 'any' functions handling odd alignment.
michael@0 22 // YUV to RGB does multiple of 8 with SIMD and remainder with C.
michael@0 23 #define YANY(NAMEANY, I420TORGB_SIMD, I420TORGB_C, UV_SHIFT, BPP, MASK) \
michael@0 24 void NAMEANY(const uint8* y_buf, \
michael@0 25 const uint8* u_buf, \
michael@0 26 const uint8* v_buf, \
michael@0 27 uint8* rgb_buf, \
michael@0 28 int width) { \
michael@0 29 int n = width & ~MASK; \
michael@0 30 I420TORGB_SIMD(y_buf, u_buf, v_buf, rgb_buf, n); \
michael@0 31 I420TORGB_C(y_buf + n, \
michael@0 32 u_buf + (n >> UV_SHIFT), \
michael@0 33 v_buf + (n >> UV_SHIFT), \
michael@0 34 rgb_buf + n * BPP, width & MASK); \
michael@0 35 }
michael@0 36
michael@0 37 #ifdef HAS_I422TOARGBROW_SSSE3
michael@0 38 YANY(I444ToARGBRow_Any_SSSE3, I444ToARGBRow_Unaligned_SSSE3, I444ToARGBRow_C,
michael@0 39 0, 4, 7)
michael@0 40 YANY(I422ToARGBRow_Any_SSSE3, I422ToARGBRow_Unaligned_SSSE3, I422ToARGBRow_C,
michael@0 41 1, 4, 7)
michael@0 42 YANY(I411ToARGBRow_Any_SSSE3, I411ToARGBRow_Unaligned_SSSE3, I411ToARGBRow_C,
michael@0 43 2, 4, 7)
michael@0 44 YANY(I422ToBGRARow_Any_SSSE3, I422ToBGRARow_Unaligned_SSSE3, I422ToBGRARow_C,
michael@0 45 1, 4, 7)
michael@0 46 YANY(I422ToABGRRow_Any_SSSE3, I422ToABGRRow_Unaligned_SSSE3, I422ToABGRRow_C,
michael@0 47 1, 4, 7)
michael@0 48 YANY(I422ToRGBARow_Any_SSSE3, I422ToRGBARow_Unaligned_SSSE3, I422ToRGBARow_C,
michael@0 49 1, 4, 7)
michael@0 50 // I422ToRGB565Row_SSSE3 is unaligned.
michael@0 51 YANY(I422ToARGB4444Row_Any_SSSE3, I422ToARGB4444Row_SSSE3, I422ToARGB4444Row_C,
michael@0 52 1, 2, 7)
michael@0 53 YANY(I422ToARGB1555Row_Any_SSSE3, I422ToARGB1555Row_SSSE3, I422ToARGB1555Row_C,
michael@0 54 1, 2, 7)
michael@0 55 YANY(I422ToRGB565Row_Any_SSSE3, I422ToRGB565Row_SSSE3, I422ToRGB565Row_C,
michael@0 56 1, 2, 7)
michael@0 57 // I422ToRGB24Row_SSSE3 is unaligned.
michael@0 58 YANY(I422ToRGB24Row_Any_SSSE3, I422ToRGB24Row_SSSE3, I422ToRGB24Row_C, 1, 3, 7)
michael@0 59 YANY(I422ToRAWRow_Any_SSSE3, I422ToRAWRow_SSSE3, I422ToRAWRow_C, 1, 3, 7)
michael@0 60 YANY(I422ToYUY2Row_Any_SSE2, I422ToYUY2Row_SSE2, I422ToYUY2Row_C, 1, 2, 15)
michael@0 61 YANY(I422ToUYVYRow_Any_SSE2, I422ToUYVYRow_SSE2, I422ToUYVYRow_C, 1, 2, 15)
michael@0 62 #endif // HAS_I422TOARGBROW_SSSE3
michael@0 63 #ifdef HAS_I422TOARGBROW_AVX2
michael@0 64 YANY(I422ToARGBRow_Any_AVX2, I422ToARGBRow_AVX2, I422ToARGBRow_C, 1, 4, 15)
michael@0 65 #endif // HAS_I422TOARGBROW_AVX2
michael@0 66 #ifdef HAS_I422TOARGBROW_NEON
michael@0 67 YANY(I444ToARGBRow_Any_NEON, I444ToARGBRow_NEON, I444ToARGBRow_C, 0, 4, 7)
michael@0 68 YANY(I422ToARGBRow_Any_NEON, I422ToARGBRow_NEON, I422ToARGBRow_C, 1, 4, 7)
michael@0 69 YANY(I411ToARGBRow_Any_NEON, I411ToARGBRow_NEON, I411ToARGBRow_C, 2, 4, 7)
michael@0 70 YANY(I422ToBGRARow_Any_NEON, I422ToBGRARow_NEON, I422ToBGRARow_C, 1, 4, 7)
michael@0 71 YANY(I422ToABGRRow_Any_NEON, I422ToABGRRow_NEON, I422ToABGRRow_C, 1, 4, 7)
michael@0 72 YANY(I422ToRGBARow_Any_NEON, I422ToRGBARow_NEON, I422ToRGBARow_C, 1, 4, 7)
michael@0 73 YANY(I422ToRGB24Row_Any_NEON, I422ToRGB24Row_NEON, I422ToRGB24Row_C, 1, 3, 7)
michael@0 74 YANY(I422ToRAWRow_Any_NEON, I422ToRAWRow_NEON, I422ToRAWRow_C, 1, 3, 7)
michael@0 75 YANY(I422ToARGB4444Row_Any_NEON, I422ToARGB4444Row_NEON, I422ToARGB4444Row_C,
michael@0 76 1, 2, 7)
michael@0 77 YANY(I422ToARGB1555Row_Any_NEON, I422ToARGB1555Row_NEON, I422ToARGB1555Row_C,
michael@0 78 1, 2, 7)
michael@0 79 YANY(I422ToRGB565Row_Any_NEON, I422ToRGB565Row_NEON, I422ToRGB565Row_C, 1, 2, 7)
michael@0 80 YANY(I422ToYUY2Row_Any_NEON, I422ToYUY2Row_NEON, I422ToYUY2Row_C, 1, 2, 15)
michael@0 81 YANY(I422ToUYVYRow_Any_NEON, I422ToUYVYRow_NEON, I422ToUYVYRow_C, 1, 2, 15)
michael@0 82 #endif // HAS_I422TOARGBROW_NEON
michael@0 83 #undef YANY
michael@0 84
michael@0 85 // Wrappers to handle odd width
michael@0 86 #define NV2NY(NAMEANY, NV12TORGB_SIMD, NV12TORGB_C, UV_SHIFT, BPP) \
michael@0 87 void NAMEANY(const uint8* y_buf, \
michael@0 88 const uint8* uv_buf, \
michael@0 89 uint8* rgb_buf, \
michael@0 90 int width) { \
michael@0 91 int n = width & ~7; \
michael@0 92 NV12TORGB_SIMD(y_buf, uv_buf, rgb_buf, n); \
michael@0 93 NV12TORGB_C(y_buf + n, \
michael@0 94 uv_buf + (n >> UV_SHIFT), \
michael@0 95 rgb_buf + n * BPP, width & 7); \
michael@0 96 }
michael@0 97
michael@0 98 #ifdef HAS_NV12TOARGBROW_SSSE3
michael@0 99 NV2NY(NV12ToARGBRow_Any_SSSE3, NV12ToARGBRow_Unaligned_SSSE3, NV12ToARGBRow_C,
michael@0 100 0, 4)
michael@0 101 NV2NY(NV21ToARGBRow_Any_SSSE3, NV21ToARGBRow_Unaligned_SSSE3, NV21ToARGBRow_C,
michael@0 102 0, 4)
michael@0 103 #endif // HAS_NV12TOARGBROW_SSSE3
michael@0 104 #ifdef HAS_NV12TOARGBROW_NEON
michael@0 105 NV2NY(NV12ToARGBRow_Any_NEON, NV12ToARGBRow_NEON, NV12ToARGBRow_C, 0, 4)
michael@0 106 NV2NY(NV21ToARGBRow_Any_NEON, NV21ToARGBRow_NEON, NV21ToARGBRow_C, 0, 4)
michael@0 107 #endif // HAS_NV12TOARGBROW_NEON
michael@0 108 #ifdef HAS_NV12TORGB565ROW_SSSE3
michael@0 109 NV2NY(NV12ToRGB565Row_Any_SSSE3, NV12ToRGB565Row_SSSE3, NV12ToRGB565Row_C,
michael@0 110 0, 2)
michael@0 111 NV2NY(NV21ToRGB565Row_Any_SSSE3, NV21ToRGB565Row_SSSE3, NV21ToRGB565Row_C,
michael@0 112 0, 2)
michael@0 113 #endif // HAS_NV12TORGB565ROW_SSSE3
michael@0 114 #ifdef HAS_NV12TORGB565ROW_NEON
michael@0 115 NV2NY(NV12ToRGB565Row_Any_NEON, NV12ToRGB565Row_NEON, NV12ToRGB565Row_C, 0, 2)
michael@0 116 NV2NY(NV21ToRGB565Row_Any_NEON, NV21ToRGB565Row_NEON, NV21ToRGB565Row_C, 0, 2)
michael@0 117 #endif // HAS_NV12TORGB565ROW_NEON
michael@0 118 #undef NVANY
michael@0 119
michael@0 120 #define RGBANY(NAMEANY, ARGBTORGB_SIMD, ARGBTORGB_C, MASK, SBPP, BPP) \
michael@0 121 void NAMEANY(const uint8* src, \
michael@0 122 uint8* dst, \
michael@0 123 int width) { \
michael@0 124 int n = width & ~MASK; \
michael@0 125 ARGBTORGB_SIMD(src, dst, n); \
michael@0 126 ARGBTORGB_C(src + n * SBPP, dst + n * BPP, width & MASK); \
michael@0 127 }
michael@0 128
michael@0 129 #if defined(HAS_ARGBTORGB24ROW_SSSE3)
michael@0 130 RGBANY(ARGBToRGB24Row_Any_SSSE3, ARGBToRGB24Row_SSSE3, ARGBToRGB24Row_C,
michael@0 131 15, 4, 3)
michael@0 132 RGBANY(ARGBToRAWRow_Any_SSSE3, ARGBToRAWRow_SSSE3, ARGBToRAWRow_C,
michael@0 133 15, 4, 3)
michael@0 134 RGBANY(ARGBToRGB565Row_Any_SSE2, ARGBToRGB565Row_SSE2, ARGBToRGB565Row_C,
michael@0 135 3, 4, 2)
michael@0 136 RGBANY(ARGBToARGB1555Row_Any_SSE2, ARGBToARGB1555Row_SSE2, ARGBToARGB1555Row_C,
michael@0 137 3, 4, 2)
michael@0 138 RGBANY(ARGBToARGB4444Row_Any_SSE2, ARGBToARGB4444Row_SSE2, ARGBToARGB4444Row_C,
michael@0 139 3, 4, 2)
michael@0 140 #endif
michael@0 141 #if defined(HAS_I400TOARGBROW_SSE2)
michael@0 142 RGBANY(I400ToARGBRow_Any_SSE2, I400ToARGBRow_Unaligned_SSE2, I400ToARGBRow_C,
michael@0 143 7, 1, 4)
michael@0 144 #endif
michael@0 145 #if defined(HAS_YTOARGBROW_SSE2)
michael@0 146 RGBANY(YToARGBRow_Any_SSE2, YToARGBRow_SSE2, YToARGBRow_C,
michael@0 147 7, 1, 4)
michael@0 148 RGBANY(YUY2ToARGBRow_Any_SSSE3, YUY2ToARGBRow_Unaligned_SSSE3, YUY2ToARGBRow_C,
michael@0 149 15, 2, 4)
michael@0 150 RGBANY(UYVYToARGBRow_Any_SSSE3, UYVYToARGBRow_Unaligned_SSSE3, UYVYToARGBRow_C,
michael@0 151 15, 2, 4)
michael@0 152 // These require alignment on ARGB, so C is used for remainder.
michael@0 153 RGBANY(RGB24ToARGBRow_Any_SSSE3, RGB24ToARGBRow_SSSE3, RGB24ToARGBRow_C,
michael@0 154 15, 3, 4)
michael@0 155 RGBANY(RAWToARGBRow_Any_SSSE3, RAWToARGBRow_SSSE3, RAWToARGBRow_C,
michael@0 156 15, 3, 4)
michael@0 157 RGBANY(RGB565ToARGBRow_Any_SSE2, RGB565ToARGBRow_SSE2, RGB565ToARGBRow_C,
michael@0 158 7, 2, 4)
michael@0 159 RGBANY(ARGB1555ToARGBRow_Any_SSE2, ARGB1555ToARGBRow_SSE2, ARGB1555ToARGBRow_C,
michael@0 160 7, 2, 4)
michael@0 161 RGBANY(ARGB4444ToARGBRow_Any_SSE2, ARGB4444ToARGBRow_SSE2, ARGB4444ToARGBRow_C,
michael@0 162 7, 2, 4)
michael@0 163 #endif
michael@0 164 #if defined(HAS_ARGBTORGB24ROW_NEON)
michael@0 165 RGBANY(ARGBToRGB24Row_Any_NEON, ARGBToRGB24Row_NEON, ARGBToRGB24Row_C, 7, 4, 3)
michael@0 166 RGBANY(ARGBToRAWRow_Any_NEON, ARGBToRAWRow_NEON, ARGBToRAWRow_C, 7, 4, 3)
michael@0 167 RGBANY(ARGBToRGB565Row_Any_NEON, ARGBToRGB565Row_NEON, ARGBToRGB565Row_C,
michael@0 168 7, 4, 2)
michael@0 169 RGBANY(ARGBToARGB1555Row_Any_NEON, ARGBToARGB1555Row_NEON, ARGBToARGB1555Row_C,
michael@0 170 7, 4, 2)
michael@0 171 RGBANY(ARGBToARGB4444Row_Any_NEON, ARGBToARGB4444Row_NEON, ARGBToARGB4444Row_C,
michael@0 172 7, 4, 2)
michael@0 173 RGBANY(I400ToARGBRow_Any_NEON, I400ToARGBRow_NEON, I400ToARGBRow_C,
michael@0 174 7, 1, 4)
michael@0 175 RGBANY(YToARGBRow_Any_NEON, YToARGBRow_NEON, YToARGBRow_C,
michael@0 176 7, 1, 4)
michael@0 177 RGBANY(YUY2ToARGBRow_Any_NEON, YUY2ToARGBRow_NEON, YUY2ToARGBRow_C,
michael@0 178 7, 2, 4)
michael@0 179 RGBANY(UYVYToARGBRow_Any_NEON, UYVYToARGBRow_NEON, UYVYToARGBRow_C,
michael@0 180 7, 2, 4)
michael@0 181 #endif
michael@0 182 #undef RGBANY
michael@0 183
michael@0 184 // ARGB to Bayer does multiple of 4 pixels, SSSE3 aligned src, unaligned dst.
michael@0 185 #define BAYERANY(NAMEANY, ARGBTORGB_SIMD, ARGBTORGB_C, MASK, SBPP, BPP) \
michael@0 186 void NAMEANY(const uint8* src, \
michael@0 187 uint8* dst, uint32 selector, \
michael@0 188 int width) { \
michael@0 189 int n = width & ~MASK; \
michael@0 190 ARGBTORGB_SIMD(src, dst, selector, n); \
michael@0 191 ARGBTORGB_C(src + n * SBPP, dst + n * BPP, selector, width & MASK); \
michael@0 192 }
michael@0 193
michael@0 194 #if defined(HAS_ARGBTOBAYERROW_SSSE3)
michael@0 195 BAYERANY(ARGBToBayerRow_Any_SSSE3, ARGBToBayerRow_SSSE3, ARGBToBayerRow_C,
michael@0 196 7, 4, 1)
michael@0 197 #endif
michael@0 198 #if defined(HAS_ARGBTOBAYERROW_NEON)
michael@0 199 BAYERANY(ARGBToBayerRow_Any_NEON, ARGBToBayerRow_NEON, ARGBToBayerRow_C,
michael@0 200 7, 4, 1)
michael@0 201 #endif
michael@0 202 #if defined(HAS_ARGBTOBAYERGGROW_SSE2)
michael@0 203 BAYERANY(ARGBToBayerGGRow_Any_SSE2, ARGBToBayerGGRow_SSE2, ARGBToBayerGGRow_C,
michael@0 204 7, 4, 1)
michael@0 205 #endif
michael@0 206 #if defined(HAS_ARGBTOBAYERGGROW_NEON)
michael@0 207 BAYERANY(ARGBToBayerGGRow_Any_NEON, ARGBToBayerGGRow_NEON, ARGBToBayerGGRow_C,
michael@0 208 7, 4, 1)
michael@0 209 #endif
michael@0 210
michael@0 211 #undef BAYERANY
michael@0 212
michael@0 213 // RGB/YUV to Y does multiple of 16 with SIMD and last 16 with SIMD.
michael@0 214 #define YANY(NAMEANY, ARGBTOY_SIMD, SBPP, BPP, NUM) \
michael@0 215 void NAMEANY(const uint8* src_argb, uint8* dst_y, int width) { \
michael@0 216 ARGBTOY_SIMD(src_argb, dst_y, width - NUM); \
michael@0 217 ARGBTOY_SIMD(src_argb + (width - NUM) * SBPP, \
michael@0 218 dst_y + (width - NUM) * BPP, NUM); \
michael@0 219 }
michael@0 220
michael@0 221 #ifdef HAS_ARGBTOYROW_AVX2
michael@0 222 YANY(ARGBToYRow_Any_AVX2, ARGBToYRow_AVX2, 4, 1, 32)
michael@0 223 YANY(ARGBToYJRow_Any_AVX2, ARGBToYJRow_AVX2, 4, 1, 32)
michael@0 224 YANY(YUY2ToYRow_Any_AVX2, YUY2ToYRow_AVX2, 2, 1, 32)
michael@0 225 YANY(UYVYToYRow_Any_AVX2, UYVYToYRow_AVX2, 2, 1, 32)
michael@0 226 #endif
michael@0 227 #ifdef HAS_ARGBTOYROW_SSSE3
michael@0 228 YANY(ARGBToYRow_Any_SSSE3, ARGBToYRow_Unaligned_SSSE3, 4, 1, 16)
michael@0 229 #endif
michael@0 230 #ifdef HAS_BGRATOYROW_SSSE3
michael@0 231 YANY(BGRAToYRow_Any_SSSE3, BGRAToYRow_Unaligned_SSSE3, 4, 1, 16)
michael@0 232 YANY(ABGRToYRow_Any_SSSE3, ABGRToYRow_Unaligned_SSSE3, 4, 1, 16)
michael@0 233 YANY(RGBAToYRow_Any_SSSE3, RGBAToYRow_Unaligned_SSSE3, 4, 1, 16)
michael@0 234 YANY(YUY2ToYRow_Any_SSE2, YUY2ToYRow_Unaligned_SSE2, 2, 1, 16)
michael@0 235 YANY(UYVYToYRow_Any_SSE2, UYVYToYRow_Unaligned_SSE2, 2, 1, 16)
michael@0 236 #endif
michael@0 237 #ifdef HAS_ARGBTOYJROW_SSSE3
michael@0 238 YANY(ARGBToYJRow_Any_SSSE3, ARGBToYJRow_Unaligned_SSSE3, 4, 1, 16)
michael@0 239 #endif
michael@0 240 #ifdef HAS_ARGBTOYROW_NEON
michael@0 241 YANY(ARGBToYRow_Any_NEON, ARGBToYRow_NEON, 4, 1, 8)
michael@0 242 YANY(ARGBToYJRow_Any_NEON, ARGBToYJRow_NEON, 4, 1, 8)
michael@0 243 YANY(BGRAToYRow_Any_NEON, BGRAToYRow_NEON, 4, 1, 8)
michael@0 244 YANY(ABGRToYRow_Any_NEON, ABGRToYRow_NEON, 4, 1, 8)
michael@0 245 YANY(RGBAToYRow_Any_NEON, RGBAToYRow_NEON, 4, 1, 8)
michael@0 246 YANY(RGB24ToYRow_Any_NEON, RGB24ToYRow_NEON, 3, 1, 8)
michael@0 247 YANY(RAWToYRow_Any_NEON, RAWToYRow_NEON, 3, 1, 8)
michael@0 248 YANY(RGB565ToYRow_Any_NEON, RGB565ToYRow_NEON, 2, 1, 8)
michael@0 249 YANY(ARGB1555ToYRow_Any_NEON, ARGB1555ToYRow_NEON, 2, 1, 8)
michael@0 250 YANY(ARGB4444ToYRow_Any_NEON, ARGB4444ToYRow_NEON, 2, 1, 8)
michael@0 251 YANY(YUY2ToYRow_Any_NEON, YUY2ToYRow_NEON, 2, 1, 16)
michael@0 252 YANY(UYVYToYRow_Any_NEON, UYVYToYRow_NEON, 2, 1, 16)
michael@0 253 YANY(RGB24ToARGBRow_Any_NEON, RGB24ToARGBRow_NEON, 3, 4, 8)
michael@0 254 YANY(RAWToARGBRow_Any_NEON, RAWToARGBRow_NEON, 3, 4, 8)
michael@0 255 YANY(RGB565ToARGBRow_Any_NEON, RGB565ToARGBRow_NEON, 2, 4, 8)
michael@0 256 YANY(ARGB1555ToARGBRow_Any_NEON, ARGB1555ToARGBRow_NEON, 2, 4, 8)
michael@0 257 YANY(ARGB4444ToARGBRow_Any_NEON, ARGB4444ToARGBRow_NEON, 2, 4, 8)
michael@0 258 #endif
michael@0 259 #undef YANY
michael@0 260
michael@0 261 #define YANY(NAMEANY, ARGBTOY_SIMD, ARGBTOY_C, SBPP, BPP, MASK) \
michael@0 262 void NAMEANY(const uint8* src_argb, uint8* dst_y, int width) { \
michael@0 263 int n = width & ~MASK; \
michael@0 264 ARGBTOY_SIMD(src_argb, dst_y, n); \
michael@0 265 ARGBTOY_C(src_argb + n * SBPP, \
michael@0 266 dst_y + n * BPP, width & MASK); \
michael@0 267 }
michael@0 268
michael@0 269 // Attenuate is destructive so last16 method can not be used due to overlap.
michael@0 270 #ifdef HAS_ARGBATTENUATEROW_SSSE3
michael@0 271 YANY(ARGBAttenuateRow_Any_SSSE3, ARGBAttenuateRow_SSSE3, ARGBAttenuateRow_C,
michael@0 272 4, 4, 3)
michael@0 273 #endif
michael@0 274 #ifdef HAS_ARGBATTENUATEROW_SSE2
michael@0 275 YANY(ARGBAttenuateRow_Any_SSE2, ARGBAttenuateRow_SSE2, ARGBAttenuateRow_C,
michael@0 276 4, 4, 3)
michael@0 277 #endif
michael@0 278 #ifdef HAS_ARGBUNATTENUATEROW_SSE2
michael@0 279 YANY(ARGBUnattenuateRow_Any_SSE2, ARGBUnattenuateRow_SSE2, ARGBUnattenuateRow_C,
michael@0 280 4, 4, 3)
michael@0 281 #endif
michael@0 282 #ifdef HAS_ARGBATTENUATEROW_AVX2
michael@0 283 YANY(ARGBAttenuateRow_Any_AVX2, ARGBAttenuateRow_AVX2, ARGBAttenuateRow_C,
michael@0 284 4, 4, 7)
michael@0 285 #endif
michael@0 286 #ifdef HAS_ARGBUNATTENUATEROW_AVX2
michael@0 287 YANY(ARGBUnattenuateRow_Any_AVX2, ARGBUnattenuateRow_AVX2, ARGBUnattenuateRow_C,
michael@0 288 4, 4, 7)
michael@0 289 #endif
michael@0 290 #ifdef HAS_ARGBATTENUATEROW_NEON
michael@0 291 YANY(ARGBAttenuateRow_Any_NEON, ARGBAttenuateRow_NEON, ARGBAttenuateRow_C,
michael@0 292 4, 4, 7)
michael@0 293 #endif
michael@0 294 #undef YANY
michael@0 295
michael@0 296 // RGB/YUV to UV does multiple of 16 with SIMD and remainder with C.
michael@0 297 #define UVANY(NAMEANY, ANYTOUV_SIMD, ANYTOUV_C, BPP, MASK) \
michael@0 298 void NAMEANY(const uint8* src_argb, int src_stride_argb, \
michael@0 299 uint8* dst_u, uint8* dst_v, int width) { \
michael@0 300 int n = width & ~MASK; \
michael@0 301 ANYTOUV_SIMD(src_argb, src_stride_argb, dst_u, dst_v, n); \
michael@0 302 ANYTOUV_C(src_argb + n * BPP, src_stride_argb, \
michael@0 303 dst_u + (n >> 1), \
michael@0 304 dst_v + (n >> 1), \
michael@0 305 width & MASK); \
michael@0 306 }
michael@0 307
michael@0 308 #ifdef HAS_ARGBTOUVROW_AVX2
michael@0 309 UVANY(ARGBToUVRow_Any_AVX2, ARGBToUVRow_AVX2, ARGBToUVRow_C, 4, 31)
michael@0 310 UVANY(YUY2ToUVRow_Any_AVX2, YUY2ToUVRow_AVX2, YUY2ToUVRow_C, 2, 31)
michael@0 311 UVANY(UYVYToUVRow_Any_AVX2, UYVYToUVRow_AVX2, UYVYToUVRow_C, 2, 31)
michael@0 312 #endif
michael@0 313 #ifdef HAS_ARGBTOUVROW_SSSE3
michael@0 314 UVANY(ARGBToUVRow_Any_SSSE3, ARGBToUVRow_Unaligned_SSSE3, ARGBToUVRow_C, 4, 15)
michael@0 315 UVANY(ARGBToUVJRow_Any_SSSE3, ARGBToUVJRow_Unaligned_SSSE3, ARGBToUVJRow_C,
michael@0 316 4, 15)
michael@0 317 UVANY(BGRAToUVRow_Any_SSSE3, BGRAToUVRow_Unaligned_SSSE3, BGRAToUVRow_C, 4, 15)
michael@0 318 UVANY(ABGRToUVRow_Any_SSSE3, ABGRToUVRow_Unaligned_SSSE3, ABGRToUVRow_C, 4, 15)
michael@0 319 UVANY(RGBAToUVRow_Any_SSSE3, RGBAToUVRow_Unaligned_SSSE3, RGBAToUVRow_C, 4, 15)
michael@0 320 UVANY(YUY2ToUVRow_Any_SSE2, YUY2ToUVRow_Unaligned_SSE2, YUY2ToUVRow_C, 2, 15)
michael@0 321 UVANY(UYVYToUVRow_Any_SSE2, UYVYToUVRow_Unaligned_SSE2, UYVYToUVRow_C, 2, 15)
michael@0 322 #endif
michael@0 323 #ifdef HAS_ARGBTOUVROW_NEON
michael@0 324 UVANY(ARGBToUVRow_Any_NEON, ARGBToUVRow_NEON, ARGBToUVRow_C, 4, 15)
michael@0 325 UVANY(ARGBToUVJRow_Any_NEON, ARGBToUVJRow_NEON, ARGBToUVJRow_C, 4, 15)
michael@0 326 UVANY(BGRAToUVRow_Any_NEON, BGRAToUVRow_NEON, BGRAToUVRow_C, 4, 15)
michael@0 327 UVANY(ABGRToUVRow_Any_NEON, ABGRToUVRow_NEON, ABGRToUVRow_C, 4, 15)
michael@0 328 UVANY(RGBAToUVRow_Any_NEON, RGBAToUVRow_NEON, RGBAToUVRow_C, 4, 15)
michael@0 329 UVANY(RGB24ToUVRow_Any_NEON, RGB24ToUVRow_NEON, RGB24ToUVRow_C, 3, 15)
michael@0 330 UVANY(RAWToUVRow_Any_NEON, RAWToUVRow_NEON, RAWToUVRow_C, 3, 15)
michael@0 331 UVANY(RGB565ToUVRow_Any_NEON, RGB565ToUVRow_NEON, RGB565ToUVRow_C, 2, 15)
michael@0 332 UVANY(ARGB1555ToUVRow_Any_NEON, ARGB1555ToUVRow_NEON, ARGB1555ToUVRow_C, 2, 15)
michael@0 333 UVANY(ARGB4444ToUVRow_Any_NEON, ARGB4444ToUVRow_NEON, ARGB4444ToUVRow_C, 2, 15)
michael@0 334 UVANY(YUY2ToUVRow_Any_NEON, YUY2ToUVRow_NEON, YUY2ToUVRow_C, 2, 15)
michael@0 335 UVANY(UYVYToUVRow_Any_NEON, UYVYToUVRow_NEON, UYVYToUVRow_C, 2, 15)
michael@0 336 #endif
michael@0 337 #undef UVANY
michael@0 338
michael@0 339 #define UV422ANY(NAMEANY, ANYTOUV_SIMD, ANYTOUV_C, BPP, MASK, SHIFT) \
michael@0 340 void NAMEANY(const uint8* src_uv, \
michael@0 341 uint8* dst_u, uint8* dst_v, int width) { \
michael@0 342 int n = width & ~MASK; \
michael@0 343 ANYTOUV_SIMD(src_uv, dst_u, dst_v, n); \
michael@0 344 ANYTOUV_C(src_uv + n * BPP, \
michael@0 345 dst_u + (n >> SHIFT), \
michael@0 346 dst_v + (n >> SHIFT), \
michael@0 347 width & MASK); \
michael@0 348 }
michael@0 349
michael@0 350 #ifdef HAS_ARGBTOUV444ROW_SSSE3
michael@0 351 UV422ANY(ARGBToUV444Row_Any_SSSE3, ARGBToUV444Row_Unaligned_SSSE3,
michael@0 352 ARGBToUV444Row_C, 4, 15, 0)
michael@0 353 #endif
michael@0 354 #ifdef HAS_YUY2TOUV422ROW_AVX2
michael@0 355 UV422ANY(YUY2ToUV422Row_Any_AVX2, YUY2ToUV422Row_AVX2,
michael@0 356 YUY2ToUV422Row_C, 2, 31, 1)
michael@0 357 UV422ANY(UYVYToUV422Row_Any_AVX2, UYVYToUV422Row_AVX2,
michael@0 358 UYVYToUV422Row_C, 2, 31, 1)
michael@0 359 #endif
michael@0 360 #ifdef HAS_ARGBTOUVROW_SSSE3
michael@0 361 UV422ANY(ARGBToUV422Row_Any_SSSE3, ARGBToUV422Row_Unaligned_SSSE3,
michael@0 362 ARGBToUV422Row_C, 4, 15, 1)
michael@0 363 UV422ANY(YUY2ToUV422Row_Any_SSE2, YUY2ToUV422Row_Unaligned_SSE2,
michael@0 364 YUY2ToUV422Row_C, 2, 15, 1)
michael@0 365 UV422ANY(UYVYToUV422Row_Any_SSE2, UYVYToUV422Row_Unaligned_SSE2,
michael@0 366 UYVYToUV422Row_C, 2, 15, 1)
michael@0 367 #endif
michael@0 368 #ifdef HAS_YUY2TOUV422ROW_NEON
michael@0 369 UV422ANY(ARGBToUV444Row_Any_NEON, ARGBToUV444Row_NEON,
michael@0 370 ARGBToUV444Row_C, 4, 7, 0)
michael@0 371 UV422ANY(ARGBToUV422Row_Any_NEON, ARGBToUV422Row_NEON,
michael@0 372 ARGBToUV422Row_C, 4, 15, 1)
michael@0 373 UV422ANY(ARGBToUV411Row_Any_NEON, ARGBToUV411Row_NEON,
michael@0 374 ARGBToUV411Row_C, 4, 31, 2)
michael@0 375 UV422ANY(YUY2ToUV422Row_Any_NEON, YUY2ToUV422Row_NEON,
michael@0 376 YUY2ToUV422Row_C, 2, 15, 1)
michael@0 377 UV422ANY(UYVYToUV422Row_Any_NEON, UYVYToUV422Row_NEON,
michael@0 378 UYVYToUV422Row_C, 2, 15, 1)
michael@0 379 #endif
michael@0 380 #undef UV422ANY
michael@0 381
michael@0 382 #define SPLITUVROWANY(NAMEANY, ANYTOUV_SIMD, ANYTOUV_C, MASK) \
michael@0 383 void NAMEANY(const uint8* src_uv, \
michael@0 384 uint8* dst_u, uint8* dst_v, int width) { \
michael@0 385 int n = width & ~MASK; \
michael@0 386 ANYTOUV_SIMD(src_uv, dst_u, dst_v, n); \
michael@0 387 ANYTOUV_C(src_uv + n * 2, \
michael@0 388 dst_u + n, \
michael@0 389 dst_v + n, \
michael@0 390 width & MASK); \
michael@0 391 }
michael@0 392
michael@0 393 #ifdef HAS_SPLITUVROW_SSE2
michael@0 394 SPLITUVROWANY(SplitUVRow_Any_SSE2, SplitUVRow_Unaligned_SSE2, SplitUVRow_C, 15)
michael@0 395 #endif
michael@0 396 #ifdef HAS_SPLITUVROW_AVX2
michael@0 397 SPLITUVROWANY(SplitUVRow_Any_AVX2, SplitUVRow_AVX2, SplitUVRow_C, 31)
michael@0 398 #endif
michael@0 399 #ifdef HAS_SPLITUVROW_NEON
michael@0 400 SPLITUVROWANY(SplitUVRow_Any_NEON, SplitUVRow_NEON, SplitUVRow_C, 15)
michael@0 401 #endif
michael@0 402 #ifdef HAS_SPLITUVROW_MIPS_DSPR2
michael@0 403 SPLITUVROWANY(SplitUVRow_Any_MIPS_DSPR2, SplitUVRow_Unaligned_MIPS_DSPR2,
michael@0 404 SplitUVRow_C, 15)
michael@0 405 #endif
michael@0 406 #undef SPLITUVROWANY
michael@0 407
michael@0 408 #define MERGEUVROW_ANY(NAMEANY, ANYTOUV_SIMD, ANYTOUV_C, MASK) \
michael@0 409 void NAMEANY(const uint8* src_u, const uint8* src_v, \
michael@0 410 uint8* dst_uv, int width) { \
michael@0 411 int n = width & ~MASK; \
michael@0 412 ANYTOUV_SIMD(src_u, src_v, dst_uv, n); \
michael@0 413 ANYTOUV_C(src_u + n, \
michael@0 414 src_v + n, \
michael@0 415 dst_uv + n * 2, \
michael@0 416 width & MASK); \
michael@0 417 }
michael@0 418
michael@0 419 #ifdef HAS_MERGEUVROW_SSE2
michael@0 420 MERGEUVROW_ANY(MergeUVRow_Any_SSE2, MergeUVRow_Unaligned_SSE2, MergeUVRow_C, 15)
michael@0 421 #endif
michael@0 422 #ifdef HAS_MERGEUVROW_AVX2
michael@0 423 MERGEUVROW_ANY(MergeUVRow_Any_AVX2, MergeUVRow_AVX2, MergeUVRow_C, 31)
michael@0 424 #endif
michael@0 425 #ifdef HAS_MERGEUVROW_NEON
michael@0 426 MERGEUVROW_ANY(MergeUVRow_Any_NEON, MergeUVRow_NEON, MergeUVRow_C, 15)
michael@0 427 #endif
michael@0 428 #undef MERGEUVROW_ANY
michael@0 429
michael@0 430 #define MATHROW_ANY(NAMEANY, ARGBMATH_SIMD, ARGBMATH_C, MASK) \
michael@0 431 void NAMEANY(const uint8* src_argb0, const uint8* src_argb1, \
michael@0 432 uint8* dst_argb, int width) { \
michael@0 433 int n = width & ~MASK; \
michael@0 434 ARGBMATH_SIMD(src_argb0, src_argb1, dst_argb, n); \
michael@0 435 ARGBMATH_C(src_argb0 + n * 4, \
michael@0 436 src_argb1 + n * 4, \
michael@0 437 dst_argb + n * 4, \
michael@0 438 width & MASK); \
michael@0 439 }
michael@0 440
michael@0 441 #ifdef HAS_ARGBMULTIPLYROW_SSE2
michael@0 442 MATHROW_ANY(ARGBMultiplyRow_Any_SSE2, ARGBMultiplyRow_SSE2, ARGBMultiplyRow_C,
michael@0 443 3)
michael@0 444 #endif
michael@0 445 #ifdef HAS_ARGBADDROW_SSE2
michael@0 446 MATHROW_ANY(ARGBAddRow_Any_SSE2, ARGBAddRow_SSE2, ARGBAddRow_C, 3)
michael@0 447 #endif
michael@0 448 #ifdef HAS_ARGBSUBTRACTROW_SSE2
michael@0 449 MATHROW_ANY(ARGBSubtractRow_Any_SSE2, ARGBSubtractRow_SSE2, ARGBSubtractRow_C,
michael@0 450 3)
michael@0 451 #endif
michael@0 452 #ifdef HAS_ARGBMULTIPLYROW_AVX2
michael@0 453 MATHROW_ANY(ARGBMultiplyRow_Any_AVX2, ARGBMultiplyRow_AVX2, ARGBMultiplyRow_C,
michael@0 454 7)
michael@0 455 #endif
michael@0 456 #ifdef HAS_ARGBADDROW_AVX2
michael@0 457 MATHROW_ANY(ARGBAddRow_Any_AVX2, ARGBAddRow_AVX2, ARGBAddRow_C, 7)
michael@0 458 #endif
michael@0 459 #ifdef HAS_ARGBSUBTRACTROW_AVX2
michael@0 460 MATHROW_ANY(ARGBSubtractRow_Any_AVX2, ARGBSubtractRow_AVX2, ARGBSubtractRow_C,
michael@0 461 7)
michael@0 462 #endif
michael@0 463 #ifdef HAS_ARGBMULTIPLYROW_NEON
michael@0 464 MATHROW_ANY(ARGBMultiplyRow_Any_NEON, ARGBMultiplyRow_NEON, ARGBMultiplyRow_C,
michael@0 465 7)
michael@0 466 #endif
michael@0 467 #ifdef HAS_ARGBADDROW_NEON
michael@0 468 MATHROW_ANY(ARGBAddRow_Any_NEON, ARGBAddRow_NEON, ARGBAddRow_C, 7)
michael@0 469 #endif
michael@0 470 #ifdef HAS_ARGBSUBTRACTROW_NEON
michael@0 471 MATHROW_ANY(ARGBSubtractRow_Any_NEON, ARGBSubtractRow_NEON, ARGBSubtractRow_C,
michael@0 472 7)
michael@0 473 #endif
michael@0 474 #undef MATHROW_ANY
michael@0 475
michael@0 476 // Shuffle may want to work in place, so last16 method can not be used.
michael@0 477 #define YANY(NAMEANY, ARGBTOY_SIMD, ARGBTOY_C, SBPP, BPP, MASK) \
michael@0 478 void NAMEANY(const uint8* src_argb, uint8* dst_argb, \
michael@0 479 const uint8* shuffler, int width) { \
michael@0 480 int n = width & ~MASK; \
michael@0 481 ARGBTOY_SIMD(src_argb, dst_argb, shuffler, n); \
michael@0 482 ARGBTOY_C(src_argb + n * SBPP, \
michael@0 483 dst_argb + n * BPP, shuffler, width & MASK); \
michael@0 484 }
michael@0 485
michael@0 486 #ifdef HAS_ARGBSHUFFLEROW_SSE2
michael@0 487 YANY(ARGBShuffleRow_Any_SSE2, ARGBShuffleRow_SSE2,
michael@0 488 ARGBShuffleRow_C, 4, 4, 3)
michael@0 489 #endif
michael@0 490 #ifdef HAS_ARGBSHUFFLEROW_SSSE3
michael@0 491 YANY(ARGBShuffleRow_Any_SSSE3, ARGBShuffleRow_Unaligned_SSSE3,
michael@0 492 ARGBShuffleRow_C, 4, 4, 7)
michael@0 493 #endif
michael@0 494 #ifdef HAS_ARGBSHUFFLEROW_AVX2
michael@0 495 YANY(ARGBShuffleRow_Any_AVX2, ARGBShuffleRow_AVX2,
michael@0 496 ARGBShuffleRow_C, 4, 4, 15)
michael@0 497 #endif
michael@0 498 #ifdef HAS_ARGBSHUFFLEROW_NEON
michael@0 499 YANY(ARGBShuffleRow_Any_NEON, ARGBShuffleRow_NEON,
michael@0 500 ARGBShuffleRow_C, 4, 4, 3)
michael@0 501 #endif
michael@0 502 #undef YANY
michael@0 503
michael@0 504 // Interpolate may want to work in place, so last16 method can not be used.
michael@0 505 #define NANY(NAMEANY, TERP_SIMD, TERP_C, SBPP, BPP, MASK) \
michael@0 506 void NAMEANY(uint8* dst_ptr, const uint8* src_ptr, \
michael@0 507 ptrdiff_t src_stride_ptr, int width, \
michael@0 508 int source_y_fraction) { \
michael@0 509 int n = width & ~MASK; \
michael@0 510 TERP_SIMD(dst_ptr, src_ptr, src_stride_ptr, \
michael@0 511 n, source_y_fraction); \
michael@0 512 TERP_C(dst_ptr + n * BPP, \
michael@0 513 src_ptr + n * SBPP, src_stride_ptr, \
michael@0 514 width & MASK, source_y_fraction); \
michael@0 515 }
michael@0 516
michael@0 517 #ifdef HAS_INTERPOLATEROW_AVX2
michael@0 518 NANY(InterpolateRow_Any_AVX2, InterpolateRow_AVX2,
michael@0 519 InterpolateRow_C, 1, 1, 32)
michael@0 520 #endif
michael@0 521 #ifdef HAS_INTERPOLATEROW_SSSE3
michael@0 522 NANY(InterpolateRow_Any_SSSE3, InterpolateRow_Unaligned_SSSE3,
michael@0 523 InterpolateRow_C, 1, 1, 15)
michael@0 524 #endif
michael@0 525 #ifdef HAS_INTERPOLATEROW_SSE2
michael@0 526 NANY(InterpolateRow_Any_SSE2, InterpolateRow_Unaligned_SSE2,
michael@0 527 InterpolateRow_C, 1, 1, 15)
michael@0 528 #endif
michael@0 529 #ifdef HAS_INTERPOLATEROW_NEON
michael@0 530 NANY(InterpolateRow_Any_NEON, InterpolateRow_NEON,
michael@0 531 InterpolateRow_C, 1, 1, 15)
michael@0 532 #endif
michael@0 533 #ifdef HAS_INTERPOLATEROW_MIPS_DSPR2
michael@0 534 NANY(InterpolateRow_Any_MIPS_DSPR2, InterpolateRow_MIPS_DSPR2,
michael@0 535 InterpolateRow_C, 1, 1, 3)
michael@0 536 #endif
michael@0 537 #undef NANY
michael@0 538
michael@0 539 #ifdef __cplusplus
michael@0 540 } // extern "C"
michael@0 541 } // namespace libyuv
michael@0 542 #endif

mercurial