<|start_filename|>opencv/include/opencv2/features2d/hal/interface.h<|end_filename|>
#ifndef OPENCV_FEATURE2D_HAL_INTERFACE_H
#define OPENCV_FEATURE2D_HAL_INTERFACE_H

#include "opencv2/core/cvdef.h"
//! @addtogroup featrure2d_hal_interface
//! @{

//! @name Fast feature detector types
//! @sa cv::FastFeatureDetector
//! @{
#define CV_HAL_TYPE_5_8  0
#define CV_HAL_TYPE_7_12 1
#define CV_HAL_TYPE_9_16 2
//! @}

//! @name Key point
//! @sa cv::KeyPoint
//! @{
struct CV_EXPORTS cvhalKeyPoint
{
    float x;
    float y;
    float size;
    float angle;
    float response;
    int octave;
    int class_id;
};
//! @}

//! @}

#endif


<|start_filename|>opencv/include/opencv2/photo/cuda.hpp<|end_filename|>
/*M///////////////////////////////////////////////////////////////////////////////////////
//
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//  By downloading, copying, installing or using the software you agree to this license.
//  If you do not agree to this license, do not download, install,
//  copy or use the software.
//
//
//                           License Agreement
//                For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2008-2012, <NAME> Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//   * Redistribution's of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//
//   * Redistribution's in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//
//   * The name of the copyright holders may not be used to endorse or promote products
//     derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/

#ifndef OPENCV_PHOTO_CUDA_HPP
#define OPENCV_PHOTO_CUDA_HPP

#include "opencv2/core/cuda.hpp"

namespace cv { namespace cuda {

//! @addtogroup photo_denoise
//! @{

/** @brief Performs pure non local means denoising without any simplification, and thus it is not fast.

@param src Source image. Supports only CV_8UC1, CV_8UC2 and CV_8UC3.
@param dst Destination image.
@param h Filter sigma regulating filter strength for color.
@param search_window Size of search window.
@param block_size Size of block used for computing weights.
@param borderMode Border type. See borderInterpolate for details. BORDER_REFLECT101 ,
BORDER_REPLICATE , BORDER_CONSTANT , BORDER_REFLECT and BORDER_WRAP are supported for now.
@param stream Stream for the asynchronous version.

@sa
   fastNlMeansDenoising
 */
CV_EXPORTS void nonLocalMeans(InputArray src, OutputArray dst,
                              float h,
                              int search_window = 21,
                              int block_size = 7,
                              int borderMode = BORDER_DEFAULT,
                              Stream& stream = Stream::Null());

/** @brief Perform image denoising using Non-local Means Denoising algorithm
<http://www.ipol.im/pub/algo/bcm_non_local_means_denoising> with several computational
optimizations. Noise expected to be a gaussian white noise

@param src Input 8-bit 1-channel, 2-channel or 3-channel image.
@param dst Output image with the same size and type as src .
@param h Parameter regulating filter strength. Big h value perfectly removes noise but also
removes image details, smaller h value preserves details but also preserves some noise
@param search_window Size in pixels of the window that is used to compute weighted average for
given pixel. Should be odd. Affect performance linearly: greater search_window - greater
denoising time. Recommended value 21 pixels
@param block_size Size in pixels of the template patch that is used to compute weights. Should be
odd. Recommended value 7 pixels
@param stream Stream for the asynchronous invocations.

This function expected to be applied to grayscale images. For colored images look at
FastNonLocalMeansDenoising::labMethod.

@sa
   fastNlMeansDenoising
 */
CV_EXPORTS void fastNlMeansDenoising(InputArray src, OutputArray dst,
                                     float h,
                                     int search_window = 21,
                                     int block_size = 7,
                                     Stream& stream = Stream::Null());

/** @brief Modification of fastNlMeansDenoising function for colored images

@param src Input 8-bit 3-channel image.
@param dst Output image with the same size and type as src .
@param h_luminance Parameter regulating filter strength. Big h value perfectly removes noise but
also removes image details, smaller h value preserves details but also preserves some noise
@param photo_render float The same as h but for color components. For most images value equals 10 will be
enough to remove colored noise and do not distort colors
@param search_window Size in pixels of the window that is used to compute weighted average for
given pixel. Should be odd. Affect performance linearly: greater search_window - greater
denoising time. Recommended value 21 pixels
@param block_size Size in pixels of the template patch that is used to compute weights. Should be
odd. Recommended value 7 pixels
@param stream Stream for the asynchronous invocations.

The function converts image to CIELAB colorspace and then separately denoise L and AB components
with given h parameters using FastNonLocalMeansDenoising::simpleMethod function.

@sa
   fastNlMeansDenoisingColored
 */
CV_EXPORTS void fastNlMeansDenoisingColored(InputArray src, OutputArray dst,
                                            float h_luminance, float photo_render,
                                            int search_window = 21,
                                            int block_size = 7,
                                            Stream& stream = Stream::Null());

//! @} photo

}} // namespace cv { namespace cuda {

#endif /* OPENCV_PHOTO_CUDA_HPP */


<|start_filename|>mobile/iOS/FaceDetection/ViewController.h<|end_filename|>
//
//  ViewController.h
//  FaceDetection
//
//  Created by Robin on 2019/3/15.
//  Copyright © 2019 . All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController


@end



<|start_filename|>opencv/include/MIPP/mipp_scalar_op.hxx<|end_filename|>
#include <limits>
#include <cstdlib>
#include <cstdint>
#include <iostream>
#include <algorithm>

#include "mipp_scalar_op.h"

namespace mipp_scop
{
template <typename T> inline T       add(const T       val1, const T       val2) { return val1 + val2; }
template <          > inline int16_t add(const int16_t val1, const int16_t val2) { return (int16_t)std::min(std::max((int32_t)((int32_t)val1 + (int32_t)val2),(int32_t)std::numeric_limits<int16_t>::min()),(int32_t)std::numeric_limits<int16_t>::max()); }
template <          > inline int8_t  add(const int8_t  val1, const int8_t  val2) { return (int8_t )std::min(std::max((int16_t)((int16_t)val1 + (int16_t)val2),(int16_t)std::numeric_limits<int8_t >::min()),(int16_t)std::numeric_limits<int8_t >::max()); }

template <typename T> inline T       sub(const T       val1, const T       val2) { return val1 - val2; }
template <          > inline int16_t sub(const int16_t val1, const int16_t val2) { return (int16_t)std::min(std::max((int32_t)((int32_t)val1 - (int32_t)val2),(int32_t)std::numeric_limits<int16_t>::min()),(int32_t)std::numeric_limits<int16_t>::max()); }
template <          > inline int8_t  sub(const int8_t  val1, const int8_t  val2) { return (int8_t )std::min(std::max((int16_t)((int16_t)val1 - (int16_t)val2),(int16_t)std::numeric_limits<int8_t >::min()),(int16_t)std::numeric_limits<int8_t >::max()); }

template <typename T> inline T      andb(const T      val1, const T      val2) { return                                          val1  &                      val2;   }
template <          > inline double andb(const double val1, const double val2) { return static_cast<double>(static_cast<int64_t>(val1) & static_cast<int64_t>(val2)); }
template <          > inline float  andb(const float  val1, const float  val2) { return static_cast<float >(static_cast<int32_t>(val1) & static_cast<int32_t>(val2)); }

template <typename T> inline T      xorb(const T      val1, const T      val2) { return                                          val1  ^                      val2;   }
template <          > inline double xorb(const double val1, const double val2) { return static_cast<double>(static_cast<int64_t>(val1) ^ static_cast<int64_t>(val2)); }
template <          > inline float  xorb(const float  val1, const float  val2) { return static_cast<float >(static_cast<int32_t>(val1) ^ static_cast<int32_t>(val2)); }

template <typename T> inline T       msb(const T       val) { return (val >> (sizeof(T) * 8 -1)) << (sizeof(T) * 8 -1);              }
template <          > inline double  msb(const double  val) { return static_cast<double >((static_cast<uint64_t>(val) >> 63) << 63); }
template <          > inline float   msb(const float   val) { return static_cast<float  >((static_cast<uint32_t>(val) >> 31) << 31); }
template <          > inline int64_t msb(const int64_t val) { return static_cast<int64_t>((static_cast<uint64_t>(val) >> 63) << 63); }
template <          > inline int32_t msb(const int32_t val) { return static_cast<int32_t>((static_cast<uint32_t>(val) >> 31) << 31); }
template <          > inline int16_t msb(const int16_t val) { return static_cast<int16_t>((static_cast<uint16_t>(val) >> 15) << 15); }
template <          > inline int8_t  msb(const int8_t  val) { return static_cast<int8_t >((static_cast<uint8_t >(val) >>  7) <<  7); }

template <typename T> inline T       div2(const T       val) { return val * (T)0.5; }
template <          > inline int64_t div2(const int64_t val) { return val >> 1;     }
template <          > inline int32_t div2(const int32_t val) { return val >> 1;     }
template <          > inline int16_t div2(const int16_t val) { return val >> 1;     }
template <          > inline int8_t  div2(const int8_t  val) { return val >> 1;     }

template <typename T> inline T       div4(const T       val) { return val * (T)0.25; }
template <          > inline int64_t div4(const int64_t val) { return val >> 2;      }
template <          > inline int32_t div4(const int32_t val) { return val >> 2;      }
template <          > inline int16_t div4(const int16_t val) { return val >> 2;      }
template <          > inline int8_t  div4(const int8_t  val) { return val >> 2;      }

template <typename T> inline T       lshift(const T       val, const int n) { return                                            val  << n;  }
template <          > inline double  lshift(const double  val, const int n) { return static_cast<double >(static_cast<uint64_t>(val) << n); }
template <          > inline float   lshift(const float   val, const int n) { return static_cast<float  >(static_cast<uint32_t>(val) << n); }
template <          > inline int64_t lshift(const int64_t val, const int n) { return static_cast<int64_t>(static_cast<uint64_t>(val) << n); }
template <          > inline int32_t lshift(const int32_t val, const int n) { return static_cast<int32_t>(static_cast<uint32_t>(val) << n); }
template <          > inline int16_t lshift(const int16_t val, const int n) { return static_cast<int16_t>(static_cast<uint16_t>(val) << n); }
template <          > inline int8_t  lshift(const int8_t  val, const int n) { return static_cast<int8_t >(static_cast<uint8_t >(val) << n); }

template <typename T> inline T       rshift(const T       val, const int n) { return                                            val  >> n;  }
template <          > inline double  rshift(const double  val, const int n) { return static_cast<double >(static_cast<uint64_t>(val) >> n); }
template <          > inline float   rshift(const float   val, const int n) { return static_cast<float  >(static_cast<uint32_t>(val) >> n); }
template <          > inline int64_t rshift(const int64_t val, const int n) { return static_cast<int64_t>(static_cast<uint64_t>(val) >> n); }
template <          > inline int32_t rshift(const int32_t val, const int n) { return static_cast<int32_t>(static_cast<uint32_t>(val) >> n); }
template <          > inline int16_t rshift(const int16_t val, const int n) { return static_cast<int16_t>(static_cast<uint16_t>(val) >> n); }
template <          > inline int8_t  rshift(const int8_t  val, const int n) { return static_cast<int8_t >(static_cast<uint8_t >(val) >> n); }
}


