1 /* 2 * Simd Library (http://ermig1979.github.io/Simd). 3 * 4 * Copyright (c) 2011-2019 Yermalayeu Ihar, 5 * 2014-2016 Antonenka Mikhail, 6 * 2019-2019 Facundo Galan. 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a copy 9 * of this software and associated documentation files (the "Software"), to deal 10 * in the Software without restriction, including without limitation the rights 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 * copies of the Software, and to permit persons to whom the Software is 13 * furnished to do so, subject to the following conditions: 14 * 15 * The above copyright notice and this permission notice shall be included in 16 * all copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 * SOFTWARE. 25 */ 26 27 #ifndef __SimdLib_h__ 28 #define __SimdLib_h__ 29 30 #include "Simd/SimdConfig.h" 31 32 #include <stddef.h> 33 34 #if defined(_MSC_VER) || defined(__CODEGEARC__) 35 36 #define SIMD_INLINE __forceinline 37 38 #elif defined(__GNUC__) 39 40 #define SIMD_INLINE inline __attribute__ ((always_inline)) 41 42 #else 43 44 #error This platform is unsupported! 45 46 #endif 47 48 #if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 1600)) || (defined(__CODEGEARC__) && (__CODEGEARC__ >= 1840)) 49 #include <stdint.h> 50 #else 51 # if (_MSC_VER < 1300) 52 typedef signed char int8_t; 53 typedef signed short int16_t; 54 typedef signed int int32_t; 55 typedef unsigned char uint8_t; 56 typedef unsigned short uint16_t; 57 typedef unsigned int uint32_t; 58 # else 59 typedef signed __int8 int8_t; 60 typedef signed __int16 int16_t; 61 typedef signed __int32 int32_t; 62 typedef unsigned __int8 uint8_t; 63 typedef unsigned __int16 uint16_t; 64 typedef unsigned __int32 uint32_t; 65 # endif 66 typedef signed __int64 int64_t; 67 typedef unsigned __int64 uint64_t; 68 #endif 69 70 /*! @ingroup c_types 71 Describes boolean type. 72 */ 73 typedef enum 74 { 75 SimdFalse = 0, /*!< False value. */ 76 SimdTrue = 1, /*!< True value. */ 77 } SimdBool; 78 79 /*! @ingroup c_types 80 Describes types of compare operation. 81 Operation compare(a, b) is 82 */ 83 typedef enum 84 { 85 /*! equal to: a == b */ 86 SimdCompareEqual, 87 /*! equal to: a != b */ 88 SimdCompareNotEqual, 89 /*! equal to: a > b */ 90 SimdCompareGreater, 91 /*! equal to: a >= b */ 92 SimdCompareGreaterOrEqual, 93 /*! equal to: a < b */ 94 SimdCompareLesser, 95 /*! equal to: a <= b */ 96 SimdCompareLesserOrEqual, 97 } SimdCompareType; 98 99 /*! @ingroup c_types 100 Describes type of information which can return function ::SimdCpuInfo. 101 */ 102 typedef enum 103 { 104 SimdCpuInfoSockets,/*!< A number of sockets. */ 105 SimdCpuInfoCores, /*!< A number of psysical CPU cores. */ 106 SimdCpuInfoThreads, /*!< A number of logical CPU cores. */ 107 SimdCpuInfoCacheL1, /*!< A size of level 1 data cache. */ 108 SimdCpuInfoCacheL2, /*!< A size of level 2 cache. */ 109 SimdCpuInfoCacheL3, /*!< A size of level 3 cache. */ 110 SimdCpuInfoSse, /*!< Availability of SSE (x86). */ 111 SimdCpuInfoSse2, /*!< Availability of SSE2 (x86). */ 112 SimdCpuInfoSse3, /*!< Availability of SSE3 (x86). */ 113 SimdCpuInfoSsse3, /*!< Availability of SSSE3 (x86). */ 114 SimdCpuInfoSse41, /*!< Availability of SSE4.1 (x86). */ 115 SimdCpuInfoSse42, /*!< Availability of SSE4.2 (x86). */ 116 SimdCpuInfoAvx, /*!< Availability of AVX (x86). */ 117 SimdCpuInfoAvx2, /*!< Availability of AVX2 (x86). */ 118 SimdCpuInfoAvx512f, /*!< Availability of AVX-512F (x86). */ 119 SimdCpuInfoAvx512bw, /*!< Availability of AVX-512BW (x86). */ 120 SimdCpuInfoVmx, /*!< Availability of VMX or Altivec (PowerPC). */ 121 SimdCpuInfoVsx, /*!< Availability of VSX (PowerPC). */ 122 SimdCpuInfoNeon, /*!< Availability of NEON (ARM). */ 123 SimdCpuInfoMsa, /*!< Availability of MSA (MIPS). */ 124 } SimdCpuInfoType; 125 126 /*! @ingroup c_types 127 Describes types of binary operation between two images performed by function ::SimdOperationBinary8u. 128 Images must have the same format (unsigned 8-bit integer for every channel). 129 */ 130 typedef enum 131 { 132 /*! Computes the average value for every channel of every point of two images. \n Average(a, b) = (a + b + 1)/2. */ 133 SimdOperationBinary8uAverage, 134 /*! Computes the bitwise AND between two images. */ 135 SimdOperationBinary8uAnd, 136 /*! Computes the bitwise OR between two images. */ 137 SimdOperationBinary8uOr, 138 /*! Computes maximal value for every channel of every point of two images. */ 139 SimdOperationBinary8uMaximum, 140 /*! Computes minimal value for every channel of every point of two images. */ 141 SimdOperationBinary8uMinimum, 142 /*! Subtracts unsigned 8-bit integer b from unsigned 8-bit integer a and saturates (for every channel of every point of the images). */ 143 SimdOperationBinary8uSaturatedSubtraction, 144 /*! Adds unsigned 8-bit integer b from unsigned 8-bit integer a and saturates (for every channel of every point of the images). */ 145 SimdOperationBinary8uSaturatedAddition, 146 /*! Subtracts unsigned 8-bit integer b from unsigned 8-bit integer a (for every channel of every point of the images). */ 147 SimdOperationBinary8uSubtraction, 148 /*! Adds unsigned 8-bit integer b from unsigned 8-bit integer a (for every channel of every point of the images). */ 149 SimdOperationBinary8uAddition, 150 } SimdOperationBinary8uType; 151 152 /*! @ingroup c_types 153 Describes pixel format types of an image. 154 In particular this type is used in functions ::SimdBayerToBgr, ::SimdBayerToBgra, ::SimdBgraToBayer and ::SimdBgrToBayer. 155 \note This type is corresponds to C++ type Simd::View::Format. 156 */ 157 typedef enum 158 { 159 /*! An undefined pixel format. */ 160 SimdPixelFormatNone = 0, 161 /*! A 8-bit gray pixel format. */ 162 SimdPixelFormatGray8, 163 /*! A 24-bit (3 8-bit channels) BGR (Blue, Green, Red) pixel format. */ 164 SimdPixelFormatBgr24, 165 /*! A 32-bit (4 8-bit channels) BGRA (Blue, Green, Red, Alpha) pixel format. */ 166 SimdPixelFormatBgra32, 167 /*! A single channel 16-bit integer pixel format. */ 168 SimdPixelFormatInt16, 169 /*! A single channel 32-bit integer pixel format. */ 170 SimdPixelFormatInt32, 171 /*! A single channel 64-bit integer pixel format. */ 172 SimdPixelFormatInt64, 173 /*! A single channel 32-bit float point pixel format. */ 174 SimdPixelFormatFloat, 175 /*! A single channel 64-bit float point pixel format. */ 176 SimdPixelFormatDouble, 177 /*! A 8-bit Bayer pixel format (GRBG). */ 178 SimdPixelFormatBayerGrbg, 179 /*! A 8-bit Bayer pixel format (GBRG). */ 180 SimdPixelFormatBayerGbrg, 181 /*! A 8-bit Bayer pixel format (RGGB). */ 182 SimdPixelFormatBayerRggb, 183 /*! A 8-bit Bayer pixel format (BGGR). */ 184 SimdPixelFormatBayerBggr, 185 /*! A 24-bit (3 8-bit channels) HSV (Hue, Saturation, Value) pixel format. */ 186 SimdPixelFormatHsv24, 187 /*! A 24-bit (3 8-bit channels) HSL (Hue, Saturation, Lightness) pixel format. */ 188 SimdPixelFormatHsl24, 189 /*! A 24-bit (3 8-bit channels) RGB (Red, Green, Blue) pixel format. */ 190 SimdPixelFormatRgb24, 191 } SimdPixelFormatType; 192 193 /*! @ingroup c_types 194 Describes type of algorithm used for image reducing (downscale in 2 times) (see function Simd::ReduceGray). 195 */ 196 enum SimdReduceType 197 { 198 SimdReduce2x2, /*!< Using of function ::SimdReduceGray2x2 for image reducing. */ 199 SimdReduce3x3, /*!< Using of function ::SimdReduceGray3x3 for image reducing. */ 200 SimdReduce4x4, /*!< Using of function ::SimdReduceGray4x4 for image reducing. */ 201 SimdReduce5x5, /*!< Using of function ::SimdReduceGray5x5 for image reducing. */ 202 }; 203 204 /*! @ingroup resizing 205 Describes resized image channel types. 206 */ 207 typedef enum 208 { 209 /*! 8-bit integer channel type. */ 210 SimdResizeChannelByte, 211 /*! 32-bit float channel type. */ 212 SimdResizeChannelFloat, 213 } SimdResizeChannelType; 214 215 /*! @ingroup resizing 216 Describes methods used in oreder to resize image. 217 */ 218 typedef enum 219 { 220 /*! Bilinear method. */ 221 SimdResizeMethodBilinear, 222 /*! caffe::interp compatible method. */ 223 SimdResizeMethodCaffeInterp, 224 /*! Area method. */ 225 SimdResizeMethodArea, 226 } SimdResizeMethodType; 227 228 // ViSP custom SIMD code 229 typedef enum 230 { 231 /*! 4-connexity. */ 232 SimdImageConnexity4, 233 /*! 8-connexity. */ 234 SimdImageConnexity8 235 } SimdImageConnexityType; 236 237 //#if defined(WIN32) && !defined(SIMD_STATIC) 238 //# ifdef SIMD_EXPORTS 239 //# define SIMD_API __declspec(dllexport) 240 //# else//SIMD_EXPORTS 241 //# define SIMD_API __declspec(dllimport) 242 //# endif//SIMD_EXPORTS 243 //#else //WIN32 244 //# define SIMD_API 245 //#endif//WIN32 246 247 #define SIMD_API 248 249 #ifdef __cplusplus 250 extern "C" 251 { 252 #endif//__cplusplus 253 254 /*! @ingroup info 255 256 \fn const char * SimdVersion(); 257 258 \short Gets version of %Simd Library. 259 260 \return string with version of %Simd Library (major version number, minor version number, release number, number of SVN's commits). 261 */ 262 SIMD_API const char * SimdVersion(); 263 264 /*! @ingroup info 265 266 \fn const char *SimdPerformanceStatistic(); 267 268 \short Gets internal performance statistics of %Simd Library. 269 270 \note %Simd Library have to be build with defined SIMD_PERFORMANCE_STATISTIC macro. 271 272 \return string with internal performance statistics of %Simd Library. 273 */ 274 SIMD_API const char * SimdPerformanceStatistic(); 275 276 /*! @ingroup memory 277 278 \fn void * SimdAllocate(size_t size, size_t align); 279 280 \short Allocates aligned memory block. 281 282 \note The memory allocated by this function is must be deleted by function ::SimdFree. 283 284 \param [in] size - a size of memory block. 285 \param [in] align - a required alignment of memory block. 286 287 \return a pointer to allocated memory. 288 */ 289 SIMD_API void * SimdAllocate(size_t size, size_t align); 290 291 /*! @ingroup memory 292 293 \fn void SimdFree(void * ptr); 294 295 \short Frees aligned memory block. 296 297 \note This function frees a memory allocated by function ::SimdAllocate. 298 299 \param [in] ptr - a pointer to the memory to be deleted. 300 */ 301 SIMD_API void SimdFree(void * ptr); 302 303 /*! @ingroup memory 304 305 \fn size_t SimdAlign(size_t size, size_t align); 306 307 \short Gets aligned size. 308 309 \param [in] size - an original size. 310 \param [in] align - a required alignment. 311 312 \return an aligned size. 313 */ 314 SIMD_API size_t SimdAlign(size_t size, size_t align); 315 316 /*! @ingroup memory 317 318 \fn size_t SimdAlignment(); 319 320 \short Gets alignment required for the most productive work of the Simd Library. 321 322 \return a required alignment. 323 */ 324 SIMD_API size_t SimdAlignment(); 325 326 /*! @ingroup memory 327 328 \fn void SimdRelease(void * context); 329 330 \short Releases context created with using of Simd Library API. 331 332 \note This function releases a context created by functions ::SimdDetectionLoadA and ::SimdDetectionInit. 333 334 \param [in] context - a context to be released. 335 */ 336 SIMD_API void SimdRelease(void * context); 337 338 /*! @ingroup cpu_flags 339 340 \fn SimdBool SimdGetFastMode(); 341 342 \short Gets current CPU Flush-To-Zero (FTZ) and Denormals-Are-Zero (DAZ) flags. It is used in order to process subnormal numbers. 343 344 \return current 'fast' mode. 345 */ 346 SIMD_API SimdBool SimdGetFastMode(); 347 348 /*! @ingroup cpu_flags 349 350 \fn void SimdSetFastMode(SimdBool value); 351 352 \short Sets current CPU Flush-To-Zero (FTZ) and Denormals-Are-Zero (DAZ) flags. It is used in order to process subnormal numbers. 353 354 \param [in] value - a value of 'fast' mode. 355 */ 356 SIMD_API void SimdSetFastMode(SimdBool value); 357 358 /*! @ingroup bgra_conversion 359 360 \fn void SimdBgraToBgr(const uint8_t * bgra, size_t width, size_t height, size_t bgraStride, uint8_t * bgr, size_t bgrStride); 361 362 \short Converts 32-bit BGRA image to 24-bit BGR image. 363 364 All images must have the same width and height. 365 366 \note This function has a C++ wrapper Simd::BgraToBgr(const View<A>& bgra, View<A>& bgr). 367 368 \param [in] bgra - a pointer to pixels data of input 32-bit BGRA image. 369 \param [in] width - an image width. 370 \param [in] height - an image height. 371 \param [in] bgraStride - a row size of the bgra image. 372 \param [out] bgr - a pointer to pixels data of output 24-bit BGR image. 373 \param [in] bgrStride - a row size of the bgr image. 374 */ 375 SIMD_API void SimdBgraToBgr(const uint8_t * bgra, size_t width, size_t height, size_t bgraStride, uint8_t * bgr, size_t bgrStride); 376 377 /*! @ingroup bgra_conversion 378 379 \fn void SimdBgraToGray(const uint8_t * bgra, size_t width, size_t height, size_t bgraStride, uint8_t * gray, size_t grayStride); 380 381 \short Converts 32-bit BGRA image to 8-bit gray image. 382 383 All images must have the same width and height. 384 385 \note This function has a C++ wrapper Simd::BgraToGray(const View<A>& bgra, View<A>& gray). 386 387 \param [in] bgra - a pointer to pixels data of input 32-bit BGRA image. 388 \param [in] width - an image width. 389 \param [in] height - an image height. 390 \param [in] bgraStride - a row size of the bgra image. 391 \param [out] gray - a pointer to pixels data of output 8-bit gray image. 392 \param [in] grayStride - a row size of the gray image. 393 */ 394 SIMD_API void SimdBgraToGray(const uint8_t * bgra, size_t width, size_t height, size_t bgraStride, uint8_t * gray, size_t grayStride); 395 396 /*! @ingroup bgra_conversion 397 398 \fn void SimdRgbaToGray(const uint8_t * rgba, size_t width, size_t height, size_t rgbaStride, uint8_t * gray, size_t grayStride); 399 400 \short Converts 32-bit RGBA image to 8-bit gray image. 401 402 All images must have the same width and height. 403 404 \param [in] rgba - a pointer to pixels data of input 32-bit RGBA image. 405 \param [in] width - an image width. 406 \param [in] height - an image height. 407 \param [in] rgbaStride - a row size of the rgba image. 408 \param [out] gray - a pointer to pixels data of output 8-bit gray image. 409 \param [in] grayStride - a row size of the gray image. 410 */ 411 SIMD_API void SimdRgbaToGray(const uint8_t * rgba, size_t width, size_t height, size_t rgbaStride, uint8_t * gray, size_t grayStride); 412 413 /*! @ingroup bgr_conversion 414 415 \fn void SimdBgrToBgra(const uint8_t * bgr, size_t width, size_t height, size_t bgrStride, uint8_t * bgra, size_t bgraStride, uint8_t alpha); 416 417 \short Converts 24-bit BGR image to 32-bit BGRA image. 418 419 All images must have the same width and height. 420 421 \note This function has a C++ wrapper Simd::BgrToBgra(const View<A>& bgr, View<A>& bgra, uint8_t alpha). 422 423 \param [in] bgr - a pointer to pixels data of input 24-bit BGR image. 424 \param [in] width - an image width. 425 \param [in] height - an image height. 426 \param [in] bgrStride - a row size of the bgr image. 427 \param [out] bgra - a pointer to pixels data of output 32-bit BGRA image. 428 \param [in] bgraStride - a row size of the bgra image. 429 \param [in] alpha - a value of alpha channel. 430 */ 431 SIMD_API void SimdBgrToBgra(const uint8_t * bgr, size_t width, size_t height, size_t bgrStride, uint8_t * bgra, size_t bgraStride, uint8_t alpha); 432 433 /*! @ingroup bgr_conversion 434 435 \fn void SimdBgrToRgba(const uint8_t * bgr, size_t width, size_t height, size_t bgrStride, uint8_t * rgba, size_t rgbaStride, uint8_t alpha); 436 437 \short Converts 24-bit BGR image to 32-bit RGBA image. 438 439 All images must have the same width and height. 440 441 \param [in] bgr - a pointer to pixels data of input 24-bit BGR image. 442 \param [in] width - an image width. 443 \param [in] height - an image height. 444 \param [in] bgrStride - a row size of the bgr image. 445 \param [out] rgba - a pointer to pixels data of output 32-bit BGRA image. 446 \param [in] rgbaStride - a row size of the bgra image. 447 \param [in] alpha - a value of alpha channel. 448 */ 449 SIMD_API void SimdBgrToRgba(const uint8_t * bgr, size_t width, size_t height, size_t bgrStride, uint8_t * rgba, size_t rgbaStride, uint8_t alpha); 450 451 /*! @ingroup bgr_conversion 452 453 \fn void SimdBgraToRgba(const uint8_t * bgra, size_t width, size_t height, size_t bgraStride, uint8_t * rgba, size_t rgbaStride); 454 455 \short Converts 32-bit BGRA image to 32-bit RGBA image. 456 457 All images must have the same width and height. 458 459 \param [in] bgra - a pointer to pixels data of input 32-bit BGRA image. 460 \param [in] width - an image width. 461 \param [in] height - an image height. 462 \param [in] bgraStride - a row size of the bgra image. 463 \param [out] rgba - a pointer to pixels data of output 32-bit RGBA image. 464 \param [in] rgbaStride - a row size of the rgba image. 465 \param [in] alpha - a value of alpha channel. 466 */ 467 SIMD_API void SimdBgraToRgba(const uint8_t * bgra, size_t width, size_t height, size_t bgraStride, uint8_t * rgba, size_t rgbaStride); 468 469 /*! @ingroup other_conversion 470 471 \fn void SimdBgr48pToBgra32(const uint8_t * blue, size_t blueStride, size_t width, size_t height, const uint8_t * green, size_t greenStride, const uint8_t * red, size_t redStride, uint8_t * bgra, size_t bgraStride, uint8_t alpha); 472 473 \short Converts 48-bit planar BGR image to 32-bit BGRA image. 474 475 All images must have the same width and height. 476 477 \note This function has a C++ wrapper Simd::Bgr48pToBgra32(const View<A>& blue, const View<A>& green, const View<A>& red, View<A>& bgra, uint8_t alpha). 478 479 \param [in] blue - a pointer to pixels data of input 16-bit image with blue color plane. 480 \param [in] blueStride - a row size of the blue image. 481 \param [in] width - an image width. 482 \param [in] height - an image height. 483 \param [in] green - a pointer to pixels data of input 16-bit image with green color plane. 484 \param [in] greenStride - a row size of the blue image. 485 \param [in] red - a pointer to pixels data of input 16-bit image with red color plane. 486 \param [in] redStride - a row size of the red image. 487 \param [out] bgra - a pointer to pixels data of output 32-bit BGRA image. 488 \param [in] bgraStride - a row size of the bgra image. 489 \param [in] alpha - a value of alpha channel. 490 */ 491 SIMD_API void SimdBgr48pToBgra32(const uint8_t * blue, size_t blueStride, size_t width, size_t height, 492 const uint8_t * green, size_t greenStride, const uint8_t * red, size_t redStride, uint8_t * bgra, size_t bgraStride, uint8_t alpha); 493 494 /*! @ingroup bgr_conversion 495 496 \fn void SimdBgrToGray(const uint8_t * bgr, size_t width, size_t height, size_t bgrStride, uint8_t * gray, size_t grayStride); 497 498 \short Converts 24-bit BGR image to 8-bit gray image. 499 500 All images must have the same width and height. 501 502 \note This function has a C++ wrapper Simd::BgrToGray(const View<A>& bgr, View<A>& gray). 503 504 \param [in] bgr - a pointer to pixels data of input 24-bit BGR image. 505 \param [in] width - an image width. 506 \param [in] height - an image height. 507 \param [in] bgrStride - a row size of the bgr image. 508 \param [out] gray - a pointer to pixels data of output 8-bit gray image. 509 \param [in] grayStride - a row size of the gray image. 510 */ 511 SIMD_API void SimdBgrToGray(const uint8_t * bgr, size_t width, size_t height, size_t bgrStride, uint8_t * gray, size_t grayStride); 512 513 /*! @ingroup bgr_conversion 514 515 \fn void SimdRgbToGray(const uint8_t * rgb, size_t width, size_t height, size_t rgbStride, uint8_t * gray, size_t grayStride); 516 517 \short Converts 24-bit RGB image to 8-bit gray image. 518 519 All images must have the same width and height. 520 521 \param [in] rgb - a pointer to pixels data of input 24-bit BGR image. 522 \param [in] width - an image width. 523 \param [in] height - an image height. 524 \param [in] rgbStride - a row size of the bgr image. 525 \param [out] gray - a pointer to pixels data of output 8-bit gray image. 526 \param [in] grayStride - a row size of the gray image. 527 */ 528 SIMD_API void SimdRgbToGray(const uint8_t * rgb, size_t width, size_t height, size_t rgbStride, uint8_t * gray, size_t grayStride); 529 530 /*! @ingroup bgr_conversion 531 532 \fn void SimdBgrToRgb(const uint8_t * bgr, size_t bgrStride, size_t width, size_t height, uint8_t * rgb, size_t rgbStride); 533 534 \short Converts 24-bit BGR image to 24-bit RGB image (also it performs backward conversion). 535 536 All images must have the same width and height. 537 538 \note This function has a C++ wrapper Simd::BgrToRgb(const View<A> & bgr, View<A> & rgb). 539 540 \param [in] bgr - a pointer to pixels data of input 24-bit BGR image. 541 \param [in] bgrStride - a row size of the bgr image. 542 \param [in] width - an image width. 543 \param [in] height - an image height. 544 \param [out] rgb - a pointer to pixels data of output 24-bit RGB image. 545 \param [in] rgbStride - a row size of the rgb image. 546 */ 547 SIMD_API void SimdBgrToRgb(const uint8_t * bgr, size_t bgrStride, size_t width, size_t height, uint8_t * rgb, size_t rgbStride); 548 549 /*! @ingroup copying 550 551 \fn void SimdCopy(const uint8_t * src, size_t srcStride, size_t width, size_t height, size_t pixelSize, uint8_t * dst, size_t dstStride); 552 553 \short Copies pixels data of image from source to destination. 554 555 All images must have the same width, height and format. 556 557 \note This function has a C++ wrapper Simd::Copy(const View<A> & src, View<B> & dst). 558 559 \param [in] src - a pointer to pixels data of source image. 560 \param [in] srcStride - a row size of the src image. 561 \param [in] width - an image width. 562 \param [in] height - an image height. 563 \param [in] pixelSize - a size of the image pixel. 564 \param [out] dst - a pointer to pixels data of destination image. 565 \param [in] dstStride - a row size of the dst image. 566 */ 567 SIMD_API void SimdCopy(const uint8_t * src, size_t srcStride, size_t width, size_t height, size_t pixelSize, uint8_t * dst, size_t dstStride); 568 569 /*! @ingroup copying 570 571 \fn void SimdCopyFrame(const uint8_t * src, size_t srcStride, size_t width, size_t height, size_t pixelSize, size_t frameLeft, size_t frameTop, size_t frameRight, size_t frameBottom, uint8_t * dst, size_t dstStride); 572 573 \short Copies pixels data of image from source to destination except for the portion bounded frame. 574 575 All images must have the same width, height and format. 576 577 \note This function has a C++ wrapper Simd::CopyFrame(const View<A>& src, const Rectangle<ptrdiff_t> & frame, View<A>& dst). 578 579 \param [in] src - a pointer to pixels data of source image. 580 \param [in] srcStride - a row size of the src image. 581 \param [in] width - an image width. 582 \param [in] height - an image height. 583 \param [in] pixelSize - a size of the image pixel. 584 \param [in] frameLeft - a frame left side. 585 \param [in] frameTop - a frame top side. 586 \param [in] frameRight - a frame right side. 587 \param [in] frameBottom - a frame bottom side. 588 \param [out] dst - a pointer to pixels data of destination image. 589 \param [in] dstStride - a row size of the dst image. 590 */ 591 SIMD_API void SimdCopyFrame(const uint8_t * src, size_t srcStride, size_t width, size_t height, size_t pixelSize, 592 size_t frameLeft, size_t frameTop, size_t frameRight, size_t frameBottom, uint8_t * dst, size_t dstStride); 593 594 /*! @ingroup other_conversion 595 596 \fn void SimdDeinterleaveBgr(const uint8_t * bgr, size_t bgrStride, size_t width, size_t height, uint8_t * b, size_t bStride, uint8_t * g, size_t gStride, uint8_t * r, size_t rStride); 597 598 \short Deinterleaves 24-bit BGR interleaved image into separated 8-bit Blue, Green and Red planar images. 599 600 All images must have the same width and height. 601 602 \note This function has a C++ wrapper Simd::DeinterleaveBgr(const View<A>& bgr, View<A>& b, View<A>& g, View<A>& r). 603 604 \param [in] bgr - a pointer to pixels data of input 24-bit BGR interleaved image. 605 \param [in] bgrStride - a row size of the bgr image. 606 \param [in] width - an image width. 607 \param [in] height - an image height. 608 \param [out] b - a pointer to pixels data of 8-bit Blue planar image. 609 \param [in] bStride - a row size of the b image. 610 \param [out] g - a pointer to pixels data of 8-bit Green planar image. 611 \param [in] gStride - a row size of the g image. 612 \param [out] r - a pointer to pixels data of 8-bit Red planar image. 613 \param [in] rStride - a row size of the r image. 614 */ 615 SIMD_API void SimdDeinterleaveBgr(const uint8_t * bgr, size_t bgrStride, size_t width, size_t height, 616 uint8_t * b, size_t bStride, uint8_t * g, size_t gStride, uint8_t * r, size_t rStride); 617 618 /*! @ingroup other_conversion 619 620 \fn void SimdDeinterleaveBgra(const uint8_t * bgra, size_t bgraStride, size_t width, size_t height, uint8_t * b, size_t bStride, uint8_t * g, size_t gStride, uint8_t * r, size_t rStride, uint8_t * a, size_t aStride); 621 622 \short Deinterleaves 32-bit BGRA interleaved image into separated 8-bit Blue, Green, Red and Alpha planar images. 623 624 All images must have the same width and height. 625 626 \note This function has a C++ wrapper Simd::DeinterleaveBgra(const View<A>& bgra, View<A>& b, View<A>& g, View<A>& r, View<A>& a). 627 628 \param [in] bgra - a pointer to pixels data of input 32-bit BGRA interleaved image. 629 \param [in] bgraStride - a row size of the bgra image. 630 \param [in] width - an image width. 631 \param [in] height - an image height. 632 \param [out] b - a pointer to pixels data of 8-bit Blue planar image. 633 \param [in] bStride - a row size of the b image. 634 \param [out] g - a pointer to pixels data of 8-bit Green planar image. 635 \param [in] gStride - a row size of the g image. 636 \param [out] r - a pointer to pixels data of 8-bit Red planar image. 637 \param [in] rStride - a row size of the r image. 638 \param [out] a - a pointer to pixels data of 8-bit Alpha planar image. 639 \param [in] aStride - a row size of the a image. 640 */ 641 SIMD_API void SimdDeinterleaveBgra(const uint8_t * bgra, size_t bgraStride, size_t width, size_t height, 642 uint8_t * b, size_t bStride, uint8_t * g, size_t gStride, uint8_t * r, size_t rStride, uint8_t * a, size_t aStride); 643 644 /*! @ingroup gaussian_filter 645 646 \fn void SimdGaussianBlur3x3(const uint8_t * src, size_t srcStride, size_t width, size_t height, size_t channelCount, uint8_t * dst, size_t dstStride); 647 648 \short Performs Gaussian blur filtration with window 3x3. 649 650 For every point: 651 \verbatim 652 dst[x, y] = (src[x-1, y-1] + 2*src[x, y-1] + src[x+1, y-1] + 653 2*(src[x-1, y] + 2*src[x, y] + src[x+1, y]) + 654 src[x-1, y+1] + 2*src[x, y+1] + src[x+1, y+1] + 8) / 16; 655 \endverbatim 656 657 All images must have the same width, height and format (8-bit gray, 16-bit UV, 24-bit BGR or 32-bit BGRA). 658 659 \note This function has a C++ wrapper Simd::GaussianBlur3x3(const View<A>& src, View<A>& dst). 660 661 \param [in] src - a pointer to pixels data of source image. 662 \param [in] srcStride - a row size of the src image. 663 \param [in] width - an image width. 664 \param [in] height - an image height. 665 \param [in] channelCount - a channel count. 666 \param [out] dst - a pointer to pixels data of destination image. 667 \param [in] dstStride - a row size of the dst image. 668 */ 669 SIMD_API void SimdGaussianBlur3x3(const uint8_t * src, size_t srcStride, size_t width, size_t height, 670 size_t channelCount, uint8_t * dst, size_t dstStride); 671 672 /*! @ingroup gaussian_filter 673 \fn void * SimdGaussianBlurInit(size_t width, size_t height, size_t channels, const float * sigma, const float* epsilon); 674 \short Creates Gaussian blur filter context. 675 In particular calculates Gaussian blur coefficients: 676 \verbatim 677 half = floor(sqrt(log(1/epsilon)) * sigma); 678 weight[2*half + 1]; 679 for(x = -half; x <= half; ++x) 680 weight[x + half] = exp(-sqr(x / sigma) / 2); 681 sum = 0; 682 for (x = -half; x <= half; ++x) 683 sum += weight[x + half]; 684 for (x = -half; x <= half; ++x) 685 weight[x + half] /= sum; 686 \endverbatim 687 \param [in] width - a width of input and output image. 688 \param [in] height - a height of input and output image. 689 \param [in] channels - a channel number of input and output image. Its value must be in range [1..4]. 690 \param [in] sigma - a pointer to sigma parameter (blur radius). MIts value must be greater than 0.000001. 691 \param [in] epsilon - a pointer to epsilon parameter (permissible relative error). 692 Its value must be greater than 0.000001. Pointer can be NULL and by default value 0.001 is used. 693 \return a pointer to filter context. On error it returns NULL. 694 This pointer is used in functions ::SimdGaussianBlurRun. 695 It must be released with using of function ::SimdRelease. 696 */ 697 SIMD_API void* SimdGaussianBlurInit(size_t width, size_t height, size_t channels, const float * sigma, const float* epsilon); 698 699 /*! @ingroup gaussian_filter 700 \fn void SimdGaussianBlurRun(const void* filter, const uint8_t* src, size_t srcStride, uint8_t* dst, size_t dstStride); 701 \short Performs image Gaussian bluring. 702 Bluring algorithm for every point: 703 \verbatim 704 sum = 0; 705 for(x = -half; x <= half; ++x) 706 { 707 sx = min(max(0, dx + x), width - 1); 708 for(y = -half; y <= half; ++y) 709 { 710 sy = min(max(0, dy + y), height - 1); 711 sum += src[sx, sy]*weight[x + half]*weight[y + half]; 712 } 713 } 714 dst[dx, dy] = sum; 715 \endverbatim 716 \param [in] filter - a filter context. It must be created by function ::SimdGaussianBlurInit and released by function ::SimdRelease. 717 \param [in] src - a pointer to pixels data of the original input image. 718 \param [in] srcStride - a row size (in bytes) of the input image. 719 \param [out] dst - a pointer to pixels data of the filtered output image. 720 \param [in] dstStride - a row size (in bytes) of the output image. 721 */ 722 SIMD_API void SimdGaussianBlurRun(const void* filter, const uint8_t* src, size_t srcStride, uint8_t* dst, size_t dstStride); 723 724 /*! @ingroup gray_conversion 725 726 \fn void SimdGrayToBgr(const uint8_t * gray, size_t width, size_t height, size_t grayStride, uint8_t * bgr, size_t bgrStride); 727 728 \short Converts 8-bit gray image to 24-bit BGR image. 729 730 All images must have the same width and height. 731 732 \note This function has a C++ wrapper Simd::GrayToBgr(const View<A>& gray, View<A>& bgr). 733 734 \param [in] gray - a pointer to pixels data of input 8-bit gray image. 735 \param [in] width - an image width. 736 \param [in] height - an image height. 737 \param [in] grayStride - a row size of the gray image. 738 \param [out] bgr - a pointer to pixels data of output 24-bit BGR image. 739 \param [in] bgrStride - a row size of the bgr image. 740 */ 741 SIMD_API void SimdGrayToBgr(const uint8_t *gray, size_t width, size_t height, size_t grayStride, uint8_t *bgr, size_t bgrStride); 742 743 /*! @ingroup gray_conversion 744 745 \fn void SimdGrayToBgra(const uint8_t * gray, size_t width, size_t height, size_t grayStride, uint8_t * bgra, size_t bgraStride, uint8_t alpha); 746 747 \short Converts 8-bit gray image to 32-bit BGRA image. 748 749 All images must have the same width and height. 750 751 \note This function has a C++ wrapper Simd::GrayToBgra(const View<A>& gray, View<A>& bgra, uint8_t alpha). 752 753 \param [in] gray - a pointer to pixels data of input 8-bit gray image. 754 \param [in] width - an image width. 755 \param [in] height - an image height. 756 \param [in] grayStride - a row size of the gray image. 757 \param [out] bgra - a pointer to pixels data of output 32-bit BGRA image. 758 \param [in] bgraStride - a row size of the bgra image. 759 \param [in] alpha - a value of alpha channel. 760 */ 761 SIMD_API void SimdGrayToBgra(const uint8_t *gray, size_t width, size_t height, size_t grayStride, 762 uint8_t *bgra, size_t bgraStride, uint8_t alpha); 763 764 /*! @ingroup other_conversion 765 766 \fn void SimdInterleaveBgr(const uint8_t * b, size_t bStride, const uint8_t * g, size_t gStride, const uint8_t * r, size_t rStride, size_t width, size_t height, uint8_t * bgr, size_t bgrStride); 767 768 \short Interleaves 8-bit Blue, Green and Red planar images into one 24-bit BGR interleaved image. 769 770 All images must have the same width and height. 771 772 \note This function has a C++ wrapper Simd::InterleaveBgr(const View<A>& b, const View<A>& g, const View<A>& r, View<A>& bgr). 773 774 \param [in] b - a pointer to pixels data of input 8-bit Blue planar image. 775 \param [in] bStride - a row size of the b image. 776 \param [in] g - a pointer to pixels data of input 8-bit Green planar image. 777 \param [in] gStride - a row size of the g image. 778 \param [in] r - a pointer to pixels data of input 8-bit Red planar image. 779 \param [in] rStride - a row size of the r image. 780 \param [in] width - an image width. 781 \param [in] height - an image height. 782 \param [out] bgr - a pointer to pixels data of output 24-bit BGR interleaved image. 783 \param [in] bgrStride - a row size of the bgr image. 784 */ 785 SIMD_API void SimdInterleaveBgr(const uint8_t * b, size_t bStride, const uint8_t * g, size_t gStride, const uint8_t * r, size_t rStride, 786 size_t width, size_t height, uint8_t * bgr, size_t bgrStride); 787 788 /*! @ingroup other_conversion 789 790 \fn void SimdInterleaveBgra(const uint8_t * b, size_t bStride, const uint8_t * g, size_t gStride, const uint8_t * r, size_t rStride, const uint8_t * a, size_t aStride, size_t width, size_t height, uint8_t * bgra, size_t bgraStride); 791 792 \short Interleaves 8-bit Blue, Green, Red and Alpha planar images into one 32-bit BGRA interleaved image. 793 794 All images must have the same width and height. 795 796 \note This function has a C++ wrapper Simd::InterleaveBgra(const View<A>& b, const View<A>& g, const View<A>& r, const View<A>& a, View<A>& bgra). 797 798 \param [in] b - a pointer to pixels data of input 8-bit Blue planar image. 799 \param [in] bStride - a row size of the b image. 800 \param [in] g - a pointer to pixels data of input 8-bit Green planar image. 801 \param [in] gStride - a row size of the g image. 802 \param [in] r - a pointer to pixels data of input 8-bit Red planar image. 803 \param [in] rStride - a row size of the r image. 804 \param [in] a - a pointer to pixels data of input 8-bit Alpha planar image. 805 \param [in] aStride - a row size of the a image. 806 \param [in] width - an image width. 807 \param [in] height - an image height. 808 \param [out] bgra - a pointer to pixels data of output 32-bit BGRA interleaved image. 809 \param [in] bgraStride - a row size of the bgr image. 810 */ 811 SIMD_API void SimdInterleaveBgra(const uint8_t * b, size_t bStride, const uint8_t * g, size_t gStride, const uint8_t * r, size_t rStride, const uint8_t * a, size_t aStride, 812 size_t width, size_t height, uint8_t * bgra, size_t bgraStride); 813 814 /*! @ingroup other_filter 815 816 \fn void SimdMeanFilter3x3(const uint8_t * src, size_t srcStride, size_t width, size_t height, size_t channelCount, uint8_t * dst, size_t dstStride); 817 818 \short Performs an averaging with window 3x3. 819 820 For every point: 821 \verbatim 822 dst[x, y] = (src[x-1, y-1] + src[x, y-1] + src[x+1, y-1] + 823 src[x-1, y] + src[x, y] + src[x+1, y] + 824 src[x-1, y+1] + src[x, y+1] + src[x+1, y+1] + 4) / 9; 825 \endverbatim 826 827 All images must have the same width, height and format (8-bit gray, 16-bit UV, 24-bit BGR or 32-bit BGRA). 828 829 \note This function has a C++ wrapper Simd::MeanFilter3x3(const View<A>& src, View<A>& dst). 830 831 \param [in] src - a pointer to pixels data of source image. 832 \param [in] srcStride - a row size of the src image. 833 \param [in] width - an image width. 834 \param [in] height - an image height. 835 \param [in] channelCount - a channel count. 836 \param [out] dst - a pointer to pixels data of destination image. 837 \param [in] dstStride - a row size of the dst image. 838 */ 839 SIMD_API void SimdMeanFilter3x3(const uint8_t * src, size_t srcStride, size_t width, size_t height, 840 size_t channelCount, uint8_t * dst, size_t dstStride); 841 842 /*! @ingroup median_filter 843 844 \fn void SimdMedianFilterRhomb3x3(const uint8_t * src, size_t srcStride, size_t width, size_t height, size_t channelCount, uint8_t * dst, size_t dstStride); 845 846 \short Performs median filtration of input image (filter window is a rhomb 3x3). 847 848 All images must have the same width, height and format (8-bit gray, 16-bit UV, 24-bit BGR or 32-bit BGRA). 849 850 \note This function has a C++ wrappers: Simd::MedianFilterRhomb3x3(const View<A>& src, View<A>& dst). 851 852 \param [in] src - a pointer to pixels data of original input image. 853 \param [in] srcStride - a row size of src image. 854 \param [in] width - an image width. 855 \param [in] height - an image height. 856 \param [in] channelCount - a channel count. 857 \param [out] dst - a pointer to pixels data of filtered output image. 858 \param [in] dstStride - a row size of dst image. 859 */ 860 SIMD_API void SimdMedianFilterRhomb3x3(const uint8_t * src, size_t srcStride, size_t width, size_t height, 861 size_t channelCount, uint8_t * dst, size_t dstStride); 862 863 /*! @ingroup median_filter 864 865 \fn void SimdMedianFilterRhomb5x5(const uint8_t * src, size_t srcStride, size_t width, size_t height, size_t channelCount, uint8_t * dst, size_t dstStride); 866 867 \short Performs median filtration of input image (filter window is a rhomb 5x5). 868 869 All images must have the same width, height and format (8-bit gray, 16-bit UV, 24-bit BGR or 32-bit BGRA). 870 871 \note This function has a C++ wrappers: Simd::MedianFilterRhomb5x5(const View<A>& src, View<A>& dst). 872 873 \param [in] src - a pointer to pixels data of original input image. 874 \param [in] srcStride - a row size of src image. 875 \param [in] width - an image width. 876 \param [in] height - an image height. 877 \param [in] channelCount - a channel count. 878 \param [out] dst - a pointer to pixels data of filtered output image. 879 \param [in] dstStride - a row size of dst image. 880 */ 881 SIMD_API void SimdMedianFilterRhomb5x5(const uint8_t * src, size_t srcStride, size_t width, size_t height, 882 size_t channelCount, uint8_t * dst, size_t dstStride); 883 884 /*! @ingroup median_filter 885 886 \fn void SimdMedianFilterSquare3x3(const uint8_t * src, size_t srcStride, size_t width, size_t height, size_t channelCount, uint8_t * dst, size_t dstStride); 887 888 \short Performs median filtration of input image (filter window is a square 3x3). 889 890 All images must have the same width, height and format (8-bit gray, 16-bit UV, 24-bit BGR or 32-bit BGRA). 891 892 \note This function has a C++ wrappers: Simd::MedianFilterSquare3x3(const View<A>& src, View<A>& dst). 893 894 \param [in] src - a pointer to pixels data of original input image. 895 \param [in] srcStride - a row size of src image. 896 \param [in] width - an image width. 897 \param [in] height - an image height. 898 \param [in] channelCount - a channel count. 899 \param [out] dst - a pointer to pixels data of filtered output image. 900 \param [in] dstStride - a row size of dst image. 901 */ 902 SIMD_API void SimdMedianFilterSquare3x3(const uint8_t * src, size_t srcStride, size_t width, size_t height, 903 size_t channelCount, uint8_t * dst, size_t dstStride); 904 905 /*! @ingroup median_filter 906 907 \fn void SimdMedianFilterSquare5x5(const uint8_t * src, size_t srcStride, size_t width, size_t height, size_t channelCount, uint8_t * dst, size_t dstStride); 908 909 \short Performs median filtration of input image (filter window is a square 5x5). 910 911 All images must have the same width, height and format (8-bit gray, 16-bit UV, 24-bit BGR or 32-bit BGRA). 912 913 \note This function has a C++ wrappers: Simd::MedianFilterSquare5x5(const View<A>& src, View<A>& dst). 914 915 \param [in] src - a pointer to pixels data of original input image. 916 \param [in] srcStride - a row size of src image. 917 \param [in] width - an image width. 918 \param [in] height - an image height. 919 \param [in] channelCount - a channel count. 920 \param [out] dst - a pointer to pixels data of filtered output image. 921 \param [in] dstStride - a row size of dst image. 922 */ 923 SIMD_API void SimdMedianFilterSquare5x5(const uint8_t * src, size_t srcStride, size_t width, size_t height, 924 size_t channelCount, uint8_t * dst, size_t dstStride); 925 926 /*! @ingroup operation 927 928 \fn void SimdOperationBinary8u(const uint8_t * a, size_t aStride, const uint8_t * b, size_t bStride, size_t width, size_t height, size_t channelCount, uint8_t * dst, size_t dstStride, SimdOperationBinary8uType type); 929 930 \short Performs given operation between two images. 931 932 All images must have the same width, height and format (8-bit gray, 16-bit UV (UV plane of NV12 pixel format), 24-bit BGR or 32-bit BGRA). 933 934 \note This function has a C++ wrappers: Simd::OperationBinary8u(const View<A>& a, const View<A>& b, View<A>& dst, SimdOperationBinary8uType type). 935 936 \param [in] a - a pointer to pixels data of the first input image. 937 \param [in] aStride - a row size of the first image. 938 \param [in] b - a pointer to pixels data of the second input image. 939 \param [in] bStride - a row size of the second image. 940 \param [in] width - an image width. 941 \param [in] height - an image height. 942 \param [in] channelCount - a channel count. 943 \param [out] dst - a pointer to pixels data of output image. 944 \param [in] dstStride - a row size of dst image. 945 \param [in] type - a type of operation (see ::SimdOperationBinary8uType). 946 */ 947 SIMD_API void SimdOperationBinary8u(const uint8_t * a, size_t aStride, const uint8_t * b, size_t bStride, 948 size_t width, size_t height, size_t channelCount, uint8_t * dst, size_t dstStride, SimdOperationBinary8uType type); 949 950 /*! @ingroup resizing 951 952 \fn void SimdReduceColor2x2(const uint8_t * src, size_t srcWidth, size_t srcHeight, size_t srcStride, uint8_t * dst, size_t dstWidth, size_t dstHeight, size_t dstStride, size_t channelCount); 953 954 \short Performs reducing and Gaussian blurring (in two time) a 8-bit channel color image with using window 2x2. 955 956 For input and output image must be performed: dstWidth = (srcWidth + 1)/2, dstHeight = (srcHeight + 1)/2. 957 958 For all points: 959 \verbatim 960 dst[x, y, c] = (src[2*x, 2*y, c] + src[2*x, 2*y + 1, c] + src[2*x + 1, 2*y, c] + src[2*x + 1, 2*y + 1, c] + 2)/4; 961 \endverbatim 962 963 \note This function has a C++ wrappers: Simd::Reduce2x2(const View<A> & src, View<A> & dst). 964 965 \param [in] src - a pointer to pixels data of the original input image. 966 \param [in] srcWidth - a width of the input image. 967 \param [in] srcHeight - a height of the input image. 968 \param [in] srcStride - a row size of the input image. 969 \param [out] dst - a pointer to pixels data of the reduced output image. 970 \param [in] dstWidth - a width of the output image. 971 \param [in] dstHeight - a height of the output image. 972 \param [in] dstStride - a row size of the output image. 973 \param [in] channelCount - a nmber of channels for input and output images. 974 */ 975 SIMD_API void SimdReduceColor2x2(const uint8_t * src, size_t srcWidth, size_t srcHeight, size_t srcStride, 976 uint8_t * dst, size_t dstWidth, size_t dstHeight, size_t dstStride, size_t channelCount); 977 978 /*! @ingroup resizing 979 980 \fn void SimdReduceGray2x2(const uint8_t * src, size_t srcWidth, size_t srcHeight, size_t srcStride, uint8_t * dst, size_t dstWidth, size_t dstHeight, size_t dstStride); 981 982 \short Performs reducing and Gaussian blurring (in two time) a 8-bit gray image with using window 2x2. 983 984 For input and output image must be performed: dstWidth = (srcWidth + 1)/2, dstHeight = (srcHeight + 1)/2. 985 986 For all points: 987 \verbatim 988 dst[x, y] = (src[2*x, 2*y] + src[2*x, 2*y + 1] + src[2*x + 1, 2*y] + src[2*x + 1, 2*y + 1] + 2)/4; 989 \endverbatim 990 991 \note This function has a C++ wrappers: Simd::ReduceGray2x2(const View<A>& src, View<A>& dst). 992 993 \param [in] src - a pointer to pixels data of the original input image. 994 \param [in] srcWidth - a width of the input image. 995 \param [in] srcHeight - a height of the input image. 996 \param [in] srcStride - a row size of the input image. 997 \param [out] dst - a pointer to pixels data of the reduced output image. 998 \param [in] dstWidth - a width of the output image. 999 \param [in] dstHeight - a height of the output image. 1000 \param [in] dstStride - a row size of the output image. 1001 */ 1002 SIMD_API void SimdReduceGray2x2(const uint8_t * src, size_t srcWidth, size_t srcHeight, size_t srcStride, 1003 uint8_t * dst, size_t dstWidth, size_t dstHeight, size_t dstStride); 1004 1005 /*! @ingroup resizing 1006 1007 \fn void SimdReduceGray3x3(const uint8_t * src, size_t srcWidth, size_t srcHeight, size_t srcStride, uint8_t * dst, size_t dstWidth, size_t dstHeight, size_t dstStride, int compensation); 1008 1009 \short Performs reducing and Gaussian blurring (in two time) a 8-bit gray image with using window 3x3. 1010 1011 For input and output image must be performed: dstWidth = (srcWidth + 1)/2, dstHeight = (srcHeight + 1)/2. 1012 1013 For every point: 1014 \verbatim 1015 dst[x, y] = (src[2*x-1, 2*y-1] + 2*src[2*x, 2*y-1] + src[2*x+1, 2*y-1] + 1016 2*(src[2*x-1, 2*y] + 2*src[2*x, 2*y] + src[2*x+1, 2*y]) + 1017 src[2*x-1, 2*y+1] + 2*src[2*x, 2*y+1] + src[2*x+1, 2*y+1] + compensation ? 8 : 0) / 16; 1018 \endverbatim 1019 1020 \note This function has a C++ wrappers: Simd::ReduceGray3x3(const View<A>& src, View<A>& dst, bool compensation). 1021 1022 \param [in] src - a pointer to pixels data of the original input image. 1023 \param [in] srcWidth - a width of the input image. 1024 \param [in] srcHeight - a height of the input image. 1025 \param [in] srcStride - a row size of the input image. 1026 \param [out] dst - a pointer to pixels data of the reduced output image. 1027 \param [in] dstWidth - a width of the output image. 1028 \param [in] dstHeight - a height of the output image. 1029 \param [in] dstStride - a row size of the output image. 1030 \param [in] compensation - a flag of compensation of rounding. 1031 */ 1032 SIMD_API void SimdReduceGray3x3(const uint8_t * src, size_t srcWidth, size_t srcHeight, size_t srcStride, 1033 uint8_t * dst, size_t dstWidth, size_t dstHeight, size_t dstStride, int compensation); 1034 1035 /*! @ingroup resizing 1036 1037 \fn void SimdReduceGray4x4(const uint8_t * src, size_t srcWidth, size_t srcHeight, size_t srcStride, uint8_t * dst, size_t dstWidth, size_t dstHeight, size_t dstStride); 1038 1039 \short Performs reducing and Gaussian blurring (in two time) a 8-bit gray image with using window 4x4. 1040 1041 For input and output image must be performed: dstWidth = (srcWidth + 1)/2, dstHeight = (srcHeight + 1)/2. 1042 1043 For every point: 1044 \verbatim 1045 dst[x, y] = (src[2*x-1, 2*y-1] + 3*src[2*x, 2*y-1] + 3*src[2*x+1, 2*y-1] + src[2*x+2, 2*y-1] 1046 3*(src[2*x-1, 2*y] + 3*src[2*x, 2*y] + 3*src[2*x+1, 2*y] + src[2*x+2, 2*y]) + 1047 3*(src[2*x-1, 2*y+1] + 3*src[2*x, 2*y+1] + 3*src[2*x+1, 2*y+1] + src[2*x+2, 2*y+1]) + 1048 src[2*x-1, 2*y+2] + 3*src[2*x, 2*y+2] + 3*src[2*x+1, 2*y+2] + src[2*x+2, 2*y+2] + 32) / 64; 1049 \endverbatim 1050 1051 \note This function has a C++ wrappers: Simd::ReduceGray4x4(const View<A>& src, View<A>& dst). 1052 1053 \param [in] src - a pointer to pixels data of the original input image. 1054 \param [in] srcWidth - a width of the input image. 1055 \param [in] srcHeight - a height of the input image. 1056 \param [in] srcStride - a row size of the input image. 1057 \param [out] dst - a pointer to pixels data of the reduced output image. 1058 \param [in] dstWidth - a width of the output image. 1059 \param [in] dstHeight - a height of the output image. 1060 \param [in] dstStride - a row size of the output image. 1061 */ 1062 SIMD_API void SimdReduceGray4x4(const uint8_t * src, size_t srcWidth, size_t srcHeight, size_t srcStride, 1063 uint8_t * dst, size_t dstWidth, size_t dstHeight, size_t dstStride); 1064 1065 /*! @ingroup resizing 1066 1067 \fn void SimdReduceGray5x5(const uint8_t * src, size_t srcWidth, size_t srcHeight, size_t srcStride, uint8_t * dst, size_t dstWidth, size_t dstHeight, size_t dstStride, int compensation); 1068 1069 \short Performs reducing and Gaussian blurring (in two time) a 8-bit gray image with using window 5x5. 1070 1071 For input and output image must be performed: dstWidth = (srcWidth + 1)/2, dstHeight = (srcHeight + 1)/2. 1072 1073 For every point: 1074 \verbatim 1075 dst[x, y] = ( 1076 src[2*x-2, 2*y-2] + 4*src[2*x-1, 2*y-2] + 6*src[2*x, 2*y-2] + 4*src[2*x+1, 2*y-2] + src[2*x+2, 2*y-2] + 1077 4*(src[2*x-2, 2*y-1] + 4*src[2*x-1, 2*y-1] + 6*src[2*x, 2*y-1] + 4*src[2*x+1, 2*y-1] + src[2*x+2, 2*y-1]) + 1078 6*(src[2*x-2, 2*y] + 4*src[2*x-1, 2*y] + 6*src[2*x, 2*y] + 4*src[2*x+1, 2*y] + src[2*x+2, 2*y]) + 1079 4*(src[2*x-2, 2*y+1] + 4*src[2*x-1, 2*y+1] + 6*src[2*x, 2*y+1] + 4*src[2*x+1, 2*y+1] + src[2*x+2, 2*y+1]) + 1080 src[2*x-2, 2*y+2] + 4*src[2*x-1, 2*y+2] + 6*src[2*x, 2*y+2] + 4*src[2*x+1, 2*y+2] + src[2*x+2, 2*y+2] + 1081 compensation ? 128 : 0) / 256; 1082 \endverbatim 1083 1084 \note This function has a C++ wrappers: Simd::ReduceGray5x5(const Viewc<A>& src, View<A>& dst, bool compensation). 1085 1086 \param [in] src - a pointer to pixels data of the original input image. 1087 \param [in] srcWidth - a width of the input image. 1088 \param [in] srcHeight - a height of the input image. 1089 \param [in] srcStride - a row size of the input image. 1090 \param [out] dst - a pointer to pixels data of the reduced output image. 1091 \param [in] dstWidth - a width of the output image. 1092 \param [in] dstHeight - a height of the output image. 1093 \param [in] dstStride - a row size of the output image. 1094 \param [in] compensation - a flag of compensation of rounding. 1095 */ 1096 SIMD_API void SimdReduceGray5x5(const uint8_t * src, size_t srcWidth, size_t srcHeight, size_t srcStride, 1097 uint8_t * dst, size_t dstWidth, size_t dstHeight, size_t dstStride, int compensation); 1098 1099 /*! @ingroup resizing 1100 1101 \fn void SimdResizeBilinear(const uint8_t *src, size_t srcWidth, size_t srcHeight, size_t srcStride, uint8_t *dst, size_t dstWidth, size_t dstHeight, size_t dstStride, size_t channelCount); 1102 1103 \short Performs resizing of input image with using bilinear interpolation. 1104 1105 All images must have the same format (8-bit gray, 16-bit UV, 24-bit BGR or 32-bit BGRA). 1106 1107 \note This function has a C++ wrappers: Simd::ResizeBilinear(const View<A>& src, View<A>& dst). 1108 1109 \param [in] src - a pointer to pixels data of the original input image. 1110 \param [in] srcWidth - a width of the input image. 1111 \param [in] srcHeight - a height of the input image. 1112 \param [in] srcStride - a row size of the input image. 1113 \param [out] dst - a pointer to pixels data of the reduced output image. 1114 \param [in] dstWidth - a width of the output image. 1115 \param [in] dstHeight - a height of the output image. 1116 \param [in] dstStride - a row size of the output image. 1117 \param [in] channelCount - a channel count. 1118 */ 1119 SIMD_API void SimdResizeBilinear(const uint8_t *src, size_t srcWidth, size_t srcHeight, size_t srcStride, 1120 uint8_t *dst, size_t dstWidth, size_t dstHeight, size_t dstStride, size_t channelCount); 1121 1122 /*! @ingroup resizing 1123 1124 \fn void * SimdResizerInit(size_t srcX, size_t srcY, size_t dstX, size_t dstY, size_t channels, SimdResizeChannelType type, SimdResizeMethodType method); 1125 1126 \short Creates resize context. 1127 1128 \param [in] srcX - a width of the input image. 1129 \param [in] srcY - a height of the input image. 1130 \param [in] dstX - a width of the output image. 1131 \param [in] dstY - a height of the output image. 1132 \param [in] channels - a channel number of input and output image. 1133 \param [in] type - a type of input and output image channel. 1134 \param [in] method - a method used in order to resize image. 1135 \return a pointer to resize context. On error it returns NULL. 1136 This pointer is used in functions ::SimdResizerRun. 1137 It must be released with using of function ::SimdRelease. 1138 */ 1139 SIMD_API void * SimdResizerInit(size_t srcX, size_t srcY, size_t dstX, size_t dstY, size_t channels, SimdResizeChannelType type, SimdResizeMethodType method); 1140 1141 /*! @ingroup resizing 1142 1143 \fn void SimdResizerRun(const void * resizer, const uint8_t * src, size_t srcStride, uint8_t * dst, size_t dstStride); 1144 1145 \short Performs image resizing. 1146 1147 \param [in] resizer - a resize context. It must be created by function ::SimdResizerInit and released by function ::SimdRelease. 1148 \param [in] src - a pointer to pixels data of the original input image. 1149 \param [in] srcStride - a row size (in bytes) of the input image. 1150 \param [out] dst - a pointer to pixels data of the resized output image. 1151 \param [in] dstStride - a row size (in bytes) of the output image. 1152 */ 1153 SIMD_API void SimdResizerRun(const void * resizer, const uint8_t * src, size_t srcStride, uint8_t * dst, size_t dstStride); 1154 1155 /*! @ingroup resizing 1156 1157 \fn void SimdStretchGray2x2(const uint8_t * src, size_t srcWidth, size_t srcHeight, size_t srcStride, uint8_t * dst, size_t dstWidth, size_t dstHeight, size_t dstStride); 1158 1159 \short Stretches input 8-bit gray image in two times. 1160 1161 \note This function has a C++ wrappers: Simd::StretchGray2x2(const View<A>& src, View<A>& dst). 1162 1163 \param [in] src - a pointer to pixels data of the original input image. 1164 \param [in] srcWidth - a width of the input image. 1165 \param [in] srcHeight - a height of the input image. 1166 \param [in] srcStride - a row size of the input image. 1167 \param [out] dst - a pointer to pixels data of the stretched output image. 1168 \param [in] dstWidth - a width of the output image. 1169 \param [in] dstHeight - a height of the output image. 1170 \param [in] dstStride - a row size of the output image. 1171 */ 1172 SIMD_API void SimdStretchGray2x2(const uint8_t * src, size_t srcWidth, size_t srcHeight, size_t srcStride, 1173 uint8_t * dst, size_t dstWidth, size_t dstHeight, size_t dstStride); 1174 1175 /* ViSP custom SIMD code */ 1176 // vpImageMorphology::erosion() 1177 SIMD_API void SimdImageErosion(uint8_t * img, const uint8_t * buff, size_t width, size_t height, SimdImageConnexityType connexityType); 1178 1179 // vpImageMorphology::dilatation 1180 SIMD_API void SimdImageDilatation(uint8_t * img, const uint8_t * buff, size_t width, size_t height, SimdImageConnexityType connexityType); 1181 1182 // vpColVector::sum() 1183 SIMD_API double SimdVectorSum(const double * vec, size_t size); 1184 1185 // vpColVector::sumSquare() 1186 SIMD_API double SimdVectorSumSquare(const double * vec, size_t size); 1187 1188 // vpColVector::stdev() 1189 SIMD_API double SimdVectorStdev(const double * vec, size_t size, bool useBesselCorrection); 1190 1191 // vpColVector::hadamard(const vpColVector &v) 1192 SIMD_API void SimdVectorHadamard(const double * src1, const double * src2, size_t size, double * dst); 1193 1194 // vpMatrix::operator*(const vpVelocityTwistMatrix &V) 1195 SIMD_API void SimdMatMulTwist(const double * mat, size_t rows, const double * twist, double * dst); 1196 1197 // vpMatrix::transpose(vpMatrix &At) 1198 SIMD_API void SimdMatTranspose(const double * mat, size_t rows, size_t cols, double * dst); 1199 1200 // vpImageTools::imageDifference 1201 SIMD_API void SimdImageDifference(const unsigned char * img1, const unsigned char * img2, size_t size, unsigned char * imgDiff); 1202 1203 // vpImageTools::normalizedCorrelation 1204 SIMD_API void SimdNormalizedCorrelation(const double * img1, double mean1, const double * img2, double mean2, size_t size, 1205 double& a2, double& b2, double& ab, bool useOptimized); 1206 1207 // vpImageTools::normalizedCorrelation 1208 SIMD_API void SimdNormalizedCorrelation2(const double * img1, size_t width1, const double * img2, 1209 size_t width2, size_t height2, size_t i0, size_t j0, double& ab); 1210 1211 // vpImageTools::remap() 1212 SIMD_API void SimdRemap(const unsigned char * src, size_t channels, size_t width, size_t height, size_t offset, 1213 const int * mapU, const int * mapV, const float * mapDu, const float * mapDv, unsigned char * dst); 1214 1215 // vpMbTracker::computeJTR(const vpMatrix &interaction, const vpColVector &error, vpColVector &JTR) 1216 SIMD_API void SimdComputeJtR(const double * J, size_t rows, const double * R, double * dst); 1217 1218 #ifdef __cplusplus 1219 } 1220 #endif // __cplusplus 1221 1222 #endif//__SimdLib_h__ 1223