<|start_filename|>opencv/include/opencv2/core/directx.hpp<|end_filename|>
/*M///////////////////////////////////////////////////////////////////////////////////////
//
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//  By downloading, copying, installing or using the software you agree to this license.
//  If you do not agree to this license, do not download, install,
//  copy or use the software.
//
//
//                           License Agreement
//                For Open Source Computer Vision Library
//
// Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//   * Redistribution's of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//
//   * Redistribution's in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//
//   * The name of the copyright holders may not be used to endorse or promote products
//     derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the copyright holders or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/

#ifndef OPENCV_CORE_DIRECTX_HPP
#define OPENCV_CORE_DIRECTX_HPP

#include "mat.hpp"
#include "ocl.hpp"

#if !defined(__d3d11_h__)
struct ID3D11Device;
struct ID3D11Texture2D;
#endif

#if !defined(__d3d10_h__)
struct ID3D10Device;
struct ID3D10Texture2D;
#endif

#if !defined(_D3D9_H_)
struct IDirect3DDevice9;
struct IDirect3DDevice9Ex;
struct IDirect3DSurface9;
#endif


namespace cv { namespace directx {

namespace ocl {
using namespace cv::ocl;

//! @addtogroup core_directx
// This section describes OpenCL and DirectX interoperability.
//
// To enable DirectX support, configure OpenCV using CMake with WITH_DIRECTX=ON . Note, DirectX is
// supported only on Windows.
//
// To use OpenCL functionality you should first initialize OpenCL context from DirectX resource.
//
//! @{

// TODO static functions in the Context class
//! @brief Creates OpenCL context from D3D11 device
//
//! @param pD3D11Device - pointer to D3D11 device
//! @return Returns reference to OpenCL Context
CV_EXPORTS Context& initializeContextFromD3D11Device(ID3D11Device* pD3D11Device);

//! @brief Creates OpenCL context from D3D10 device
//
//! @param pD3D10Device - pointer to D3D10 device
//! @return Returns reference to OpenCL Context
CV_EXPORTS Context& initializeContextFromD3D10Device(ID3D10Device* pD3D10Device);

//! @brief Creates OpenCL context from Direct3DDevice9Ex device
//
//! @param pDirect3DDevice9Ex - pointer to Direct3DDevice9Ex device
//! @return Returns reference to OpenCL Context
CV_EXPORTS Context& initializeContextFromDirect3DDevice9Ex(IDirect3DDevice9Ex* pDirect3DDevice9Ex);

//! @brief Creates OpenCL context from Direct3DDevice9 device
//
//! @param pDirect3DDevice9 - pointer to Direct3Device9 device
//! @return Returns reference to OpenCL Context
CV_EXPORTS Context& initializeContextFromDirect3DDevice9(IDirect3DDevice9* pDirect3DDevice9);

//! @}

} // namespace cv::directx::ocl

//! @addtogroup core_directx
//! @{

//! @brief Converts InputArray to ID3D11Texture2D. If destination texture format is DXGI_FORMAT_NV12 then
//!        input UMat expected to be in BGR format and data will be downsampled and color-converted to NV12.
//
//! @note Note: Destination texture must be allocated by application. Function does memory copy from src to
//!             pD3D11Texture2D
//
//! @param src - source InputArray
//! @param pD3D11Texture2D - destination D3D11 texture
CV_EXPORTS void convertToD3D11Texture2D(InputArray src, ID3D11Texture2D* pD3D11Texture2D);

//! @brief Converts ID3D11Texture2D to OutputArray. If input texture format is DXGI_FORMAT_NV12 then
//!        data will be upsampled and color-converted to BGR format.
//
//! @note Note: Destination matrix will be re-allocated if it has not enough memory to match texture size.
//!             function does memory copy from pD3D11Texture2D to dst
//
//! @param pD3D11Texture2D - source D3D11 texture
//! @param dst             - destination OutputArray
CV_EXPORTS void convertFromD3D11Texture2D(ID3D11Texture2D* pD3D11Texture2D, OutputArray dst);

//! @brief Converts InputArray to ID3D10Texture2D
//
//! @note Note: function does memory copy from src to
//!             pD3D10Texture2D
//
//! @param src             - source InputArray
//! @param pD3D10Texture2D - destination D3D10 texture
CV_EXPORTS void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D);

//! @brief Converts ID3D10Texture2D to OutputArray
//
//! @note Note: function does memory copy from pD3D10Texture2D
//!             to dst
//
//! @param pD3D10Texture2D - source D3D10 texture
//! @param dst             - destination OutputArray
CV_EXPORTS void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst);

//! @brief Converts InputArray to IDirect3DSurface9
//
//! @note Note: function does memory copy from src to
//!             pDirect3DSurface9
//
//! @param src                 - source InputArray
//! @param pDirect3DSurface9   - destination D3D10 texture
//! @param surfaceSharedHandle - shared handle
CV_EXPORTS void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurface9, void* surfaceSharedHandle = NULL);

//! @brief Converts IDirect3DSurface9 to OutputArray
//
//! @note Note: function does memory copy from pDirect3DSurface9
//!             to dst
//
//! @param pDirect3DSurface9   - source D3D10 texture
//! @param dst                 - destination OutputArray
//! @param surfaceSharedHandle - shared handle
CV_EXPORTS void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArray dst, void* surfaceSharedHandle = NULL);

//! @brief Get OpenCV type from DirectX type
//! @param iDXGI_FORMAT - enum DXGI_FORMAT for D3D10/D3D11
//! @return OpenCV type or -1 if there is no equivalent
CV_EXPORTS int getTypeFromDXGI_FORMAT(const int iDXGI_FORMAT); // enum DXGI_FORMAT for D3D10/D3D11

//! @brief Get OpenCV type from DirectX type
//! @param iD3DFORMAT - enum D3DTYPE for D3D9
//! @return OpenCV type or -1 if there is no equivalent
CV_EXPORTS int getTypeFromD3DFORMAT(const int iD3DFORMAT); // enum D3DTYPE for D3D9

//! @}

} } // namespace cv::directx

#endif // OPENCV_CORE_DIRECTX_HPP


<|start_filename|>opencv_dnn/cpp/utils.cpp<|end_filename|>
#include "utils.hpp"

void draw(cv::Mat& img,
          const std::vector<Face>& faces) {

    const int thickness = 2;
    const cv::Scalar bbox_color = {  0, 255,   0};
    const cv::Scalar text_color = {255, 255, 255};
    const std::vector<cv::Scalar> landmarks_color = {
        {255,   0,   0}, // right eye
        {  0,   0, 255}, // left eye
        {  0, 255,   0}, // nose
        {255,   0, 255}, // mouth right
        {  0, 255, 255}  // mouth left
    };

    for (auto i = 0; i < faces.size(); ++i) {
        // draw bbox
        cv::rectangle(img,
                      cv::Rect(faces[i].bbox_tlwh),
                      bbox_color,
                      thickness);
        // put score by the corner of bbox
        std::string str_score = std::to_string(faces[i].score);
        if (str_score.size() > 6) {
            str_score.erase(6);
        }
        cv::putText(img,
                    str_score,
                    cv::Point(faces[i].bbox_tlwh.x, faces[i].bbox_tlwh.y + 12),
                    cv::FONT_HERSHEY_DUPLEX,
                    0.5, // Font scale
                    text_color);
        // draw landmarks
        const int radius = 2;
        cv::circle(img, cv::Point(faces[i].landmarks.right_eye),   radius, landmarks_color[0], thickness);
        cv::circle(img, cv::Point(faces[i].landmarks.left_eye),    radius, landmarks_color[1], thickness);
        cv::circle(img, cv::Point(faces[i].landmarks.nose_tip),    radius, landmarks_color[2], thickness);
        cv::circle(img, cv::Point(faces[i].landmarks.mouth_right), radius, landmarks_color[3], thickness);
        cv::circle(img, cv::Point(faces[i].landmarks.mouth_left),  radius, landmarks_color[4], thickness);
    }
}


<|start_filename|>opencv/include/opencv/cxmisc.h<|end_filename|>
#ifndef OPENCV_OLD_CXMISC_H
#define OPENCV_OLD_CXMISC_H

#ifdef __cplusplus
#  include "opencv2/core/utility.hpp"
#endif

#endif


<|start_filename|>opencv_dnn/cpp/utils.hpp<|end_filename|>
#ifndef UTILS_HPP
#define UTILS_HPP

#include <string>
#include <vector>
#include <algorithm>
#include "face_def.hpp"
#include "opencv2/opencv.hpp"

void draw(cv::Mat& img,
          const std::vector<Face>& faces);

#endif

<|start_filename|>mobile/Android/app/src/main/java/org/dp/facedetection/Face.java<|end_filename|>
package org.dp.facedetection;

import org.opencv.core.Rect;

/**
 * Stay Hungry Stay Foolish
 * Author: dp on 2019/3/25 12:51
 */
public class Face {
    public Rect faceRect;
    public int faceConfidence;
    public int faceAngle;
}


<|start_filename|>opencv/include/opencv2/core/utils/trace.hpp<|end_filename|>
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.

#ifndef OPENCV_TRACE_HPP
#define OPENCV_TRACE_HPP

#include <opencv2/core/cvdef.h>

//! @addtogroup core_logging
// This section describes OpenCV tracing utilities.
//
//! @{

namespace cv {
namespace utils {
namespace trace {

//! Macro to trace function
#define CV_TRACE_FUNCTION()

#define CV_TRACE_FUNCTION_SKIP_NESTED()

//! Trace code scope.
//! @note Dynamic names are not supported in this macro (on stack or heap). Use string literals here only, like "initialize".
#define CV_TRACE_REGION(name_as_static_string_literal)
//! mark completed of the current opened region and create new one
//! @note Dynamic names are not supported in this macro (on stack or heap). Use string literals here only, like "step1".
#define CV_TRACE_REGION_NEXT(name_as_static_string_literal)

//! Macro to trace argument value
#define CV_TRACE_ARG(arg_id)

//! Macro to trace argument value (expanded version)
#define CV_TRACE_ARG_VALUE(arg_id, arg_name, value)

//! @cond IGNORED
#define CV_TRACE_NS cv::utils::trace

namespace details {

#ifndef __OPENCV_TRACE
# if defined __OPENCV_BUILD && !defined __OPENCV_TESTS && !defined __OPENCV_APPS
#   define __OPENCV_TRACE 1
# else
#   define __OPENCV_TRACE 0
# endif
#endif

#ifndef CV_TRACE_FILENAME
# define CV_TRACE_FILENAME __FILE__
#endif

#ifndef CV__TRACE_FUNCTION
# if defined _MSC_VER
#   define CV__TRACE_FUNCTION __FUNCSIG__
# elif defined __GNUC__
#   define CV__TRACE_FUNCTION __PRETTY_FUNCTION__
# else
#   define CV__TRACE_FUNCTION "<unknown>"
# endif
#endif

//! Thread-local instance (usually allocated on stack)
class CV_EXPORTS Region
{
public:
    struct LocationExtraData;
    struct LocationStaticStorage
    {
        LocationExtraData** ppExtra;   //< implementation specific data
        const char* name;              //< region name (function name or other custom name)
        const char* filename;          //< source code filename
        int line;                      //< source code line
        int flags;                     //< flags (implementation code path: Plain, IPP, OpenCL)
    };

    Region(const LocationStaticStorage& location);
    inline ~Region()
    {
        if (implFlags != 0)
            destroy();
        CV_DbgAssert(implFlags == 0);
        CV_DbgAssert(pImpl == NULL);
    }

    class Impl;
    Impl* pImpl; // NULL if current region is not active
    int implFlags; // see RegionFlag, 0 if region is ignored

    bool isActive() const { return pImpl != NULL; }

    void destroy();
private:
    Region(const Region&); // disabled
    Region& operator= (const Region&); // disabled
};

//! Specify region flags
enum RegionLocationFlag {
    REGION_FLAG_FUNCTION = (1 << 0),             //< region is function (=1) / nested named region (=0)
    REGION_FLAG_APP_CODE = (1 << 1),             //< region is Application code (=1) / OpenCV library code (=0)
    REGION_FLAG_SKIP_NESTED = (1 << 2),          //< avoid processing of nested regions

    REGION_FLAG_IMPL_IPP = (1 << 16),            //< region is part of IPP code path
    REGION_FLAG_IMPL_OPENCL = (2 << 16),         //< region is part of OpenCL code path
    REGION_FLAG_IMPL_OPENVX = (3 << 16),         //< region is part of OpenVX code path

    REGION_FLAG_IMPL_MASK = (15 << 16),

    REGION_FLAG_REGION_FORCE = (1 << 30),
    REGION_FLAG_REGION_NEXT = (1 << 31),         //< close previous region (see #CV_TRACE_REGION_NEXT macro)

    ENUM_REGION_FLAG_FORCE_INT = INT_MAX
};

struct CV_EXPORTS TraceArg {
public:
    struct ExtraData;
    ExtraData** ppExtra;
    const char* name;
    int flags;
};
/** @brief Add meta information to current region (function)
 * See CV_TRACE_ARG macro
 * @param arg argument information structure (global static cache)
 * @param value argument value (can by dynamic string literal in case of string, static allocation is not required)
 */
CV_EXPORTS void traceArg(const TraceArg& arg, const char* value);
//! @overload
CV_EXPORTS void traceArg(const TraceArg& arg, int value);
//! @overload
CV_EXPORTS void traceArg(const TraceArg& arg, int64 value);
//! @overload
CV_EXPORTS void traceArg(const TraceArg& arg, double value);

#define CV__TRACE_LOCATION_VARNAME(loc_id) CVAUX_CONCAT(CVAUX_CONCAT(__cv_trace_location_, loc_id), __LINE__)
#define CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id) CVAUX_CONCAT(CVAUX_CONCAT(__cv_trace_location_extra_, loc_id) , __LINE__)

#define CV__TRACE_DEFINE_LOCATION_(loc_id, name, flags) \
    static CV_TRACE_NS::details::Region::LocationExtraData* CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id) = 0; \
    static const CV_TRACE_NS::details::Region::LocationStaticStorage \
        CV__TRACE_LOCATION_VARNAME(loc_id) = { &(CV__TRACE_LOCATION_EXTRA_VARNAME(loc_id)), name, CV_TRACE_FILENAME, __LINE__, flags};

#define CV__TRACE_DEFINE_LOCATION_FN(name, flags) CV__TRACE_DEFINE_LOCATION_(fn, name, (flags | CV_TRACE_NS::details::REGION_FLAG_FUNCTION))


#define CV__TRACE_OPENCV_FUNCTION() \
    CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, 0); \
    const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));

#define CV__TRACE_OPENCV_FUNCTION_NAME(name) \
    CV__TRACE_DEFINE_LOCATION_FN(name, 0); \
    const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));

#define CV__TRACE_APP_FUNCTION() \
    CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \
    const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));

#define CV__TRACE_APP_FUNCTION_NAME(name) \
    CV__TRACE_DEFINE_LOCATION_FN(name, CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \
    const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));


#define CV__TRACE_OPENCV_FUNCTION_SKIP_NESTED() \
    CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED); \
    const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));

#define CV__TRACE_OPENCV_FUNCTION_NAME_SKIP_NESTED(name) \
    CV__TRACE_DEFINE_LOCATION_FN(name, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED); \
    const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));

#define CV__TRACE_APP_FUNCTION_SKIP_NESTED() \
    CV__TRACE_DEFINE_LOCATION_FN(CV__TRACE_FUNCTION, CV_TRACE_NS::details::REGION_FLAG_SKIP_NESTED | CV_TRACE_NS::details::REGION_FLAG_APP_CODE); \
    const CV_TRACE_NS::details::Region __region_fn(CV__TRACE_LOCATION_VARNAME(fn));


#define CV__TRACE_REGION_(name_as_static_string_literal, flags) \
    CV__TRACE_DEFINE_LOCATION_(region, name_as_static_string_literal, flags); \
    CV_TRACE_NS::details::Region CVAUX_CONCAT(__region_, __LINE__)(CV__TRACE_LOCATION_VARNAME(region));

#define CV__TRACE_REGION(name_as_static_string_literal) CV__TRACE_REGION_(name_as_static_string_literal, 0)
#define CV__TRACE_REGION_NEXT(name_as_static_string_literal) CV__TRACE_REGION_(name_as_static_string_literal, CV_TRACE_NS::details::REGION_FLAG_REGION_NEXT)

#define CV__TRACE_ARG_VARNAME(arg_id) CVAUX_CONCAT(__cv_trace_arg_ ## arg_id, __LINE__)
#define CV__TRACE_ARG_EXTRA_VARNAME(arg_id) CVAUX_CONCAT(__cv_trace_arg_extra_ ## arg_id, __LINE__)

#define CV__TRACE_DEFINE_ARG_(arg_id, name, flags) \
    static CV_TRACE_NS::details::TraceArg::ExtraData* CV__TRACE_ARG_EXTRA_VARNAME(arg_id) = 0; \
    static const CV_TRACE_NS::details::TraceArg \
        CV__TRACE_ARG_VARNAME(arg_id) = { &(CV__TRACE_ARG_EXTRA_VARNAME(arg_id)), name, flags };

#define CV__TRACE_ARG_VALUE(arg_id, arg_name, value) \
        CV__TRACE_DEFINE_ARG_(arg_id, arg_name, 0); \
        CV_TRACE_NS::details::traceArg((CV__TRACE_ARG_VARNAME(arg_id)), value);

#define CV__TRACE_ARG(arg_id) CV_TRACE_ARG_VALUE(arg_id, #arg_id, (arg_id))

} // namespace

#ifndef OPENCV_DISABLE_TRACE
#undef CV_TRACE_FUNCTION
#undef CV_TRACE_FUNCTION_SKIP_NESTED
#if __OPENCV_TRACE
#define CV_TRACE_FUNCTION CV__TRACE_OPENCV_FUNCTION
#define CV_TRACE_FUNCTION_SKIP_NESTED CV__TRACE_OPENCV_FUNCTION_SKIP_NESTED
#else
#define CV_TRACE_FUNCTION CV__TRACE_APP_FUNCTION
#define CV_TRACE_FUNCTION_SKIP_NESTED CV__TRACE_APP_FUNCTION_SKIP_NESTED
#endif

#undef CV_TRACE_REGION
#define CV_TRACE_REGION CV__TRACE_REGION

#undef CV_TRACE_REGION_NEXT
#define CV_TRACE_REGION_NEXT CV__TRACE_REGION_NEXT

#undef CV_TRACE_ARG_VALUE
#define CV_TRACE_ARG_VALUE(arg_id, arg_name, value) \
        if (__region_fn.isActive()) \
        { \
            CV__TRACE_ARG_VALUE(arg_id, arg_name, value); \
        }

#undef CV_TRACE_ARG
#define CV_TRACE_ARG CV__TRACE_ARG

#endif // OPENCV_DISABLE_TRACE

#ifdef OPENCV_TRACE_VERBOSE
#define CV_TRACE_FUNCTION_VERBOSE CV_TRACE_FUNCTION
#define CV_TRACE_REGION_VERBOSE CV_TRACE_REGION
#define CV_TRACE_REGION_NEXT_VERBOSE CV_TRACE_REGION_NEXT
#define CV_TRACE_ARG_VALUE_VERBOSE CV_TRACE_ARG_VALUE
#define CV_TRACE_ARG_VERBOSE CV_TRACE_ARG
#else
#define CV_TRACE_FUNCTION_VERBOSE(...)
#define CV_TRACE_REGION_VERBOSE(...)
#define CV_TRACE_REGION_NEXT_VERBOSE(...)
#define CV_TRACE_ARG_VALUE_VERBOSE(...)
#define CV_TRACE_ARG_VERBOSE(...)
#endif

//! @endcond

}}} // namespace

//! @}

#endif // OPENCV_TRACE_HPP


<|start_filename|>opencv/include/MIPP/mipp_object.hxx<|end_filename|>
#include "mipp.h"

template <typename T>
class Reg;

template <typename T> inline Reg<T> add(const Reg<T> v1, const Reg<T> v2);
template <typename T> inline Reg<T> sub(const Reg<T> v1, const Reg<T> v2);
template <typename T> inline Reg<T> mul(const Reg<T> v1, const Reg<T> v2);
template <typename T> inline Reg<T> div(const Reg<T> v1, const Reg<T> v2);
template <typename T> inline Reg<T> min(const Reg<T> v1, const Reg<T> v2);
template <typename T> inline Reg<T> max(const Reg<T> v1, const Reg<T> v2);

template <typename T>
class Reg_2;

template <typename T>
class Regx2;

template <int N>
class Msk;

template <typename T>
class Reg
{
public:
#ifndef MIPP_NO_INTRINSICS
	reg r;
#else
	T r;
#endif

#ifndef MIPP_NO_INTRINSICS
	Reg(                            )                         {}
	Reg(const reg r                 ) : r(r)                  {}
	Reg(const T   val               ) : r(mipp::set1<T>(val)) {}
//	Reg(const T   vals[mipp::N<T>()]) : r(mipp::set <T>(vals)){}
	Reg(const T  *data              ) : r(mipp::load<T>(data)){}

	Reg(const std::initializer_list<T> &l)
	{
		if (l.size() >= (unsigned)mipp::nElReg<T>())
			r = mipp::loadu<T>(l.begin());
		else
			throw std::runtime_error("mipp::Reg<T>: invalid 'initializer_list' size.");
	}

	~Reg() {}
#else
	Reg(                )              {}
	Reg(const T  val    ) : r(val)     {}
	Reg(const T  vals[1]) : r(vals[0]) {}
//	Reg(const T *data   ) : r(data[0]) {}

	Reg(const std::initializer_list<T> &l)
	{
		auto vec = mipp::vector<T>(mipp::nElReg<T>());
		vec = l;
		r = vec[0];
	}

	~Reg() {}
#endif

#ifndef MIPP_NO_INTRINSICS
	static inline Reg<T> cmask (const uint32_t mask[nElReg<T>()  ]) { return mipp::cmask <T>(mask); }
	static inline Reg<T> cmask2(const uint32_t mask[nElReg<T>()/2]) { return mipp::cmask2<T>(mask); }
	static inline Reg<T> cmask4(const uint32_t mask[nElReg<T>()/4]) { return mipp::cmask4<T>(mask); }
#else
	static inline Reg<T> cmask (const uint32_t mask[1]) { return Reg<T>((T)0);          }
	static inline Reg<T> cmask2(const uint32_t mask[1]) { return Reg<T>((T)0);          }
	static inline Reg<T> cmask4(const uint32_t mask[1]) { return Reg<T>((T)0);          }
#endif

	static inline void transpose(Reg<T> regs[nElReg<T>()])
	{
#ifndef MIPP_NO_INTRINSICS
		reg rs[nElReg<T>()];
		for (auto i = 0; i < nElReg<T>(); i++) rs[i] = regs[i].r;
		mipp::transpose<T>(rs);
		for (auto i = 0; i < nElReg<T>(); i++) regs[i].r = rs[i];
#endif
	}

	static inline void transpose8x8(Reg<T> regs[8])
	{
#ifndef MIPP_NO_INTRINSICS
		reg rs[8];
		for (auto i = 0; i < 8; i++) rs[i] = regs[i].r;
		mipp::transpose8x8<T>(rs);
		for (auto i = 0; i < 8; i++) regs[i].r = rs[i];
#else
		throw std::runtime_error("mipp::Reg<T>::transpose8x8: non-sense in sequential mode.");
#endif
	}

	static inline void transpose2(Reg<T> regs[nElReg<T>()/2])
	{
#ifndef MIPP_NO_INTRINSICS
		reg rs[nElReg<T>()/2];
		for (auto i = 0; i < nElReg<T>()/2; i++) rs[i] = regs[i].r;
		mipp::transpose2<T>(rs);
		for (auto i = 0; i < nElReg<T>()/2; i++) regs[i].r = rs[i];
#else
		throw std::runtime_error("mipp::Reg<T>::transpose2: non-sense in sequential mode.");
#endif
	}

	static inline void transpose28x8(Reg<T> regs[8])
	{
#ifndef MIPP_NO_INTRINSICS
		reg rs[8];
		for (auto i = 0; i < 8; i++) rs[i] = regs[i].r;
		mipp::transpose28x8<T>(rs);
		for (auto i = 0; i < 8; i++) regs[i].r = rs[i];
#else
		throw std::runtime_error("mipp::Reg<T>::transpose28x8: non-sense in sequential mode.");
#endif
	}

#ifndef MIPP_NO_INTRINSICS
	inline void        set0         ()                                           { r = mipp::set0<T>();                           }
	inline void        set1         (const T val)                                { r = mipp::set1<T>(val);                        }
	inline void        set          (const T vals[mipp::N<T>()])                 { r = mipp::set <T>(vals);                       }
	inline void        load         (const T* data)                              { r = mipp::load<T>(data);                       }
	inline void        loadu        (const T* data)                              { r = mipp::loadu<T>(data);                      }
	inline void        store        (T* data)                              const { mipp::store<T>(data, r);                       }
	inline void        storeu       (T* data)                              const { mipp::storeu<T>(data, r);                      }
	inline Reg_2<T>    low          ()                                     const { return mipp::low <T>(r);                       }
	inline Reg_2<T>    high         ()                                     const { return mipp::high<T>(r);                       }
	inline Reg<T>      shuff        (const Reg<T> v_shu)                   const { return mipp::shuff        <T>(r, v_shu.r);     }
	inline Reg<T>      shuff2       (const Reg<T> v_shu)                   const { return mipp::shuff2       <T>(r, v_shu.r);     }
	inline Reg<T>      shuff4       (const Reg<T> v_shu)                   const { return mipp::shuff4       <T>(r, v_shu.r);     }
	inline Reg<T>      interleavelo (const Reg<T> v)                       const { return mipp::interleavelo <T>(r, v.r);         }
	inline Reg<T>      interleavehi (const Reg<T> v)                       const { return mipp::interleavehi <T>(r, v.r);         }
	inline Reg<T>      interleavelo2(const Reg<T> v)                       const { return mipp::interleavelo2<T>(r, v.r);         }
	inline Reg<T>      interleavehi2(const Reg<T> v)                       const { return mipp::interleavehi2<T>(r, v.r);         }
	inline Reg<T>      interleavelo4(const Reg<T> v)                       const { return mipp::interleavelo4<T>(r, v.r);         }
	inline Reg<T>      interleavehi4(const Reg<T> v)                       const { return mipp::interleavehi4<T>(r, v.r);         }
	inline Regx2<T>    interleave   (const Reg<T> v)                       const { return mipp::interleave   <T>(r, v.r);         }
	inline Regx2<T>    interleave2  (const Reg<T> v)                       const { return mipp::interleave2  <T>(r, v.r);         }
	inline Regx2<T>    interleave4  (const Reg<T> v)                       const { return mipp::interleave4  <T>(r, v.r);         }
	inline Reg<T>      interleave   ()                                     const { return mipp::interleave   <T>(r);              }
	inline Regx2<T>    interleavex2 (const Reg<T> v)                       const { return mipp::interleavex2 <T>(r, v.r);         }
	inline Reg<T>      interleavex4 ()                                     const { return mipp::interleavex4 <T>(r);              }
	inline Reg<T>      interleavex16()                                     const { return mipp::interleavex16<T>(r);              }
	inline Reg<T>      andb         (const Reg<T> v)                       const { return mipp::andb         <T>(r, v.r);         }
	inline Reg<T>      andnb        (const Reg<T> v)                       const { return mipp::andnb        <T>(r, v.r);         }
	inline Reg<T>      notb         ()                                     const { return mipp::notb         <T>(r);              }
	inline Reg<T>      orb          (const Reg<T> v)                       const { return mipp::orb          <T>(r, v.r);         }
	inline Reg<T>      xorb         (const Reg<T> v)                       const { return mipp::xorb         <T>(r, v.r);         }
	inline Reg<T>      lshift       (const uint32_t n)                     const { return mipp::lshift       <T>(r, n);           }
	inline Reg<T>      rshift       (const uint32_t n)                     const { return mipp::rshift       <T>(r, n);           }
	inline Msk<N<T>()> cmpeq        (const Reg<T> v)                       const { return mipp::cmpeq        <T>(r, v.r);         }
	inline Msk<N<T>()> cmpneq       (const Reg<T> v)                       const { return mipp::cmpneq       <T>(r, v.r);         }
	inline Msk<N<T>()> cmplt        (const Reg<T> v)                       const { return mipp::cmplt        <T>(r, v.r);         }
	inline Msk<N<T>()> cmple        (const Reg<T> v)                       const { return mipp::cmple        <T>(r, v.r);         }
	inline Msk<N<T>()> cmpgt        (const Reg<T> v)                       const { return mipp::cmpgt        <T>(r, v.r);         }
	inline Msk<N<T>()> cmpge        (const Reg<T> v)                       const { return mipp::cmpge        <T>(r, v.r);         }
	inline Reg<T>      add          (const Reg<T> v)                       const { return mipp::add          <T>(r, v.r);         }
	inline Reg<T>      sub          (const Reg<T> v)                       const { return mipp::sub          <T>(r, v.r);         }
	inline Reg<T>      mul          (const Reg<T> v)                       const { return mipp::mul          <T>(r, v.r);         }
	inline Reg<T>      div          (const Reg<T> v)                       const { return mipp::div          <T>(r, v.r);         }
	inline Reg<T>      min          (const Reg<T> v)                       const { return mipp::min          <T>(r, v.r);         }
	inline Reg<T>      max          (const Reg<T> v)                       const { return mipp::max          <T>(r, v.r);         }
	inline Reg<T>      msb          ()                                     const { return mipp::msb          <T>(r);              }
	inline Reg<T>      msb          (const Reg<T> v)                       const { return mipp::msb          <T>(r, v.r);         }
	inline Msk<N<T>()> sign         ()                                     const { return mipp::sign         <T>(r);              }
	inline Reg<T>      neg          (const Reg<T> v)                       const { return mipp::neg          <T>(r, v.r);         }
	inline Reg<T>      neg          (const Msk<N<T>()> v)                  const { return mipp::neg          <T>(r, v.m);         }
	inline Reg<T>      copysign     (const Reg<T> v)                       const { return mipp::copysign     <T>(r, v.r);         }
	inline Reg<T>      copysign     (const Msk<N<T>()> v)                  const { return mipp::copysign     <T>(r, v.m);         }
	inline Reg<T>      abs          ()                                     const { return mipp::abs          <T>(r);              }
	inline Reg<T>      sqrt         ()                                     const { return mipp::sqrt         <T>(r);              }
	inline Reg<T>      rsqrt        ()                                     const { return mipp::rsqrt        <T>(r);              }
	inline Reg<T>      log          ()                                     const { return mipp::log          <T>(r);              }
	inline Reg<T>      exp          ()                                     const { return mipp::exp          <T>(r);              }
	inline Reg<T>      sin          ()                                     const { return mipp::sin          <T>(r);              }
	inline Reg<T>      cos          ()                                     const { return mipp::cos          <T>(r);              }
	inline Reg<T>      tan          ()                                     const { return mipp::tan          <T>(r);              }
	inline void        sincos       (      Reg<T> &s,       Reg<T> &c)     const {        mipp::sincos       <T>(r,  s.r,  c.r);  }
	inline Reg<T>      sinh         ()                                     const { return mipp::sinh         <T>(r);              }
	inline Reg<T>      cosh         ()                                     const { return mipp::cosh         <T>(r);              }
	inline Reg<T>      tanh         ()                                     const { return mipp::tanh         <T>(r);              }
	inline Reg<T>      asinh        ()                                     const { return mipp::asinh        <T>(r);              }
	inline Reg<T>      acosh        ()                                     const { return mipp::acosh        <T>(r);              }
	inline Reg<T>      atanh        ()                                     const { return mipp::atanh        <T>(r);              }
//	inline Reg<T>      csch         ()                                     const { return mipp::csch         <T>(r);              }
//	inline Reg<T>      sech         ()                                     const { return mipp::sech         <T>(r);              }
//	inline Reg<T>      coth         ()                                     const { return mipp::coth         <T>(r);              }
//	inline Reg<T>      acsch        ()                                     const { return mipp::acsch        <T>(r);              }
//	inline Reg<T>      asech        ()                                     const { return mipp::asech        <T>(r);              }
//	inline Reg<T>      acoth        ()                                     const { return mipp::acoth        <T>(r);              }
	inline Reg<T>      fmadd        (const Reg<T> v1, const Reg<T> v2)     const { return mipp::fmadd        <T>(r, v1.r, v2.r);  }
	inline Reg<T>      fnmadd       (const Reg<T> v1, const Reg<T> v2)     const { return mipp::fnmadd       <T>(r, v1.r, v2.r);  }
	inline Reg<T>      fmsub        (const Reg<T> v1, const Reg<T> v2)     const { return mipp::fmsub        <T>(r, v1.r, v2.r);  }
	inline Reg<T>      fnmsub       (const Reg<T> v1, const Reg<T> v2)     const { return mipp::fnmsub       <T>(r, v1.r, v2.r);  }
	inline Reg<T>      blend        (const Reg<T> v1, const Msk<N<T>()> m) const { return mipp::blend        <T>(r, v1.r,  m.m);  }
	inline Reg<T>      lrot         ()                                     const { return mipp::lrot         <T>(r);              }
	inline Reg<T>      rrot         ()                                     const { return mipp::rrot         <T>(r);              }
	inline Reg<T>      div2         ()                                     const { return mipp::div2         <T>(r);              }
	inline Reg<T>      div4         ()                                     const { return mipp::div4         <T>(r);              }
	inline Reg<T>      sat          (T min, T max)                         const { return mipp::sat          <T>(r, min, max);    }
	inline Reg<T>      round        ()                                     const { return mipp::round        <T>(r);              }
	inline bool        testz        (const Reg<T> v)                       const { return mipp::testz        <T>(r, v.r);         }
	inline bool        testz        ()                                     const { return mipp::testz        <T>(r);              }
#else
	inline void        set0         ()                                           { r = 0;                                         }
	inline void        set1         (const T val)                                { r = val;                                       }
	inline void        set          (const T vals[1])                            { r = vals[0];                                   }
	inline void        load         (const T* data)                              { r = data[0];                                   }
	inline void        loadu        (const T* data)                              { r = data[0];                                   }
	inline void        store        (T* data)                              const { data[0] = r;                                   }
	inline void        storeu       (T* data)                              const { data[0] = r;                                   }
	inline Reg_2<T>    low          ()                                     const { return r;                                      }
	inline Reg_2<T>    high         ()                                     const { return r;                                      }
	inline Reg<T>      shuff        (const Reg<T> v_shu)                   const { return *this;                                  }
	inline Reg<T>      shuff2       (const Reg<T> v_shu)                   const { return *this;                                  }
	inline Reg<T>      shuff4       (const Reg<T> v_shu)                   const { return *this;                                  }
	inline Reg<T>      interleavelo (const Reg<T> v)                       const { return *this;                                  }
	inline Reg<T>      interleavehi (const Reg<T> v)                       const { return *this;                                  }
	inline Reg<T>      interleavelo2(const Reg<T> v)                       const { return *this;                                  }
	inline Reg<T>      interleavehi2(const Reg<T> v)                       const { return *this;                                  }
	inline Reg<T>      interleavelo4(const Reg<T> v)                       const { return *this;                                  }
	inline Reg<T>      interleavehi4(const Reg<T> v)                       const { return *this;                                  }
	inline Regx2<T>    interleave   (const Reg<T> v)                       const { return Regx2<T>(*this, v);                     }
	inline Regx2<T>    interleave2  (const Reg<T> v)                       const { return Regx2<T>(*this, v);                     }
	inline Regx2<T>    interleave4  (const Reg<T> v)                       const { return Regx2<T>(*this, v);                     }
	inline Reg<T>      interleave   ()                                     const { return *this;                                  }
	inline Regx2<T>    interleavex2 (const Reg<T> v)                       const { return Regx2<T>(*this, v);                     }
	inline Reg<T>      interleavex4 ()                                     const { return *this;                                  }
	inline Reg<T>      interleavex16()                                     const { return *this;                                  }
	inline Reg<T>      andb         (const Reg<T> v)                       const { return mipp_scop::andb<T>( r, v.r);            }
	inline Reg<T>      andnb        (const Reg<T> v)                       const { return mipp_scop::andb<T>(~r, v.r);            }
	inline Reg<T>      notb         ()                                     const { return ~r;                                     }
	inline Reg<T>      orb          (const Reg<T> v)                       const { return  r  |  v.r;                             }
	inline Reg<T>      xorb         (const Reg<T> v)                       const { return mipp_scop::xorb<T>(r, v.r);             }
	inline Reg<T>      lshift       (const uint32_t n)                     const { return mipp_scop::lshift<T>(r, n);             }
	inline Reg<T>      rshift       (const uint32_t n)                     const { return mipp_scop::rshift<T>(r, n);             }
	inline Msk<N<T>()> cmpeq        (const Reg<T> v)                       const { return (msk)(r  == v.r);                       }
	inline Msk<N<T>()> cmpneq       (const Reg<T> v)                       const { return (msk)(r  != v.r);                       }
	inline Msk<N<T>()> cmplt        (const Reg<T> v)                       const { return (msk)(r  <  v.r);                       }
	inline Msk<N<T>()> cmple        (const Reg<T> v)                       const { return (msk)(r  <= v.r);                       }
	inline Msk<N<T>()> cmpgt        (const Reg<T> v)                       const { return (msk)(r  >  v.r);                       }
	inline Msk<N<T>()> cmpge        (const Reg<T> v)                       const { return (msk)(r  >= v.r);                       }
	inline Reg<T>      add          (const Reg<T> v)                       const { return mipp_scop::add<T>(r,v.r);               }
	inline Reg<T>      sub          (const Reg<T> v)                       const { return mipp_scop::sub<T>(r,v.r);               }
	inline Reg<T>      mul          (const Reg<T> v)                       const { return r  *  v.r;                              }
	inline Reg<T>      div          (const Reg<T> v)                       const { return r  /  v.r;                              }
	inline Reg<T>      min          (const Reg<T> v)                       const { return std::min<T>(r, v.r);                    }
	inline Reg<T>      max          (const Reg<T> v)                       const { return std::max<T>(r, v.r);                    }
	// (1 = positive, -1 = negative, 0 = 0)
	inline Reg<T>      msb          ()                                     const { return mipp_scop::msb<T>(r);                   }
	inline Reg<T>      msb          (const Reg<T> v)                       const { return msb(Reg<T>(r ^ v.r));                   }
	inline Msk<N<T>()> sign         ()                                     const { return r < 0;                                  }
	inline Reg<T>      neg          (const Reg<T> v)                       const { return v.r >= 0 ? Reg<T>(r) : Reg<T>(-r);      }
	inline Reg<T>      neg          (const Msk<N<T>()> v)                  const { return v.m == 0 ? Reg<T>(r) : Reg<T>(-r);      }
	inline Reg<T>      copysign     (const Reg<T> v)                       const { return this->neg(v);                           }
	inline Reg<T>      copysign     (const Msk<N<T>()> v)                  const { return this->neg(v);                           }
	inline Reg<T>      abs          ()                                     const { return std::abs(r);                            }
	inline Reg<T>      sqrt         ()                                     const { return (T)std::sqrt(r);                        }
	inline Reg<T>      rsqrt        ()                                     const { return (T)(1 / std::sqrt(r));                  }
	inline Reg<T>      log          ()                                     const { return (T)std::log(r);                         }
	inline Reg<T>      exp          ()                                     const { return (T)std::exp(r);                         }
	inline Reg<T>      sin          ()                                     const { return (T)std::sin(r);                         }
	inline Reg<T>      cos          ()                                     const { return (T)std::cos(r);                         }
	inline Reg<T>      tan          ()                                     const { return (T)std::tan(r);                         }
	inline void        sincos       (      Reg<T> &s,       Reg<T> &c)     const { s = std::sin(r); c = std::cos(r);              }
	inline Reg<T>      sinh         ()                                     const { return (T)std::sinh(r);                        }
	inline Reg<T>      cosh         ()                                     const { return (T)std::cosh(r);                        }
	inline Reg<T>      tanh         ()                                     const { return (T)std::tanh(r);                        }
	inline Reg<T>      asinh        ()                                     const { return (T)std::asinh(r);                       }
	inline Reg<T>      acosh        ()                                     const { return (T)std::acosh(r);                       }
	inline Reg<T>      atanh        ()                                     const { return (T)std::atanh(r);                       }
	inline Reg<T>      fmadd        (const Reg<T> v1, const Reg<T> v2)     const { return   r * v1.r + v2.r;                      }
	inline Reg<T>      fnmadd       (const Reg<T> v1, const Reg<T> v2)     const { return v2.r -(r * v1.r);                       }
	inline Reg<T>      fmsub        (const Reg<T> v1, const Reg<T> v2)     const { return   r * v1.r - v2.r;                      }
	inline Reg<T>      fnmsub       (const Reg<T> v1, const Reg<T> v2)     const { return -v2.r - (r * v1.r) ;                    }
	inline Reg<T>      blend        (const Reg<T> v1, const Msk<N<T>()> m) const { return (m.m) ? r : v1.r;                       }
	inline Reg<T>      lrot         ()                                     const { return r;                                      }
	inline Reg<T>      rrot         ()                                     const { return r;                                      }
	inline Reg<T>      div2         ()                                     const { return mipp_scop::div2<T>(r);                  }
	inline Reg<T>      div4         ()                                     const { return mipp_scop::div4<T>(r);                  }
	inline Reg<T>      sat          (T min, T max)                         const { return std::min(std::max(r, min), max);        }
	inline Reg<T>      round        ()                                     const { return std::round(r);                          }
	inline bool        testz        (const Reg<T> v)                       const { return mipp_scop::andb<T>(r, v.r) == 0 ? 1 : 0;}
	inline bool        testz        ()                                     const { return !r;                                     }
#endif
	inline Reg<T>      andb         (const Msk<N<T>()> m)                  const { return this->andb (m.template toReg<T>().r); }
	inline Reg<T>      andnb        (const Msk<N<T>()> m)                  const { return this->andnb(m.template toReg<T>().r); }
	inline Reg<T>      orb          (const Msk<N<T>()> m)                  const { return this->orb  (m.template toReg<T>().r); }
	inline Reg<T>      xorb         (const Msk<N<T>()> m)                  const { return this->xorb (m.template toReg<T>().r); }

#ifndef MIPP_NO_INTRINSICS
	template <typename T2> inline Reg<T2> cvt ()               const { return mipp::cvt<T,T2>(r);       }
	template <typename T2> inline Reg<T2> pack(const Reg<T> v) const { return mipp::pack<T,T2>(r, v.r); }
	template <typename T2> inline Reg<T2> cast()               const { return Reg<T2>(this->r);         }
#else
	template <typename T2> inline Reg<T2> cvt ()               const { return (T2)std::round(r);        }
	template <typename T2> inline Reg<T2> pack(const Reg<T> v) const
	{
		throw std::runtime_error("mipp::Reg<T>::pack: non-sense in sequential mode.");
	}
	template <typename T2> inline Reg<T2> cast()               const { return Reg<T2>((T2)this->r);     }
#endif

	inline Reg<T>& operator+= (const Reg<T>      &v)       { r =    this->add(v).r;    return *this; }
	inline Reg<T>  operator+  (const Reg<T>       v) const { return this->add(v);                    }

	inline Reg<T>& operator-= (const Reg<T>      &v)       { r =    this->sub(v).r;    return *this; }
	inline Reg<T>  operator-  (const Reg<T>       v) const { return this->sub(v);                    }

	inline Reg<T>& operator*= (const Reg<T>      &v)       { r =    this->mul(v).r;    return *this; }
	inline Reg<T>  operator*  (const Reg<T>       v) const { return this->mul(v);                    }

	inline Reg<T>& operator/= (const Reg<T>      &v)       { r =    this->div(v).r;    return *this; }
	inline Reg<T>  operator/  (const Reg<T>       v) const { return this->div(v);                    }

	inline Reg<T>  operator~  (                    )       { return this->notb();                    }

	inline Reg<T>& operator^= (const Reg<T>      &v)       { r =    this->xorb(v).r;   return *this; }
	inline Reg<T>  operator^  (const Reg<T>       v) const { return this->xorb(v);                   }
//	inline Reg<T>& operator^= (const Msk<N<T>()> &v)       { r =    this->xorb(v).r;   return *this; }
//	inline Reg<T>  operator^  (const Msk<N<T>()>  v) const { return this->xorb(v);                   }

	inline Reg<T>& operator|= (const Reg<T>      &v)       { r =    this->orb(v).r;    return *this; }
	inline Reg<T>  operator|  (const Reg<T>       v) const { return this->orb(v);                    }
//	inline Reg<T>& operator|= (const Msk<N<T>()> &v)       { r =    this->orb(v).r;    return *this; }
//	inline Reg<T>  operator|  (const Msk<N<T>()>  v) const { return this->orb(v);                    }

	inline Reg<T>& operator&= (const Reg<T>      &v)       { r =    this->andb(v).r;   return *this; }
	inline Reg<T>  operator&  (const Reg<T>       v) const { return this->andb(v);                   }
//	inline Reg<T>& operator&= (const Msk<N<T>()> &v)       { r =    this->andb(v).r;   return *this; }
//	inline Reg<T>  operator&  (const Msk<N<T>()>  v) const { return this->andb(v);                   }

	inline Reg<T>& operator<<=(const uint32_t     n)       { r =    this->lshift(n).r; return *this; }
	inline Reg<T>  operator<< (const uint32_t     n) const { return this->lshift(n);                 }

	inline Reg<T>& operator>>=(const uint32_t     n)       { r =    this->rshift(n).r; return *this; }
	inline Reg<T>  operator>> (const uint32_t     n) const { return this->rshift(n);                 }

	inline Msk<N<T>()> operator==(Reg<T> v) const { return this->cmpeq (v); }
	inline Msk<N<T>()> operator!=(Reg<T> v) const { return this->cmpneq(v); }
	inline Msk<N<T>()> operator< (Reg<T> v) const { return this->cmplt (v); }
	inline Msk<N<T>()> operator<=(Reg<T> v) const { return this->cmple (v); }
	inline Msk<N<T>()> operator> (Reg<T> v) const { return this->cmpgt (v); }
	inline Msk<N<T>()> operator>=(Reg<T> v) const { return this->cmpge (v); }

#ifndef MIPP_NO_INTRINSICS
	inline const T& operator[](size_t index) const { return *((T*)&this->r + index); }
#else
	inline const T& operator[](size_t index) const { return r; }
#endif

	// ------------------------------------------------------------------------------------------------------ reduction
#ifndef MIPP_NO_INTRINSICS
	inline T sum () const { return Reduction<T,mipp::add>::sapply(*this); }
	inline T hadd() const { return Reduction<T,mipp::add>::sapply(*this); }
	inline T hmul() const { return Reduction<T,mipp::mul>::sapply(*this); }
	inline T hmin() const { return Reduction<T,mipp::min>::sapply(*this); }
	inline T hmax() const { return Reduction<T,mipp::max>::sapply(*this); }
#else
	inline T sum () const { return this->r; }
	inline T hadd() const { return this->r; }
	inline T hmul() const { return this->r; }
	inline T hmin() const { return this->r; }
	inline T hmax() const { return this->r; }
#endif

	// -------------------------------------------------------------------------------------------------------- masking
	template <proto_I1<T> I1>
	inline Reg<T> mask(const Msk<N<T>()> m, const Reg<T> src) const
	{
		return mipp::mask<T, I1>(m, src, *this);
	}

	template <proto_I2<T> I2>
	inline Reg<T> mask(const Msk<N<T>()> m, const Reg<T> src, const Reg<T> b) const
	{
		return mipp::mask<T, I2>(m, src, *this, b);
	}

	template <proto_I3<T> I3>
	inline Reg<T> mask(const Msk<N<T>()> m, const Reg<T> src, const Reg<T> b, const Reg<T> c) const
	{
		return mipp::mask<T, I3>(m, src, *this, b, c);
	}

	template <proto_I1<T> I1>
	inline Reg<T> maskz(const Msk<N<T>()> m) const
	{
		return mipp::maskz<T, I1>(m, *this);
	}

	template <proto_I2<T> I2>
	inline Reg<T> maskz(const Msk<N<T>()> m, const Reg<T> b) const
	{
		return mipp::maskz<T, I2>(m, *this, b);
	}

	template <proto_I3<T> I3>
	inline Reg<T> maskz(const Msk<N<T>()> m, const Reg<T> b, const Reg<T> c) const
	{
		return mipp::maskz<T, I3>(m, *this, b, c);
	}
};

template <int N>
class Msk
{
public:
	msk m;

	Msk(){}
	Msk(const msk m) : m(m) {}

#ifndef MIPP_NO_INTRINSICS
	Msk(const bool val    ) : m(mipp::set1<N>(val) ) {}
	Msk(const bool vals[N]) : m(mipp::set <N>(vals)) {}
	Msk(const std::initializer_list<bool> &l)
	{
		if ((int)l.size() >= N)
			m = mipp::set<N>(l.begin());
		else
			throw std::runtime_error("mipp::Msk<N>: invalid 'initializer_list' size.");
	}

#else
	Msk(const bool val    ) : m(val     ? ~0 : 0) {}
	Msk(const bool vals[N]) : m(vals[0] ? ~0 : 0) {}
	Msk(const std::initializer_list<bool> &l)
	{
		auto vec = std::vector<bool>(N);
		vec = l;
		m = vec[0] ? ~0 : 0;
	}

#endif

#ifndef MIPP_NO_INTRINSICS
	template <typename T>
	inline Reg<T> toReg() const
	{
		static_assert(mipp::N<T>() == N, "mipp::Msk<N>: T type is invalid.");
		return Reg<T>(mipp::toreg<N>(this->m));
	}
#else
	template <typename T>
	inline Reg<T> toReg() const
	{
		return this->m ? (T)1 : (T)0;
	}
#endif

	~Msk() {}

#ifndef MIPP_NO_INTRINSICS
	inline void set0(              ) { m = mipp::set0<N>(   ); }
	inline void set1(const bool val) { m = mipp::set1<N>(val); }
#else
	inline void set0(              ) { m = 0;                   }
	inline void set1(const bool val) { m = val ? ~0 : 0;        }
#endif

#ifndef MIPP_NO_INTRINSICS
	inline Msk<N> andb  (const Msk<N>   v) const { return mipp::andb  <N>(m, v.m); }
	inline Msk<N> andnb (const Msk<N>   v) const { return mipp::andnb <N>(m, v.m); }
	inline Msk<N> notb  ()                 const { return mipp::notb  <N>(m);      }
	inline Msk<N> orb   (const Msk<N>   v) const { return mipp::orb   <N>(m, v.m); }
	inline Msk<N> xorb  (const Msk<N>   v) const { return mipp::xorb  <N>(m, v.m); }
	inline Msk<N> lshift(const uint32_t n) const { return mipp::lshift<N>(m, n);   }
	inline Msk<N> rshift(const uint32_t n) const { return mipp::rshift<N>(m, n);   }
	inline bool   testz (const Msk<N>   v) const { return mipp::testz <N>(m, v.m); }
	inline bool   testz ()                 const { return mipp::testz <N>(m);      }
#else
	inline Msk<N> andb  (const Msk<N>   v) const { return mipp_scop::andb<msk>( m, v.m);                  }
	inline Msk<N> andnb (const Msk<N>   v) const { return mipp_scop::andb<msk>(~m, v.m);                  }
	inline Msk<N> notb  ()                 const { return (msk)~m;                                        }
	inline Msk<N> orb   (const Msk<N>   v) const { return (msk)(m | v.m);                                 }
	inline Msk<N> xorb  (const Msk<N>   v) const { return mipp_scop::xorb  <msk>(m, v.m);                 }
	inline Msk<N> lshift(const uint32_t n) const { return mipp_scop::lshift<msk>(m, n * sizeof(msk) * 8); }
	inline Msk<N> rshift(const uint32_t n) const { return mipp_scop::rshift<msk>(m, n * sizeof(msk) * 8); }
	inline bool   testz (const Msk<N>   v) const { return mipp_scop::andb  <msk>(m, v.m) == 0 ? 1 : 0;    }
	inline bool   testz ()                 const { return !m;                                             }
#endif

	template <typename T> inline Reg<T> andb  (const Reg<T> v)  const { return this->toReg<T>().andb (v); }
	template <typename T> inline Reg<T> andnb (const Reg<T> v)  const { return this->toReg<T>().andnb(v); }
	template <typename T> inline Reg<T> orb   (const Reg<T> v)  const { return this->toReg<T>().orb  (v); }
	template <typename T> inline Reg<T> xorb  (const Reg<T> v)  const { return this->toReg<T>().xorb (v); }

	inline Msk<N>  operator~  (                )       { return this->notb();                    }

//	template <typename T>
//	inline Reg<T>  operator^  (const Reg<T>   v) const { return this->xorb(v);                   }
	inline Msk<N>& operator^= (const Msk<N>  &v)       { m =    this->xorb(v).m;  return *this;  }
	inline Msk<N>  operator^  (const Msk<N>   v) const { return this->xorb(v);                   }

//	template <typename T>
//	inline Reg<T>  operator|  (const Reg<T>   v) const { return this->orb(v);                    }
	inline Msk<N>& operator|= (const Msk<N>  &v)       { m =    this->orb(v).m;   return *this;  }
	inline Msk<N>  operator|  (const Msk<N>   v) const { return this->orb(v);                    }

//	template <typename T>
//	inline Reg<T>  operator&  (const Reg<T>   v) const { return this->andb(v);                   }
	inline Msk<N>& operator&= (const Msk<N>  &v)       { m =    this->andb(v).m;  return *this;  }
	inline Msk<N>  operator&  (const Msk<N>   v) const { return this->andb(v);                   }

	inline Msk<N>& operator<<=(const uint32_t n)       { m =    this->lshift(n).m; return *this; }
	inline Msk<N>  operator<< (const uint32_t n) const { return this->lshift(n);                 }

	inline Msk<N>& operator>>=(const uint32_t n)       { m =    this->rshift(n).m; return *this; }
	inline Msk<N>  operator>> (const uint32_t n) const { return this->rshift(n);                 }

#ifndef MIPP_NO_INTRINSICS
	inline bool operator[](size_t index) const
	{
#ifdef MIPP_AVX512
		return (this->m >> index) & 0x1;
#else
		uint8_t* ptr = (uint8_t*)&this->m;
		return ptr[index * (mipp::RegisterSizeBit / (N * 8))];
#endif
	}
#else
	inline bool operator[](size_t index) const { return m; }
#endif
};

template <typename T>
class Reg_2
{
public:
#ifndef MIPP_NO_INTRINSICS
	reg_2 r;
#else
	T r;
#endif

#ifndef MIPP_NO_INTRINSICS
	Reg_2(const reg_2 r) : r(r)   {}
#else
	Reg_2(const T val  ) : r(val) {}
#endif

	virtual ~Reg_2() {}

#ifndef MIPP_NO_INTRINSICS
	template <typename T2> inline Reg<T2> cvt() const { return mipp::cvt<T,T2>(r); }
#else
	template <typename T2> inline Reg<T2> cvt() const { return (T2)std::round(r);  }
#endif

#ifndef MIPP_NO_INTRINSICS
	inline const T& operator[](size_t index) const { return *((T*)&this->r + index); }
#else
	inline const T& operator[](size_t index) const { return r; }
#endif
};

template <typename T>
class Regx2
{
public:
	Reg<T> val[2];

	Regx2(                    )                                             {}
	Regx2(Reg<T> r1, Reg<T> r2) : val{r1, r2}                               {}
#ifndef MIPP_NO_INTRINSICS
	Regx2(regx2 r2            ) : val{Reg<T>(r2.val[0]), Reg<T>(r2.val[1])} {}
#endif

	inline const Reg<T>& operator[](size_t index) const { return val[index]; }

	~Regx2() {}
};

#ifndef MIPP_NO_INTRINSICS
template <typename T>
std::ostream& operator<<(std::ostream& os, const Reg<T>& r)
{
	dump<T>(r.r, os); return os;
}

template <int N>
std::ostream& operator<<(std::ostream& os, const Msk<N>& m)
{
	dump<N>(m.m, os); return os;
}
#else
template <typename T>
std::ostream& operator<<(std::ostream& os, const Reg<T>& r)
{
	os << +r.r;
	return os;
}

template <int N>
std::ostream& operator<<(std::ostream& os, const Msk<N>& m)
{
	os << (m.m ? 1 : 0);
	return os;
}
#endif

//template <typename T> inline Reg<T>      load         (const T* in)                                           { Reg<T> r; r.load (in); return r; }
//template <typename T> inline Reg<T>      loadu        (const T* in)                                           { Reg<T> r; r.loadu(in); return r; }
//template <typename T> inline void        store        (T* out, const Reg<T> v)                                { v.store (out);                   }
//template <typename T> inline void        storeu       (T* out, const Reg<T> v)                                { v.storeu(out);                   }
//template <typename T> inline Reg<T>      set          (const T in[N<T>()])                                    { Reg<T> r; r.set(in);   return r; }
//#ifdef _MSC_VER
//template <int      N> inline Msk<N>      set          (const bool in[])                                       { Msk<N> m; m.set(in);   return m; }
//#else
//template <int      N> inline Msk<N>      set          (const bool in[N])                                      { Msk<N> m; m.set(in);   return m; }
//#endif
//template <typename T> inline Reg<T>      set1         (const T val)                                           { Reg<T> r; r.set1(val); return r; }
//template <int      N> inline Msk<N>      set1         (const bool val)                                        { Msk<N> m; m.set1(val); return m; }
//template <typename T> inline Reg<T>      set0         ()                                                      { Reg<T> r; r.set0();    return r; }
//template <int      N> inline Msk<N>      set0         ()                                                      { Msk<N> m; m.set0();    return m; }
template <typename T> inline Reg<T>      shuff        (const Reg<T> v1, const Reg<T> v2)                      { return v1.shuff(v2);             }
template <typename T> inline Reg<T>      shuff2       (const Reg<T> v1, const Reg<T> v2)                      { return v1.shuff2(v2);            }
template <typename T> inline Reg<T>      shuff4       (const Reg<T> v1, const Reg<T> v2)                      { return v1.shuff4(v2);            }
template <typename T> inline Reg<T>      interleavelo (const Reg<T> v1, const Reg<T> v2)                      { return v1.interleavelo(v2);      }
template <typename T> inline Reg<T>      interleavehi (const Reg<T> v1, const Reg<T> v2)                      { return v1.interleavehi(v2);      }
template <typename T> inline Reg<T>      interleavelo2(const Reg<T> v1, const Reg<T> v2)                      { return v1.interleavelo2(v2);     }
template <typename T> inline Reg<T>      interleavehi2(const Reg<T> v1, const Reg<T> v2)                      { return v1.interleavehi2(v2);     }
template <typename T> inline Reg<T>      interleavelo4(const Reg<T> v1, const Reg<T> v2)                      { return v1.interleavelo4(v2);     }
template <typename T> inline Reg<T>      interleavehi4(const Reg<T> v1, const Reg<T> v2)                      { return v1.interleavehi4(v2);     }
template <typename T> inline Regx2<T>    interleave   (const Reg<T> v1, const Reg<T> v2)                      { return v1.interleave(v2);        }
template <typename T> inline Regx2<T>    interleave2  (const Reg<T> v1, const Reg<T> v2)                      { return v1.interleave2(v2);       }
template <typename T> inline Regx2<T>    interleave4  (const Reg<T> v1, const Reg<T> v2)                      { return v1.interleave4(v2);       }
template <typename T> inline Reg<T>      interleave   (const Reg<T> v)                                        { return v.interleave();           }
template <typename T> inline Regx2<T>    interleavex2 (const Reg<T> v1, const Reg<T> v2)                      { return v1.interleavex2(v2);      }
template <typename T> inline Reg<T>      interleavex4 (const Reg<T> v)                                        { return v.interleavex4();         }
template <typename T> inline Reg<T>      interleavex16(const Reg<T> v)                                        { return v.interleavex16();        }
template <typename T> inline Reg<T>      andb         (const Reg<T> v1, const Reg<T> v2)                      { return v1.andb(v2);              }
template <int      N> inline Msk<N>      andb         (const Msk<N> v1, const Msk<N> v2)                      { return v1.andb(v2);              }
template <typename T> inline Reg<T>      andb         (const Reg<T> v1, const Msk<N<T>()> v2)                 { return v1.andb(v2);              }
template <typename T> inline Reg<T>      andb         (const Msk<N<T>()> v1, const Reg<T> v2)                 { return v1.andb(v2);              }
template <typename T> inline Reg<T>      andnb        (const Reg<T> v1, const Reg<T>v2)                       { return v1.andnb(v2);             }
template <int      N> inline Msk<N>      andnb        (const Msk<N> v1, const Msk<N>v2)                       { return v1.andnb(v2);             }
template <typename T> inline Reg<T>      andnb        (const Reg<T> v1, const Msk<N<T>()> v2)                 { return v1.andnb(v2);             }
template <typename T> inline Reg<T>      andnb        (const Msk<N<T>()> v1, const Reg<T> v2)                 { return v1.andnb(v2);             }
template <typename T> inline Reg<T>      notb         (const Reg<T> v)                                        { return v.notb();                 }
template <int      N> inline Msk<N>      notb         (const Msk<N> v)                                        { return v.notb();                 }
template <typename T> inline Reg<T>      orb          (const Reg<T> v1, const Reg<T> v2)                      { return v1.orb(v2);               }
template <int      N> inline Msk<N>      orb          (const Msk<N> v1, const Msk<N> v2)                      { return v1.orb(v2);               }
template <typename T> inline Reg<T>      orb          (const Reg<T> v1, const Msk<N<T>()> v2)                 { return v1.orb(v2);               }
template <typename T> inline Reg<T>      orb          (const Msk<N<T>()> v1, const Reg<T> v2)                 { return v1.orb(v2);               }
template <typename T> inline Reg<T>      xorb         (const Reg<T> v1, const Reg<T> v2)                      { return v1.xorb(v2);              }
template <int      N> inline Msk<N>      xorb         (const Msk<N> v1, const Msk<N> v2)                      { return v1.xorb(v2);              }
template <typename T> inline Reg<T>      xorb         (const Reg<T> v1, const Msk<N<T>()> v2)                 { return v1.xorb(v2);              }
template <typename T> inline Reg<T>      xorb         (const Msk<N<T>()> v1, const Reg<T> v2)                 { return v1.xorb(v2);              }
template <typename T> inline Reg<T>      lshift       (const Reg<T> v,  const uint32_t n)                     { return v.lshift(n);              }
template <int      N> inline Msk<N>      lshift       (const Msk<N> v,  const uint32_t n)                     { return v.lshift(n);              }
template <typename T> inline Reg<T>      rshift       (const Reg<T> v,  const uint32_t n)                     { return v.rshift(n);              }
template <int      N> inline Msk<N>      rshift       (const Msk<N> v,  const uint32_t n)                     { return v.rshift(n);              }
template <typename T> inline Msk<N<T>()> cmpeq        (const Reg<T> v1, const Reg<T> v2)                      { return v1.cmpeq(v2);             }
template <typename T> inline Msk<N<T>()> cmpneq       (const Reg<T> v1, const Reg<T> v2)                      { return v1.cmpneq(v2);            }
template <typename T> inline Msk<N<T>()> cmplt        (const Reg<T> v1, const Reg<T> v2)                      { return v1.cmplt(v2);             }
template <typename T> inline Msk<N<T>()> cmple        (const Reg<T> v1, const Reg<T> v2)                      { return v1.cmple(v2);             }
template <typename T> inline Msk<N<T>()> cmpgt        (const Reg<T> v1, const Reg<T> v2)                      { return v1.cmpgt(v2);             }
template <typename T> inline Msk<N<T>()> cmpge        (const Reg<T> v1, const Reg<T> v2)                      { return v1.cmpge(v2);             }
template <typename T> inline Reg<T>      add          (const Reg<T> v1, const Reg<T> v2)                      { return v1.add(v2);               }
template <typename T> inline Reg<T>      sub          (const Reg<T> v1, const Reg<T> v2)                      { return v1.sub(v2);               }
template <typename T> inline Reg<T>      mul          (const Reg<T> v1, const Reg<T> v2)                      { return v1.mul(v2);               }
template <typename T> inline Reg<T>      div          (const Reg<T> v1, const Reg<T> v2)                      { return v1.div(v2);               }
template <typename T> inline Reg<T>      min          (const Reg<T> v1, const Reg<T> v2)                      { return v1.min(v2);               }
template <typename T> inline Reg<T>      max          (const Reg<T> v1, const Reg<T> v2)                      { return v1.max(v2);               }
template <typename T> inline Reg<T>      msb          (const Reg<T> v)                                        { return v.msb();                  }
template <typename T> inline Reg<T>      msb          (const Reg<T> v1, const Reg<T> v2)                      { return v1.msb(v2);               }
template <typename T> inline Msk<N<T>()> sign         (const Reg<T> v)                                        { return v.sign();                 }
template <typename T> inline Reg<T>      neg          (const Reg<T> v1, const Reg<T> v2)                      { return v1.neg(v2);               }
template <typename T> inline Reg<T>      neg          (const Reg<T> v1, const Msk<N<T>()> v2)                 { return v1.neg(v2);               }
template <typename T> inline Reg<T>      copysign     (const Reg<T> v1, const Reg<T> v2)                      { return v1.copysign(v2);          }
template <typename T> inline Reg<T>      copysign     (const Reg<T> v1, const Msk<N<T>()> v2)                 { return v1.copysign(v2);          }
template <typename T> inline Reg<T>      abs          (const Reg<T> v)                                        { return v.abs();                  }
template <typename T> inline Reg<T>      sqrt         (const Reg<T> v)                                        { return v.sqrt();                 }
template <typename T> inline Reg<T>      rsqrt        (const Reg<T> v)                                        { return v.rsqrt();                }
template <typename T> inline Reg<T>      log          (const Reg<T> v)                                        { return v.log();                  }
template <typename T> inline Reg<T>      exp          (const Reg<T> v)                                        { return v.exp();                  }
template <typename T> inline Reg<T>      sin          (const Reg<T> v)                                        { return v.sin();                  }
template <typename T> inline Reg<T>      cos          (const Reg<T> v)                                        { return v.cos();                  }
template <typename T> inline Reg<T>      tan          (const Reg<T> v)                                        { return v.tan();                  }
template <typename T> inline void        sincos       (const Reg<T> x,        Reg<T> &s,       Reg<T> &c)     { return x.sincos(s,c);            }
template <typename T> inline Reg<T>      sinh         (const Reg<T> v)                                        { return v.sinh();                 }
template <typename T> inline Reg<T>      cosh         (const Reg<T> v)                                        { return v.cosh();                 }
template <typename T> inline Reg<T>      tanh         (const Reg<T> v)                                        { return v.tanh();                 }
template <typename T> inline Reg<T>      asinh        (const Reg<T> v)                                        { return v.asinh();                }
template <typename T> inline Reg<T>      acosh        (const Reg<T> v)                                        { return v.acosh();                }
template <typename T> inline Reg<T>      atanh        (const Reg<T> v)                                        { return v.atanh();                }
template <typename T> inline Reg<T>      fmadd        (const Reg<T> v1, const Reg<T> v2, const Reg<T> v3)     { return v1.fmadd(v2, v3);         }
template <typename T> inline Reg<T>      fnmadd       (const Reg<T> v1, const Reg<T> v2, const Reg<T> v3)     { return v1.fnmadd(v2, v3);        }
template <typename T> inline Reg<T>      fmsub        (const Reg<T> v1, const Reg<T> v2, const Reg<T> v3)     { return v1.fmsub(v2, v3);         }
template <typename T> inline Reg<T>      fnmsub       (const Reg<T> v1, const Reg<T> v2, const Reg<T> v3)     { return v1.fnmsub(v2, v3);        }
template <typename T> inline Reg<T>      blend        (const Reg<T> v1, const Reg<T> v2, const Msk<N<T>()> m) { return v1.blend(v2, m );         }
template <typename T> inline Reg<T>      lrot         (const Reg<T> v)                                        { return v.lrot();                 }
template <typename T> inline Reg<T>      rrot         (const Reg<T> v)                                        { return v.rrot();                 }
template <typename T> inline Reg<T>      div2         (const Reg<T> v)                                        { return v.div2();                 }
template <typename T> inline Reg<T>      div4         (const Reg<T> v)                                        { return v.div4();                 }
template <typename T> inline Reg<T>      sat          (const Reg<T> v, T min, T max)                          { return v.sat(min, max);          }
template <typename T> inline Reg<T>      round        (const Reg<T> v)                                        { return v.round();                }
template <typename T> inline bool        testz        (const Reg<T> v1, const Reg<T> v2)                      { return v1.testz(v2);             }
template <int      N> inline bool        testz        (const Msk<N> v1, const Msk<N> v2)                      { return v1.testz(v2);             }
template <typename T> inline bool        testz        (const Reg<T> v1)                                       { return v1.testz();               }
template <int      N> inline bool        testz        (const Msk<N> v1)                                       { return v1.testz();               }
template <typename T> inline     T       sum          (const Reg<T> v)                                        { return v.sum();                  }
template <typename T> inline     T       hadd         (const Reg<T> v)                                        { return v.hadd();                 }
template <typename T> inline     T       hmul         (const Reg<T> v)                                        { return v.hmul();                 }
template <typename T> inline     T       hmin         (const Reg<T> v)                                        { return v.hmin();                 }
template <typename T> inline     T       hmax         (const Reg<T> v)                                        { return v.hmax();                 }

template <typename T>
inline Reg<T> toReg(const Msk<N<T>()> m)
{
	return m.template toReg<T>();
}

template <typename T1, typename T2>
inline Reg<T2> cvt(const Reg<T1> v) {
	return v.template cvt<T2>();
}

template <typename T1, typename T2>
inline Reg<T2> cvt(const Reg_2<T1> v) {
	return v.template cvt<T2>();
}

template <typename T1, typename T2>
inline Reg<T2> pack(const Reg<T1> v1, const Reg<T1> v2) {
	return v1.template pack<T2>(v2);
}

template <typename T1, typename T2>
inline Reg<T2> cast(const Reg<T1> v)
{
	return v.template cast<T2>();
}


<|start_filename|>opencv/include/MIPP/mipp_scalar_op.h<|end_filename|>
#ifndef MIPP_SCALAR_OP_H_
#define MIPP_SCALAR_OP_H_

namespace mipp_scop // My Intrinsics Plus Plus SCalar OPerations
{
	template <typename T>
	inline T add(const T val1, const T val2);

	template <typename T>
	inline T sub(const T val1, const T val2);

	template <typename T>
	inline T andb(const T val1, const T val2);

	template <typename T>
	inline T xorb(const T val1, const T val2);

	template <typename T>
	inline T msb(const T val);

	template <typename T>
	inline T div2(const T val);

	template <typename T>
	inline T div4(const T val);

	template <typename T>
	inline T rshift(const T val, const int n);

	template <typename T>
	inline T lshift(const T val, const int n);
}

#include "mipp_scalar_op.hxx"

#endif /* MIPP_SCALAR_OP_H_ */


<|start_filename|>opencv/include/opencv2/imgproc/hal/interface.h<|end_filename|>
#ifndef OPENCV_IMGPROC_HAL_INTERFACE_H
#define OPENCV_IMGPROC_HAL_INTERFACE_H

//! @addtogroup imgproc_hal_interface
//! @{

//! @name Interpolation modes
//! @sa cv::InterpolationFlags
//! @{
#define CV_HAL_INTER_NEAREST 0
#define CV_HAL_INTER_LINEAR 1
#define CV_HAL_INTER_CUBIC 2
#define CV_HAL_INTER_AREA 3
#define CV_HAL_INTER_LANCZOS4 4
//! @}

//! @name Morphology operations
//! @sa cv::MorphTypes
//! @{
#define CV_HAL_MORPH_ERODE 0
#define CV_HAL_MORPH_DILATE 1
//! @}

//! @name Threshold types
//! @sa cv::ThresholdTypes
//! @{
#define CV_HAL_THRESH_BINARY      0
#define CV_HAL_THRESH_BINARY_INV  1
#define CV_HAL_THRESH_TRUNC       2
#define CV_HAL_THRESH_TOZERO      3
#define CV_HAL_THRESH_TOZERO_INV  4
#define CV_HAL_THRESH_MASK        7
#define CV_HAL_THRESH_OTSU        8
#define CV_HAL_THRESH_TRIANGLE    16
//! @}

//! @name Adaptive threshold algorithm
//! @sa cv::AdaptiveThresholdTypes
//! @{
#define CV_HAL_ADAPTIVE_THRESH_MEAN_C     0
#define CV_HAL_ADAPTIVE_THRESH_GAUSSIAN_C 1
//! @}

//! @}

#endif


<|start_filename|>opencv_dnn/cpp/face_def.hpp<|end_filename|>
#ifndef FACE_DEF_HPP
#define FACE_DEF_HPP

#pragma once

#include "opencv2/opencv.hpp"

// center/topleft: [x, y], width: w, height: h
typedef cv::Rect2f Box;

typedef struct Landmarks_5 {
    // right eye
    cv::Point2f right_eye;
    // left eye
    cv::Point2f left_eye;
    // nose tip
    cv::Point2f nose_tip;
    // mouth right
    cv::Point2f mouth_right;
    // mouth left
    cv::Point2f mouth_left;
} Landmarks_5;

typedef struct Face {
    Box bbox_tlwh;
    Landmarks_5 landmarks;
    float score;
} Face;

#endif 


<|start_filename|>opencv/include/opencv2/core/utils/logger.hpp<|end_filename|>
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.

#ifndef OPENCV_LOGGER_HPP
#define OPENCV_LOGGER_HPP

#include <iostream>
#include <sstream>
#include <limits.h> // INT_MAX

#include "logger.defines.hpp"

//! @addtogroup core_logging
// This section describes OpenCV logging utilities.
//
//! @{

namespace cv {
namespace utils {
namespace logging {

//! Supported logging levels and their semantic
enum LogLevel {
    LOG_LEVEL_SILENT = 0,              //!< for using in setLogVevel() call
    LOG_LEVEL_FATAL = 1,               //!< Fatal (critical) error (unrecoverable internal error)
    LOG_LEVEL_ERROR = 2,               //!< Error message
    LOG_LEVEL_WARNING = 3,             //!< Warning message
    LOG_LEVEL_INFO = 4,                //!< Info message
    LOG_LEVEL_DEBUG = 5,               //!< Debug message. Disabled in the "Release" build.
    LOG_LEVEL_VERBOSE = 6,             //!< Verbose (trace) messages. Requires verbosity level. Disabled in the "Release" build.
#ifndef CV_DOXYGEN
    ENUM_LOG_LEVEL_FORCE_INT = INT_MAX
#endif
};

/** Set global logging level
@return previous logging level
*/
CV_EXPORTS LogLevel setLogLevel(LogLevel logLevel);
/** Get global logging level */
CV_EXPORTS LogLevel getLogLevel();

namespace internal {
/** Write log message */
CV_EXPORTS void writeLogMessage(LogLevel logLevel, const char* message);
} // namespace

/**
 * \def CV_LOG_STRIP_LEVEL
 *
 * Define CV_LOG_STRIP_LEVEL=CV_LOG_LEVEL_[DEBUG|INFO|WARN|ERROR|FATAL|DISABLED] to compile out anything at that and before that logging level
 */
#ifndef CV_LOG_STRIP_LEVEL
# if defined NDEBUG
#   define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_DEBUG
# else
#   define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE
# endif
#endif


#define CV_LOG_FATAL(tag, ...)   for(;;) { if (cv::utils::logging::getLogLevel() < cv::utils::logging::LOG_LEVEL_FATAL) break; std::stringstream ss; ss << __VA_ARGS__; cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LOG_LEVEL_FATAL, ss.str().c_str()); break; }
#define CV_LOG_ERROR(tag, ...)   for(;;) { if (cv::utils::logging::getLogLevel() < cv::utils::logging::LOG_LEVEL_ERROR) break; std::stringstream ss; ss << __VA_ARGS__; cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LOG_LEVEL_ERROR, ss.str().c_str()); break; }
#define CV_LOG_WARNING(tag, ...) for(;;) { if (cv::utils::logging::getLogLevel() < cv::utils::logging::LOG_LEVEL_WARNING) break; std::stringstream ss; ss << __VA_ARGS__; cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LOG_LEVEL_WARNING, ss.str().c_str()); break; }
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_INFO
#define CV_LOG_INFO(tag, ...)
#else
#define CV_LOG_INFO(tag, ...)    for(;;) { if (cv::utils::logging::getLogLevel() < cv::utils::logging::LOG_LEVEL_INFO) break; std::stringstream ss; ss << __VA_ARGS__; cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LOG_LEVEL_INFO, ss.str().c_str()); break; }
#endif
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_DEBUG
#define CV_LOG_DEBUG(tag, ...)
#else
#define CV_LOG_DEBUG(tag, ...)   for(;;) { if (cv::utils::logging::getLogLevel() < cv::utils::logging::LOG_LEVEL_DEBUG) break; std::stringstream ss; ss << __VA_ARGS__; cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LOG_LEVEL_DEBUG, ss.str().c_str()); break; }
#endif
#if CV_LOG_STRIP_LEVEL <= CV_LOG_LEVEL_VERBOSE
#define CV_LOG_VERBOSE(tag, v, ...)
#else
#define CV_LOG_VERBOSE(tag, v, ...) for(;;) { if (cv::utils::logging::getLogLevel() < cv::utils::logging::LOG_LEVEL_VERBOSE) break; std::stringstream ss; ss << "[VERB" << v << ":" << cv::utils::getThreadID() << "] " << __VA_ARGS__; cv::utils::logging::internal::writeLogMessage(cv::utils::logging::LOG_LEVEL_VERBOSE, ss.str().c_str()); break; }
#endif


}}} // namespace

//! @}

#endif // OPENCV_LOGGER_HPP
