mirror of
https://github.com/opencv/opencv.git
synced 2026-07-25 13:23:02 +04:00
Compare commits
196 Commits
4.5.0
...
4.5.1-openvino
| Author | SHA1 | Date | |
|---|---|---|---|
| 705e7b207c | |||
| ea91f7e57d | |||
| decdb68636 | |||
| d4cc7f4299 | |||
| 4699d2ba0c | |||
| e8536c4a0e | |||
| 2687a2b6dc | |||
| aab6362705 | |||
| 94e8a08d1d | |||
| ce8027c6fb | |||
| 301c078d19 | |||
| 9485113923 | |||
| 9acbfc6e05 | |||
| 4f3130f562 | |||
| a783bf4a93 | |||
| f7e8dc770a | |||
| 34909d97b4 | |||
| 474a67231c | |||
| a316b11aaa | |||
| b645fc10a3 | |||
| 8e1e08ee38 | |||
| d266fee8bb | |||
| 8357e865bc | |||
| 2c6a2f0381 | |||
| fe9a8ebea2 | |||
| b866d0dc38 | |||
| 2b558a3787 | |||
| 72d06080c6 | |||
| 3cdf926454 | |||
| 23baf1a75e | |||
| 025a9647af | |||
| 32e7ef8a3d | |||
| 2b82f8f12c | |||
| b5c162175b | |||
| 60c76cc289 | |||
| efd556b1a9 | |||
| 3a184ae677 | |||
| b4b2a276c8 | |||
| 464d53bb16 | |||
| 4c9e3723e8 | |||
| 06477743ab | |||
| e4a9ad1730 | |||
| d0b6637c1d | |||
| 58268b6eef | |||
| 14aa8affe5 | |||
| 56074c2eb3 | |||
| 3da1e8b2f8 | |||
| 786cecfe66 | |||
| dde3cb3b99 | |||
| 24f2b7dd3f | |||
| 936530f795 | |||
| cfbdbffcad | |||
| 71db9d3b57 | |||
| b455e1cf52 | |||
| 564d1a0f79 | |||
| 90bea15e35 | |||
| 892cac9e1b | |||
| f58f36dc88 | |||
| 9e84b860f2 | |||
| 2e7ef6f4e8 | |||
| cea137f313 | |||
| 79a82013ad | |||
| 05c011e842 | |||
| 3826158547 | |||
| a7c150ec66 | |||
| 61144f935e | |||
| d23435baac | |||
| 389495f76a | |||
| a3f3fbe05d | |||
| 4d00ed8df7 | |||
| 41e906d1a4 | |||
| 41c2669476 | |||
| 0e4b5b88dc | |||
| 011d8e80d8 | |||
| 1f8f0abe92 | |||
| d9c5b85671 | |||
| 76cf31bee7 | |||
| ed3591ed1f | |||
| d986cc4861 | |||
| 724001aa0f | |||
| 5564d73071 | |||
| 3fc1c73064 | |||
| 1b0dca9c2c | |||
| 5dae278652 | |||
| ef32d7fd16 | |||
| 30d91e8ed6 | |||
| 5f1ca33c6f | |||
| c69417149d | |||
| 08271e5591 | |||
| a104e7c593 | |||
| c3e7a23da5 | |||
| 083edb201c | |||
| df7bf9a048 | |||
| bed5debca6 | |||
| caa1658a4c | |||
| bb5b628cce | |||
| e12adcdf08 | |||
| 127a44f2b9 | |||
| 527cedd848 | |||
| ec5065eb53 | |||
| 90524a8528 | |||
| ad71a1633c | |||
| eb24575e2c | |||
| d9877efe1d | |||
| 7459613623 | |||
| fb69620a27 | |||
| a6e15b2f57 | |||
| 39ecd96b09 | |||
| 21a8d9569d | |||
| 07736c912f | |||
| 24d60da553 | |||
| 039795b405 | |||
| a110ede0a2 | |||
| 2a3cdba724 | |||
| 099ad1a259 | |||
| 6df92b3bca | |||
| 48ccbe39b4 | |||
| 716450ceb5 | |||
| 691c3d1e3c | |||
| ca8bb8d053 | |||
| 56d2b7137c | |||
| d9a62c42e5 | |||
| 97eaddd93b | |||
| e3ce0fbee3 | |||
| 364702b1c9 | |||
| 978f387961 | |||
| 209f6cdcc7 | |||
| 0f7b2eb79f | |||
| 4a0760719e | |||
| d011383a3d | |||
| 1fe276d041 | |||
| f345ed564a | |||
| 3d4563913d | |||
| 93c3775927 | |||
| afbf383ba3 | |||
| 36598677cf | |||
| 0ec94630d4 | |||
| c71f2714c6 | |||
| 71462d9f99 | |||
| 72dfd4846e | |||
| 61a8cf8ba7 | |||
| bd40952097 | |||
| 8869d3212f | |||
| ea1e3fb90d | |||
| 3a99fb9d34 | |||
| e1b56e376e | |||
| aac7c5465b | |||
| 22ee5c0c4d | |||
| e8058b9fdb | |||
| d31b6c3480 | |||
| 95ff928228 | |||
| 510dc17c2e | |||
| 2669d8ce73 | |||
| 7f3d8de26f | |||
| 331b73c8e4 | |||
| 1729297ef3 | |||
| 9138c98b25 | |||
| 456af21d8b | |||
| b87f7a625e | |||
| c3e8790dfd | |||
| bf49149c97 | |||
| 49d5960a32 | |||
| dcfa23d5d2 | |||
| 5ac0712cf1 | |||
| c82417697a | |||
| adac1da64e | |||
| 9c8626bf3c | |||
| ef21fd3cf8 | |||
| bd19f991a5 | |||
| e87ba1d317 | |||
| f9d1f5196a | |||
| b5717f82a0 | |||
| aa51382dbc | |||
| bc6a70c689 | |||
| 1fb6c6e6e5 | |||
| d2dbc9d7a0 | |||
| 8bf451a3e0 | |||
| 0d3e05f9b3 | |||
| 8c4d415412 | |||
| 06a09d5991 | |||
| 57c894f44d | |||
| 7de189114b | |||
| 4c048a487e | |||
| 09a62012b2 | |||
| b494de6a01 | |||
| dbeec7715d | |||
| 25163eb008 | |||
| 1048feac3b | |||
| 96e8b83d41 | |||
| 78476a0fe2 | |||
| de93782fab | |||
| 16561ed71e | |||
| 2dd2d60955 | |||
| e3da18121f | |||
| da555a2c9b | |||
| dfb9832a25 |
Vendored
+2
-2
@@ -27,7 +27,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_library(carotene_objs OBJECT
|
||||
add_library(carotene_objs OBJECT EXCLUDE_FROM_ALL
|
||||
${carotene_headers}
|
||||
${carotene_sources}
|
||||
)
|
||||
@@ -41,4 +41,4 @@ if(WITH_NEON)
|
||||
endif()
|
||||
|
||||
# we add dummy file to fix XCode build
|
||||
add_library(carotene STATIC EXCLUDE_FROM_ALL "$<TARGET_OBJECTS:carotene_objs>" "${CAROTENE_SOURCE_DIR}/dummy.cpp")
|
||||
add_library(carotene STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} "$<TARGET_OBJECTS:carotene_objs>" "${CAROTENE_SOURCE_DIR}/dummy.cpp")
|
||||
|
||||
Vendored
+2
-2
@@ -14,7 +14,7 @@ if(NOT DEFINED CPUFEATURES_SOURCES)
|
||||
endif()
|
||||
|
||||
include_directories(${CPUFEATURES_INCLUDE_DIRS})
|
||||
add_library(${OPENCV_CPUFEATURES_TARGET_NAME} STATIC ${CPUFEATURES_SOURCES})
|
||||
add_library(${OPENCV_CPUFEATURES_TARGET_NAME} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${CPUFEATURES_SOURCES})
|
||||
|
||||
set_target_properties(${OPENCV_CPUFEATURES_TARGET_NAME}
|
||||
PROPERTIES OUTPUT_NAME cpufeatures
|
||||
@@ -29,7 +29,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${OPENCV_CPUFEATURES_TARGET_NAME} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${OPENCV_CPUFEATURES_TARGET_NAME} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(cpufeatures LICENSE README.md)
|
||||
|
||||
Vendored
+2
-2
@@ -17,7 +17,7 @@ file(GLOB lib_hdrs ${IPP_IW_PATH}/include/*.h ${IPP_IW_PATH}/include/iw/*.h ${IP
|
||||
# Define the library target:
|
||||
# ----------------------------------------------------------------------------------
|
||||
|
||||
add_library(${IPP_IW_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
||||
add_library(${IPP_IW_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs} ${lib_hdrs})
|
||||
|
||||
if(UNIX)
|
||||
if(CV_GCC OR CV_CLANG OR CV_ICC)
|
||||
@@ -41,5 +41,5 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${IPP_IW_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${IPP_IW_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
Vendored
+2
-2
@@ -37,7 +37,7 @@ set(ITT_SRCS
|
||||
src/ittnotify/jitprofiling.c
|
||||
)
|
||||
|
||||
add_library(${ITT_LIBRARY} STATIC ${ITT_SRCS} ${ITT_PUBLIC_HDRS} ${ITT_PRIVATE_HDRS})
|
||||
add_library(${ITT_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${ITT_SRCS} ${ITT_PUBLIC_HDRS} ${ITT_PRIVATE_HDRS})
|
||||
|
||||
if(NOT WIN32)
|
||||
if(HAVE_DL_LIBRARY)
|
||||
@@ -60,7 +60,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${ITT_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${ITT_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(ittnotify src/ittnotify/LICENSE.BSD src/ittnotify/LICENSE.GPL)
|
||||
|
||||
Vendored
+2
-2
@@ -17,7 +17,7 @@ file(GLOB lib_ext_hdrs jasper/*.h)
|
||||
# Define the library target:
|
||||
# ----------------------------------------------------------------------------------
|
||||
|
||||
add_library(${JASPER_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs} ${lib_ext_hdrs})
|
||||
add_library(${JASPER_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs} ${lib_hdrs} ${lib_ext_hdrs})
|
||||
|
||||
if(WIN32 AND NOT MINGW)
|
||||
add_definitions(-DJAS_WIN_MSVC_BUILD)
|
||||
@@ -46,7 +46,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${JASPER_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${JASPER_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(jasper LICENSE README copyright)
|
||||
|
||||
+4
-4
@@ -4,9 +4,9 @@ ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter -Wsign-compare -Wshorten-6
|
||||
|
||||
set(VERSION_MAJOR 2)
|
||||
set(VERSION_MINOR 0)
|
||||
set(VERSION_REVISION 5)
|
||||
set(VERSION_REVISION 6)
|
||||
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION})
|
||||
set(LIBJPEG_TURBO_VERSION_NUMBER 2000005)
|
||||
set(LIBJPEG_TURBO_VERSION_NUMBER 2000006)
|
||||
|
||||
string(TIMESTAMP BUILD "opencv-${OPENCV_VERSION}-libjpeg-turbo")
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
@@ -106,7 +106,7 @@ set(JPEG_SOURCES ${JPEG_SOURCES} jsimd_none.c)
|
||||
|
||||
ocv_list_add_prefix(JPEG_SOURCES src/)
|
||||
|
||||
add_library(${JPEG_LIBRARY} STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
|
||||
add_library(${JPEG_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${JPEG_SOURCES} ${SIMD_OBJS})
|
||||
|
||||
set_target_properties(${JPEG_LIBRARY}
|
||||
PROPERTIES OUTPUT_NAME ${JPEG_LIBRARY}
|
||||
@@ -121,7 +121,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${JPEG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${JPEG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(libjpeg-turbo README.md LICENSE.md README.ijg)
|
||||
|
||||
Vendored
+1
-1
@@ -91,7 +91,7 @@ best of our understanding.
|
||||
The Modified (3-clause) BSD License
|
||||
===================================
|
||||
|
||||
Copyright (C)2009-2019 D. R. Commander. All Rights Reserved.
|
||||
Copyright (C)2009-2020 D. R. Commander. All Rights Reserved.
|
||||
Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
Vendored
+8
-14
@@ -223,12 +223,12 @@ https://www.iso.org/standard/54989.html and http://www.itu.int/rec/T-REC-T.871.
|
||||
A PDF file of the older JFIF 1.02 specification is available at
|
||||
http://www.w3.org/Graphics/JPEG/jfif3.pdf.
|
||||
|
||||
The TIFF 6.0 file format specification can be obtained by FTP from
|
||||
ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme
|
||||
found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems.
|
||||
IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6).
|
||||
Instead, we recommend the JPEG design proposed by TIFF Technical Note #2
|
||||
(Compression tag 7). Copies of this Note can be obtained from
|
||||
The TIFF 6.0 file format specification can be obtained from
|
||||
http://mirrors.ctan.org/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation
|
||||
scheme found in the TIFF 6.0 spec of 3-June-92 has a number of serious
|
||||
problems. IJG does not recommend use of the TIFF 6.0 design (TIFF Compression
|
||||
tag 6). Instead, we recommend the JPEG design proposed by TIFF Technical Note
|
||||
#2 (Compression tag 7). Copies of this Note can be obtained from
|
||||
http://www.ijg.org/files/. It is expected that the next revision
|
||||
of the TIFF spec will replace the 6.0 JPEG design with the Note's design.
|
||||
Although IJG's own code does not support TIFF/JPEG, the free libtiff library
|
||||
@@ -243,14 +243,8 @@ The most recent released version can always be found there in
|
||||
directory "files".
|
||||
|
||||
The JPEG FAQ (Frequently Asked Questions) article is a source of some
|
||||
general information about JPEG.
|
||||
It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/
|
||||
and other news.answers archive sites, including the official news.answers
|
||||
archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/.
|
||||
If you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu
|
||||
with body
|
||||
send usenet/news.answers/jpeg-faq/part1
|
||||
send usenet/news.answers/jpeg-faq/part2
|
||||
general information about JPEG. It is available at
|
||||
http://www.faqs.org/faqs/jpeg-faq.
|
||||
|
||||
|
||||
FILE FORMAT COMPATIBILITY
|
||||
|
||||
Vendored
+11
-10
@@ -2,7 +2,7 @@ Background
|
||||
==========
|
||||
|
||||
libjpeg-turbo is a JPEG image codec that uses SIMD instructions to accelerate
|
||||
baseline JPEG compression and decompression on x86, x86-64, ARM, PowerPC, and
|
||||
baseline JPEG compression and decompression on x86, x86-64, Arm, PowerPC, and
|
||||
MIPS systems, as well as progressive JPEG compression on x86 and x86-64
|
||||
systems. On such systems, libjpeg-turbo is generally 2-6x as fast as libjpeg,
|
||||
all else being equal. On other types of systems, libjpeg-turbo can still
|
||||
@@ -179,8 +179,8 @@ supported and which aren't.
|
||||
|
||||
NOTE: As of this writing, extensive research has been conducted into the
|
||||
usefulness of DCT scaling as a means of data reduction and SmartScale as a
|
||||
means of quality improvement. The reader is invited to peruse the research at
|
||||
<http://www.libjpeg-turbo.org/About/SmartScale> and draw his/her own conclusions,
|
||||
means of quality improvement. Readers are invited to peruse the research at
|
||||
<http://www.libjpeg-turbo.org/About/SmartScale> and draw their own conclusions,
|
||||
but it is the general belief of our project that these features have not
|
||||
demonstrated sufficient usefulness to justify inclusion in libjpeg-turbo.
|
||||
|
||||
@@ -287,12 +287,13 @@ following reasons:
|
||||
(and slightly faster) floating point IDCT algorithm introduced in libjpeg
|
||||
v8a as opposed to the algorithm used in libjpeg v6b. It should be noted,
|
||||
however, that this algorithm basically brings the accuracy of the floating
|
||||
point IDCT in line with the accuracy of the slow integer IDCT. The floating
|
||||
point DCT/IDCT algorithms are mainly a legacy feature, and they do not
|
||||
produce significantly more accuracy than the slow integer algorithms (to put
|
||||
numbers on this, the typical difference in PNSR between the two algorithms
|
||||
is less than 0.10 dB, whereas changing the quality level by 1 in the upper
|
||||
range of the quality scale is typically more like a 1.0 dB difference.)
|
||||
point IDCT in line with the accuracy of the accurate integer IDCT. The
|
||||
floating point DCT/IDCT algorithms are mainly a legacy feature, and they do
|
||||
not produce significantly more accuracy than the accurate integer algorithms
|
||||
(to put numbers on this, the typical difference in PNSR between the two
|
||||
algorithms is less than 0.10 dB, whereas changing the quality level by 1 in
|
||||
the upper range of the quality scale is typically more like a 1.0 dB
|
||||
difference.)
|
||||
|
||||
- If the floating point algorithms in libjpeg-turbo are not implemented using
|
||||
SIMD instructions on a particular platform, then the accuracy of the
|
||||
@@ -340,7 +341,7 @@ The algorithm used by the SIMD-accelerated quantization function cannot produce
|
||||
correct results whenever the fast integer forward DCT is used along with a JPEG
|
||||
quality of 98-100. Thus, libjpeg-turbo must use the non-SIMD quantization
|
||||
function in those cases. This causes performance to drop by as much as 40%.
|
||||
It is therefore strongly advised that you use the slow integer forward DCT
|
||||
It is therefore strongly advised that you use the accurate integer forward DCT
|
||||
whenever encoding images with a JPEG quality of 98 or higher.
|
||||
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -34,10 +34,10 @@
|
||||
* memory footprint by 64k, which is important for some mobile applications
|
||||
* that create many isolated instances of libjpeg-turbo (web browsers, for
|
||||
* instance.) This may improve performance on some mobile platforms as well.
|
||||
* This feature is enabled by default only on ARM processors, because some x86
|
||||
* This feature is enabled by default only on Arm processors, because some x86
|
||||
* chips have a slow implementation of bsr, and the use of clz/bsr cannot be
|
||||
* shown to have a significant performance impact even on the x86 chips that
|
||||
* have a fast implementation of it. When building for ARMv6, you can
|
||||
* have a fast implementation of it. When building for Armv6, you can
|
||||
* explicitly disable the use of clz/bsr by adding -mthumb to the compiler
|
||||
* flags (this defines __thumb__).
|
||||
*/
|
||||
|
||||
Vendored
+4
-1
@@ -1,8 +1,10 @@
|
||||
/*
|
||||
* jcinit.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -19,6 +21,7 @@
|
||||
#define JPEG_INTERNALS
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jpegcomp.h"
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Vendored
+2
-2
@@ -43,10 +43,10 @@
|
||||
* memory footprint by 64k, which is important for some mobile applications
|
||||
* that create many isolated instances of libjpeg-turbo (web browsers, for
|
||||
* instance.) This may improve performance on some mobile platforms as well.
|
||||
* This feature is enabled by default only on ARM processors, because some x86
|
||||
* This feature is enabled by default only on Arm processors, because some x86
|
||||
* chips have a slow implementation of bsr, and the use of clz/bsr cannot be
|
||||
* shown to have a significant performance impact even on the x86 chips that
|
||||
* have a fast implementation of it. When building for ARMv6, you can
|
||||
* have a fast implementation of it. When building for Armv6, you can
|
||||
* explicitly disable the use of clz/bsr by adding -mthumb to the compiler
|
||||
* flags (this defines __thumb__).
|
||||
*/
|
||||
|
||||
Vendored
+3
-2
@@ -4,8 +4,8 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1995-1998, Thomas G. Lane.
|
||||
* Modified 2000-2009 by Guido Vollbeding.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -17,6 +17,7 @@
|
||||
#define JPEG_INTERNALS
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jpegcomp.h"
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
|
||||
+36
-9
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2010, 2015-2018, D. R. Commander.
|
||||
* Copyright (C) 2010, 2015-2018, 2020, D. R. Commander.
|
||||
* Copyright (C) 2015, Google, Inc.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "jinclude.h"
|
||||
#include "jdmainct.h"
|
||||
#include "jdcoefct.h"
|
||||
#include "jdmaster.h"
|
||||
#include "jdmerge.h"
|
||||
#include "jdsample.h"
|
||||
#include "jmemsys.h"
|
||||
|
||||
@@ -316,6 +318,8 @@ LOCAL(void)
|
||||
read_and_discard_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
{
|
||||
JDIMENSION n;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
JSAMPARRAY scanlines = NULL;
|
||||
void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||
int num_rows) = NULL;
|
||||
@@ -332,8 +336,13 @@ read_and_discard_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
cinfo->cquantize->color_quantize = noop_quantize;
|
||||
}
|
||||
|
||||
if (master->using_merged_upsample && cinfo->max_v_samp_factor == 2) {
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
scanlines = &upsample->spare_row;
|
||||
}
|
||||
|
||||
for (n = 0; n < num_lines; n++)
|
||||
jpeg_read_scanlines(cinfo, NULL, 1);
|
||||
jpeg_read_scanlines(cinfo, scanlines, 1);
|
||||
|
||||
if (color_convert)
|
||||
cinfo->cconvert->color_convert = color_convert;
|
||||
@@ -353,6 +362,12 @@ increment_simple_rowgroup_ctr(j_decompress_ptr cinfo, JDIMENSION rows)
|
||||
{
|
||||
JDIMENSION rows_left;
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
|
||||
if (master->using_merged_upsample && cinfo->max_v_samp_factor == 2) {
|
||||
read_and_discard_scanlines(cinfo, rows);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Increment the counter to the next row group after the skipped rows. */
|
||||
main_ptr->rowgroup_ctr += rows / cinfo->max_v_samp_factor;
|
||||
@@ -382,21 +397,27 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
{
|
||||
my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
|
||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
JDIMENSION i, x;
|
||||
int y;
|
||||
JDIMENSION lines_per_iMCU_row, lines_left_in_iMCU_row, lines_after_iMCU_row;
|
||||
JDIMENSION lines_to_skip, lines_to_read;
|
||||
|
||||
/* Two-pass color quantization is not supported. */
|
||||
if (cinfo->quantize_colors && cinfo->two_pass_quantize)
|
||||
ERREXIT(cinfo, JERR_NOTIMPL);
|
||||
|
||||
if (cinfo->global_state != DSTATE_SCANNING)
|
||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||
|
||||
/* Do not skip past the bottom of the image. */
|
||||
if (cinfo->output_scanline + num_lines >= cinfo->output_height) {
|
||||
num_lines = cinfo->output_height - cinfo->output_scanline;
|
||||
cinfo->output_scanline = cinfo->output_height;
|
||||
(*cinfo->inputctl->finish_input_pass) (cinfo);
|
||||
cinfo->inputctl->eoi_reached = TRUE;
|
||||
return cinfo->output_height - cinfo->output_scanline;
|
||||
return num_lines;
|
||||
}
|
||||
|
||||
if (num_lines == 0)
|
||||
@@ -445,8 +466,10 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
main_ptr->buffer_full = FALSE;
|
||||
main_ptr->rowgroup_ctr = 0;
|
||||
main_ptr->context_state = CTX_PREPARE_FOR_IMCU;
|
||||
upsample->next_row_out = cinfo->max_v_samp_factor;
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
if (!master->using_merged_upsample) {
|
||||
upsample->next_row_out = cinfo->max_v_samp_factor;
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
}
|
||||
}
|
||||
|
||||
/* Skipping is much simpler when context rows are not required. */
|
||||
@@ -458,8 +481,10 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
cinfo->output_scanline += lines_left_in_iMCU_row;
|
||||
main_ptr->buffer_full = FALSE;
|
||||
main_ptr->rowgroup_ctr = 0;
|
||||
upsample->next_row_out = cinfo->max_v_samp_factor;
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
if (!master->using_merged_upsample) {
|
||||
upsample->next_row_out = cinfo->max_v_samp_factor;
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,7 +519,8 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
cinfo->output_iMCU_row += lines_to_skip / lines_per_iMCU_row;
|
||||
increment_simple_rowgroup_ctr(cinfo, lines_to_read);
|
||||
}
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
if (!master->using_merged_upsample)
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
return num_lines;
|
||||
}
|
||||
|
||||
@@ -535,7 +561,8 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
||||
* bit odd, since "rows_to_go" seems to be redundantly keeping track of
|
||||
* output_scanline.
|
||||
*/
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
if (!master->using_merged_upsample)
|
||||
upsample->rows_to_go = cinfo->output_height - cinfo->output_scanline;
|
||||
|
||||
/* Always skip the requested number of lines. */
|
||||
return num_lines;
|
||||
|
||||
+5
-3
@@ -6,7 +6,7 @@
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2010, 2015-2016, D. R. Commander.
|
||||
* Copyright (C) 2015, Google, Inc.
|
||||
* Copyright (C) 2015, 2020, Google, Inc.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -495,11 +495,13 @@ decompress_smooth_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
||||
if (first_row && block_row == 0)
|
||||
prev_block_row = buffer_ptr;
|
||||
else
|
||||
prev_block_row = buffer[block_row - 1];
|
||||
prev_block_row = buffer[block_row - 1] +
|
||||
cinfo->master->first_MCU_col[ci];
|
||||
if (last_row && block_row == block_rows - 1)
|
||||
next_block_row = buffer_ptr;
|
||||
else
|
||||
next_block_row = buffer[block_row + 1];
|
||||
next_block_row = buffer[block_row + 1] +
|
||||
cinfo->master->first_MCU_col[ci];
|
||||
/* We fetch the surrounding DC values using a sliding-register approach.
|
||||
* Initialize all nine here so as to do the right thing on narrow pics.
|
||||
*/
|
||||
|
||||
Vendored
+4
-5
@@ -571,11 +571,10 @@ ycck_cmyk_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
* RGB565 conversion
|
||||
*/
|
||||
|
||||
#define PACK_SHORT_565_LE(r, g, b) ((((r) << 8) & 0xF800) | \
|
||||
(((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_SHORT_565_BE(r, g, b) (((r) & 0xF8) | ((g) >> 5) | \
|
||||
(((g) << 11) & 0xE000) | \
|
||||
(((b) << 5) & 0x1F00))
|
||||
#define PACK_SHORT_565_LE(r, g, b) \
|
||||
((((r) << 8) & 0xF800) | (((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_SHORT_565_BE(r, g, b) \
|
||||
(((r) & 0xF8) | ((g) >> 5) | (((g) << 11) & 0xE000) | (((b) << 5) & 0x1F00))
|
||||
|
||||
#define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l)
|
||||
#define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r)
|
||||
|
||||
Vendored
+13
-42
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2009, 2011, 2014-2015, D. R. Commander.
|
||||
* Copyright (C) 2009, 2011, 2014-2015, 2020, D. R. Commander.
|
||||
* Copyright (C) 2013, Linaro Limited.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
@@ -40,41 +40,13 @@
|
||||
#define JPEG_INTERNALS
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jdmerge.h"
|
||||
#include "jsimd.h"
|
||||
#include "jconfigint.h"
|
||||
|
||||
#ifdef UPSAMPLE_MERGING_SUPPORTED
|
||||
|
||||
|
||||
/* Private subobject */
|
||||
|
||||
typedef struct {
|
||||
struct jpeg_upsampler pub; /* public fields */
|
||||
|
||||
/* Pointer to routine to do actual upsampling/conversion of one row group */
|
||||
void (*upmethod) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf);
|
||||
|
||||
/* Private state for YCC->RGB conversion */
|
||||
int *Cr_r_tab; /* => table for Cr to R conversion */
|
||||
int *Cb_b_tab; /* => table for Cb to B conversion */
|
||||
JLONG *Cr_g_tab; /* => table for Cr to G conversion */
|
||||
JLONG *Cb_g_tab; /* => table for Cb to G conversion */
|
||||
|
||||
/* For 2:1 vertical sampling, we produce two output rows at a time.
|
||||
* We need a "spare" row buffer to hold the second output row if the
|
||||
* application provides just a one-row buffer; we also use the spare
|
||||
* to discard the dummy last row if the image height is odd.
|
||||
*/
|
||||
JSAMPROW spare_row;
|
||||
boolean spare_full; /* T if spare buffer is occupied */
|
||||
|
||||
JDIMENSION out_row_width; /* samples per output row */
|
||||
JDIMENSION rows_to_go; /* counts rows remaining in image */
|
||||
} my_upsampler;
|
||||
|
||||
typedef my_upsampler *my_upsample_ptr;
|
||||
|
||||
#define SCALEBITS 16 /* speediest right-shift on some machines */
|
||||
#define ONE_HALF ((JLONG)1 << (SCALEBITS - 1))
|
||||
#define FIX(x) ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
|
||||
@@ -189,7 +161,7 @@ typedef my_upsampler *my_upsample_ptr;
|
||||
LOCAL(void)
|
||||
build_ycc_rgb_table(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
int i;
|
||||
JLONG x;
|
||||
SHIFT_TEMPS
|
||||
@@ -232,7 +204,7 @@ build_ycc_rgb_table(j_decompress_ptr cinfo)
|
||||
METHODDEF(void)
|
||||
start_pass_merged_upsample(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
|
||||
/* Mark the spare buffer empty */
|
||||
upsample->spare_full = FALSE;
|
||||
@@ -254,7 +226,7 @@ merged_2v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
/* 2:1 vertical sampling case: may need a spare row. */
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
JSAMPROW work_ptrs[2];
|
||||
JDIMENSION num_rows; /* number of rows returned to caller */
|
||||
|
||||
@@ -305,7 +277,7 @@ merged_1v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
/* 1:1 vertical sampling case: much easier, never need a spare row. */
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
|
||||
/* Just do the upsampling. */
|
||||
(*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr,
|
||||
@@ -420,11 +392,10 @@ h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
* RGB565 conversion
|
||||
*/
|
||||
|
||||
#define PACK_SHORT_565_LE(r, g, b) ((((r) << 8) & 0xF800) | \
|
||||
(((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_SHORT_565_BE(r, g, b) (((r) & 0xF8) | ((g) >> 5) | \
|
||||
(((g) << 11) & 0xE000) | \
|
||||
(((b) << 5) & 0x1F00))
|
||||
#define PACK_SHORT_565_LE(r, g, b) \
|
||||
((((r) << 8) & 0xF800) | (((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_SHORT_565_BE(r, g, b) \
|
||||
(((r) & 0xF8) | ((g) >> 5) | (((g) << 11) & 0xE000) | (((b) << 5) & 0x1F00))
|
||||
|
||||
#define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l)
|
||||
#define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r)
|
||||
@@ -566,11 +537,11 @@ h2v2_merged_upsample_565D(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
GLOBAL(void)
|
||||
jinit_merged_upsampler(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample;
|
||||
my_merged_upsample_ptr upsample;
|
||||
|
||||
upsample = (my_upsample_ptr)
|
||||
upsample = (my_merged_upsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_upsampler));
|
||||
sizeof(my_merged_upsampler));
|
||||
cinfo->upsample = (struct jpeg_upsampler *)upsample;
|
||||
upsample->pub.start_pass = start_pass_merged_upsample;
|
||||
upsample->pub.need_context_rows = FALSE;
|
||||
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* jdmerge.h
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*/
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
#include "jpeglib.h"
|
||||
|
||||
#ifdef UPSAMPLE_MERGING_SUPPORTED
|
||||
|
||||
|
||||
/* Private subobject */
|
||||
|
||||
typedef struct {
|
||||
struct jpeg_upsampler pub; /* public fields */
|
||||
|
||||
/* Pointer to routine to do actual upsampling/conversion of one row group */
|
||||
void (*upmethod) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf);
|
||||
|
||||
/* Private state for YCC->RGB conversion */
|
||||
int *Cr_r_tab; /* => table for Cr to R conversion */
|
||||
int *Cb_b_tab; /* => table for Cb to B conversion */
|
||||
JLONG *Cr_g_tab; /* => table for Cr to G conversion */
|
||||
JLONG *Cb_g_tab; /* => table for Cb to G conversion */
|
||||
|
||||
/* For 2:1 vertical sampling, we produce two output rows at a time.
|
||||
* We need a "spare" row buffer to hold the second output row if the
|
||||
* application provides just a one-row buffer; we also use the spare
|
||||
* to discard the dummy last row if the image height is odd.
|
||||
*/
|
||||
JSAMPROW spare_row;
|
||||
boolean spare_full; /* T if spare buffer is occupied */
|
||||
|
||||
JDIMENSION out_row_width; /* samples per output row */
|
||||
JDIMENSION rows_to_go; /* counts rows remaining in image */
|
||||
} my_merged_upsampler;
|
||||
|
||||
typedef my_merged_upsampler *my_merged_upsample_ptr;
|
||||
|
||||
#endif /* UPSAMPLE_MERGING_SUPPORTED */
|
||||
+5
-5
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2013, Linaro Limited.
|
||||
* Copyright (C) 2014-2015, 2018, D. R. Commander.
|
||||
* Copyright (C) 2014-2015, 2018, 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -19,7 +19,7 @@ h2v1_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
@@ -90,7 +90,7 @@ h2v1_merged_upsample_565D_internal(j_decompress_ptr cinfo,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
@@ -163,7 +163,7 @@ h2v2_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
@@ -259,7 +259,7 @@ h2v2_merged_upsample_565D_internal(j_decompress_ptr cinfo,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2011, 2015, D. R. Commander.
|
||||
* Copyright (C) 2011, 2015, 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -25,7 +25,7 @@ h2v1_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
@@ -97,7 +97,7 @@ h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
|
||||
Vendored
+3
-2
@@ -3,8 +3,8 @@
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1995-1997, Thomas G. Lane.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -16,6 +16,7 @@
|
||||
#define JPEG_INTERNALS
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jpegcomp.h"
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
|
||||
+2
-2
@@ -4,11 +4,11 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander.
|
||||
* Copyright (C) 2015, 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
* This file contains a slow-but-accurate integer implementation of the
|
||||
* This file contains a slower but more accurate integer implementation of the
|
||||
* forward DCT (Discrete Cosine Transform).
|
||||
*
|
||||
* A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT
|
||||
|
||||
+2
-2
@@ -5,11 +5,11 @@
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modification developed 2002-2009 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015, D. R. Commander.
|
||||
* Copyright (C) 2015, 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
* This file contains a slow-but-accurate integer implementation of the
|
||||
* This file contains a slower but more accurate integer implementation of the
|
||||
* inverse DCT (Discrete Cosine Transform). In the IJG code, this routine
|
||||
* must also perform dequantization of the input coefficients.
|
||||
*
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 1997-2009 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009, 2011, 2014-2015, 2018, D. R. Commander.
|
||||
* Copyright (C) 2009, 2011, 2014-2015, 2018, 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -273,9 +273,9 @@ typedef int boolean;
|
||||
|
||||
/* Capability options common to encoder and decoder: */
|
||||
|
||||
#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
|
||||
#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
|
||||
#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
|
||||
#define DCT_ISLOW_SUPPORTED /* accurate integer method */
|
||||
#define DCT_IFAST_SUPPORTED /* less accurate int method [legacy feature] */
|
||||
#define DCT_FLOAT_SUPPORTED /* floating-point method [legacy feature] */
|
||||
|
||||
/* Encoder capability options: */
|
||||
|
||||
|
||||
+2
-1
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* jpegcomp.h
|
||||
*
|
||||
* Copyright (C) 2010, D. R. Commander.
|
||||
* Copyright (C) 2010, 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -19,6 +19,7 @@
|
||||
#define _min_DCT_v_scaled_size min_DCT_v_scaled_size
|
||||
#define _jpeg_width jpeg_width
|
||||
#define _jpeg_height jpeg_height
|
||||
#define JERR_ARITH_NOTIMPL JERR_NOT_COMPILED
|
||||
#else
|
||||
#define _DCT_scaled_size DCT_scaled_size
|
||||
#define _DCT_h_scaled_size DCT_scaled_size
|
||||
|
||||
Vendored
+4
-4
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||
* Modified 2002-2009 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009-2011, 2013-2014, 2016-2017, D. R. Commander.
|
||||
* Copyright (C) 2009-2011, 2013-2014, 2016-2017, 2020, D. R. Commander.
|
||||
* Copyright (C) 2015, Google, Inc.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
@@ -244,9 +244,9 @@ typedef enum {
|
||||
/* DCT/IDCT algorithm options. */
|
||||
|
||||
typedef enum {
|
||||
JDCT_ISLOW, /* slow but accurate integer algorithm */
|
||||
JDCT_IFAST, /* faster, less accurate integer method */
|
||||
JDCT_FLOAT /* floating-point: accurate, fast on fast HW */
|
||||
JDCT_ISLOW, /* accurate integer method */
|
||||
JDCT_IFAST, /* less accurate integer method [legacy feature] */
|
||||
JDCT_FLOAT /* floating-point method [legacy feature] */
|
||||
} J_DCT_METHOD;
|
||||
|
||||
#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */
|
||||
|
||||
Vendored
+3
-3
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009, 2014-2015, D. R. Commander.
|
||||
* Copyright (C) 2009, 2014-2015, 2020, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -1145,7 +1145,7 @@ start_pass_2_quant(j_decompress_ptr cinfo, boolean is_pre_scan)
|
||||
int i;
|
||||
|
||||
/* Only F-S dithering or no dithering is supported. */
|
||||
/* If user asks for ordered dither, give him F-S. */
|
||||
/* If user asks for ordered dither, give them F-S. */
|
||||
if (cinfo->dither_mode != JDITHER_NONE)
|
||||
cinfo->dither_mode = JDITHER_FS;
|
||||
|
||||
@@ -1263,7 +1263,7 @@ jinit_2pass_quantizer(j_decompress_ptr cinfo)
|
||||
cquantize->sv_colormap = NULL;
|
||||
|
||||
/* Only F-S dithering or no dithering is supported. */
|
||||
/* If user asks for ordered dither, give him F-S. */
|
||||
/* If user asks for ordered dither, give them F-S. */
|
||||
if (cinfo->dither_mode != JDITHER_NONE)
|
||||
cinfo->dither_mode = JDITHER_FS;
|
||||
|
||||
|
||||
+8
-6
@@ -30,23 +30,25 @@
|
||||
* NOTE: It is our convention to place the authors in the following order:
|
||||
* - libjpeg-turbo authors (2009-) in descending order of the date of their
|
||||
* most recent contribution to the project, then in ascending order of the
|
||||
* date of their first contribution to the project
|
||||
* date of their first contribution to the project, then in alphabetical
|
||||
* order
|
||||
* - Upstream authors in descending order of the date of the first inclusion of
|
||||
* their code
|
||||
*/
|
||||
|
||||
#define JCOPYRIGHT \
|
||||
"Copyright (C) 2009-2020 D. R. Commander\n" \
|
||||
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
|
||||
"Copyright (C) 2015, 2020 Google, Inc.\n" \
|
||||
"Copyright (C) 2019 Arm Limited\n" \
|
||||
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
|
||||
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
|
||||
"Copyright (C) 2015 Intel Corporation\n" \
|
||||
"Copyright (C) 2015 Google, Inc.\n" \
|
||||
"Copyright (C) 2013-2014 Linaro Limited\n" \
|
||||
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
|
||||
"Copyright (C) 2013 Linaro Limited\n" \
|
||||
"Copyright (C) 2009, 2012 Pierre Ossman for Cendio AB\n" \
|
||||
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
|
||||
"Copyright (C) 2009 Pierre Ossman for Cendio AB\n" \
|
||||
"Copyright (C) 1999-2006 MIYASAKA Masaru\n" \
|
||||
"Copyright (C) 1991-2016 Thomas G. Lane, Guido Vollbeding"
|
||||
"Copyright (C) 1991-2017 Thomas G. Lane, Guido Vollbeding"
|
||||
|
||||
#define JCOPYRIGHT_SHORT \
|
||||
"Copyright (C) 1991-2020 The libjpeg-turbo Project and many others"
|
||||
|
||||
Vendored
+2
-2
@@ -19,7 +19,7 @@ endif()
|
||||
# Define the library target:
|
||||
# ----------------------------------------------------------------------------------
|
||||
|
||||
add_library(${JPEG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
||||
add_library(${JPEG_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs} ${lib_hdrs})
|
||||
|
||||
if(CV_GCC OR CV_CLANG)
|
||||
set_source_files_properties(jcdctmgr.c PROPERTIES COMPILE_FLAGS "-O1")
|
||||
@@ -42,7 +42,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${JPEG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${JPEG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(libjpeg README)
|
||||
|
||||
Vendored
+2
-2
@@ -74,7 +74,7 @@ if(MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
endif(MSVC)
|
||||
|
||||
add_library(${PNG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
||||
add_library(${PNG_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs} ${lib_hdrs})
|
||||
target_link_libraries(${PNG_LIBRARY} ${ZLIB_LIBRARIES})
|
||||
|
||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wundef -Wcast-align -Wimplicit-fallthrough -Wunused-parameter -Wsign-compare)
|
||||
@@ -92,7 +92,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${PNG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${PNG_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(libpng LICENSE README)
|
||||
|
||||
Vendored
+2
-2
@@ -462,7 +462,7 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4456 /wd4457 /wd4312) # vs2015
|
||||
|
||||
ocv_warnings_disable(CMAKE_C_FLAGS /wd4267 /wd4244 /wd4018 /wd4311 /wd4312)
|
||||
|
||||
add_library(${TIFF_LIBRARY} STATIC ${lib_srcs})
|
||||
add_library(${TIFF_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs})
|
||||
target_link_libraries(${TIFF_LIBRARY} ${ZLIB_LIBRARIES})
|
||||
|
||||
set_target_properties(${TIFF_LIBRARY}
|
||||
@@ -479,7 +479,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${TIFF_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${TIFF_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(libtiff COPYRIGHT)
|
||||
|
||||
Vendored
+2
-2
@@ -34,7 +34,7 @@ endif()
|
||||
|
||||
add_definitions(-DWEBP_USE_THREAD)
|
||||
|
||||
add_library(${WEBP_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
||||
add_library(${WEBP_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs} ${lib_hdrs})
|
||||
if(ANDROID)
|
||||
target_link_libraries(${WEBP_LIBRARY} ${CPUFEATURES_LIBRARIES})
|
||||
endif()
|
||||
@@ -59,6 +59,6 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${WEBP_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${WEBP_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -125,7 +125,7 @@ if(MSVC AND CV_ICC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Qrestrict")
|
||||
endif()
|
||||
|
||||
add_library(IlmImf STATIC ${lib_hdrs} ${lib_srcs})
|
||||
add_library(IlmImf STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_hdrs} ${lib_srcs})
|
||||
target_link_libraries(IlmImf ${ZLIB_LIBRARIES})
|
||||
|
||||
set_target_properties(IlmImf
|
||||
@@ -142,7 +142,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(IlmImf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(IlmImf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(openexr LICENSE AUTHORS.ilmbase AUTHORS.openexr)
|
||||
|
||||
Vendored
+3
-2
@@ -140,7 +140,8 @@ append_if_exist(Protobuf_SRCS
|
||||
${PROTOBUF_ROOT}/src/google/protobuf/wrappers.pb.cc
|
||||
)
|
||||
|
||||
add_library(libprotobuf STATIC ${Protobuf_SRCS})
|
||||
include_directories(BEFORE "${PROTOBUF_ROOT}/src") # ensure using if own headers: https://github.com/opencv/opencv/issues/13328
|
||||
add_library(libprotobuf STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${Protobuf_SRCS})
|
||||
target_include_directories(libprotobuf SYSTEM PUBLIC $<BUILD_INTERFACE:${PROTOBUF_ROOT}/src>)
|
||||
set_target_properties(libprotobuf
|
||||
PROPERTIES
|
||||
@@ -156,7 +157,7 @@ get_protobuf_version(Protobuf_VERSION "${PROTOBUF_ROOT}/src")
|
||||
set(Protobuf_VERSION ${Protobuf_VERSION} CACHE INTERNAL "" FORCE)
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(libprotobuf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(libprotobuf EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(protobuf LICENSE README.md)
|
||||
|
||||
Vendored
+2
-2
@@ -8,7 +8,7 @@ ocv_include_directories(${CURR_INCLUDE_DIR})
|
||||
file(GLOB_RECURSE quirc_headers RELATIVE "${CMAKE_CURRENT_LIST_DIR}" "include/*.h")
|
||||
file(GLOB_RECURSE quirc_sources RELATIVE "${CMAKE_CURRENT_LIST_DIR}" "src/*.c")
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC ${quirc_headers} ${quirc_sources})
|
||||
add_library(${PROJECT_NAME} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${quirc_headers} ${quirc_sources})
|
||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-variable -Wshadow)
|
||||
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
@@ -24,7 +24,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${PROJECT_NAME} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
ocv_install_target(${PROJECT_NAME} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
|
||||
endif()
|
||||
|
||||
ocv_install_3rdparty_licenses(${PROJECT_NAME} LICENSE)
|
||||
|
||||
Vendored
+2
-1
@@ -108,7 +108,7 @@ set(tbb_version_file "version_string.ver")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${tbb_version_file}.cmakein" "${CMAKE_CURRENT_BINARY_DIR}/${tbb_version_file}" @ONLY)
|
||||
list(APPEND TBB_SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/${tbb_version_file}")
|
||||
|
||||
add_library(tbb ${TBB_SOURCE_FILES})
|
||||
add_library(tbb ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${TBB_SOURCE_FILES})
|
||||
target_compile_definitions(tbb PUBLIC
|
||||
TBB_USE_GCC_BUILTINS=1
|
||||
__TBB_GCC_BUILTIN_ATOMICS_PRESENT=1
|
||||
@@ -165,6 +165,7 @@ ocv_install_target(tbb EXPORT OpenCVModules
|
||||
RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs
|
||||
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT libs
|
||||
ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev
|
||||
OPTIONAL
|
||||
)
|
||||
|
||||
ocv_install_3rdparty_licenses(tbb "${tbb_src_dir}/LICENSE" "${tbb_src_dir}/README")
|
||||
|
||||
Vendored
+1
-1
@@ -76,7 +76,7 @@ set(ZLIB_SRCS
|
||||
zutil.c
|
||||
)
|
||||
|
||||
add_library(${ZLIB_LIBRARY} STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
add_library(${ZLIB_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
set_target_properties(${ZLIB_LIBRARY} PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
|
||||
|
||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wshorten-64-to-32 -Wattributes -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshift-negative-value
|
||||
|
||||
@@ -367,6 +367,9 @@ OCV_OPTION(WITH_MSMF_DXVA "Enable hardware acceleration in Media Foundation back
|
||||
OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF
|
||||
VISIBLE_IF NOT ANDROID AND NOT WINRT
|
||||
VERIFY HAVE_XIMEA)
|
||||
OCV_OPTION(WITH_UEYE "Include UEYE camera support" OFF
|
||||
VISIBLE_IF NOT ANDROID AND NOT APPLE AND NOT WINRT
|
||||
VERIFY HAVE_UEYE)
|
||||
OCV_OPTION(WITH_XINE "Include Xine support (GPL)" OFF
|
||||
VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID
|
||||
VERIFY HAVE_XINE)
|
||||
@@ -439,6 +442,9 @@ OCV_OPTION(WITH_ANDROID_MEDIANDK "Use Android Media NDK for Video I/O (Android)"
|
||||
OCV_OPTION(WITH_TENGINE "Include Arm Inference Tengine support" OFF
|
||||
VISIBLE_IF (ARM OR AARCH64) AND (UNIX OR ANDROID) AND NOT IOS
|
||||
VERIFY HAVE_TENGINE)
|
||||
OCV_OPTION(WITH_ONNX "Include Microsoft ONNX Runtime support" OFF
|
||||
VISIBLE_IF TRUE
|
||||
VERIFY HAVE_ONNX)
|
||||
|
||||
# OpenCV build components
|
||||
# ===================================================
|
||||
@@ -775,6 +781,11 @@ if(WITH_QUIRC)
|
||||
add_subdirectory(3rdparty/quirc)
|
||||
set(HAVE_QUIRC TRUE)
|
||||
endif()
|
||||
|
||||
if(WITH_ONNX)
|
||||
include(cmake/FindONNX.cmake)
|
||||
endif()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# OpenCV HAL
|
||||
# ----------------------------------------------------------------------------
|
||||
@@ -1372,6 +1383,10 @@ if(WITH_XIMEA OR HAVE_XIMEA)
|
||||
status(" XIMEA:" HAVE_XIMEA THEN YES ELSE NO)
|
||||
endif()
|
||||
|
||||
if(WITH_UEYE OR HAVE_UEYE)
|
||||
status(" uEye:" HAVE_UEYE THEN YES ELSE NO)
|
||||
endif()
|
||||
|
||||
if(WITH_XINE OR HAVE_XINE)
|
||||
status(" Xine:" HAVE_XINE THEN "YES (ver ${XINE_VERSION})" ELSE NO)
|
||||
endif()
|
||||
@@ -1556,6 +1571,15 @@ if(WITH_OPENCL OR HAVE_OPENCL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_ONNX OR HAVE_ONNX)
|
||||
status("")
|
||||
status(" ONNX:" HAVE_ONNX THEN "YES" ELSE "NO")
|
||||
if(HAVE_ONNX)
|
||||
status(" Include path:" ONNX_INCLUDE_DIR THEN "${ONNX_INCLUDE_DIR}" ELSE "NO")
|
||||
status(" Link libraries:" ONNX_LIBRARIES THEN "${ONNX_LIBRARIES}" ELSE "NO")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ========================== python ==========================
|
||||
if(BUILD_opencv_python2)
|
||||
status("")
|
||||
|
||||
@@ -32,7 +32,7 @@ bool calib::parametersController::loadFromFile(const std::string &inputFileName)
|
||||
|
||||
if(!reader.isOpened()) {
|
||||
std::cerr << "Warning: Unable to open " << inputFileName <<
|
||||
" Applicatioin stated with default advanced parameters" << std::endl;
|
||||
" Application started with default advanced parameters" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
ocv_clear_vars(HAVE_ONNX)
|
||||
|
||||
set(ONNXRT_ROOT_DIR "" CACHE PATH "ONNX Runtime install directory")
|
||||
|
||||
# For now, check the old name ORT_INSTALL_DIR
|
||||
if(ORT_INSTALL_DIR AND NOT ONNXRT_ROOT_DIR)
|
||||
set(ONNXRT_ROOT_DIR ORT_INSTALL_DIR)
|
||||
endif()
|
||||
|
||||
if(ONNXRT_ROOT_DIR)
|
||||
find_library(ORT_LIB onnxruntime
|
||||
${ONNXRT_ROOT_DIR}/lib
|
||||
CMAKE_FIND_ROOT_PATH_BOTH)
|
||||
find_path(ORT_INCLUDE onnxruntime_cxx_api.h
|
||||
${ONNXRT_ROOT_DIR}/include/onnxruntime/core/session
|
||||
CMAKE_FIND_ROOT_PATH_BOTH)
|
||||
endif()
|
||||
|
||||
if(ORT_LIB AND ORT_INCLUDE)
|
||||
set(HAVE_ONNX TRUE)
|
||||
# For CMake output only
|
||||
set(ONNX_LIBRARIES "${ORT_LIB}" CACHE STRING "ONNX Runtime libraries")
|
||||
set(ONNX_INCLUDE_DIR "${ORT_INCLUDE}" CACHE STRING "ONNX Runtime include path")
|
||||
|
||||
# Link target with associated interface headers
|
||||
set(ONNX_LIBRARY "onnxruntime" CACHE STRING "ONNX Link Target")
|
||||
ocv_add_library(${ONNX_LIBRARY} SHARED IMPORTED)
|
||||
set_target_properties(${ONNX_LIBRARY} PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${ORT_INCLUDE}
|
||||
IMPORTED_LOCATION ${ORT_LIB}
|
||||
IMPORTED_IMPLIB ${ORT_LIB})
|
||||
endif()
|
||||
|
||||
if(NOT HAVE_ONNX)
|
||||
ocv_clear_vars(HAVE_ONNX ORT_LIB ORT_INCLUDE_DIR)
|
||||
endif()
|
||||
@@ -129,9 +129,9 @@ endif()
|
||||
|
||||
if(INF_ENGINE_TARGET)
|
||||
if(NOT INF_ENGINE_RELEASE)
|
||||
message(WARNING "InferenceEngine version has not been set, 2020.4 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.")
|
||||
message(WARNING "InferenceEngine version has not been set, 2021.2 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.")
|
||||
endif()
|
||||
set(INF_ENGINE_RELEASE "2020040000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2020.1.0.2 -> 2020010002)")
|
||||
set(INF_ENGINE_RELEASE "2021020000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2020.1.0.2 -> 2020010002)")
|
||||
set_target_properties(${INF_ENGINE_TARGET} PROPERTIES
|
||||
INTERFACE_COMPILE_DEFINITIONS "HAVE_INF_ENGINE=1;INF_ENGINE_RELEASE=${INF_ENGINE_RELEASE}"
|
||||
)
|
||||
|
||||
@@ -51,7 +51,12 @@ endif(WITH_CUDA)
|
||||
|
||||
# --- Eigen ---
|
||||
if(WITH_EIGEN AND NOT HAVE_EIGEN)
|
||||
find_package(Eigen3 QUIET)
|
||||
if(NOT OPENCV_SKIP_EIGEN_FIND_PACKAGE_CONFIG)
|
||||
find_package(Eigen3 CONFIG QUIET) # Ceres 2.0.0 CMake scripts doesn't work with CMake's FindEigen3.cmake module (due to missing EIGEN3_VERSION_STRING)
|
||||
endif()
|
||||
if(NOT Eigen3_FOUND)
|
||||
find_package(Eigen3 QUIET)
|
||||
endif()
|
||||
|
||||
if(Eigen3_FOUND)
|
||||
if(TARGET Eigen3::Eigen)
|
||||
|
||||
@@ -57,7 +57,7 @@ SET(Open_BLAS_INCLUDE_SEARCH_PATHS
|
||||
)
|
||||
|
||||
SET(Open_BLAS_LIB_SEARCH_PATHS
|
||||
$ENV{OpenBLAS}cd
|
||||
$ENV{OpenBLAS}
|
||||
$ENV{OpenBLAS}/lib
|
||||
$ENV{OpenBLAS_HOME}
|
||||
$ENV{OpenBLAS_HOME}/lib
|
||||
|
||||
@@ -1881,3 +1881,9 @@ function(ocv_update_file filepath content)
|
||||
file(WRITE "${filepath}" "${content}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS AND (CMAKE_VERSION VERSION_LESS "3.14.0"))
|
||||
ocv_update(OPENCV_3RDPARTY_EXCLUDE_FROM_ALL "") # avoid CMake warnings: https://gitlab.kitware.com/cmake/cmake/-/issues/18938
|
||||
else()
|
||||
ocv_update(OPENCV_3RDPARTY_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL")
|
||||
endif()
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
opencv2/flann/hdf5.h
|
||||
opencv2/imgcodecs/imgcodecs_c.h
|
||||
opencv2/imgcodecs/ios.h
|
||||
opencv2/imgcodecs/macosx.h
|
||||
opencv2/videoio/videoio_c.h
|
||||
opencv2/videoio/cap_ios.h
|
||||
opencv2/xobjdetect/private.hpp
|
||||
|
||||
+15
-1
@@ -145,9 +145,23 @@ if(DOXYGEN_FOUND)
|
||||
set(tutorial_js_path "${CMAKE_CURRENT_SOURCE_DIR}/js_tutorials")
|
||||
set(example_path "${CMAKE_SOURCE_DIR}/samples")
|
||||
|
||||
set(doxygen_image_path
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/images
|
||||
${paths_doc}
|
||||
${tutorial_path}
|
||||
${tutorial_py_path}
|
||||
${tutorial_js_path}
|
||||
${paths_tutorial}
|
||||
#${OpenCV_SOURCE_DIR}/samples/data # TODO: need to resolve ambiguous conflicts first
|
||||
${OpenCV_SOURCE_DIR}
|
||||
${OpenCV_SOURCE_DIR}/modules # <opencv>/modules
|
||||
${OPENCV_EXTRA_MODULES_PATH} # <opencv_contrib>/modules
|
||||
${OPENCV_DOCS_EXTRA_IMAGE_PATH} # custom variable for user modules
|
||||
)
|
||||
|
||||
# set export variables
|
||||
string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_INPUT_LIST "${rootfile} ; ${faqfile} ; ${paths_include} ; ${paths_hal_interface} ; ${paths_doc} ; ${tutorial_path} ; ${tutorial_py_path} ; ${tutorial_js_path} ; ${paths_tutorial} ; ${tutorial_contrib_root}")
|
||||
string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_IMAGE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/images ; ${paths_doc} ; ${tutorial_path} ; ${tutorial_py_path} ; ${tutorial_js_path} ; ${paths_tutorial}")
|
||||
string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_IMAGE_PATH "${doxygen_image_path}")
|
||||
string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_EXCLUDE_LIST "${CMAKE_DOXYGEN_EXCLUDE_LIST}")
|
||||
string(REPLACE ";" " " CMAKE_DOXYGEN_ENABLED_SECTIONS "${CMAKE_DOXYGEN_ENABLED_SECTIONS}")
|
||||
# TODO: remove paths_doc from EXAMPLE_PATH after face module tutorials/samples moved to separate folders
|
||||
|
||||
@@ -32,6 +32,15 @@ source ./emsdk_env.sh
|
||||
echo ${EMSCRIPTEN}
|
||||
@endcode
|
||||
|
||||
The version 1.39.16 of emscripten is verified for latest WebAssembly. Please check the version of emscripten to use the newest features of WebAssembly.
|
||||
|
||||
For example:
|
||||
@code{.bash}
|
||||
./emsdk update
|
||||
./emsdk install 1.39.16
|
||||
./emsdk activate 1.39.16
|
||||
@endcode
|
||||
|
||||
Obtaining OpenCV Source Code
|
||||
--------------------------
|
||||
|
||||
@@ -76,6 +85,31 @@ Building OpenCV.js from Source
|
||||
python ./platforms/js/build_js.py build_wasm --build_wasm
|
||||
@endcode
|
||||
|
||||
-# [Optional] To build the OpenCV.js loader, append `--build_loader`.
|
||||
|
||||
For example:
|
||||
@code{.bash}
|
||||
python ./platforms/js/build_js.py build_js --build_loader
|
||||
@endcode
|
||||
|
||||
@note
|
||||
The loader is implemented as a js file in the path `<opencv_js_dir>/bin/loader.js`. The loader utilizes the [WebAssembly Feature Detection](https://github.com/GoogleChromeLabs/wasm-feature-detect) to detect the features of the broswer and load corresponding OpenCV.js automatically. To use it, you need to use the UMD version of [WebAssembly Feature Detection](https://github.com/GoogleChromeLabs/wasm-feature-detect) and introduce the `loader.js` in your Web application.
|
||||
|
||||
Example Code:
|
||||
@code{.javascipt}
|
||||
// Set paths configuration
|
||||
let pathsConfig = {
|
||||
wasm: "../../build_wasm/opencv.js",
|
||||
threads: "../../build_mt/opencv.js",
|
||||
simd: "../../build_simd/opencv.js",
|
||||
threadsSimd: "../../build_mtSIMD/opencv.js",
|
||||
}
|
||||
|
||||
// Load OpenCV.js and use the pathsConfiguration and main function as the params.
|
||||
loadOpenCV(pathsConfig, main);
|
||||
@endcode
|
||||
|
||||
|
||||
-# [optional] To build documents, append `--build_doc` option.
|
||||
|
||||
For example:
|
||||
|
||||
@@ -92,11 +92,11 @@ def main():
|
||||
dest="square_size", type=float)
|
||||
parser.add_argument("-R", "--radius_rate", help="circles_radius = square_size/radius_rate", default="5.0",
|
||||
action="store", dest="radius_rate", type=float)
|
||||
parser.add_argument("-w", "--page_width", help="page width in units", default="216", action="store",
|
||||
parser.add_argument("-w", "--page_width", help="page width in units", default=argparse.SUPPRESS, action="store",
|
||||
dest="page_width", type=float)
|
||||
parser.add_argument("-h", "--page_height", help="page height in units", default="279", action="store",
|
||||
dest="page_width", type=float)
|
||||
parser.add_argument("-a", "--page_size", help="page size, supersedes -h -w arguments", default="A4", action="store",
|
||||
parser.add_argument("-h", "--page_height", help="page height in units", default=argparse.SUPPRESS, action="store",
|
||||
dest="page_height", type=float)
|
||||
parser.add_argument("-a", "--page_size", help="page size, superseded if -h and -w are set", default="A4", action="store",
|
||||
dest="page_size", choices=["A0", "A1", "A2", "A3", "A4", "A5"])
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -111,12 +111,16 @@ def main():
|
||||
units = args.units
|
||||
square_size = args.square_size
|
||||
radius_rate = args.radius_rate
|
||||
page_size = args.page_size
|
||||
# page size dict (ISO standard, mm) for easy lookup. format - size: [width, height]
|
||||
page_sizes = {"A0": [840, 1188], "A1": [594, 840], "A2": [420, 594], "A3": [297, 420], "A4": [210, 297],
|
||||
"A5": [148, 210]}
|
||||
page_width = page_sizes[page_size.upper()][0]
|
||||
page_height = page_sizes[page_size.upper()][1]
|
||||
if 'page_width' and 'page_height' in args:
|
||||
page_width = args.page_width
|
||||
page_height = args.page_height
|
||||
else:
|
||||
page_size = args.page_size
|
||||
# page size dict (ISO standard, mm) for easy lookup. format - size: [width, height]
|
||||
page_sizes = {"A0": [840, 1188], "A1": [594, 840], "A2": [420, 594], "A3": [297, 420], "A4": [210, 297],
|
||||
"A5": [148, 210]}
|
||||
page_width = page_sizes[page_size][0]
|
||||
page_height = page_sizes[page_size][1]
|
||||
pm = PatternMaker(columns, rows, output, units, square_size, radius_rate, page_width, page_height)
|
||||
# dict for easy lookup of pattern type
|
||||
mp = {"circles": pm.make_circles_pattern, "acircles": pm.make_acircles_pattern,
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 18 KiB |
@@ -48,7 +48,7 @@ titles = ['Original Image','BINARY','BINARY_INV','TRUNC','TOZERO','TOZERO_INV']
|
||||
images = [img, thresh1, thresh2, thresh3, thresh4, thresh5]
|
||||
|
||||
for i in xrange(6):
|
||||
plt.subplot(2,3,i+1),plt.imshow(images[i],'gray')
|
||||
plt.subplot(2,3,i+1),plt.imshow(images[i],'gray',vmin=0,vmax=255)
|
||||
plt.title(titles[i])
|
||||
plt.xticks([]),plt.yticks([])
|
||||
|
||||
|
||||
@@ -46,14 +46,14 @@ Open your Doxyfile using your favorite text editor and search for the key
|
||||
`TAGFILES`. Change it as follows:
|
||||
|
||||
@code
|
||||
TAGFILES = ./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/4.5.0
|
||||
TAGFILES = ./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/4.5.1
|
||||
@endcode
|
||||
|
||||
If you had other definitions already, you can append the line using a `\`:
|
||||
|
||||
@code
|
||||
TAGFILES = ./docs/doxygen-tags/libstdc++.tag=https://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen \
|
||||
./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/4.5.0
|
||||
./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/4.5.1
|
||||
@endcode
|
||||
|
||||
Doxygen can now use the information from the tag file to link to the OpenCV
|
||||
|
||||
@@ -32,8 +32,7 @@ In this tutorial you will learn how to:
|
||||
-# Create and update the background model by using @ref cv::BackgroundSubtractor class;
|
||||
-# Get and show the foreground mask by using @ref cv::imshow ;
|
||||
|
||||
Code
|
||||
----
|
||||
### Code
|
||||
|
||||
In the following you can find the source code. We will let the user choose to process either a video
|
||||
file or a sequence of images.
|
||||
|
||||
@@ -126,13 +126,12 @@ captRefrnc.set(CAP_PROP_POS_FRAMES, 10); // go to the 10th frame of the video
|
||||
For properties you can read and change look into the documentation of the @ref cv::VideoCapture::get and
|
||||
@ref cv::VideoCapture::set functions.
|
||||
|
||||
Image similarity - PSNR and SSIM
|
||||
--------------------------------
|
||||
### Image similarity - PSNR and SSIM
|
||||
|
||||
We want to check just how imperceptible our video converting operation went, therefore we need a
|
||||
system to check frame by frame the similarity or differences. The most common algorithm used for
|
||||
this is the PSNR (aka **Peak signal-to-noise ratio**). The simplest definition of this starts out
|
||||
from the *mean squad error*. Let there be two images: I1 and I2; with a two dimensional size i and
|
||||
from the *mean squared error*. Let there be two images: I1 and I2; with a two dimensional size i and
|
||||
j, composed of c number of channels.
|
||||
|
||||
\f[MSE = \frac{1}{c*i*j} \sum{(I_1-I_2)^2}\f]
|
||||
@@ -145,15 +144,15 @@ Here the \f$MAX_I\f$ is the maximum valid value for a pixel. In case of the simp
|
||||
per pixel per channel this is 255. When two images are the same the MSE will give zero, resulting in
|
||||
an invalid divide by zero operation in the PSNR formula. In this case the PSNR is undefined and as
|
||||
we'll need to handle this case separately. The transition to a logarithmic scale is made because the
|
||||
pixel values have a very wide dynamic range. All this translated to OpenCV and a C++ function looks
|
||||
pixel values have a very wide dynamic range. All this translated to OpenCV and a function looks
|
||||
like:
|
||||
|
||||
@add_toggle_cpp
|
||||
@include cpp/tutorial_code/videoio/video-input-psnr-ssim/video-input-psnr-ssim.cpp get-psnr
|
||||
@snippet cpp/tutorial_code/videoio/video-input-psnr-ssim/video-input-psnr-ssim.cpp get-psnr
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
@include samples/python/tutorial_code/videoio/video-input-psnr-ssim.py get-psnr
|
||||
@snippet samples/python/tutorial_code/videoio/video-input-psnr-ssim.py get-psnr
|
||||
@end_toggle
|
||||
|
||||
Typically result values are anywhere between 30 and 50 for video compression, where higher is
|
||||
@@ -172,11 +171,11 @@ implementation below.
|
||||
Transactions on Image Processing, vol. 13, no. 4, pp. 600-612, Apr. 2004." article.
|
||||
|
||||
@add_toggle_cpp
|
||||
@include cpp/tutorial_code/videoio/video-input-psnr-ssim/video-input-psnr-ssim.cpp get-mssim
|
||||
@snippet samples/cpp/tutorial_code/videoio/video-input-psnr-ssim/video-input-psnr-ssim.cpp get-mssim
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
@include samples/python/tutorial_code/videoio/video-input-psnr-ssim.py get-mssim
|
||||
@snippet samples/python/tutorial_code/videoio/video-input-psnr-ssim.py get-mssim
|
||||
@end_toggle
|
||||
|
||||
This will return a similarity index for each channel of the image. This value is between zero and
|
||||
|
||||
@@ -63,7 +63,7 @@ specialized video writing libraries such as *FFMpeg* or codecs as *HuffYUV*, *Co
|
||||
an alternative, create the video track with OpenCV and expand it with sound tracks or convert it to
|
||||
other formats by using video manipulation programs such as *VirtualDub* or *AviSynth*.
|
||||
|
||||
The *VideoWriter* class
|
||||
The VideoWriter class
|
||||
-----------------------
|
||||
|
||||
The content written here builds on the assumption you
|
||||
|
||||
@@ -550,17 +550,18 @@ enum NeighborSearchMethod { NEIGH_FLANN_KNN, NEIGH_GRID, NEIGH_FLANN_RADIUS };
|
||||
|
||||
struct CV_EXPORTS_W_SIMPLE UsacParams
|
||||
{ // in alphabetical order
|
||||
double confidence = 0.99;
|
||||
bool isParallel = false;
|
||||
int loIterations = 5;
|
||||
LocalOptimMethod loMethod = LocalOptimMethod::LOCAL_OPTIM_INNER_LO;
|
||||
int loSampleSize = 14;
|
||||
int maxIterations = 5000;
|
||||
NeighborSearchMethod neighborsSearch = NeighborSearchMethod::NEIGH_GRID;
|
||||
int randomGeneratorState = 0;
|
||||
SamplingMethod sampler = SamplingMethod::SAMPLING_UNIFORM;
|
||||
ScoreMethod score = ScoreMethod::SCORE_METHOD_MSAC;
|
||||
double threshold = 1.5;
|
||||
CV_WRAP UsacParams();
|
||||
CV_PROP_RW double confidence;
|
||||
CV_PROP_RW bool isParallel;
|
||||
CV_PROP_RW int loIterations;
|
||||
CV_PROP_RW LocalOptimMethod loMethod;
|
||||
CV_PROP_RW int loSampleSize;
|
||||
CV_PROP_RW int maxIterations;
|
||||
CV_PROP_RW NeighborSearchMethod neighborsSearch;
|
||||
CV_PROP_RW int randomGeneratorState;
|
||||
CV_PROP_RW SamplingMethod sampler;
|
||||
CV_PROP_RW ScoreMethod score;
|
||||
CV_PROP_RW double threshold;
|
||||
};
|
||||
|
||||
/** @brief Converts a rotation matrix to a rotation vector or vice versa.
|
||||
|
||||
@@ -197,6 +197,21 @@ public:
|
||||
Mat tvec;
|
||||
};
|
||||
|
||||
UsacParams::UsacParams()
|
||||
{
|
||||
confidence = 0.99;
|
||||
isParallel = false;
|
||||
loIterations = 5;
|
||||
loMethod = LocalOptimMethod::LOCAL_OPTIM_INNER_LO;
|
||||
loSampleSize = 14;
|
||||
maxIterations = 5000;
|
||||
neighborsSearch = NeighborSearchMethod::NEIGH_GRID;
|
||||
randomGeneratorState = 0;
|
||||
sampler = SamplingMethod::SAMPLING_UNIFORM;
|
||||
score = ScoreMethod::SCORE_METHOD_MSAC;
|
||||
threshold = 1.5;
|
||||
}
|
||||
|
||||
bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
|
||||
InputArray _cameraMatrix, InputArray _distCoeffs,
|
||||
OutputArray _rvec, OutputArray _tvec, bool useExtrinsicGuess,
|
||||
|
||||
@@ -421,7 +421,7 @@ struct SPRT_history {
|
||||
double epsilon, delta, A;
|
||||
// number of samples processed by test
|
||||
int tested_samples; // k
|
||||
SPRT_history () {
|
||||
SPRT_history () : epsilon(0), delta(0), A(0) {
|
||||
tested_samples = 0;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -286,7 +286,7 @@ public:
|
||||
current_score = quality->getScore(models[i]);
|
||||
} else {
|
||||
if (is_magsac && iters % repeat_magsac == 0) {
|
||||
if (!local_optimization->refineModel
|
||||
if (local_optimization && !local_optimization->refineModel
|
||||
(models[i], best_score_thread, models[i], current_score))
|
||||
continue;
|
||||
} else if (model_verifier->isModelGood(models[i])) {
|
||||
@@ -1028,4 +1028,4 @@ bool run (const Ptr<const Model> ¶ms, InputArray points1, InputArray points2
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}}
|
||||
}}
|
||||
|
||||
@@ -220,6 +220,11 @@ struct VZeroUpperGuard {
|
||||
# define CV_VSX 1
|
||||
#endif
|
||||
|
||||
#ifdef __F16C__
|
||||
# include <immintrin.h>
|
||||
# define CV_FP16 1
|
||||
#endif
|
||||
|
||||
#endif // !__OPENCV_BUILD && !__CUDACC (Compatibility code)
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace cv { namespace debug_build_guard { } using namespace debug_build_guard
|
||||
// keep current value (through OpenCV port file)
|
||||
#elif defined __GNUC__ || (defined (__cpluscplus) && (__cpluscplus >= 201103))
|
||||
#define CV_Func __func__
|
||||
#elif defined __clang__ && (__clang_minor__ * 100 + __clang_major >= 305)
|
||||
#elif defined __clang__ && (__clang_minor__ * 100 + __clang_major__ >= 305)
|
||||
#define CV_Func __func__
|
||||
#elif defined(__STDC_VERSION__) && (__STDC_VERSION >= 199901)
|
||||
#define CV_Func __func__
|
||||
@@ -844,7 +844,7 @@ protected:
|
||||
float16_t() : w(0) {}
|
||||
explicit float16_t(float x)
|
||||
{
|
||||
#if CV_AVX2
|
||||
#if CV_FP16
|
||||
__m128 v = _mm_load_ss(&x);
|
||||
w = (ushort)_mm_cvtsi128_si32(_mm_cvtps_ph(v, 0));
|
||||
#else
|
||||
@@ -875,7 +875,7 @@ protected:
|
||||
|
||||
operator float() const
|
||||
{
|
||||
#if CV_AVX2
|
||||
#if CV_FP16
|
||||
float f;
|
||||
_mm_store_ss(&f, _mm_cvtph_ps(_mm_cvtsi32_si128(w)));
|
||||
return f;
|
||||
|
||||
@@ -3121,18 +3121,39 @@ OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_float32x8, float, f32, v_uint32x8, un
|
||||
OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_int64x4, int64, s64, v_uint64x4, uint64, u64)
|
||||
OPENCV_HAL_IMPL_AVX_LOADSTORE_INTERLEAVE(v_float64x4, double, f64, v_uint64x4, uint64, u64)
|
||||
|
||||
//
|
||||
// FP16
|
||||
//
|
||||
|
||||
inline v_float32x8 v256_load_expand(const float16_t* ptr)
|
||||
{
|
||||
#if CV_FP16
|
||||
return v_float32x8(_mm256_cvtph_ps(_mm_loadu_si128((const __m128i*)ptr)));
|
||||
#else
|
||||
float CV_DECL_ALIGNED(32) buf[8];
|
||||
for (int i = 0; i < 8; i++)
|
||||
buf[i] = (float)ptr[i];
|
||||
return v256_load_aligned(buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void v_pack_store(float16_t* ptr, const v_float32x8& a)
|
||||
{
|
||||
#if CV_FP16
|
||||
__m128i ah = _mm256_cvtps_ph(a.val, 0);
|
||||
_mm_storeu_si128((__m128i*)ptr, ah);
|
||||
#else
|
||||
float CV_DECL_ALIGNED(32) buf[8];
|
||||
v_store_aligned(buf, a);
|
||||
for (int i = 0; i < 8; i++)
|
||||
ptr[i] = float16_t(buf[i]);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// end of FP16
|
||||
//
|
||||
|
||||
inline void v256_cleanup() { _mm256_zeroall(); }
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
|
||||
@@ -207,13 +207,7 @@ struct v_uint64x2
|
||||
|
||||
uint64 get0() const
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
return (uint64)wasm_i64x2_extract_lane(val, 0);
|
||||
#else
|
||||
uint64 des[2];
|
||||
wasm_v128_store(des, val);
|
||||
return des[0];
|
||||
#endif
|
||||
}
|
||||
|
||||
v128_t val;
|
||||
@@ -235,13 +229,7 @@ struct v_int64x2
|
||||
|
||||
int64 get0() const
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
return wasm_i64x2_extract_lane(val, 0);
|
||||
#else
|
||||
int64 des[2];
|
||||
wasm_v128_store(des, val);
|
||||
return des[0];
|
||||
#endif
|
||||
}
|
||||
|
||||
v128_t val;
|
||||
@@ -263,13 +251,7 @@ struct v_float64x2
|
||||
|
||||
double get0() const
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
return wasm_f64x2_extract_lane(val, 0);
|
||||
#else
|
||||
double des[2];
|
||||
wasm_v128_store(des, val);
|
||||
return des[0];
|
||||
#endif
|
||||
}
|
||||
|
||||
v128_t val;
|
||||
@@ -1797,22 +1779,9 @@ OPENCV_HAL_IMPL_WASM_INITVEC(v_int16x8, short, s16, i16x8, short)
|
||||
OPENCV_HAL_IMPL_WASM_INITVEC(v_uint32x4, unsigned, u32, i32x4, int)
|
||||
OPENCV_HAL_IMPL_WASM_INITVEC(v_int32x4, int, s32, i32x4, int)
|
||||
OPENCV_HAL_IMPL_WASM_INITVEC(v_float32x4, float, f32, f32x4, float)
|
||||
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
OPENCV_HAL_IMPL_WASM_INITVEC(v_uint64x2, uint64, u64, i64x2, int64)
|
||||
OPENCV_HAL_IMPL_WASM_INITVEC(v_int64x2, int64, s64, i64x2, int64)
|
||||
OPENCV_HAL_IMPL_WASM_INITVEC(v_float64x2, double, f64, f64x2, double)
|
||||
#else
|
||||
#define OPENCV_HAL_IMPL_FALLBACK_INITVEC(_Tpvec, _Tp, suffix, _Tps) \
|
||||
inline _Tpvec v_setzero_##suffix() { return _Tpvec((_Tps)0, (_Tps)0); } \
|
||||
inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec((_Tps)v, (_Tps)v); } \
|
||||
template<typename _Tpvec0> inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0& a) \
|
||||
{ return _Tpvec(a.val); }
|
||||
|
||||
OPENCV_HAL_IMPL_FALLBACK_INITVEC(v_uint64x2, uint64, u64, int64)
|
||||
OPENCV_HAL_IMPL_FALLBACK_INITVEC(v_int64x2, int64, s64, int64)
|
||||
OPENCV_HAL_IMPL_FALLBACK_INITVEC(v_float64x2, double, f64, double)
|
||||
#endif
|
||||
|
||||
//////////////// PACK ///////////////
|
||||
inline v_uint8x16 v_pack(const v_uint16x8& a, const v_uint16x8& b)
|
||||
@@ -1931,28 +1900,18 @@ inline v_int16x8 v_rshr_pack(const v_int32x4& a, const v_int32x4& b)
|
||||
template<int n>
|
||||
inline v_uint32x4 v_rshr_pack(const v_uint64x2& a, const v_uint64x2& b)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
v128_t delta = wasm_i64x2_splat(((int64)1 << (n-1)));
|
||||
v128_t a1 = wasm_u64x2_shr(wasm_i64x2_add(a.val, delta), n);
|
||||
v128_t b1 = wasm_u64x2_shr(wasm_i64x2_add(b.val, delta), n);
|
||||
return v_uint32x4(wasm_v8x16_shuffle(a1, b1, 0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27));
|
||||
#else
|
||||
fallback::v_uint64x2 a_(a), b_(b);
|
||||
return fallback::v_rshr_pack<n>(a_, b_);
|
||||
#endif
|
||||
}
|
||||
template<int n>
|
||||
inline v_int32x4 v_rshr_pack(const v_int64x2& a, const v_int64x2& b)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
v128_t delta = wasm_i64x2_splat(((int64)1 << (n-1)));
|
||||
v128_t a1 = wasm_i64x2_shr(wasm_i64x2_add(a.val, delta), n);
|
||||
v128_t b1 = wasm_i64x2_shr(wasm_i64x2_add(b.val, delta), n);
|
||||
return v_int32x4(wasm_v8x16_shuffle(a1, b1, 0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27));
|
||||
#else
|
||||
fallback::v_int64x2 a_(a), b_(b);
|
||||
return fallback::v_rshr_pack<n>(a_, b_);
|
||||
#endif
|
||||
}
|
||||
template<int n>
|
||||
inline v_uint8x16 v_rshr_pack_u(const v_int16x8& a, const v_int16x8& b)
|
||||
@@ -2139,7 +2098,6 @@ inline void v_rshr_pack_store(short* ptr, const v_int32x4& a)
|
||||
template<int n>
|
||||
inline void v_rshr_pack_store(unsigned* ptr, const v_uint64x2& a)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
v128_t delta = wasm_i64x2_splat(((int64)1 << (n-1)));
|
||||
v128_t a1 = wasm_u64x2_shr(wasm_i64x2_add(a.val, delta), n);
|
||||
v128_t r = wasm_v8x16_shuffle(a1, a1, 0,1,2,3,8,9,10,11,0,1,2,3,8,9,10,11);
|
||||
@@ -2148,15 +2106,10 @@ inline void v_rshr_pack_store(unsigned* ptr, const v_uint64x2& a)
|
||||
for (int i=0; i<2; ++i) {
|
||||
ptr[i] = t_ptr[i];
|
||||
}
|
||||
#else
|
||||
fallback::v_uint64x2 _a(a);
|
||||
fallback::v_rshr_pack_store<n>(ptr, _a);
|
||||
#endif
|
||||
}
|
||||
template<int n>
|
||||
inline void v_rshr_pack_store(int* ptr, const v_int64x2& a)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
v128_t delta = wasm_i64x2_splat(((int64)1 << (n-1)));
|
||||
v128_t a1 = wasm_i64x2_shr(wasm_i64x2_add(a.val, delta), n);
|
||||
v128_t r = wasm_v8x16_shuffle(a1, a1, 0,1,2,3,8,9,10,11,0,1,2,3,8,9,10,11);
|
||||
@@ -2165,10 +2118,6 @@ inline void v_rshr_pack_store(int* ptr, const v_int64x2& a)
|
||||
for (int i=0; i<2; ++i) {
|
||||
ptr[i] = t_ptr[i];
|
||||
}
|
||||
#else
|
||||
fallback::v_int64x2 _a(a);
|
||||
fallback::v_rshr_pack_store<n>(ptr, _a);
|
||||
#endif
|
||||
}
|
||||
template<int n>
|
||||
inline void v_rshr_pack_u_store(uchar* ptr, const v_int16x8& a)
|
||||
@@ -2228,7 +2177,6 @@ inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uin
|
||||
const v_uint64x2& d, const v_uint64x2& e, const v_uint64x2& f,
|
||||
const v_uint64x2& g, const v_uint64x2& h)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
v128_t maxval = wasm_i32x4_splat(255);
|
||||
v128_t a1 = wasm_v128_bitselect(maxval, a.val, ((__u64x2)(a.val) > (__u64x2)maxval));
|
||||
v128_t b1 = wasm_v128_bitselect(maxval, b.val, ((__u64x2)(b.val) > (__u64x2)maxval));
|
||||
@@ -2245,10 +2193,6 @@ inline v_uint8x16 v_pack_b(const v_uint64x2& a, const v_uint64x2& b, const v_uin
|
||||
v128_t abcd = wasm_v8x16_shuffle(ab, cd, 0,1,2,3,16,17,18,19,0,1,2,3,16,17,18,19);
|
||||
v128_t efgh = wasm_v8x16_shuffle(ef, gh, 0,1,2,3,16,17,18,19,0,1,2,3,16,17,18,19);
|
||||
return v_uint8x16(wasm_v8x16_shuffle(abcd, efgh, 0,1,2,3,4,5,6,7,16,17,18,19,20,21,22,23));
|
||||
#else
|
||||
fallback::v_uint64x2 a_(a), b_(b), c_(c), d_(d), e_(e), f_(f), g_(g), h_(h);
|
||||
return fallback::v_pack_b(a_, b_, c_, d_, e_, f_, g_, h_);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0,
|
||||
@@ -2310,8 +2254,6 @@ OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_float32x4, wasm_f32x4_add)
|
||||
OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_float32x4, wasm_f32x4_sub)
|
||||
OPENCV_HAL_IMPL_WASM_BIN_OP(*, v_float32x4, wasm_f32x4_mul)
|
||||
OPENCV_HAL_IMPL_WASM_BIN_OP(/, v_float32x4, wasm_f32x4_div)
|
||||
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_uint64x2, wasm_i64x2_add)
|
||||
OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_uint64x2, wasm_i64x2_sub)
|
||||
OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_int64x2, wasm_i64x2_add)
|
||||
@@ -2320,30 +2262,6 @@ OPENCV_HAL_IMPL_WASM_BIN_OP(+, v_float64x2, wasm_f64x2_add)
|
||||
OPENCV_HAL_IMPL_WASM_BIN_OP(-, v_float64x2, wasm_f64x2_sub)
|
||||
OPENCV_HAL_IMPL_WASM_BIN_OP(*, v_float64x2, wasm_f64x2_mul)
|
||||
OPENCV_HAL_IMPL_WASM_BIN_OP(/, v_float64x2, wasm_f64x2_div)
|
||||
#else
|
||||
#define OPENCV_HAL_IMPL_FALLBACK_BIN_OP(bin_op, _Tpvec) \
|
||||
inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
fallback::_Tpvec a_(a), b_(b); \
|
||||
return _Tpvec((a_) bin_op (b_)); \
|
||||
} \
|
||||
inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
fallback::_Tpvec a_(a), b_(b); \
|
||||
a_ bin_op##= b_; \
|
||||
a = _Tpvec(a_); \
|
||||
return a; \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_FALLBACK_BIN_OP(+, v_uint64x2)
|
||||
OPENCV_HAL_IMPL_FALLBACK_BIN_OP(-, v_uint64x2)
|
||||
OPENCV_HAL_IMPL_FALLBACK_BIN_OP(+, v_int64x2)
|
||||
OPENCV_HAL_IMPL_FALLBACK_BIN_OP(-, v_int64x2)
|
||||
OPENCV_HAL_IMPL_FALLBACK_BIN_OP(+, v_float64x2)
|
||||
OPENCV_HAL_IMPL_FALLBACK_BIN_OP(-, v_float64x2)
|
||||
OPENCV_HAL_IMPL_FALLBACK_BIN_OP(*, v_float64x2)
|
||||
OPENCV_HAL_IMPL_FALLBACK_BIN_OP(/, v_float64x2)
|
||||
#endif
|
||||
|
||||
// saturating multiply 8-bit, 16-bit
|
||||
#define OPENCV_HAL_IMPL_WASM_MUL_SAT(_Tpvec, _Tpwvec) \
|
||||
@@ -2405,19 +2323,11 @@ inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b,
|
||||
inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b,
|
||||
v_uint64x2& c, v_uint64x2& d)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
v_uint64x2 a0, a1, b0, b1;
|
||||
v_expand(a, a0, a1);
|
||||
v_expand(b, b0, b1);
|
||||
c.val = ((__u64x2)(a0.val) * (__u64x2)(b0.val));
|
||||
d.val = ((__u64x2)(a1.val) * (__u64x2)(b1.val));
|
||||
#else
|
||||
fallback::v_uint32x4 a_(a), b_(b);
|
||||
fallback::v_uint64x2 c_, d_;
|
||||
fallback::v_mul_expand(a_, b_, c_, d_);
|
||||
c = v_uint64x2(c_);
|
||||
d = v_uint64x2(d_);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline v_int16x8 v_mul_hi(const v_int16x8& a, const v_int16x8& b)
|
||||
@@ -2457,7 +2367,6 @@ inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b, const v_int32
|
||||
|
||||
inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
v128_t a0 = wasm_i64x2_shr(wasm_i64x2_shl(a.val, 32), 32);
|
||||
v128_t a1 = wasm_i64x2_shr(a.val, 32);
|
||||
v128_t b0 = wasm_i64x2_shr(wasm_i64x2_shl(b.val, 32), 32);
|
||||
@@ -2465,22 +2374,10 @@ inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b)
|
||||
v128_t c = (v128_t)((__i64x2)a0 * (__i64x2)b0);
|
||||
v128_t d = (v128_t)((__i64x2)a1 * (__i64x2)b1);
|
||||
return v_int64x2(wasm_i64x2_add(c, d));
|
||||
#else
|
||||
fallback::v_int32x4 a_(a);
|
||||
fallback::v_int32x4 b_(b);
|
||||
return fallback::v_dotprod(a_, b_);
|
||||
#endif
|
||||
}
|
||||
inline v_int64x2 v_dotprod(const v_int32x4& a, const v_int32x4& b, const v_int64x2& c)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
return v_dotprod(a, b) + c;
|
||||
#else
|
||||
fallback::v_int32x4 a_(a);
|
||||
fallback::v_int32x4 b_(b);
|
||||
fallback::v_int64x2 c_(c);
|
||||
return fallback::v_dotprod(a_, b_, c_);
|
||||
#endif
|
||||
}
|
||||
|
||||
// 8 >> 32
|
||||
@@ -2515,32 +2412,32 @@ inline v_int32x4 v_dotprod_expand(const v_int8x16& a, const v_int8x16& b, const
|
||||
// 16 >> 64
|
||||
inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b)
|
||||
{
|
||||
fallback::v_uint16x8 a_(a);
|
||||
fallback::v_uint16x8 b_(b);
|
||||
return fallback::v_dotprod_expand(a_, b_);
|
||||
v128_t a0 = wasm_u32x4_shr(wasm_i32x4_shl(a.val, 16), 16);
|
||||
v128_t a1 = wasm_u32x4_shr(a.val, 16);
|
||||
v128_t b0 = wasm_u32x4_shr(wasm_i32x4_shl(b.val, 16), 16);
|
||||
v128_t b1 = wasm_u32x4_shr(b.val, 16);
|
||||
return v_uint64x2((
|
||||
v_dotprod(v_int32x4(a0), v_int32x4(b0)) +
|
||||
v_dotprod(v_int32x4(a1), v_int32x4(b1))).val
|
||||
);
|
||||
}
|
||||
inline v_uint64x2 v_dotprod_expand(const v_uint16x8& a, const v_uint16x8& b, const v_uint64x2& c)
|
||||
{
|
||||
fallback::v_uint16x8 a_(a);
|
||||
fallback::v_uint16x8 b_(b);
|
||||
fallback::v_uint64x2 c_(c);
|
||||
return fallback::v_dotprod_expand(a_, b_, c_);
|
||||
}
|
||||
{ return v_dotprod_expand(a, b) + c; }
|
||||
|
||||
inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b)
|
||||
{
|
||||
fallback::v_int16x8 a_(a);
|
||||
fallback::v_int16x8 b_(b);
|
||||
return fallback::v_dotprod_expand(a_, b_);
|
||||
v128_t a0 = wasm_i32x4_shr(wasm_i32x4_shl(a.val, 16), 16);
|
||||
v128_t a1 = wasm_i32x4_shr(a.val, 16);
|
||||
v128_t b0 = wasm_i32x4_shr(wasm_i32x4_shl(b.val, 16), 16);
|
||||
v128_t b1 = wasm_i32x4_shr(b.val, 16);
|
||||
return v_int64x2((
|
||||
v_dotprod(v_int32x4(a0), v_int32x4(b0)) +
|
||||
v_dotprod(v_int32x4(a1), v_int32x4(b1)))
|
||||
);
|
||||
}
|
||||
|
||||
inline v_int64x2 v_dotprod_expand(const v_int16x8& a, const v_int16x8& b, const v_int64x2& c)
|
||||
{
|
||||
fallback::v_int16x8 a_(a);
|
||||
fallback::v_int16x8 b_(b);
|
||||
fallback::v_int64x2 c_(c);
|
||||
return fallback::v_dotprod_expand(a_, b_, c_);
|
||||
}
|
||||
{ return v_dotprod_expand(a, b) + c; }
|
||||
|
||||
// 32 >> 64f
|
||||
inline v_float64x2 v_dotprod_expand(const v_int32x4& a, const v_int32x4& b)
|
||||
@@ -2610,44 +2507,24 @@ OPENCV_HAL_IMPL_WASM_LOGIC_OP(v_float64x2)
|
||||
|
||||
inline v_float32x4 v_sqrt(const v_float32x4& x)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
return v_float32x4(wasm_f32x4_sqrt(x.val));
|
||||
#else
|
||||
fallback::v_float32x4 x_(x);
|
||||
return fallback::v_sqrt(x_);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline v_float32x4 v_invsqrt(const v_float32x4& x)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
const v128_t _1_0 = wasm_f32x4_splat(1.0);
|
||||
return v_float32x4(wasm_f32x4_div(_1_0, wasm_f32x4_sqrt(x.val)));
|
||||
#else
|
||||
fallback::v_float32x4 x_(x);
|
||||
return fallback::v_invsqrt(x_);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline v_float64x2 v_sqrt(const v_float64x2& x)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
return v_float64x2(wasm_f64x2_sqrt(x.val));
|
||||
#else
|
||||
fallback::v_float64x2 x_(x);
|
||||
return fallback::v_sqrt(x_);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline v_float64x2 v_invsqrt(const v_float64x2& x)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
const v128_t _1_0 = wasm_f64x2_splat(1.0);
|
||||
return v_float64x2(wasm_f64x2_div(_1_0, wasm_f64x2_sqrt(x.val)));
|
||||
#else
|
||||
fallback::v_float64x2 x_(x);
|
||||
return fallback::v_invsqrt(x_);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_WASM_ABS_INT_FUNC(_Tpuvec, _Tpsvec, suffix, zsuffix, shiftWidth) \
|
||||
@@ -2666,12 +2543,7 @@ inline v_float32x4 v_abs(const v_float32x4& x)
|
||||
{ return v_float32x4(wasm_f32x4_abs(x.val)); }
|
||||
inline v_float64x2 v_abs(const v_float64x2& x)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
return v_float64x2(wasm_f64x2_abs(x.val));
|
||||
#else
|
||||
fallback::v_float64x2 x_(x);
|
||||
return fallback::v_abs(x_);
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO: exp, log, sin, cos
|
||||
@@ -2684,21 +2556,8 @@ inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \
|
||||
|
||||
OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_float32x4, v_min, wasm_f32x4_min)
|
||||
OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_float32x4, v_max, wasm_f32x4_max)
|
||||
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_float64x2, v_min, wasm_f64x2_min)
|
||||
OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_float64x2, v_max, wasm_f64x2_max)
|
||||
#else
|
||||
#define OPENCV_HAL_IMPL_WASM_MINMAX_64f_FUNC(func) \
|
||||
inline v_float64x2 func(const v_float64x2& a, const v_float64x2& b) \
|
||||
{ \
|
||||
fallback::v_float64x2 a_(a), b_(b); \
|
||||
return fallback::func(a_, b_); \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_WASM_MINMAX_64f_FUNC(v_min)
|
||||
OPENCV_HAL_IMPL_WASM_MINMAX_64f_FUNC(v_max)
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_WASM_MINMAX_S_INIT_FUNC(_Tpvec, suffix) \
|
||||
inline _Tpvec v_min(const _Tpvec& a, const _Tpvec& b) \
|
||||
@@ -2753,24 +2612,7 @@ OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_int16x8, i16x8, i16x8)
|
||||
OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_uint32x4, u32x4, i32x4)
|
||||
OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_int32x4, i32x4, i32x4)
|
||||
OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_float32x4, f32x4, f32x4)
|
||||
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
OPENCV_HAL_IMPL_WASM_INIT_CMP_OP(v_float64x2, f64x2, f64x2)
|
||||
#else
|
||||
#define OPENCV_HAL_IMPL_INIT_FALLBACK_CMP_OP(_Tpvec, bin_op) \
|
||||
inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
fallback::_Tpvec a_(a), b_(b); \
|
||||
return _Tpvec((a_) bin_op (b_));\
|
||||
} \
|
||||
|
||||
OPENCV_HAL_IMPL_INIT_FALLBACK_CMP_OP(v_float64x2, ==)
|
||||
OPENCV_HAL_IMPL_INIT_FALLBACK_CMP_OP(v_float64x2, !=)
|
||||
OPENCV_HAL_IMPL_INIT_FALLBACK_CMP_OP(v_float64x2, <)
|
||||
OPENCV_HAL_IMPL_INIT_FALLBACK_CMP_OP(v_float64x2, >)
|
||||
OPENCV_HAL_IMPL_INIT_FALLBACK_CMP_OP(v_float64x2, <=)
|
||||
OPENCV_HAL_IMPL_INIT_FALLBACK_CMP_OP(v_float64x2, >=)
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_WASM_64BIT_CMP_OP(_Tpvec, cast) \
|
||||
inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \
|
||||
@@ -2789,14 +2631,9 @@ inline v_float32x4 v_not_nan(const v_float32x4& a)
|
||||
}
|
||||
inline v_float64x2 v_not_nan(const v_float64x2& a)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
v128_t z = wasm_i64x2_splat(0x7fffffffffffffff);
|
||||
v128_t t = wasm_i64x2_splat(0x7ff0000000000000);
|
||||
return v_float64x2((__u64x2)(wasm_v128_and(a.val, z)) < (__u64x2)t);
|
||||
#else
|
||||
fallback::v_float64x2 a_(a);
|
||||
return fallback::v_not_nan(a_);
|
||||
#endif
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_WASM_BIN_FUNC(v_uint8x16, v_add_wrap, wasm_i8x16_add)
|
||||
@@ -2877,32 +2714,30 @@ inline v_float32x4 v_absdiff(const v_float32x4& a, const v_float32x4& b)
|
||||
}
|
||||
inline v_float64x2 v_absdiff(const v_float64x2& a, const v_float64x2& b)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
v128_t absmask_vec = wasm_u64x2_shr(wasm_i32x4_splat(-1), 1);
|
||||
return v_float64x2(wasm_v128_and(wasm_f64x2_sub(a.val, b.val), absmask_vec));
|
||||
#else
|
||||
fallback::v_float64x2 a_(a), b_(b);
|
||||
return fallback::v_absdiff(a_, b_);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_WASM_MISC_FLT_OP(_Tpvec) \
|
||||
#define OPENCV_HAL_IMPL_WASM_MISC_FLT_OP(_Tpvec, suffix) \
|
||||
inline _Tpvec v_magnitude(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
fallback::_Tpvec a_(a), b_(b); \
|
||||
return fallback::v_magnitude(a_, b_); \
|
||||
v128_t a_Square = wasm_##suffix##_mul(a.val, a.val); \
|
||||
v128_t b_Square = wasm_##suffix##_mul(b.val, b.val); \
|
||||
return _Tpvec(wasm_##suffix##_sqrt(wasm_##suffix##_add(a_Square, b_Square))); \
|
||||
} \
|
||||
inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
return v_fma(a, a, b*b); \
|
||||
v128_t a_Square = wasm_##suffix##_mul(a.val, a.val); \
|
||||
v128_t b_Square = wasm_##suffix##_mul(b.val, b.val); \
|
||||
return _Tpvec(wasm_##suffix##_add(a_Square, b_Square)); \
|
||||
} \
|
||||
inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \
|
||||
{ \
|
||||
return v_fma(a, b, c); \
|
||||
return _Tpvec(wasm_##suffix##_add(wasm_##suffix##_mul(a.val, b.val), c.val)); \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_WASM_MISC_FLT_OP(v_float32x4)
|
||||
OPENCV_HAL_IMPL_WASM_MISC_FLT_OP(v_float64x2)
|
||||
OPENCV_HAL_IMPL_WASM_MISC_FLT_OP(v_float32x4, f32x4)
|
||||
OPENCV_HAL_IMPL_WASM_MISC_FLT_OP(v_float64x2, f64x2)
|
||||
|
||||
#define OPENCV_HAL_IMPL_WASM_SHIFT_OP(_Tpuvec, _Tpsvec, suffix, ssuffix) \
|
||||
inline _Tpuvec operator << (const _Tpuvec& a, int imm) \
|
||||
@@ -2945,37 +2780,7 @@ inline _Tpsvec v_shr(const _Tpsvec& a) \
|
||||
OPENCV_HAL_IMPL_WASM_SHIFT_OP(v_uint8x16, v_int8x16, i8x16, u8x16)
|
||||
OPENCV_HAL_IMPL_WASM_SHIFT_OP(v_uint16x8, v_int16x8, i16x8, u16x8)
|
||||
OPENCV_HAL_IMPL_WASM_SHIFT_OP(v_uint32x4, v_int32x4, i32x4, u32x4)
|
||||
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
OPENCV_HAL_IMPL_WASM_SHIFT_OP(v_uint64x2, v_int64x2, i64x2, u64x2)
|
||||
#else
|
||||
#define OPENCV_HAL_IMPL_FALLBACK_SHIFT_OP(_Tpvec) \
|
||||
inline _Tpvec operator << (const _Tpvec& a, int imm) \
|
||||
{ \
|
||||
fallback::_Tpvec a_(a); \
|
||||
return a_ << imm; \
|
||||
} \
|
||||
inline _Tpvec operator >> (const _Tpvec& a, int imm) \
|
||||
{ \
|
||||
fallback::_Tpvec a_(a); \
|
||||
return a_ >> imm; \
|
||||
} \
|
||||
template<int imm> \
|
||||
inline _Tpvec v_shl(const _Tpvec& a) \
|
||||
{ \
|
||||
fallback::_Tpvec a_(a); \
|
||||
return fallback::v_shl<imm>(a_); \
|
||||
} \
|
||||
template<int imm> \
|
||||
inline _Tpvec v_shr(const _Tpvec& a) \
|
||||
{ \
|
||||
fallback::_Tpvec a_(a); \
|
||||
return fallback::v_shr<imm>(a_); \
|
||||
} \
|
||||
|
||||
OPENCV_HAL_IMPL_FALLBACK_SHIFT_OP(v_uint64x2)
|
||||
OPENCV_HAL_IMPL_FALLBACK_SHIFT_OP(v_int64x2)
|
||||
#endif
|
||||
|
||||
namespace hal_wasm_internal
|
||||
{
|
||||
@@ -3180,9 +2985,18 @@ OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_uint8x16, unsigned)
|
||||
OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_int8x16, int)
|
||||
OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_uint16x8, unsigned)
|
||||
OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_int16x8, int)
|
||||
OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_uint64x2, uint64)
|
||||
OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_int64x2, int64)
|
||||
OPENCV_HAL_IMPL_FALLBACK_REDUCE_OP_SUM(v_float64x2, double)
|
||||
|
||||
|
||||
#define OPENCV_HAL_IMPL_WASM_REDUCE_OP_2_SUM(_Tpvec, scalartype, regtype, suffix, esuffix) \
|
||||
inline scalartype v_reduce_sum(const _Tpvec& a) \
|
||||
{ \
|
||||
regtype val = a.val; \
|
||||
val = wasm_##suffix##_add(val, wasm_v8x16_shuffle(val, val, 8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7)); \
|
||||
return (scalartype)wasm_##esuffix##_extract_lane(val, 0); \
|
||||
}
|
||||
OPENCV_HAL_IMPL_WASM_REDUCE_OP_2_SUM(v_uint64x2, uint64, v128_t, i64x2, i64x2)
|
||||
OPENCV_HAL_IMPL_WASM_REDUCE_OP_2_SUM(v_int64x2, int64, v128_t, i64x2, i64x2)
|
||||
OPENCV_HAL_IMPL_WASM_REDUCE_OP_2_SUM(v_float64x2, double, v128_t, f64x2,f64x2)
|
||||
|
||||
inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b,
|
||||
const v_float32x4& c, const v_float32x4& d)
|
||||
@@ -3318,30 +3132,27 @@ OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_int16x8, i16x8, short)
|
||||
OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_uint32x4, i32x4, int)
|
||||
OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_int32x4, i32x4, int)
|
||||
OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_float32x4, i32x4, float)
|
||||
OPENCV_HAL_IMPL_WASM_CHECK_SIGNS(v_float64x2, f64x2, double)
|
||||
|
||||
#define OPENCV_HAL_IMPL_WASM_CHECK_ALL_ANY(_Tpvec, suffix, esuffix) \
|
||||
inline bool v_check_all(const _Tpvec& a) \
|
||||
{ \
|
||||
v128_t masked = v_reinterpret_as_##esuffix(a).val; \
|
||||
masked = wasm_i32x4_replace_lane(masked, 0, 0xffffffff); \
|
||||
masked = wasm_i32x4_replace_lane(masked, 2, 0xffffffff); \
|
||||
return wasm_i8x16_all_true(wasm_##suffix##_lt(masked, wasm_##suffix##_splat(0))); \
|
||||
} \
|
||||
inline bool v_check_any(const _Tpvec& a) \
|
||||
{ \
|
||||
v128_t masked = v_reinterpret_as_##esuffix(a).val; \
|
||||
masked = wasm_i32x4_replace_lane(masked, 0, 0x0); \
|
||||
masked = wasm_i32x4_replace_lane(masked, 2, 0x0); \
|
||||
return wasm_i8x16_any_true(wasm_##suffix##_lt(masked, wasm_##suffix##_splat(0))); \
|
||||
} \
|
||||
|
||||
OPENCV_HAL_IMPL_WASM_CHECK_ALL_ANY(v_int64x2, i32x4, s32)
|
||||
OPENCV_HAL_IMPL_WASM_CHECK_ALL_ANY(v_uint64x2, i32x4, u32)
|
||||
|
||||
inline int v_signmask(const v_float64x2& a)
|
||||
{
|
||||
fallback::v_float64x2 a_(a);
|
||||
return fallback::v_signmask(a_);
|
||||
}
|
||||
inline bool v_check_all(const v_float64x2& a)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
return wasm_i8x16_all_true((__i64x2)(a.val) < (__i64x2)(wasm_i64x2_splat(0)));
|
||||
#else
|
||||
fallback::v_float64x2 a_(a);
|
||||
return fallback::v_check_all(a_);
|
||||
#endif
|
||||
}
|
||||
inline bool v_check_any(const v_float64x2& a)
|
||||
{
|
||||
#ifdef __wasm_unimplemented_simd128__
|
||||
return wasm_i8x16_any_true((__i64x2)(a.val) < (__i64x2)(wasm_i64x2_splat(0)));;
|
||||
#else
|
||||
fallback::v_float64x2 a_(a);
|
||||
return fallback::v_check_any(a_);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline int v_scan_forward(const v_int8x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))); }
|
||||
inline int v_scan_forward(const v_uint8x16& a) { return trailingZeros32(v_signmask(v_reinterpret_as_s8(a))); }
|
||||
@@ -3366,8 +3177,8 @@ OPENCV_HAL_IMPL_WASM_SELECT(v_uint16x8)
|
||||
OPENCV_HAL_IMPL_WASM_SELECT(v_int16x8)
|
||||
OPENCV_HAL_IMPL_WASM_SELECT(v_uint32x4)
|
||||
OPENCV_HAL_IMPL_WASM_SELECT(v_int32x4)
|
||||
// OPENCV_HAL_IMPL_WASM_SELECT(v_uint64x2)
|
||||
// OPENCV_HAL_IMPL_WASM_SELECT(v_int64x2)
|
||||
OPENCV_HAL_IMPL_WASM_SELECT(v_uint64x2)
|
||||
OPENCV_HAL_IMPL_WASM_SELECT(v_int64x2)
|
||||
OPENCV_HAL_IMPL_WASM_SELECT(v_float32x4)
|
||||
OPENCV_HAL_IMPL_WASM_SELECT(v_float64x2)
|
||||
|
||||
|
||||
@@ -458,158 +458,6 @@ CV__DEBUG_NS_END
|
||||
|
||||
//////////////////////////////////////////// Mat //////////////////////////////////////////
|
||||
|
||||
inline
|
||||
Mat::Mat()
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{}
|
||||
|
||||
inline
|
||||
Mat::Mat(int _rows, int _cols, int _type)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create(_rows, _cols, _type);
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create(_rows, _cols, _type);
|
||||
*this = _s;
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::Mat(Size _sz, int _type)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create( _sz.height, _sz.width, _type );
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::Mat(Size _sz, int _type, const Scalar& _s)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create(_sz.height, _sz.width, _type);
|
||||
*this = _s;
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::Mat(int _dims, const int* _sz, int _type)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create(_dims, _sz, _type);
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create(_dims, _sz, _type);
|
||||
*this = _s;
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::Mat(const std::vector<int>& _sz, int _type)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create(_sz, _type);
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::Mat(const std::vector<int>& _sz, int _type, const Scalar& _s)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create(_sz, _type);
|
||||
*this = _s;
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::Mat(const Mat& m)
|
||||
: flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), data(m.data),
|
||||
datastart(m.datastart), dataend(m.dataend), datalimit(m.datalimit), allocator(m.allocator),
|
||||
u(m.u), size(&rows), step(0)
|
||||
{
|
||||
if( u )
|
||||
CV_XADD(&u->refcount, 1);
|
||||
if( m.dims <= 2 )
|
||||
{
|
||||
step[0] = m.step[0]; step[1] = m.step[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
dims = 0;
|
||||
copySize(m);
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step)
|
||||
: flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_rows), cols(_cols),
|
||||
data((uchar*)_data), datastart((uchar*)_data), dataend(0), datalimit(0),
|
||||
allocator(0), u(0), size(&rows)
|
||||
{
|
||||
CV_Assert(total() == 0 || data != NULL);
|
||||
|
||||
size_t esz = CV_ELEM_SIZE(_type), esz1 = CV_ELEM_SIZE1(_type);
|
||||
size_t minstep = cols * esz;
|
||||
if( _step == AUTO_STEP )
|
||||
{
|
||||
_step = minstep;
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_DbgAssert( _step >= minstep );
|
||||
if (_step % esz1 != 0)
|
||||
{
|
||||
CV_Error(Error::BadStep, "Step must be a multiple of esz1");
|
||||
}
|
||||
}
|
||||
step[0] = _step;
|
||||
step[1] = esz;
|
||||
datalimit = datastart + _step * rows;
|
||||
dataend = datalimit - _step + minstep;
|
||||
updateContinuityFlag();
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
|
||||
: flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_sz.height), cols(_sz.width),
|
||||
data((uchar*)_data), datastart((uchar*)_data), dataend(0), datalimit(0),
|
||||
allocator(0), u(0), size(&rows)
|
||||
{
|
||||
CV_Assert(total() == 0 || data != NULL);
|
||||
|
||||
size_t esz = CV_ELEM_SIZE(_type), esz1 = CV_ELEM_SIZE1(_type);
|
||||
size_t minstep = cols*esz;
|
||||
if( _step == AUTO_STEP )
|
||||
{
|
||||
_step = minstep;
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_DbgAssert( _step >= minstep );
|
||||
|
||||
if (_step % esz1 != 0)
|
||||
{
|
||||
CV_Error(Error::BadStep, "Step must be a multiple of esz1");
|
||||
}
|
||||
}
|
||||
step[0] = _step;
|
||||
step[1] = esz;
|
||||
datalimit = datastart + _step*rows;
|
||||
dataend = datalimit - _step + minstep;
|
||||
updateContinuityFlag();
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
Mat::Mat(const std::vector<_Tp>& vec, bool copyData)
|
||||
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
|
||||
@@ -743,43 +591,6 @@ Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer)
|
||||
*this = commaInitializer.operator Mat_<_Tp>();
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::~Mat()
|
||||
{
|
||||
release();
|
||||
if( step.p != step.buf )
|
||||
fastFree(step.p);
|
||||
}
|
||||
|
||||
inline
|
||||
Mat& Mat::operator = (const Mat& m)
|
||||
{
|
||||
if( this != &m )
|
||||
{
|
||||
if( m.u )
|
||||
CV_XADD(&m.u->refcount, 1);
|
||||
release();
|
||||
flags = m.flags;
|
||||
if( dims <= 2 && m.dims <= 2 )
|
||||
{
|
||||
dims = m.dims;
|
||||
rows = m.rows;
|
||||
cols = m.cols;
|
||||
step[0] = m.step[0];
|
||||
step[1] = m.step[1];
|
||||
}
|
||||
else
|
||||
copySize(m);
|
||||
data = m.data;
|
||||
datastart = m.datastart;
|
||||
dataend = m.dataend;
|
||||
datalimit = m.datalimit;
|
||||
allocator = m.allocator;
|
||||
u = m.u;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
Mat Mat::row(int y) const
|
||||
{
|
||||
@@ -816,67 +627,6 @@ Mat Mat::colRange(const Range& r) const
|
||||
return Mat(*this, Range::all(), r);
|
||||
}
|
||||
|
||||
inline
|
||||
Mat Mat::clone() const
|
||||
{
|
||||
Mat m;
|
||||
copyTo(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
inline
|
||||
void Mat::assignTo( Mat& m, int _type ) const
|
||||
{
|
||||
if( _type < 0 )
|
||||
m = *this;
|
||||
else
|
||||
convertTo(m, _type);
|
||||
}
|
||||
|
||||
inline
|
||||
void Mat::create(int _rows, int _cols, int _type)
|
||||
{
|
||||
_type &= TYPE_MASK;
|
||||
if( dims <= 2 && rows == _rows && cols == _cols && type() == _type && data )
|
||||
return;
|
||||
int sz[] = {_rows, _cols};
|
||||
create(2, sz, _type);
|
||||
}
|
||||
|
||||
inline
|
||||
void Mat::create(Size _sz, int _type)
|
||||
{
|
||||
create(_sz.height, _sz.width, _type);
|
||||
}
|
||||
|
||||
inline
|
||||
void Mat::addref()
|
||||
{
|
||||
if( u )
|
||||
CV_XADD(&u->refcount, 1);
|
||||
}
|
||||
|
||||
inline
|
||||
void Mat::release()
|
||||
{
|
||||
if( u && CV_XADD(&u->refcount, -1) == 1 )
|
||||
deallocate();
|
||||
u = NULL;
|
||||
datastart = dataend = datalimit = data = 0;
|
||||
for(int i = 0; i < dims; i++)
|
||||
size.p[i] = 0;
|
||||
#ifdef _DEBUG
|
||||
flags = MAGIC_VAL;
|
||||
dims = rows = cols = 0;
|
||||
if(step.p != step.buf)
|
||||
{
|
||||
fastFree(step.p);
|
||||
step.p = step.buf;
|
||||
size.p = &rows;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
Mat Mat::operator()( Range _rowRange, Range _colRange ) const
|
||||
{
|
||||
@@ -945,40 +695,6 @@ int Mat::channels() const
|
||||
return CV_MAT_CN(flags);
|
||||
}
|
||||
|
||||
inline
|
||||
size_t Mat::step1(int i) const
|
||||
{
|
||||
return step.p[i] / elemSize1();
|
||||
}
|
||||
|
||||
inline
|
||||
bool Mat::empty() const
|
||||
{
|
||||
return data == 0 || total() == 0 || dims == 0;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t Mat::total() const
|
||||
{
|
||||
if( dims <= 2 )
|
||||
return (size_t)rows * cols;
|
||||
size_t p = 1;
|
||||
for( int i = 0; i < dims; i++ )
|
||||
p *= size[i];
|
||||
return p;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t Mat::total(int startDim, int endDim) const
|
||||
{
|
||||
CV_Assert( 0 <= startDim && startDim <= endDim);
|
||||
size_t p = 1;
|
||||
int endDim_ = endDim <= dims ? endDim : dims;
|
||||
for( int i = startDim; i < endDim_; i++ )
|
||||
p *= size[i];
|
||||
return p;
|
||||
}
|
||||
|
||||
inline
|
||||
uchar* Mat::ptr(int y)
|
||||
{
|
||||
@@ -1396,67 +1112,6 @@ void Mat::push_back(const std::vector<_Tp>& v)
|
||||
push_back(Mat(v));
|
||||
}
|
||||
|
||||
inline
|
||||
Mat::Mat(Mat&& m)
|
||||
: flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), data(m.data),
|
||||
datastart(m.datastart), dataend(m.dataend), datalimit(m.datalimit), allocator(m.allocator),
|
||||
u(m.u), size(&rows)
|
||||
{
|
||||
if (m.dims <= 2) // move new step/size info
|
||||
{
|
||||
step[0] = m.step[0];
|
||||
step[1] = m.step[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_DbgAssert(m.step.p != m.step.buf);
|
||||
step.p = m.step.p;
|
||||
size.p = m.size.p;
|
||||
m.step.p = m.step.buf;
|
||||
m.size.p = &m.rows;
|
||||
}
|
||||
m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0;
|
||||
m.data = NULL; m.datastart = NULL; m.dataend = NULL; m.datalimit = NULL;
|
||||
m.allocator = NULL;
|
||||
m.u = NULL;
|
||||
}
|
||||
|
||||
inline
|
||||
Mat& Mat::operator = (Mat&& m)
|
||||
{
|
||||
if (this == &m)
|
||||
return *this;
|
||||
|
||||
release();
|
||||
flags = m.flags; dims = m.dims; rows = m.rows; cols = m.cols; data = m.data;
|
||||
datastart = m.datastart; dataend = m.dataend; datalimit = m.datalimit; allocator = m.allocator;
|
||||
u = m.u;
|
||||
if (step.p != step.buf) // release self step/size
|
||||
{
|
||||
fastFree(step.p);
|
||||
step.p = step.buf;
|
||||
size.p = &rows;
|
||||
}
|
||||
if (m.dims <= 2) // move new step/size info
|
||||
{
|
||||
step[0] = m.step[0];
|
||||
step[1] = m.step[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_DbgAssert(m.step.p != m.step.buf);
|
||||
step.p = m.step.p;
|
||||
size.p = m.size.p;
|
||||
m.step.p = m.step.buf;
|
||||
m.size.p = &m.rows;
|
||||
}
|
||||
m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0;
|
||||
m.data = NULL; m.datastart = NULL; m.dataend = NULL; m.datalimit = NULL;
|
||||
m.allocator = NULL;
|
||||
m.u = NULL;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////// MatSize ////////////////////////////
|
||||
|
||||
@@ -1503,22 +1158,6 @@ MatSize::operator const int*() const
|
||||
return p;
|
||||
}
|
||||
|
||||
inline
|
||||
bool MatSize::operator == (const MatSize& sz) const
|
||||
{
|
||||
int d = dims();
|
||||
int dsz = sz.dims();
|
||||
if( d != dsz )
|
||||
return false;
|
||||
if( d == 2 )
|
||||
return p[0] == sz.p[0] && p[1] == sz.p[1];
|
||||
|
||||
for( int i = 0; i < d; i++ )
|
||||
if( p[i] != sz.p[i] )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
bool MatSize::operator != (const MatSize& sz) const
|
||||
{
|
||||
@@ -1775,9 +1414,7 @@ template<typename _Tp> inline
|
||||
void Mat_<_Tp>::release()
|
||||
{
|
||||
Mat::release();
|
||||
#ifdef _DEBUG
|
||||
flags = (flags & ~CV_MAT_TYPE_MASK) + traits::Type<_Tp>::value;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
@@ -2132,51 +1769,6 @@ Mat_<_Tp>::Mat_(MatExpr&& e)
|
||||
|
||||
///////////////////////////// SparseMat /////////////////////////////
|
||||
|
||||
inline
|
||||
SparseMat::SparseMat()
|
||||
: flags(MAGIC_VAL), hdr(0)
|
||||
{}
|
||||
|
||||
inline
|
||||
SparseMat::SparseMat(int _dims, const int* _sizes, int _type)
|
||||
: flags(MAGIC_VAL), hdr(0)
|
||||
{
|
||||
create(_dims, _sizes, _type);
|
||||
}
|
||||
|
||||
inline
|
||||
SparseMat::SparseMat(const SparseMat& m)
|
||||
: flags(m.flags), hdr(m.hdr)
|
||||
{
|
||||
addref();
|
||||
}
|
||||
|
||||
inline
|
||||
SparseMat::~SparseMat()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
inline
|
||||
SparseMat& SparseMat::operator = (const SparseMat& m)
|
||||
{
|
||||
if( this != &m )
|
||||
{
|
||||
if( m.hdr )
|
||||
CV_XADD(&m.hdr->refcount, 1);
|
||||
release();
|
||||
flags = m.flags;
|
||||
hdr = m.hdr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
SparseMat& SparseMat::operator = (const Mat& m)
|
||||
{
|
||||
return (*this = SparseMat(m));
|
||||
}
|
||||
|
||||
inline
|
||||
SparseMat SparseMat::clone() const
|
||||
{
|
||||
@@ -2185,30 +1777,6 @@ SparseMat SparseMat::clone() const
|
||||
return temp;
|
||||
}
|
||||
|
||||
inline
|
||||
void SparseMat::assignTo( SparseMat& m, int _type ) const
|
||||
{
|
||||
if( _type < 0 )
|
||||
m = *this;
|
||||
else
|
||||
convertTo(m, _type);
|
||||
}
|
||||
|
||||
inline
|
||||
void SparseMat::addref()
|
||||
{
|
||||
if( hdr )
|
||||
CV_XADD(&hdr->refcount, 1);
|
||||
}
|
||||
|
||||
inline
|
||||
void SparseMat::release()
|
||||
{
|
||||
if( hdr && CV_XADD(&hdr->refcount, -1) == 1 )
|
||||
delete hdr;
|
||||
hdr = 0;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t SparseMat::elemSize() const
|
||||
{
|
||||
@@ -2268,36 +1836,6 @@ size_t SparseMat::nzcount() const
|
||||
return hdr ? hdr->nodeCount : 0;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t SparseMat::hash(int i0) const
|
||||
{
|
||||
return (size_t)i0;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t SparseMat::hash(int i0, int i1) const
|
||||
{
|
||||
return (size_t)(unsigned)i0 * HASH_SCALE + (unsigned)i1;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t SparseMat::hash(int i0, int i1, int i2) const
|
||||
{
|
||||
return ((size_t)(unsigned)i0 * HASH_SCALE + (unsigned)i1) * HASH_SCALE + (unsigned)i2;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t SparseMat::hash(const int* idx) const
|
||||
{
|
||||
size_t h = (unsigned)idx[0];
|
||||
if( !hdr )
|
||||
return 0;
|
||||
int d = hdr->dims;
|
||||
for(int i = 1; i < d; i++ )
|
||||
h = h * HASH_SCALE + (unsigned)idx[i];
|
||||
return h;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
_Tp& SparseMat::ref(int i0, size_t* hashval)
|
||||
{
|
||||
@@ -3617,74 +3155,6 @@ const Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, const MatExpr& b)
|
||||
|
||||
//////////////////////////////// UMat ////////////////////////////////
|
||||
|
||||
inline
|
||||
UMat::UMat(UMatUsageFlags _usageFlags)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows)
|
||||
{}
|
||||
|
||||
inline
|
||||
UMat::UMat(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows)
|
||||
{
|
||||
create(_rows, _cols, _type);
|
||||
}
|
||||
|
||||
inline
|
||||
UMat::UMat(int _rows, int _cols, int _type, const Scalar& _s, UMatUsageFlags _usageFlags)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows)
|
||||
{
|
||||
create(_rows, _cols, _type);
|
||||
*this = _s;
|
||||
}
|
||||
|
||||
inline
|
||||
UMat::UMat(Size _sz, int _type, UMatUsageFlags _usageFlags)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows)
|
||||
{
|
||||
create( _sz.height, _sz.width, _type );
|
||||
}
|
||||
|
||||
inline
|
||||
UMat::UMat(Size _sz, int _type, const Scalar& _s, UMatUsageFlags _usageFlags)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows)
|
||||
{
|
||||
create(_sz.height, _sz.width, _type);
|
||||
*this = _s;
|
||||
}
|
||||
|
||||
inline
|
||||
UMat::UMat(int _dims, const int* _sz, int _type, UMatUsageFlags _usageFlags)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows)
|
||||
{
|
||||
create(_dims, _sz, _type);
|
||||
}
|
||||
|
||||
inline
|
||||
UMat::UMat(int _dims, const int* _sz, int _type, const Scalar& _s, UMatUsageFlags _usageFlags)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), allocator(0), usageFlags(_usageFlags), u(0), offset(0), size(&rows)
|
||||
{
|
||||
create(_dims, _sz, _type);
|
||||
*this = _s;
|
||||
}
|
||||
|
||||
inline
|
||||
UMat::UMat(const UMat& m)
|
||||
: flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), allocator(m.allocator),
|
||||
usageFlags(m.usageFlags), u(m.u), offset(m.offset), size(&rows)
|
||||
{
|
||||
addref();
|
||||
if( m.dims <= 2 )
|
||||
{
|
||||
step[0] = m.step[0]; step[1] = m.step[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
dims = 0;
|
||||
copySize(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename _Tp> inline
|
||||
UMat::UMat(const std::vector<_Tp>& vec, bool copyData)
|
||||
: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()),
|
||||
@@ -3701,33 +3171,6 @@ cols(1), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows)
|
||||
Mat((int)vec.size(), 1, traits::Type<_Tp>::value, (uchar*)&vec[0]).copyTo(*this);
|
||||
}
|
||||
|
||||
inline
|
||||
UMat& UMat::operator = (const UMat& m)
|
||||
{
|
||||
if( this != &m )
|
||||
{
|
||||
const_cast<UMat&>(m).addref();
|
||||
release();
|
||||
flags = m.flags;
|
||||
if( dims <= 2 && m.dims <= 2 )
|
||||
{
|
||||
dims = m.dims;
|
||||
rows = m.rows;
|
||||
cols = m.cols;
|
||||
step[0] = m.step[0];
|
||||
step[1] = m.step[1];
|
||||
}
|
||||
else
|
||||
copySize(m);
|
||||
allocator = m.allocator;
|
||||
if (usageFlags == USAGE_DEFAULT)
|
||||
usageFlags = m.usageFlags;
|
||||
u = m.u;
|
||||
offset = m.offset;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
UMat UMat::row(int y) const
|
||||
{
|
||||
@@ -3764,55 +3207,6 @@ UMat UMat::colRange(const Range& r) const
|
||||
return UMat(*this, Range::all(), r);
|
||||
}
|
||||
|
||||
inline
|
||||
UMat UMat::clone() const
|
||||
{
|
||||
UMat m;
|
||||
copyTo(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
inline
|
||||
void UMat::assignTo( UMat& m, int _type ) const
|
||||
{
|
||||
if( _type < 0 )
|
||||
m = *this;
|
||||
else
|
||||
convertTo(m, _type);
|
||||
}
|
||||
|
||||
inline
|
||||
void UMat::create(int _rows, int _cols, int _type, UMatUsageFlags _usageFlags)
|
||||
{
|
||||
_type &= TYPE_MASK;
|
||||
if( dims <= 2 && rows == _rows && cols == _cols && type() == _type && u )
|
||||
return;
|
||||
int sz[] = {_rows, _cols};
|
||||
create(2, sz, _type, _usageFlags);
|
||||
}
|
||||
|
||||
inline
|
||||
void UMat::create(Size _sz, int _type, UMatUsageFlags _usageFlags)
|
||||
{
|
||||
create(_sz.height, _sz.width, _type, _usageFlags);
|
||||
}
|
||||
|
||||
inline
|
||||
void UMat::addref()
|
||||
{
|
||||
if( u )
|
||||
CV_XADD(&(u->urefcount), 1);
|
||||
}
|
||||
|
||||
inline void UMat::release()
|
||||
{
|
||||
if( u && CV_XADD(&(u->urefcount), -1) == 1 )
|
||||
deallocate();
|
||||
for(int i = 0; i < dims; i++)
|
||||
size.p[i] = 0;
|
||||
u = 0;
|
||||
}
|
||||
|
||||
inline
|
||||
UMat UMat::operator()( Range _rowRange, Range _colRange ) const
|
||||
{
|
||||
@@ -3887,83 +3281,6 @@ size_t UMat::step1(int i) const
|
||||
return step.p[i] / elemSize1();
|
||||
}
|
||||
|
||||
inline
|
||||
bool UMat::empty() const
|
||||
{
|
||||
return u == 0 || total() == 0 || dims == 0;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t UMat::total() const
|
||||
{
|
||||
if( dims <= 2 )
|
||||
return (size_t)rows * cols;
|
||||
size_t p = 1;
|
||||
for( int i = 0; i < dims; i++ )
|
||||
p *= size[i];
|
||||
return p;
|
||||
}
|
||||
|
||||
inline
|
||||
UMat::UMat(UMat&& m)
|
||||
: flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), allocator(m.allocator),
|
||||
usageFlags(m.usageFlags), u(m.u), offset(m.offset), size(&rows)
|
||||
{
|
||||
if (m.dims <= 2) // move new step/size info
|
||||
{
|
||||
step[0] = m.step[0];
|
||||
step[1] = m.step[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_DbgAssert(m.step.p != m.step.buf);
|
||||
step.p = m.step.p;
|
||||
size.p = m.size.p;
|
||||
m.step.p = m.step.buf;
|
||||
m.size.p = &m.rows;
|
||||
}
|
||||
m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0;
|
||||
m.allocator = NULL;
|
||||
m.u = NULL;
|
||||
m.offset = 0;
|
||||
}
|
||||
|
||||
inline
|
||||
UMat& UMat::operator = (UMat&& m)
|
||||
{
|
||||
if (this == &m)
|
||||
return *this;
|
||||
release();
|
||||
flags = m.flags; dims = m.dims; rows = m.rows; cols = m.cols;
|
||||
allocator = m.allocator; usageFlags = m.usageFlags;
|
||||
u = m.u;
|
||||
offset = m.offset;
|
||||
if (step.p != step.buf) // release self step/size
|
||||
{
|
||||
fastFree(step.p);
|
||||
step.p = step.buf;
|
||||
size.p = &rows;
|
||||
}
|
||||
if (m.dims <= 2) // move new step/size info
|
||||
{
|
||||
step[0] = m.step[0];
|
||||
step[1] = m.step[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_DbgAssert(m.step.p != m.step.buf);
|
||||
step.p = m.step.p;
|
||||
size.p = m.size.p;
|
||||
m.step.p = m.step.buf;
|
||||
m.size.p = &m.rows;
|
||||
}
|
||||
m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0;
|
||||
m.allocator = NULL;
|
||||
m.u = NULL;
|
||||
m.offset = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline bool UMatData::hostCopyObsolete() const { return (flags & HOST_COPY_OBSOLETE) != 0; }
|
||||
inline bool UMatData::deviceCopyObsolete() const { return (flags & DEVICE_COPY_OBSOLETE) != 0; }
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
#define CV_VERSION_MAJOR 4
|
||||
#define CV_VERSION_MINOR 5
|
||||
#define CV_VERSION_REVISION 0
|
||||
#define CV_VERSION_STATUS ""
|
||||
#define CV_VERSION_REVISION 1
|
||||
#define CV_VERSION_STATUS "-openvino"
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import <opencv2/opencv.hpp>
|
||||
#import <opencv2/core.hpp>
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
@@ -97,6 +97,7 @@ CV_EXPORTS @interface Mat : NSObject
|
||||
- (void)createEx:(NSArray<NSNumber*>*)sizes type:(int)type NS_SWIFT_NAME(create(sizes:type:));
|
||||
- (void)copySize:(Mat*)mat;
|
||||
- (Mat*)cross:(Mat*)mat;
|
||||
- (unsigned char*)dataPtr NS_SWIFT_NAME(dataPointer());
|
||||
- (int)depth;
|
||||
- (Mat*)diag:(int)diagonal;
|
||||
- (Mat*)diag;
|
||||
|
||||
@@ -286,6 +286,10 @@ static bool updateIdx(cv::Mat* mat, std::vector<int>& indices, int inc) {
|
||||
return [[Mat alloc] initWithNativeMat:new cv::Mat(_nativePtr->cross(*(cv::Mat*)mat.nativePtr))];
|
||||
}
|
||||
|
||||
- (unsigned char*)dataPtr {
|
||||
return _nativePtr->data;
|
||||
}
|
||||
|
||||
- (int)depth {
|
||||
return _nativePtr->depth();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "opencv.hpp"
|
||||
#import "opencv2/core.hpp"
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
@@ -215,6 +215,13 @@
|
||||
"from_cpp": "[NSString stringWithUTF8String:%(n)s.c_str()]",
|
||||
"swift_type": "String"
|
||||
},
|
||||
"string": {
|
||||
"cast_to": "std::string",
|
||||
"objc_type": "NSString*",
|
||||
"to_cpp": "std::string(%(n)s.UTF8String)",
|
||||
"from_cpp": "[NSString stringWithUTF8String:%(n)s.c_str()]",
|
||||
"swift_type": "String"
|
||||
},
|
||||
"TermCriteria": {
|
||||
"objc_type": "TermCriteria*",
|
||||
"to_cpp": "%(n)s.nativeRef",
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
#include "precomp.hpp"
|
||||
#include "convert.hpp"
|
||||
|
||||
#if !defined(OPENCV_SUPRESS_WARNING_AVX2_WITHOUT_FP16C) && \
|
||||
(defined(__GNUC__) && defined(__AVX2__) && !defined(__F16C__))
|
||||
#warning "Non-optimal compiler flags: AVX2 without FP16. Generated code is very slow. Consider adding '-mf16c' compiler option."
|
||||
#endif
|
||||
|
||||
namespace cv {
|
||||
namespace hal {
|
||||
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
||||
|
||||
+238
-185
@@ -49,6 +49,7 @@
|
||||
#ifdef HAVE_DIRECTX
|
||||
#include <vector>
|
||||
#include "directx.inc.hpp"
|
||||
#include "directx.hpp"
|
||||
#else // HAVE_DIRECTX
|
||||
#define NO_DIRECTX_SUPPORT_ERROR CV_Error(cv::Error::StsBadFunc, "OpenCV was build without DirectX support")
|
||||
#endif
|
||||
@@ -234,11 +235,191 @@ int getTypeFromD3DFORMAT(const int iD3DFORMAT)
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace ocl {
|
||||
|
||||
#if defined(HAVE_DIRECTX) && defined(HAVE_OPENCL)
|
||||
static bool g_isDirect3DDevice9Ex = false; // Direct3DDevice9Ex or Direct3DDevice9 was used
|
||||
namespace internal {
|
||||
struct OpenCLDirectXImpl
|
||||
{
|
||||
cl_platform_id platform_;
|
||||
|
||||
cl_platform_id initializedPlatform9 = NULL;
|
||||
cl_platform_id initializedPlatform10 = NULL;
|
||||
cl_platform_id initializedPlatform11 = NULL;
|
||||
public:
|
||||
OpenCLDirectXImpl()
|
||||
: platform_(0)
|
||||
{
|
||||
}
|
||||
|
||||
bool isDirect3DDevice9Ex = false; // Direct3DDevice9Ex or Direct3DDevice9 was used
|
||||
|
||||
#ifdef HAVE_OPENCL_D3D11_NV
|
||||
clCreateFromD3D11Texture2DNV_fn clCreateFromD3D11Texture2DNV = NULL;
|
||||
clEnqueueAcquireD3D11ObjectsNV_fn clEnqueueAcquireD3D11ObjectsNV = NULL;
|
||||
clEnqueueReleaseD3D11ObjectsNV_fn clEnqueueReleaseD3D11ObjectsNV = NULL;
|
||||
#endif
|
||||
clCreateFromD3D11Texture2DKHR_fn clCreateFromD3D11Texture2DKHR = NULL;
|
||||
clEnqueueAcquireD3D11ObjectsKHR_fn clEnqueueAcquireD3D11ObjectsKHR = NULL;
|
||||
clEnqueueReleaseD3D11ObjectsKHR_fn clEnqueueReleaseD3D11ObjectsKHR = NULL;
|
||||
|
||||
clCreateFromD3D10Texture2DKHR_fn clCreateFromD3D10Texture2DKHR = NULL;
|
||||
clEnqueueAcquireD3D10ObjectsKHR_fn clEnqueueAcquireD3D10ObjectsKHR = NULL;
|
||||
clEnqueueReleaseD3D10ObjectsKHR_fn clEnqueueReleaseD3D10ObjectsKHR = NULL;
|
||||
|
||||
clCreateFromDX9MediaSurfaceKHR_fn clCreateFromDX9MediaSurfaceKHR = NULL;
|
||||
clEnqueueAcquireDX9MediaSurfacesKHR_fn clEnqueueAcquireDX9MediaSurfacesKHR = NULL;
|
||||
clEnqueueReleaseDX9MediaSurfacesKHR_fn clEnqueueReleaseDX9MediaSurfacesKHR = NULL;
|
||||
|
||||
cl_platform_id getPlatform()
|
||||
{
|
||||
if (!platform_)
|
||||
{
|
||||
CV_Assert(cv::ocl::haveOpenCL());
|
||||
|
||||
cl_device_id device = (cl_device_id)ocl::Device::getDefault().ptr();
|
||||
CV_Assert(device);
|
||||
cl_int status = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform_), &platform_, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't get platform corresponding to device");
|
||||
}
|
||||
|
||||
return platform_;
|
||||
}
|
||||
|
||||
|
||||
bool initializeD3D11()
|
||||
{
|
||||
using namespace cv::ocl;
|
||||
cl_platform_id platform = getPlatform();
|
||||
|
||||
bool useCLNVEXT = false;
|
||||
size_t exts_len;
|
||||
cl_int status = clGetPlatformInfo(platform, CL_PLATFORM_EXTENSIONS, 0, NULL, &exts_len);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't get length of CL_PLATFORM_EXTENSIONS");
|
||||
cv::AutoBuffer<char> extensions(exts_len);
|
||||
status = clGetPlatformInfo(platform, CL_PLATFORM_EXTENSIONS, exts_len, static_cast<void*>(extensions.data()), NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: No available CL_PLATFORM_EXTENSIONS");
|
||||
bool is_support_cl_khr_d3d11_sharing = false;
|
||||
if (strstr(extensions.data(), "cl_khr_d3d11_sharing"))
|
||||
is_support_cl_khr_d3d11_sharing = true;
|
||||
#ifdef HAVE_OPENCL_D3D11_NV
|
||||
bool is_support_cl_nv_d3d11_sharing = false;
|
||||
if (strstr(extensions.data(), "cl_nv_d3d11_sharing"))
|
||||
is_support_cl_nv_d3d11_sharing = true;
|
||||
if (!is_support_cl_nv_d3d11_sharing && !is_support_cl_khr_d3d11_sharing)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: No supported extensions");
|
||||
#else
|
||||
if (!is_support_cl_khr_d3d11_sharing)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: No supported extensions");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENCL_D3D11_NV
|
||||
if (is_support_cl_nv_d3d11_sharing)
|
||||
{
|
||||
if (initializedPlatform11 != platform)
|
||||
{
|
||||
clCreateFromD3D11Texture2DNV = (clCreateFromD3D11Texture2DNV_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clCreateFromD3D11Texture2DNV");
|
||||
clEnqueueAcquireD3D11ObjectsNV = (clEnqueueAcquireD3D11ObjectsNV_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueAcquireD3D11ObjectsNV");
|
||||
clEnqueueReleaseD3D11ObjectsNV = (clEnqueueReleaseD3D11ObjectsNV_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueReleaseD3D11ObjectsNV");
|
||||
initializedPlatform11 = platform;
|
||||
}
|
||||
if (clCreateFromD3D11Texture2DNV && clEnqueueAcquireD3D11ObjectsNV && clEnqueueReleaseD3D11ObjectsNV)
|
||||
{
|
||||
useCLNVEXT = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (is_support_cl_khr_d3d11_sharing)
|
||||
{
|
||||
if (initializedPlatform11 != platform)
|
||||
{
|
||||
clCreateFromD3D11Texture2DKHR = (clCreateFromD3D11Texture2DKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clCreateFromD3D11Texture2DKHR");
|
||||
clEnqueueAcquireD3D11ObjectsKHR = (clEnqueueAcquireD3D11ObjectsKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueAcquireD3D11ObjectsKHR");
|
||||
clEnqueueReleaseD3D11ObjectsKHR = (clEnqueueReleaseD3D11ObjectsKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueReleaseD3D11ObjectsKHR");
|
||||
initializedPlatform11 = platform;
|
||||
}
|
||||
if (!clCreateFromD3D11Texture2DKHR || !clEnqueueAcquireD3D11ObjectsKHR || !clEnqueueReleaseD3D11ObjectsKHR)
|
||||
{
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't find functions for D3D11");
|
||||
}
|
||||
}
|
||||
}
|
||||
return useCLNVEXT;
|
||||
}
|
||||
|
||||
void initializeD3D9()
|
||||
{
|
||||
using namespace cv::ocl;
|
||||
cl_platform_id platform = getPlatform();
|
||||
if (initializedPlatform9 != platform)
|
||||
{
|
||||
clCreateFromDX9MediaSurfaceKHR = (clCreateFromDX9MediaSurfaceKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clCreateFromDX9MediaSurfaceKHR");
|
||||
clEnqueueAcquireDX9MediaSurfacesKHR = (clEnqueueAcquireDX9MediaSurfacesKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueAcquireDX9MediaSurfacesKHR");
|
||||
clEnqueueReleaseDX9MediaSurfacesKHR = (clEnqueueReleaseDX9MediaSurfacesKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueReleaseDX9MediaSurfacesKHR");
|
||||
initializedPlatform9 = platform;
|
||||
}
|
||||
if (!clCreateFromDX9MediaSurfaceKHR || !clEnqueueAcquireDX9MediaSurfacesKHR || !clEnqueueReleaseDX9MediaSurfacesKHR)
|
||||
{
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't find functions for D3D9");
|
||||
}
|
||||
}
|
||||
|
||||
void initializeD3D10()
|
||||
{
|
||||
using namespace cv::ocl;
|
||||
cl_platform_id platform = getPlatform();
|
||||
if (initializedPlatform10 != platform)
|
||||
{
|
||||
clCreateFromD3D10Texture2DKHR = (clCreateFromD3D10Texture2DKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clCreateFromD3D10Texture2DKHR");
|
||||
clEnqueueAcquireD3D10ObjectsKHR = (clEnqueueAcquireD3D10ObjectsKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueAcquireD3D10ObjectsKHR");
|
||||
clEnqueueReleaseD3D10ObjectsKHR = (clEnqueueReleaseD3D10ObjectsKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueReleaseD3D10ObjectsKHR");
|
||||
initializedPlatform10 = platform;
|
||||
}
|
||||
if (!clCreateFromD3D10Texture2DKHR || !clEnqueueAcquireD3D10ObjectsKHR || !clEnqueueReleaseD3D10ObjectsKHR)
|
||||
{
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't find functions for D3D10");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
OpenCLDirectXImpl* createDirectXImpl()
|
||||
{
|
||||
return new OpenCLDirectXImpl();
|
||||
}
|
||||
void deleteDirectXImpl(OpenCLDirectXImpl** p)
|
||||
{
|
||||
if (*p)
|
||||
{
|
||||
delete (*p);
|
||||
*p = NULL;
|
||||
}
|
||||
}
|
||||
OpenCLDirectXImpl& getImpl()
|
||||
{
|
||||
OpenCLDirectXImpl* i = getDirectXImpl(ocl::Context::getDefault());
|
||||
CV_Assert(i);
|
||||
return *i;
|
||||
}
|
||||
}
|
||||
using namespace internal;
|
||||
#endif
|
||||
|
||||
namespace ocl {
|
||||
|
||||
Context& initializeContextFromD3D11Device(ID3D11Device* pD3D11Device)
|
||||
{
|
||||
@@ -715,7 +896,7 @@ Context& initializeContextFromDirect3DDevice9Ex(IDirect3DDevice9Ex* pDirect3DDev
|
||||
throw;
|
||||
}
|
||||
clExecCtx.bind();
|
||||
g_isDirect3DDevice9Ex = true;
|
||||
getImpl().isDirect3DDevice9Ex = true;
|
||||
return const_cast<Context&>(clExecCtx.getContext());
|
||||
#endif
|
||||
}
|
||||
@@ -838,96 +1019,13 @@ Context& initializeContextFromDirect3DDevice9(IDirect3DDevice9* pDirect3DDevice9
|
||||
throw;
|
||||
}
|
||||
clExecCtx.bind();
|
||||
g_isDirect3DDevice9Ex = false;
|
||||
getImpl().isDirect3DDevice9Ex = false;
|
||||
return const_cast<Context&>(clExecCtx.getContext());
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace cv::ocl
|
||||
|
||||
#if defined(HAVE_DIRECTX) && defined(HAVE_OPENCL)
|
||||
|
||||
#ifdef HAVE_OPENCL_D3D11_NV
|
||||
clCreateFromD3D11Texture2DNV_fn clCreateFromD3D11Texture2DNV = NULL;
|
||||
clEnqueueAcquireD3D11ObjectsNV_fn clEnqueueAcquireD3D11ObjectsNV = NULL;
|
||||
clEnqueueReleaseD3D11ObjectsNV_fn clEnqueueReleaseD3D11ObjectsNV = NULL;
|
||||
#endif
|
||||
clCreateFromD3D11Texture2DKHR_fn clCreateFromD3D11Texture2DKHR = NULL;
|
||||
clEnqueueAcquireD3D11ObjectsKHR_fn clEnqueueAcquireD3D11ObjectsKHR = NULL;
|
||||
clEnqueueReleaseD3D11ObjectsKHR_fn clEnqueueReleaseD3D11ObjectsKHR = NULL;
|
||||
|
||||
static bool __OpenCLinitializeD3D11()
|
||||
{
|
||||
using namespace cv::ocl;
|
||||
static cl_platform_id initializedPlatform = NULL;
|
||||
cl_platform_id platform = (cl_platform_id)Platform::getDefault().ptr();
|
||||
|
||||
bool useCLNVEXT = false;
|
||||
size_t exts_len;
|
||||
cl_int status = clGetPlatformInfo(platform, CL_PLATFORM_EXTENSIONS, 0, NULL, &exts_len);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't get length of CL_PLATFORM_EXTENSIONS");
|
||||
cv::AutoBuffer<char> extensions(exts_len);
|
||||
status = clGetPlatformInfo(platform, CL_PLATFORM_EXTENSIONS, exts_len, static_cast<void*>(extensions.data()), NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: No available CL_PLATFORM_EXTENSIONS");
|
||||
bool is_support_cl_khr_d3d11_sharing = false;
|
||||
if (strstr(extensions.data(), "cl_khr_d3d11_sharing"))
|
||||
is_support_cl_khr_d3d11_sharing = true;
|
||||
#ifdef HAVE_OPENCL_D3D11_NV
|
||||
bool is_support_cl_nv_d3d11_sharing = false;
|
||||
if (strstr(extensions.data(), "cl_nv_d3d11_sharing"))
|
||||
is_support_cl_nv_d3d11_sharing = true;
|
||||
if (!is_support_cl_nv_d3d11_sharing && !is_support_cl_khr_d3d11_sharing)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: No supported extensions");
|
||||
#else
|
||||
if (!is_support_cl_khr_d3d11_sharing)
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: No supported extensions");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENCL_D3D11_NV
|
||||
if (is_support_cl_nv_d3d11_sharing)
|
||||
{
|
||||
if (initializedPlatform != platform)
|
||||
{
|
||||
clCreateFromD3D11Texture2DNV = (clCreateFromD3D11Texture2DNV_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clCreateFromD3D11Texture2DNV");
|
||||
clEnqueueAcquireD3D11ObjectsNV = (clEnqueueAcquireD3D11ObjectsNV_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueAcquireD3D11ObjectsNV");
|
||||
clEnqueueReleaseD3D11ObjectsNV = (clEnqueueReleaseD3D11ObjectsNV_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueReleaseD3D11ObjectsNV");
|
||||
initializedPlatform = platform;
|
||||
}
|
||||
if (clCreateFromD3D11Texture2DNV && clEnqueueAcquireD3D11ObjectsNV && clEnqueueReleaseD3D11ObjectsNV)
|
||||
{
|
||||
useCLNVEXT = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (is_support_cl_khr_d3d11_sharing)
|
||||
{
|
||||
if (initializedPlatform != platform)
|
||||
{
|
||||
clCreateFromD3D11Texture2DKHR = (clCreateFromD3D11Texture2DKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clCreateFromD3D11Texture2DKHR");
|
||||
clEnqueueAcquireD3D11ObjectsKHR = (clEnqueueAcquireD3D11ObjectsKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueAcquireD3D11ObjectsKHR");
|
||||
clEnqueueReleaseD3D11ObjectsKHR = (clEnqueueReleaseD3D11ObjectsKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueReleaseD3D11ObjectsKHR");
|
||||
initializedPlatform = platform;
|
||||
}
|
||||
if (!clCreateFromD3D11Texture2DKHR || !clEnqueueAcquireD3D11ObjectsKHR || !clEnqueueReleaseD3D11ObjectsKHR)
|
||||
{
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't find functions for D3D11");
|
||||
}
|
||||
}
|
||||
}
|
||||
return useCLNVEXT;
|
||||
}
|
||||
#endif // defined(HAVE_DIRECTX) && defined(HAVE_OPENCL)
|
||||
|
||||
} // namespace directx
|
||||
|
||||
|
||||
@@ -1009,20 +1107,21 @@ static void __convertToD3D11Texture2DKHR(InputArray src, ID3D11Texture2D* pD3D11
|
||||
using namespace cv::ocl;
|
||||
Context& ctx = Context::getDefault();
|
||||
cl_context context = (cl_context)ctx.ptr();
|
||||
OpenCLDirectXImpl& impl = getImpl();
|
||||
|
||||
cl_int status = 0;
|
||||
cl_mem clImage = 0;
|
||||
#ifdef HAVE_DIRECTX_NV12
|
||||
cl_mem clImageUV = 0;
|
||||
#endif
|
||||
clImage = clCreateFromD3D11Texture2DKHR(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
|
||||
clImage = impl.clCreateFromD3D11Texture2DKHR(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromD3D11Texture2DKHR failed");
|
||||
|
||||
#ifdef HAVE_DIRECTX_NV12
|
||||
if(DXGI_FORMAT_NV12 == desc.Format)
|
||||
{
|
||||
clImageUV = clCreateFromD3D11Texture2DKHR(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 1, &status);
|
||||
clImageUV = impl.clCreateFromD3D11Texture2DKHR(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 1, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromD3D11Texture2DKHR failed");
|
||||
}
|
||||
@@ -1030,21 +1129,21 @@ static void __convertToD3D11Texture2DKHR(InputArray src, ID3D11Texture2D* pD3D11
|
||||
|
||||
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
|
||||
|
||||
status = clEnqueueAcquireD3D11ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueAcquireD3D11ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D11ObjectsKHR failed");
|
||||
|
||||
#ifdef HAVE_DIRECTX_NV12
|
||||
if(DXGI_FORMAT_NV12 == desc.Format)
|
||||
{
|
||||
status = clEnqueueAcquireD3D11ObjectsKHR(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
status = impl.clEnqueueAcquireD3D11ObjectsKHR(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D11ObjectsKHR failed");
|
||||
|
||||
if(!ocl::ocl_convert_bgr_to_nv12(clBuffer, (int)u.step[0], u.cols, u.rows, clImage, clImageUV))
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: ocl_convert_bgr_to_nv12 failed");
|
||||
|
||||
status = clEnqueueReleaseD3D11ObjectsKHR(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
status = impl.clEnqueueReleaseD3D11ObjectsKHR(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseD3D11ObjectsKHR failed");
|
||||
}
|
||||
@@ -1060,7 +1159,7 @@ static void __convertToD3D11Texture2DKHR(InputArray src, ID3D11Texture2D* pD3D11
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyBufferToImage failed");
|
||||
}
|
||||
|
||||
status = clEnqueueReleaseD3D11ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueReleaseD3D11ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseD3D11ObjectsKHR failed");
|
||||
|
||||
@@ -1107,40 +1206,41 @@ static void __convertToD3D11Texture2DNV(InputArray src, ID3D11Texture2D* pD3D11T
|
||||
using namespace cv::ocl;
|
||||
Context& ctx = Context::getDefault();
|
||||
cl_context context = (cl_context)ctx.ptr();
|
||||
OpenCLDirectXImpl& impl = getImpl();
|
||||
|
||||
cl_int status = 0;
|
||||
cl_mem clImage = 0;
|
||||
#ifdef HAVE_DIRECTX_NV12
|
||||
cl_mem clImageUV = 0;
|
||||
#endif
|
||||
clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
|
||||
clImage = impl.clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromD3D11Texture2DNV failed");
|
||||
|
||||
#ifdef HAVE_DIRECTX_NV12
|
||||
if (DXGI_FORMAT_NV12 == desc.Format)
|
||||
{
|
||||
clImageUV = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 1, &status);
|
||||
clImageUV = impl.clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 1, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromD3D11Texture2DNV failed");
|
||||
}
|
||||
#endif
|
||||
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
|
||||
status = clEnqueueAcquireD3D11ObjectsNV(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueAcquireD3D11ObjectsNV(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D11ObjectsNV failed");
|
||||
|
||||
#ifdef HAVE_DIRECTX_NV12
|
||||
if(DXGI_FORMAT_NV12 == desc.Format)
|
||||
{
|
||||
status = clEnqueueAcquireD3D11ObjectsNV(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
status = impl.clEnqueueAcquireD3D11ObjectsNV(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D11ObjectsNV failed");
|
||||
|
||||
if(!ocl::ocl_convert_bgr_to_nv12(clBuffer, (int)u.step[0], u.cols, u.rows, clImage, clImageUV))
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: ocl_convert_bgr_to_nv12 failed");
|
||||
|
||||
status = clEnqueueReleaseD3D11ObjectsNV(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
status = impl.clEnqueueReleaseD3D11ObjectsNV(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseD3D11ObjectsNV failed");
|
||||
}
|
||||
@@ -1156,7 +1256,7 @@ static void __convertToD3D11Texture2DNV(InputArray src, ID3D11Texture2D* pD3D11T
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyBufferToImage failed");
|
||||
}
|
||||
|
||||
status = clEnqueueReleaseD3D11ObjectsNV(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueReleaseD3D11ObjectsNV(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseD3D11ObjectsNV failed");
|
||||
|
||||
@@ -1201,11 +1301,12 @@ static void __convertFromD3D11Texture2DKHR(ID3D11Texture2D* pD3D11Texture2D, Out
|
||||
using namespace cv::ocl;
|
||||
Context& ctx = Context::getDefault();
|
||||
cl_context context = (cl_context)ctx.ptr();
|
||||
OpenCLDirectXImpl& impl = getImpl();
|
||||
|
||||
cl_int status = 0;
|
||||
cl_mem clImage = 0;
|
||||
|
||||
clImage = clCreateFromD3D11Texture2DKHR(context, CL_MEM_READ_ONLY, pD3D11Texture2D, 0, &status);
|
||||
clImage = impl.clCreateFromD3D11Texture2DKHR(context, CL_MEM_READ_ONLY, pD3D11Texture2D, 0, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromD3D11Texture2DKHR failed");
|
||||
|
||||
@@ -1213,7 +1314,7 @@ static void __convertFromD3D11Texture2DKHR(ID3D11Texture2D* pD3D11Texture2D, Out
|
||||
cl_mem clImageUV = 0;
|
||||
if(DXGI_FORMAT_NV12 == desc.Format)
|
||||
{
|
||||
clImageUV = clCreateFromD3D11Texture2DKHR(context, CL_MEM_READ_ONLY, pD3D11Texture2D, 1, &status);
|
||||
clImageUV = impl.clCreateFromD3D11Texture2DKHR(context, CL_MEM_READ_ONLY, pD3D11Texture2D, 1, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromD3D11Texture2DKHR failed");
|
||||
}
|
||||
@@ -1221,21 +1322,21 @@ static void __convertFromD3D11Texture2DKHR(ID3D11Texture2D* pD3D11Texture2D, Out
|
||||
|
||||
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
|
||||
|
||||
status = clEnqueueAcquireD3D11ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueAcquireD3D11ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D11ObjectsKHR failed");
|
||||
|
||||
#ifdef HAVE_DIRECTX_NV12
|
||||
if(DXGI_FORMAT_NV12 == desc.Format)
|
||||
{
|
||||
status = clEnqueueAcquireD3D11ObjectsKHR(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
status = impl.clEnqueueAcquireD3D11ObjectsKHR(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D11ObjectsKHR failed");
|
||||
|
||||
if(!ocl::ocl_convert_nv12_to_bgr(clImage, clImageUV, clBuffer, (int)u.step[0], u.cols, u.rows))
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: ocl_convert_nv12_to_bgr failed");
|
||||
|
||||
status = clEnqueueReleaseD3D11ObjectsKHR(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
status = impl.clEnqueueReleaseD3D11ObjectsKHR(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseD3D11ObjectsKHR failed");
|
||||
}
|
||||
@@ -1251,7 +1352,7 @@ static void __convertFromD3D11Texture2DKHR(ID3D11Texture2D* pD3D11Texture2D, Out
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyImageToBuffer failed");
|
||||
}
|
||||
|
||||
status = clEnqueueReleaseD3D11ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueReleaseD3D11ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseD3D11ObjectsKHR failed");
|
||||
|
||||
@@ -1296,11 +1397,12 @@ static void __convertFromD3D11Texture2DNV(ID3D11Texture2D* pD3D11Texture2D, Outp
|
||||
using namespace cv::ocl;
|
||||
Context& ctx = Context::getDefault();
|
||||
cl_context context = (cl_context)ctx.ptr();
|
||||
OpenCLDirectXImpl& impl = getImpl();
|
||||
|
||||
cl_int status = 0;
|
||||
cl_mem clImage = 0;
|
||||
|
||||
clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_READ_ONLY, pD3D11Texture2D, 0, &status);
|
||||
clImage = impl.clCreateFromD3D11Texture2DNV(context, CL_MEM_READ_ONLY, pD3D11Texture2D, 0, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromD3D11Texture2DNV failed");
|
||||
|
||||
@@ -1308,28 +1410,28 @@ static void __convertFromD3D11Texture2DNV(ID3D11Texture2D* pD3D11Texture2D, Outp
|
||||
cl_mem clImageUV = 0;
|
||||
if(DXGI_FORMAT_NV12 == desc.Format)
|
||||
{
|
||||
clImageUV = clCreateFromD3D11Texture2DNV(context, CL_MEM_READ_ONLY, pD3D11Texture2D, 1, &status);
|
||||
clImageUV = impl.clCreateFromD3D11Texture2DNV(context, CL_MEM_READ_ONLY, pD3D11Texture2D, 1, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromD3D11Texture2DNV failed");
|
||||
}
|
||||
#endif
|
||||
|
||||
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
|
||||
status = clEnqueueAcquireD3D11ObjectsNV(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueAcquireD3D11ObjectsNV(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D11ObjectsNV failed");
|
||||
|
||||
#ifdef HAVE_DIRECTX_NV12
|
||||
if (DXGI_FORMAT::DXGI_FORMAT_NV12 == desc.Format)
|
||||
{
|
||||
status = clEnqueueAcquireD3D11ObjectsNV(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
status = impl.clEnqueueAcquireD3D11ObjectsNV(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D11ObjectsNV failed");
|
||||
|
||||
if (!ocl::ocl_convert_nv12_to_bgr(clImage, clImageUV, clBuffer, (int)u.step[0], u.cols, u.rows))
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: ocl_convert_nv12_to_bgr failed");
|
||||
|
||||
status = clEnqueueReleaseD3D11ObjectsNV(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
status = impl.clEnqueueReleaseD3D11ObjectsNV(q, 1, &clImageUV, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseD3D11ObjectsNV failed");
|
||||
}
|
||||
@@ -1345,7 +1447,7 @@ static void __convertFromD3D11Texture2DNV(ID3D11Texture2D* pD3D11Texture2D, Outp
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyImageToBuffer failed");
|
||||
}
|
||||
|
||||
status = clEnqueueReleaseD3D11ObjectsNV(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueReleaseD3D11ObjectsNV(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseD3D11ObjectsNV failed");
|
||||
|
||||
@@ -1377,7 +1479,7 @@ void convertToD3D11Texture2D(InputArray src, ID3D11Texture2D* pD3D11Texture2D)
|
||||
NO_OPENCL_SUPPORT_ERROR;
|
||||
#else
|
||||
|
||||
bool useCLNVEXT = __OpenCLinitializeD3D11();
|
||||
bool useCLNVEXT = getImpl().initializeD3D11();
|
||||
if(!useCLNVEXT){
|
||||
__convertToD3D11Texture2DKHR(src,pD3D11Texture2D);
|
||||
}
|
||||
@@ -1399,7 +1501,7 @@ void convertFromD3D11Texture2D(ID3D11Texture2D* pD3D11Texture2D, OutputArray dst
|
||||
NO_OPENCL_SUPPORT_ERROR;
|
||||
#else
|
||||
|
||||
bool useCLNVEXT = __OpenCLinitializeD3D11();
|
||||
bool useCLNVEXT = getImpl().initializeD3D11();
|
||||
if(!useCLNVEXT){
|
||||
__convertFromD3D11Texture2DKHR(pD3D11Texture2D,dst);
|
||||
}
|
||||
@@ -1412,40 +1514,14 @@ void convertFromD3D11Texture2D(ID3D11Texture2D* pD3D11Texture2D, OutputArray dst
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(HAVE_DIRECTX) && defined(HAVE_OPENCL)
|
||||
clCreateFromD3D10Texture2DKHR_fn clCreateFromD3D10Texture2DKHR = NULL;
|
||||
clEnqueueAcquireD3D10ObjectsKHR_fn clEnqueueAcquireD3D10ObjectsKHR = NULL;
|
||||
clEnqueueReleaseD3D10ObjectsKHR_fn clEnqueueReleaseD3D10ObjectsKHR = NULL;
|
||||
|
||||
static void __OpenCLinitializeD3D10()
|
||||
{
|
||||
using namespace cv::ocl;
|
||||
static cl_platform_id initializedPlatform = NULL;
|
||||
cl_platform_id platform = (cl_platform_id)Platform::getDefault().ptr();
|
||||
if (initializedPlatform != platform)
|
||||
{
|
||||
clCreateFromD3D10Texture2DKHR = (clCreateFromD3D10Texture2DKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clCreateFromD3D10Texture2DKHR");
|
||||
clEnqueueAcquireD3D10ObjectsKHR = (clEnqueueAcquireD3D10ObjectsKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueAcquireD3D10ObjectsKHR");
|
||||
clEnqueueReleaseD3D10ObjectsKHR = (clEnqueueReleaseD3D10ObjectsKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueReleaseD3D10ObjectsKHR");
|
||||
initializedPlatform = platform;
|
||||
}
|
||||
if (!clCreateFromD3D10Texture2DKHR || !clEnqueueAcquireD3D10ObjectsKHR || !clEnqueueReleaseD3D10ObjectsKHR)
|
||||
{
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't find functions for D3D10");
|
||||
}
|
||||
}
|
||||
#endif // defined(HAVE_DIRECTX) && defined(HAVE_OPENCL)
|
||||
|
||||
void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D)
|
||||
{
|
||||
CV_UNUSED(src); CV_UNUSED(pD3D10Texture2D);
|
||||
#if !defined(HAVE_DIRECTX)
|
||||
NO_DIRECTX_SUPPORT_ERROR;
|
||||
#elif defined(HAVE_OPENCL)
|
||||
__OpenCLinitializeD3D10();
|
||||
OpenCLDirectXImpl& impl = getImpl();
|
||||
impl.initializeD3D10();
|
||||
|
||||
D3D10_TEXTURE2D_DESC desc = { 0 };
|
||||
pD3D10Texture2D->GetDesc(&desc);
|
||||
@@ -1468,14 +1544,14 @@ void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D)
|
||||
CV_Assert(u.isContinuous());
|
||||
|
||||
cl_int status = 0;
|
||||
cl_mem clImage = clCreateFromD3D10Texture2DKHR(context, CL_MEM_WRITE_ONLY, pD3D10Texture2D, 0, &status);
|
||||
cl_mem clImage = impl.clCreateFromD3D10Texture2DKHR(context, CL_MEM_WRITE_ONLY, pD3D10Texture2D, 0, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromD3D10Texture2DKHR failed");
|
||||
|
||||
cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ);
|
||||
|
||||
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
|
||||
status = clEnqueueAcquireD3D10ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueAcquireD3D10ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D10ObjectsKHR failed");
|
||||
size_t offset = 0; // TODO
|
||||
@@ -1484,7 +1560,7 @@ void convertToD3D10Texture2D(InputArray src, ID3D10Texture2D* pD3D10Texture2D)
|
||||
status = clEnqueueCopyBufferToImage(q, clBuffer, clImage, offset, dst_origin, region, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyBufferToImage failed");
|
||||
status = clEnqueueReleaseD3D10ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueReleaseD3D10ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseD3D10ObjectsKHR failed");
|
||||
|
||||
@@ -1506,7 +1582,8 @@ void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst
|
||||
#if !defined(HAVE_DIRECTX)
|
||||
NO_DIRECTX_SUPPORT_ERROR;
|
||||
#elif defined(HAVE_OPENCL)
|
||||
__OpenCLinitializeD3D10();
|
||||
OpenCLDirectXImpl& impl = getImpl();
|
||||
impl.initializeD3D10();
|
||||
|
||||
D3D10_TEXTURE2D_DESC desc = { 0 };
|
||||
pD3D10Texture2D->GetDesc(&desc);
|
||||
@@ -1527,14 +1604,14 @@ void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst
|
||||
CV_Assert(u.isContinuous());
|
||||
|
||||
cl_int status = 0;
|
||||
cl_mem clImage = clCreateFromD3D10Texture2DKHR(context, CL_MEM_READ_ONLY, pD3D10Texture2D, 0, &status);
|
||||
cl_mem clImage = impl.clCreateFromD3D10Texture2DKHR(context, CL_MEM_READ_ONLY, pD3D10Texture2D, 0, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromD3D10Texture2DKHR failed");
|
||||
|
||||
cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ);
|
||||
|
||||
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
|
||||
status = clEnqueueAcquireD3D10ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueAcquireD3D10ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireD3D10ObjectsKHR failed");
|
||||
size_t offset = 0; // TODO
|
||||
@@ -1543,7 +1620,7 @@ void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst
|
||||
status = clEnqueueCopyImageToBuffer(q, clImage, clBuffer, src_origin, region, offset, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyImageToBuffer failed");
|
||||
status = clEnqueueReleaseD3D10ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueReleaseD3D10ObjectsKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseD3D10ObjectsKHR failed");
|
||||
|
||||
@@ -1560,32 +1637,6 @@ void convertFromD3D10Texture2D(ID3D10Texture2D* pD3D10Texture2D, OutputArray dst
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(HAVE_DIRECTX) && defined(HAVE_OPENCL)
|
||||
clCreateFromDX9MediaSurfaceKHR_fn clCreateFromDX9MediaSurfaceKHR = NULL;
|
||||
clEnqueueAcquireDX9MediaSurfacesKHR_fn clEnqueueAcquireDX9MediaSurfacesKHR = NULL;
|
||||
clEnqueueReleaseDX9MediaSurfacesKHR_fn clEnqueueReleaseDX9MediaSurfacesKHR = NULL;
|
||||
|
||||
static void __OpenCLinitializeD3D9()
|
||||
{
|
||||
using namespace cv::ocl;
|
||||
static cl_platform_id initializedPlatform = NULL;
|
||||
cl_platform_id platform = (cl_platform_id)Platform::getDefault().ptr();
|
||||
if (initializedPlatform != platform)
|
||||
{
|
||||
clCreateFromDX9MediaSurfaceKHR = (clCreateFromDX9MediaSurfaceKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clCreateFromDX9MediaSurfaceKHR");
|
||||
clEnqueueAcquireDX9MediaSurfacesKHR = (clEnqueueAcquireDX9MediaSurfacesKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueAcquireDX9MediaSurfacesKHR");
|
||||
clEnqueueReleaseDX9MediaSurfacesKHR = (clEnqueueReleaseDX9MediaSurfacesKHR_fn)
|
||||
clGetExtensionFunctionAddressForPlatform(platform, "clEnqueueReleaseDX9MediaSurfacesKHR");
|
||||
initializedPlatform = platform;
|
||||
}
|
||||
if (!clCreateFromDX9MediaSurfaceKHR || !clEnqueueAcquireDX9MediaSurfacesKHR || !clEnqueueReleaseDX9MediaSurfacesKHR)
|
||||
{
|
||||
CV_Error(cv::Error::OpenCLInitError, "OpenCL: Can't find functions for D3D9");
|
||||
}
|
||||
}
|
||||
#endif // defined(HAVE_DIRECTX) && defined(HAVE_OPENCL)
|
||||
|
||||
void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurface9, void* surfaceSharedHandle)
|
||||
{
|
||||
@@ -1593,7 +1644,8 @@ void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurfa
|
||||
#if !defined(HAVE_DIRECTX)
|
||||
NO_DIRECTX_SUPPORT_ERROR;
|
||||
#elif defined(HAVE_OPENCL)
|
||||
__OpenCLinitializeD3D9();
|
||||
OpenCLDirectXImpl& impl = getImpl();
|
||||
impl.initializeD3D9();
|
||||
|
||||
D3DSURFACE_DESC desc;
|
||||
if (FAILED(pDirect3DSurface9->GetDesc(&desc)))
|
||||
@@ -1620,8 +1672,8 @@ void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurfa
|
||||
|
||||
cl_int status = 0;
|
||||
cl_dx9_surface_info_khr surfaceInfo = {pDirect3DSurface9, (HANDLE)surfaceSharedHandle};
|
||||
cl_mem clImage = clCreateFromDX9MediaSurfaceKHR(context, CL_MEM_WRITE_ONLY,
|
||||
ocl::g_isDirect3DDevice9Ex ? CL_ADAPTER_D3D9EX_KHR : CL_ADAPTER_D3D9_KHR,
|
||||
cl_mem clImage = impl.clCreateFromDX9MediaSurfaceKHR(context, CL_MEM_WRITE_ONLY,
|
||||
impl.isDirect3DDevice9Ex ? CL_ADAPTER_D3D9EX_KHR : CL_ADAPTER_D3D9_KHR,
|
||||
&surfaceInfo, 0, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromDX9MediaSurfaceKHR failed");
|
||||
@@ -1629,7 +1681,7 @@ void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurfa
|
||||
cl_mem clBuffer = (cl_mem)u.handle(ACCESS_READ);
|
||||
|
||||
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
|
||||
status = clEnqueueAcquireDX9MediaSurfacesKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueAcquireDX9MediaSurfacesKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireDX9MediaSurfacesKHR failed");
|
||||
size_t offset = 0; // TODO
|
||||
@@ -1638,7 +1690,7 @@ void convertToDirect3DSurface9(InputArray src, IDirect3DSurface9* pDirect3DSurfa
|
||||
status = clEnqueueCopyBufferToImage(q, clBuffer, clImage, offset, dst_origin, region, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyBufferToImage failed");
|
||||
status = clEnqueueReleaseDX9MediaSurfacesKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueReleaseDX9MediaSurfacesKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseDX9MediaSurfacesKHR failed");
|
||||
|
||||
@@ -1661,7 +1713,8 @@ void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArr
|
||||
#if !defined(HAVE_DIRECTX)
|
||||
NO_DIRECTX_SUPPORT_ERROR;
|
||||
#elif defined(HAVE_OPENCL)
|
||||
__OpenCLinitializeD3D9();
|
||||
OpenCLDirectXImpl& impl = getImpl();
|
||||
impl.initializeD3D9();
|
||||
|
||||
D3DSURFACE_DESC desc;
|
||||
if (FAILED(pDirect3DSurface9->GetDesc(&desc)))
|
||||
@@ -1686,8 +1739,8 @@ void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArr
|
||||
|
||||
cl_int status = 0;
|
||||
cl_dx9_surface_info_khr surfaceInfo = {pDirect3DSurface9, (HANDLE)surfaceSharedHandle};
|
||||
cl_mem clImage = clCreateFromDX9MediaSurfaceKHR(context, CL_MEM_READ_ONLY,
|
||||
ocl::g_isDirect3DDevice9Ex ? CL_ADAPTER_D3D9EX_KHR : CL_ADAPTER_D3D9_KHR,
|
||||
cl_mem clImage = impl.clCreateFromDX9MediaSurfaceKHR(context, CL_MEM_READ_ONLY,
|
||||
impl.isDirect3DDevice9Ex ? CL_ADAPTER_D3D9EX_KHR : CL_ADAPTER_D3D9_KHR,
|
||||
&surfaceInfo, 0, &status);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clCreateFromDX9MediaSurfaceKHR failed");
|
||||
@@ -1695,7 +1748,7 @@ void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArr
|
||||
cl_mem clBuffer = (cl_mem)u.handle(ACCESS_WRITE);
|
||||
|
||||
cl_command_queue q = (cl_command_queue)Queue::getDefault().ptr();
|
||||
status = clEnqueueAcquireDX9MediaSurfacesKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueAcquireDX9MediaSurfacesKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueAcquireDX9MediaSurfacesKHR failed");
|
||||
size_t offset = 0; // TODO
|
||||
@@ -1704,7 +1757,7 @@ void convertFromDirect3DSurface9(IDirect3DSurface9* pDirect3DSurface9, OutputArr
|
||||
status = clEnqueueCopyImageToBuffer(q, clImage, clBuffer, src_origin, region, offset, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueCopyImageToBuffer failed");
|
||||
status = clEnqueueReleaseDX9MediaSurfacesKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
status = impl.clEnqueueReleaseDX9MediaSurfacesKHR(q, 1, &clImage, 0, NULL, NULL);
|
||||
if (status != CL_SUCCESS)
|
||||
CV_Error(cv::Error::OpenCLApiCallError, "OpenCL: clEnqueueReleaseDX9MediaSurfacesKHR failed");
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// 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_CORE_SRC_DIRECTX_HPP
|
||||
#define OPENCV_CORE_SRC_DIRECTX_HPP
|
||||
|
||||
#ifndef HAVE_DIRECTX
|
||||
#error Invalid build configuration
|
||||
#endif
|
||||
|
||||
namespace cv {
|
||||
namespace directx {
|
||||
namespace internal {
|
||||
|
||||
struct OpenCLDirectXImpl;
|
||||
OpenCLDirectXImpl* createDirectXImpl();
|
||||
void deleteDirectXImpl(OpenCLDirectXImpl**);
|
||||
OpenCLDirectXImpl* getDirectXImpl(ocl::Context& ctx);
|
||||
|
||||
}}} // namespace internal
|
||||
|
||||
#endif // OPENCV_CORE_SRC_DIRECTX_HPP
|
||||
+280
-109
@@ -122,6 +122,33 @@ static const double DFTTab[][2] =
|
||||
{ 1.00000000000000000, 0.00000000292583616 }
|
||||
};
|
||||
|
||||
namespace {
|
||||
template <typename T>
|
||||
struct Constants {
|
||||
static const T sin_120;
|
||||
static const T fft5_2;
|
||||
static const T fft5_3;
|
||||
static const T fft5_4;
|
||||
static const T fft5_5;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
const T Constants<T>::sin_120 = (T)0.86602540378443864676372317075294;
|
||||
|
||||
template <typename T>
|
||||
const T Constants<T>::fft5_2 = (T)0.559016994374947424102293417182819;
|
||||
|
||||
template <typename T>
|
||||
const T Constants<T>::fft5_3 = (T)-0.951056516295153572116439333379382;
|
||||
|
||||
template <typename T>
|
||||
const T Constants<T>::fft5_4 = (T)-1.538841768587626701285145288018455;
|
||||
|
||||
template <typename T>
|
||||
const T Constants<T>::fft5_5 = (T)0.363271264002680442947733378740309;
|
||||
|
||||
} //namespace
|
||||
|
||||
#define BitRev(i,shift) \
|
||||
((int)((((unsigned)bitrevTab[(i)&255] << 24)+ \
|
||||
((unsigned)bitrevTab[((i)>> 8)&255] << 16)+ \
|
||||
@@ -372,6 +399,149 @@ DFTInit( int n0, int nf, const int* factors, int* itab, int elem_size, void* _wa
|
||||
}
|
||||
}
|
||||
|
||||
// Reference radix-2 implementation.
|
||||
template<typename T> struct DFT_R2
|
||||
{
|
||||
void operator()(Complex<T>* dst, const int c_n, const int n, const int dw0, const Complex<T>* wave) const {
|
||||
const int nx = n/2;
|
||||
for(int i = 0 ; i < c_n; i += n)
|
||||
{
|
||||
Complex<T>* v = dst + i;
|
||||
T r0 = v[0].re + v[nx].re;
|
||||
T i0 = v[0].im + v[nx].im;
|
||||
T r1 = v[0].re - v[nx].re;
|
||||
T i1 = v[0].im - v[nx].im;
|
||||
v[0].re = r0; v[0].im = i0;
|
||||
v[nx].re = r1; v[nx].im = i1;
|
||||
|
||||
for( int j = 1, dw = dw0; j < nx; j++, dw += dw0 )
|
||||
{
|
||||
v = dst + i + j;
|
||||
r1 = v[nx].re*wave[dw].re - v[nx].im*wave[dw].im;
|
||||
i1 = v[nx].im*wave[dw].re + v[nx].re*wave[dw].im;
|
||||
r0 = v[0].re; i0 = v[0].im;
|
||||
|
||||
v[0].re = r0 + r1; v[0].im = i0 + i1;
|
||||
v[nx].re = r0 - r1; v[nx].im = i0 - i1;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Reference radix-3 implementation.
|
||||
template<typename T> struct DFT_R3
|
||||
{
|
||||
void operator()(Complex<T>* dst, const int c_n, const int n, const int dw0, const Complex<T>* wave) const {
|
||||
const int nx = n / 3;
|
||||
for(int i = 0; i < c_n; i += n )
|
||||
{
|
||||
{
|
||||
Complex<T>* v = dst + i;
|
||||
T r1 = v[nx].re + v[nx*2].re;
|
||||
T i1 = v[nx].im + v[nx*2].im;
|
||||
T r0 = v[0].re;
|
||||
T i0 = v[0].im;
|
||||
T r2 = Constants<T>::sin_120*(v[nx].im - v[nx*2].im);
|
||||
T i2 = Constants<T>::sin_120*(v[nx*2].re - v[nx].re);
|
||||
v[0].re = r0 + r1; v[0].im = i0 + i1;
|
||||
r0 -= (T)0.5*r1; i0 -= (T)0.5*i1;
|
||||
v[nx].re = r0 + r2; v[nx].im = i0 + i2;
|
||||
v[nx*2].re = r0 - r2; v[nx*2].im = i0 - i2;
|
||||
}
|
||||
|
||||
for(int j = 1, dw = dw0; j < nx; j++, dw += dw0 )
|
||||
{
|
||||
Complex<T>* v = dst + i + j;
|
||||
T r0 = v[nx].re*wave[dw].re - v[nx].im*wave[dw].im;
|
||||
T i0 = v[nx].re*wave[dw].im + v[nx].im*wave[dw].re;
|
||||
T i2 = v[nx*2].re*wave[dw*2].re - v[nx*2].im*wave[dw*2].im;
|
||||
T r2 = v[nx*2].re*wave[dw*2].im + v[nx*2].im*wave[dw*2].re;
|
||||
T r1 = r0 + i2; T i1 = i0 + r2;
|
||||
|
||||
r2 = Constants<T>::sin_120*(i0 - r2); i2 = Constants<T>::sin_120*(i2 - r0);
|
||||
r0 = v[0].re; i0 = v[0].im;
|
||||
v[0].re = r0 + r1; v[0].im = i0 + i1;
|
||||
r0 -= (T)0.5*r1; i0 -= (T)0.5*i1;
|
||||
v[nx].re = r0 + r2; v[nx].im = i0 + i2;
|
||||
v[nx*2].re = r0 - r2; v[nx*2].im = i0 - i2;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Reference radix-5 implementation.
|
||||
template<typename T> struct DFT_R5
|
||||
{
|
||||
void operator()(Complex<T>* dst, const int c_n, const int n, const int dw0, const Complex<T>* wave) const {
|
||||
const int nx = n / 5;
|
||||
for(int i = 0; i < c_n; i += n )
|
||||
{
|
||||
for(int j = 0, dw = 0; j < nx; j++, dw += dw0 )
|
||||
{
|
||||
Complex<T>* v0 = dst + i + j;
|
||||
Complex<T>* v1 = v0 + nx*2;
|
||||
Complex<T>* v2 = v1 + nx*2;
|
||||
|
||||
T r0, i0, r1, i1, r2, i2, r3, i3, r4, i4, r5, i5;
|
||||
|
||||
r3 = v0[nx].re*wave[dw].re - v0[nx].im*wave[dw].im;
|
||||
i3 = v0[nx].re*wave[dw].im + v0[nx].im*wave[dw].re;
|
||||
r2 = v2[0].re*wave[dw*4].re - v2[0].im*wave[dw*4].im;
|
||||
i2 = v2[0].re*wave[dw*4].im + v2[0].im*wave[dw*4].re;
|
||||
|
||||
r1 = r3 + r2; i1 = i3 + i2;
|
||||
r3 -= r2; i3 -= i2;
|
||||
|
||||
r4 = v1[nx].re*wave[dw*3].re - v1[nx].im*wave[dw*3].im;
|
||||
i4 = v1[nx].re*wave[dw*3].im + v1[nx].im*wave[dw*3].re;
|
||||
r0 = v1[0].re*wave[dw*2].re - v1[0].im*wave[dw*2].im;
|
||||
i0 = v1[0].re*wave[dw*2].im + v1[0].im*wave[dw*2].re;
|
||||
|
||||
r2 = r4 + r0; i2 = i4 + i0;
|
||||
r4 -= r0; i4 -= i0;
|
||||
|
||||
r0 = v0[0].re; i0 = v0[0].im;
|
||||
r5 = r1 + r2; i5 = i1 + i2;
|
||||
|
||||
v0[0].re = r0 + r5; v0[0].im = i0 + i5;
|
||||
|
||||
r0 -= (T)0.25*r5; i0 -= (T)0.25*i5;
|
||||
r1 = Constants<T>::fft5_2*(r1 - r2); i1 = Constants<T>::fft5_2*(i1 - i2);
|
||||
r2 = -Constants<T>::fft5_3*(i3 + i4); i2 = Constants<T>::fft5_3*(r3 + r4);
|
||||
|
||||
i3 *= -Constants<T>::fft5_5; r3 *= Constants<T>::fft5_5;
|
||||
i4 *= -Constants<T>::fft5_4; r4 *= Constants<T>::fft5_4;
|
||||
|
||||
r5 = r2 + i3; i5 = i2 + r3;
|
||||
r2 -= i4; i2 -= r4;
|
||||
|
||||
r3 = r0 + r1; i3 = i0 + i1;
|
||||
r0 -= r1; i0 -= i1;
|
||||
|
||||
v0[nx].re = r3 + r2; v0[nx].im = i3 + i2;
|
||||
v2[0].re = r3 - r2; v2[0].im = i3 - i2;
|
||||
|
||||
v1[0].re = r0 + r5; v1[0].im = i0 + i5;
|
||||
v1[nx].re = r0 - r5; v1[nx].im = i0 - i5;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T> struct DFT_VecR2
|
||||
{
|
||||
void operator()(Complex<T>* dst, const int c_n, const int n, const int dw0, const Complex<T>* wave) const {
|
||||
DFT_R2<T>()(dst, c_n, n, dw0, wave);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T> struct DFT_VecR3
|
||||
{
|
||||
void operator()(Complex<T>* dst, const int c_n, const int n, const int dw0, const Complex<T>* wave) const {
|
||||
DFT_R3<T>()(dst, c_n, n, dw0, wave);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T> struct DFT_VecR4
|
||||
{
|
||||
int operator()(Complex<T>*, int, int, int&, const Complex<T>*) const { return 1; }
|
||||
@@ -379,6 +549,98 @@ template<typename T> struct DFT_VecR4
|
||||
|
||||
#if CV_SSE3
|
||||
|
||||
// multiplies *a and *b:
|
||||
// r_re + i*r_im = (a_re + i*a_im)*(b_re + i*b_im)
|
||||
// r_re and r_im are placed respectively in bits 31:0 and 63:32 of the resulting
|
||||
// vector register.
|
||||
inline __m128 complexMul(const Complex<float>* const a, const Complex<float>* const b) {
|
||||
const __m128 z = _mm_setzero_ps();
|
||||
const __m128 neg_elem0 = _mm_set_ps(0.0f,0.0f,0.0f,-0.0f);
|
||||
// v_a[31:0] is a->re and v_a[63:32] is a->im.
|
||||
const __m128 v_a = _mm_loadl_pi(z, (const __m64*)a);
|
||||
const __m128 v_b = _mm_loadl_pi(z, (const __m64*)b);
|
||||
// x_1 = v[nx] * wave[dw].
|
||||
const __m128 v_a_riri = _mm_shuffle_ps(v_a, v_a, _MM_SHUFFLE(0, 1, 0, 1));
|
||||
const __m128 v_b_irri = _mm_shuffle_ps(v_b, v_b, _MM_SHUFFLE(1, 0, 0, 1));
|
||||
const __m128 mul = _mm_mul_ps(v_a_riri, v_b_irri);
|
||||
const __m128 xored = _mm_xor_ps(mul, neg_elem0);
|
||||
return _mm_hadd_ps(xored, z);
|
||||
}
|
||||
|
||||
// optimized radix-2 transform
|
||||
template<> struct DFT_VecR2<float> {
|
||||
void operator()(Complex<float>* dst, const int c_n, const int n, const int dw0, const Complex<float>* wave) const {
|
||||
const __m128 z = _mm_setzero_ps();
|
||||
const int nx = n/2;
|
||||
for(int i = 0 ; i < c_n; i += n)
|
||||
{
|
||||
{
|
||||
Complex<float>* v = dst + i;
|
||||
float r0 = v[0].re + v[nx].re;
|
||||
float i0 = v[0].im + v[nx].im;
|
||||
float r1 = v[0].re - v[nx].re;
|
||||
float i1 = v[0].im - v[nx].im;
|
||||
v[0].re = r0; v[0].im = i0;
|
||||
v[nx].re = r1; v[nx].im = i1;
|
||||
}
|
||||
|
||||
for( int j = 1, dw = dw0; j < nx; j++, dw += dw0 )
|
||||
{
|
||||
Complex<float>* v = dst + i + j;
|
||||
const __m128 x_1 = complexMul(&v[nx], &wave[dw]);
|
||||
const __m128 v_0 = _mm_loadl_pi(z, (const __m64*)&v[0]);
|
||||
_mm_storel_pi((__m64*)&v[0], _mm_add_ps(v_0, x_1));
|
||||
_mm_storel_pi((__m64*)&v[nx], _mm_sub_ps(v_0, x_1));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Optimized radix-3 implementation.
|
||||
template<> struct DFT_VecR3<float> {
|
||||
void operator()(Complex<float>* dst, const int c_n, const int n, const int dw0, const Complex<float>* wave) const {
|
||||
const int nx = n / 3;
|
||||
const __m128 z = _mm_setzero_ps();
|
||||
const __m128 neg_elem1 = _mm_set_ps(0.0f,0.0f,-0.0f,0.0f);
|
||||
const __m128 sin_120 = _mm_set1_ps(Constants<float>::sin_120);
|
||||
const __m128 one_half = _mm_set1_ps(0.5f);
|
||||
for(int i = 0; i < c_n; i += n )
|
||||
{
|
||||
{
|
||||
Complex<float>* v = dst + i;
|
||||
|
||||
float r1 = v[nx].re + v[nx*2].re;
|
||||
float i1 = v[nx].im + v[nx*2].im;
|
||||
float r0 = v[0].re;
|
||||
float i0 = v[0].im;
|
||||
float r2 = Constants<float>::sin_120*(v[nx].im - v[nx*2].im);
|
||||
float i2 = Constants<float>::sin_120*(v[nx*2].re - v[nx].re);
|
||||
v[0].re = r0 + r1; v[0].im = i0 + i1;
|
||||
r0 -= (float)0.5*r1; i0 -= (float)0.5*i1;
|
||||
v[nx].re = r0 + r2; v[nx].im = i0 + i2;
|
||||
v[nx*2].re = r0 - r2; v[nx*2].im = i0 - i2;
|
||||
}
|
||||
|
||||
for(int j = 1, dw = dw0; j < nx; j++, dw += dw0 )
|
||||
{
|
||||
Complex<float>* v = dst + i + j;
|
||||
const __m128 x_0 = complexMul(&v[nx], &wave[dw]);
|
||||
const __m128 x_2 = complexMul(&v[nx*2], &wave[dw*2]);
|
||||
const __m128 x_1 = _mm_add_ps(x_0, x_2);
|
||||
|
||||
const __m128 v_0 = _mm_loadl_pi(z, (const __m64*)&v[0]);
|
||||
_mm_storel_pi((__m64*)&v[0], _mm_add_ps(v_0, x_1));
|
||||
|
||||
const __m128 x_3 = _mm_mul_ps(sin_120, _mm_xor_ps(_mm_sub_ps(x_2, x_0), neg_elem1));
|
||||
const __m128 x_3s = _mm_shuffle_ps(x_3, x_3, _MM_SHUFFLE(0, 1, 0, 1));
|
||||
const __m128 x_4 = _mm_sub_ps(v_0, _mm_mul_ps(one_half, x_1));
|
||||
_mm_storel_pi((__m64*)&v[nx], _mm_add_ps(x_4, x_3s));
|
||||
_mm_storel_pi((__m64*)&v[nx*2], _mm_sub_ps(x_4, x_3s));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// optimized radix-4 transform
|
||||
template<> struct DFT_VecR4<float>
|
||||
{
|
||||
@@ -573,12 +835,6 @@ struct OcvDftOptions {
|
||||
template<typename T> static void
|
||||
DFT(const OcvDftOptions & c, const Complex<T>* src, Complex<T>* dst)
|
||||
{
|
||||
static const T sin_120 = (T)0.86602540378443864676372317075294;
|
||||
static const T fft5_2 = (T)0.559016994374947424102293417182819;
|
||||
static const T fft5_3 = (T)-0.951056516295153572116439333379382;
|
||||
static const T fft5_4 = (T)-1.538841768587626701285145288018455;
|
||||
static const T fft5_5 = (T)0.363271264002680442947733378740309;
|
||||
|
||||
const Complex<T>* wave = (Complex<T>*)c.wave;
|
||||
const int * itab = c.itab;
|
||||
|
||||
@@ -775,30 +1031,18 @@ DFT(const OcvDftOptions & c, const Complex<T>* src, Complex<T>* dst)
|
||||
for( ; n < c.factors[0]; )
|
||||
{
|
||||
// do the remaining radix-2 transform
|
||||
nx = n;
|
||||
n *= 2;
|
||||
dw0 /= 2;
|
||||
|
||||
for( i = 0; i < c.n; i += n )
|
||||
if(c.haveSSE3)
|
||||
{
|
||||
Complex<T>* v = dst + i;
|
||||
T r0 = v[0].re + v[nx].re;
|
||||
T i0 = v[0].im + v[nx].im;
|
||||
T r1 = v[0].re - v[nx].re;
|
||||
T i1 = v[0].im - v[nx].im;
|
||||
v[0].re = r0; v[0].im = i0;
|
||||
v[nx].re = r1; v[nx].im = i1;
|
||||
|
||||
for( j = 1, dw = dw0; j < nx; j++, dw += dw0 )
|
||||
{
|
||||
v = dst + i + j;
|
||||
r1 = v[nx].re*wave[dw].re - v[nx].im*wave[dw].im;
|
||||
i1 = v[nx].im*wave[dw].re + v[nx].re*wave[dw].im;
|
||||
r0 = v[0].re; i0 = v[0].im;
|
||||
|
||||
v[0].re = r0 + r1; v[0].im = i0 + i1;
|
||||
v[nx].re = r0 - r1; v[nx].im = i0 - i1;
|
||||
}
|
||||
DFT_VecR2<T> vr2;
|
||||
vr2(dst, c.n, n, dw0, wave);
|
||||
}
|
||||
else
|
||||
{
|
||||
DFT_R2<T> vr2;
|
||||
vr2(dst, c.n, n, dw0, wave);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -813,94 +1057,21 @@ DFT(const OcvDftOptions & c, const Complex<T>* src, Complex<T>* dst)
|
||||
|
||||
if( factor == 3 )
|
||||
{
|
||||
// radix-3
|
||||
for( i = 0; i < c.n; i += n )
|
||||
if(c.haveSSE3)
|
||||
{
|
||||
Complex<T>* v = dst + i;
|
||||
|
||||
T r1 = v[nx].re + v[nx*2].re;
|
||||
T i1 = v[nx].im + v[nx*2].im;
|
||||
T r0 = v[0].re;
|
||||
T i0 = v[0].im;
|
||||
T r2 = sin_120*(v[nx].im - v[nx*2].im);
|
||||
T i2 = sin_120*(v[nx*2].re - v[nx].re);
|
||||
v[0].re = r0 + r1; v[0].im = i0 + i1;
|
||||
r0 -= (T)0.5*r1; i0 -= (T)0.5*i1;
|
||||
v[nx].re = r0 + r2; v[nx].im = i0 + i2;
|
||||
v[nx*2].re = r0 - r2; v[nx*2].im = i0 - i2;
|
||||
|
||||
for( j = 1, dw = dw0; j < nx; j++, dw += dw0 )
|
||||
{
|
||||
v = dst + i + j;
|
||||
r0 = v[nx].re*wave[dw].re - v[nx].im*wave[dw].im;
|
||||
i0 = v[nx].re*wave[dw].im + v[nx].im*wave[dw].re;
|
||||
i2 = v[nx*2].re*wave[dw*2].re - v[nx*2].im*wave[dw*2].im;
|
||||
r2 = v[nx*2].re*wave[dw*2].im + v[nx*2].im*wave[dw*2].re;
|
||||
r1 = r0 + i2; i1 = i0 + r2;
|
||||
|
||||
r2 = sin_120*(i0 - r2); i2 = sin_120*(i2 - r0);
|
||||
r0 = v[0].re; i0 = v[0].im;
|
||||
v[0].re = r0 + r1; v[0].im = i0 + i1;
|
||||
r0 -= (T)0.5*r1; i0 -= (T)0.5*i1;
|
||||
v[nx].re = r0 + r2; v[nx].im = i0 + i2;
|
||||
v[nx*2].re = r0 - r2; v[nx*2].im = i0 - i2;
|
||||
}
|
||||
DFT_VecR3<T> vr3;
|
||||
vr3(dst, c.n, n, dw0, wave);
|
||||
}
|
||||
else
|
||||
{
|
||||
DFT_R3<T> vr3;
|
||||
vr3(dst, c.n, n, dw0, wave);
|
||||
}
|
||||
}
|
||||
else if( factor == 5 )
|
||||
{
|
||||
// radix-5
|
||||
for( i = 0; i < c.n; i += n )
|
||||
{
|
||||
for( j = 0, dw = 0; j < nx; j++, dw += dw0 )
|
||||
{
|
||||
Complex<T>* v0 = dst + i + j;
|
||||
Complex<T>* v1 = v0 + nx*2;
|
||||
Complex<T>* v2 = v1 + nx*2;
|
||||
|
||||
T r0, i0, r1, i1, r2, i2, r3, i3, r4, i4, r5, i5;
|
||||
|
||||
r3 = v0[nx].re*wave[dw].re - v0[nx].im*wave[dw].im;
|
||||
i3 = v0[nx].re*wave[dw].im + v0[nx].im*wave[dw].re;
|
||||
r2 = v2[0].re*wave[dw*4].re - v2[0].im*wave[dw*4].im;
|
||||
i2 = v2[0].re*wave[dw*4].im + v2[0].im*wave[dw*4].re;
|
||||
|
||||
r1 = r3 + r2; i1 = i3 + i2;
|
||||
r3 -= r2; i3 -= i2;
|
||||
|
||||
r4 = v1[nx].re*wave[dw*3].re - v1[nx].im*wave[dw*3].im;
|
||||
i4 = v1[nx].re*wave[dw*3].im + v1[nx].im*wave[dw*3].re;
|
||||
r0 = v1[0].re*wave[dw*2].re - v1[0].im*wave[dw*2].im;
|
||||
i0 = v1[0].re*wave[dw*2].im + v1[0].im*wave[dw*2].re;
|
||||
|
||||
r2 = r4 + r0; i2 = i4 + i0;
|
||||
r4 -= r0; i4 -= i0;
|
||||
|
||||
r0 = v0[0].re; i0 = v0[0].im;
|
||||
r5 = r1 + r2; i5 = i1 + i2;
|
||||
|
||||
v0[0].re = r0 + r5; v0[0].im = i0 + i5;
|
||||
|
||||
r0 -= (T)0.25*r5; i0 -= (T)0.25*i5;
|
||||
r1 = fft5_2*(r1 - r2); i1 = fft5_2*(i1 - i2);
|
||||
r2 = -fft5_3*(i3 + i4); i2 = fft5_3*(r3 + r4);
|
||||
|
||||
i3 *= -fft5_5; r3 *= fft5_5;
|
||||
i4 *= -fft5_4; r4 *= fft5_4;
|
||||
|
||||
r5 = r2 + i3; i5 = i2 + r3;
|
||||
r2 -= i4; i2 -= r4;
|
||||
|
||||
r3 = r0 + r1; i3 = i0 + i1;
|
||||
r0 -= r1; i0 -= i1;
|
||||
|
||||
v0[nx].re = r3 + r2; v0[nx].im = i3 + i2;
|
||||
v2[0].re = r3 - r2; v2[0].im = i3 - i2;
|
||||
|
||||
v1[0].re = r0 + r5; v1[0].im = i0 + i5;
|
||||
v1[nx].re = r0 - r5; v1[nx].im = i0 - i5;
|
||||
}
|
||||
}
|
||||
DFT_R5<T> vr5;
|
||||
vr5(dst, c.n, n, dw0, wave);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+339
-1
@@ -204,6 +204,21 @@ MatAllocator* Mat::getStdAllocator()
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
bool MatSize::operator==(const MatSize& sz) const
|
||||
{
|
||||
int d = dims();
|
||||
int dsz = sz.dims();
|
||||
if( d != dsz )
|
||||
return false;
|
||||
if( d == 2 )
|
||||
return p[0] == sz.p[0] && p[1] == sz.p[1];
|
||||
|
||||
for( int i = 0; i < d; i++ )
|
||||
if( p[i] != sz.p[i] )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void setSize( Mat& m, int _dims, const int* _sz, const size_t* _steps, bool autoSteps)
|
||||
{
|
||||
CV_Assert( 0 <= _dims && _dims <= CV_MAX_DIM );
|
||||
@@ -320,7 +335,330 @@ void finalizeHdr(Mat& m)
|
||||
m.dataend = m.datalimit = 0;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
//======================================= Mat ======================================================
|
||||
|
||||
Mat::Mat()
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{}
|
||||
|
||||
Mat::Mat(int _rows, int _cols, int _type)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create(_rows, _cols, _type);
|
||||
}
|
||||
|
||||
Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create(_rows, _cols, _type);
|
||||
*this = _s;
|
||||
}
|
||||
|
||||
Mat::Mat(Size _sz, int _type)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create( _sz.height, _sz.width, _type );
|
||||
}
|
||||
|
||||
Mat::Mat(Size _sz, int _type, const Scalar& _s)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create(_sz.height, _sz.width, _type);
|
||||
*this = _s;
|
||||
}
|
||||
|
||||
Mat::Mat(int _dims, const int* _sz, int _type)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create(_dims, _sz, _type);
|
||||
}
|
||||
|
||||
Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create(_dims, _sz, _type);
|
||||
*this = _s;
|
||||
}
|
||||
|
||||
Mat::Mat(const std::vector<int>& _sz, int _type)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create(_sz, _type);
|
||||
}
|
||||
|
||||
Mat::Mat(const std::vector<int>& _sz, int _type, const Scalar& _s)
|
||||
: flags(MAGIC_VAL), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0),
|
||||
datalimit(0), allocator(0), u(0), size(&rows), step(0)
|
||||
{
|
||||
create(_sz, _type);
|
||||
*this = _s;
|
||||
}
|
||||
|
||||
Mat::Mat(const Mat& m)
|
||||
: flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), data(m.data),
|
||||
datastart(m.datastart), dataend(m.dataend), datalimit(m.datalimit), allocator(m.allocator),
|
||||
u(m.u), size(&rows), step(0)
|
||||
{
|
||||
if( u )
|
||||
CV_XADD(&u->refcount, 1);
|
||||
if( m.dims <= 2 )
|
||||
{
|
||||
step[0] = m.step[0]; step[1] = m.step[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
dims = 0;
|
||||
copySize(m);
|
||||
}
|
||||
}
|
||||
|
||||
Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step)
|
||||
: flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_rows), cols(_cols),
|
||||
data((uchar*)_data), datastart((uchar*)_data), dataend(0), datalimit(0),
|
||||
allocator(0), u(0), size(&rows)
|
||||
{
|
||||
CV_Assert(total() == 0 || data != NULL);
|
||||
|
||||
size_t esz = CV_ELEM_SIZE(_type), esz1 = CV_ELEM_SIZE1(_type);
|
||||
size_t minstep = cols * esz;
|
||||
if( _step == AUTO_STEP )
|
||||
{
|
||||
_step = minstep;
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert( _step >= minstep );
|
||||
if (_step % esz1 != 0)
|
||||
{
|
||||
CV_Error(Error::BadStep, "Step must be a multiple of esz1");
|
||||
}
|
||||
}
|
||||
step[0] = _step;
|
||||
step[1] = esz;
|
||||
datalimit = datastart + _step * rows;
|
||||
dataend = datalimit - _step + minstep;
|
||||
updateContinuityFlag();
|
||||
}
|
||||
|
||||
Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
|
||||
: flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_sz.height), cols(_sz.width),
|
||||
data((uchar*)_data), datastart((uchar*)_data), dataend(0), datalimit(0),
|
||||
allocator(0), u(0), size(&rows)
|
||||
{
|
||||
CV_Assert(total() == 0 || data != NULL);
|
||||
|
||||
size_t esz = CV_ELEM_SIZE(_type), esz1 = CV_ELEM_SIZE1(_type);
|
||||
size_t minstep = cols*esz;
|
||||
if( _step == AUTO_STEP )
|
||||
{
|
||||
_step = minstep;
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert(_step >= minstep);
|
||||
|
||||
if (_step % esz1 != 0)
|
||||
{
|
||||
CV_Error(Error::BadStep, "Step must be a multiple of esz1");
|
||||
}
|
||||
}
|
||||
step[0] = _step;
|
||||
step[1] = esz;
|
||||
datalimit = datastart + _step*rows;
|
||||
dataend = datalimit - _step + minstep;
|
||||
updateContinuityFlag();
|
||||
}
|
||||
|
||||
|
||||
Mat::~Mat()
|
||||
{
|
||||
release();
|
||||
if( step.p != step.buf )
|
||||
fastFree(step.p);
|
||||
}
|
||||
|
||||
Mat& Mat::operator=(const Mat& m)
|
||||
{
|
||||
if( this != &m )
|
||||
{
|
||||
if( m.u )
|
||||
CV_XADD(&m.u->refcount, 1);
|
||||
release();
|
||||
flags = m.flags;
|
||||
if( dims <= 2 && m.dims <= 2 )
|
||||
{
|
||||
dims = m.dims;
|
||||
rows = m.rows;
|
||||
cols = m.cols;
|
||||
step[0] = m.step[0];
|
||||
step[1] = m.step[1];
|
||||
}
|
||||
else
|
||||
copySize(m);
|
||||
data = m.data;
|
||||
datastart = m.datastart;
|
||||
dataend = m.dataend;
|
||||
datalimit = m.datalimit;
|
||||
allocator = m.allocator;
|
||||
u = m.u;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Mat Mat::clone() const
|
||||
{
|
||||
Mat m;
|
||||
copyTo(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
void Mat::assignTo( Mat& m, int _type ) const
|
||||
{
|
||||
if( _type < 0 )
|
||||
m = *this;
|
||||
else
|
||||
convertTo(m, _type);
|
||||
}
|
||||
|
||||
void Mat::create(int _rows, int _cols, int _type)
|
||||
{
|
||||
_type &= TYPE_MASK;
|
||||
if( dims <= 2 && rows == _rows && cols == _cols && type() == _type && data )
|
||||
return;
|
||||
int sz[] = {_rows, _cols};
|
||||
create(2, sz, _type);
|
||||
}
|
||||
|
||||
void Mat::create(Size _sz, int _type)
|
||||
{
|
||||
create(_sz.height, _sz.width, _type);
|
||||
}
|
||||
|
||||
void Mat::addref()
|
||||
{
|
||||
if( u )
|
||||
CV_XADD(&u->refcount, 1);
|
||||
}
|
||||
|
||||
void Mat::release()
|
||||
{
|
||||
if( u && CV_XADD(&u->refcount, -1) == 1 )
|
||||
deallocate();
|
||||
u = NULL;
|
||||
datastart = dataend = datalimit = data = 0;
|
||||
for(int i = 0; i < dims; i++)
|
||||
size.p[i] = 0;
|
||||
#ifdef _DEBUG
|
||||
flags = MAGIC_VAL;
|
||||
dims = rows = cols = 0;
|
||||
if(step.p != step.buf)
|
||||
{
|
||||
fastFree(step.p);
|
||||
step.p = step.buf;
|
||||
size.p = &rows;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t Mat::step1(int i) const
|
||||
{
|
||||
return step.p[i] / elemSize1();
|
||||
}
|
||||
|
||||
bool Mat::empty() const
|
||||
{
|
||||
return data == 0 || total() == 0 || dims == 0;
|
||||
}
|
||||
|
||||
size_t Mat::total() const
|
||||
{
|
||||
if( dims <= 2 )
|
||||
return (size_t)rows * cols;
|
||||
size_t p = 1;
|
||||
for( int i = 0; i < dims; i++ )
|
||||
p *= size[i];
|
||||
return p;
|
||||
}
|
||||
|
||||
size_t Mat::total(int startDim, int endDim) const
|
||||
{
|
||||
CV_Assert( 0 <= startDim && startDim <= endDim);
|
||||
size_t p = 1;
|
||||
int endDim_ = endDim <= dims ? endDim : dims;
|
||||
for( int i = startDim; i < endDim_; i++ )
|
||||
p *= size[i];
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
Mat::Mat(Mat&& m)
|
||||
: flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), data(m.data),
|
||||
datastart(m.datastart), dataend(m.dataend), datalimit(m.datalimit), allocator(m.allocator),
|
||||
u(m.u), size(&rows)
|
||||
{
|
||||
if (m.dims <= 2) // move new step/size info
|
||||
{
|
||||
step[0] = m.step[0];
|
||||
step[1] = m.step[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert(m.step.p != m.step.buf);
|
||||
step.p = m.step.p;
|
||||
size.p = m.size.p;
|
||||
m.step.p = m.step.buf;
|
||||
m.size.p = &m.rows;
|
||||
}
|
||||
m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0;
|
||||
m.data = NULL; m.datastart = NULL; m.dataend = NULL; m.datalimit = NULL;
|
||||
m.allocator = NULL;
|
||||
m.u = NULL;
|
||||
}
|
||||
|
||||
|
||||
Mat& Mat::operator=(Mat&& m)
|
||||
{
|
||||
if (this == &m)
|
||||
return *this;
|
||||
|
||||
release();
|
||||
flags = m.flags; dims = m.dims; rows = m.rows; cols = m.cols; data = m.data;
|
||||
datastart = m.datastart; dataend = m.dataend; datalimit = m.datalimit; allocator = m.allocator;
|
||||
u = m.u;
|
||||
if (step.p != step.buf) // release self step/size
|
||||
{
|
||||
fastFree(step.p);
|
||||
step.p = step.buf;
|
||||
size.p = &rows;
|
||||
}
|
||||
if (m.dims <= 2) // move new step/size info
|
||||
{
|
||||
step[0] = m.step[0];
|
||||
step[1] = m.step[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert(m.step.p != m.step.buf);
|
||||
step.p = m.step.p;
|
||||
size.p = m.size.p;
|
||||
m.step.p = m.step.buf;
|
||||
m.size.p = &m.rows;
|
||||
}
|
||||
m.flags = MAGIC_VAL; m.dims = m.rows = m.cols = 0;
|
||||
m.data = NULL; m.datastart = NULL; m.dataend = NULL; m.datalimit = NULL;
|
||||
m.allocator = NULL;
|
||||
m.u = NULL;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Mat::create(int d, const int* _sizes, int _type)
|
||||
{
|
||||
|
||||
@@ -176,6 +176,94 @@ void SparseMat::Hdr::clear()
|
||||
nodeCount = freeList = 0;
|
||||
}
|
||||
|
||||
///////////////////////////// SparseMat /////////////////////////////
|
||||
|
||||
SparseMat::SparseMat()
|
||||
: flags(MAGIC_VAL), hdr(0)
|
||||
{}
|
||||
|
||||
SparseMat::SparseMat(int _dims, const int* _sizes, int _type)
|
||||
: flags(MAGIC_VAL), hdr(0)
|
||||
{
|
||||
create(_dims, _sizes, _type);
|
||||
}
|
||||
|
||||
SparseMat::SparseMat(const SparseMat& m)
|
||||
: flags(m.flags), hdr(m.hdr)
|
||||
{
|
||||
addref();
|
||||
}
|
||||
|
||||
SparseMat::~SparseMat()
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
SparseMat& SparseMat::operator = (const SparseMat& m)
|
||||
{
|
||||
if( this != &m )
|
||||
{
|
||||
if( m.hdr )
|
||||
CV_XADD(&m.hdr->refcount, 1);
|
||||
release();
|
||||
flags = m.flags;
|
||||
hdr = m.hdr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
SparseMat& SparseMat::operator=(const Mat& m)
|
||||
{
|
||||
return (*this = SparseMat(m));
|
||||
}
|
||||
|
||||
void SparseMat::assignTo(SparseMat& m, int _type) const
|
||||
{
|
||||
if( _type < 0 )
|
||||
m = *this;
|
||||
else
|
||||
convertTo(m, _type);
|
||||
}
|
||||
|
||||
void SparseMat::addref()
|
||||
{
|
||||
if( hdr )
|
||||
CV_XADD(&hdr->refcount, 1);
|
||||
}
|
||||
|
||||
void SparseMat::release()
|
||||
{
|
||||
if( hdr && CV_XADD(&hdr->refcount, -1) == 1 )
|
||||
delete hdr;
|
||||
hdr = 0;
|
||||
}
|
||||
|
||||
size_t SparseMat::hash(int i0) const
|
||||
{
|
||||
return (size_t)i0;
|
||||
}
|
||||
|
||||
size_t SparseMat::hash(int i0, int i1) const
|
||||
{
|
||||
return (size_t)(unsigned)i0 * HASH_SCALE + (unsigned)i1;
|
||||
}
|
||||
|
||||
size_t SparseMat::hash(int i0, int i1, int i2) const
|
||||
{
|
||||
return ((size_t)(unsigned)i0 * HASH_SCALE + (unsigned)i1) * HASH_SCALE + (unsigned)i2;
|
||||
}
|
||||
|
||||
size_t SparseMat::hash(const int* idx) const
|
||||
{
|
||||
size_t h = (unsigned)idx[0];
|
||||
if( !hdr )
|
||||
return 0;
|
||||
int d = hdr->dims;
|
||||
for(int i = 1; i < d; i++ )
|
||||
h = h * HASH_SCALE + (unsigned)idx[i];
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
SparseMat::SparseMat(const Mat& m)
|
||||
: flags(MAGIC_VAL), hdr(0)
|
||||
|
||||
@@ -113,6 +113,10 @@
|
||||
|
||||
#include "opencv2/core/opencl/runtime/opencl_core.hpp"
|
||||
|
||||
#ifdef HAVE_DIRECTX
|
||||
#include "directx.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENCL_SVM
|
||||
#include "opencv2/core/opencl/runtime/opencl_svm_20.hpp"
|
||||
#include "opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp"
|
||||
@@ -2327,6 +2331,9 @@ protected:
|
||||
, contextId(CV_XADD(&g_contextId, 1))
|
||||
, configuration(configuration_)
|
||||
, handle(0)
|
||||
#ifdef HAVE_DIRECTX
|
||||
, p_directx_impl(0)
|
||||
#endif
|
||||
#ifdef HAVE_OPENCL_SVM
|
||||
, svmInitialized(false)
|
||||
#endif
|
||||
@@ -2352,6 +2359,9 @@ protected:
|
||||
handle = NULL;
|
||||
}
|
||||
devices.clear();
|
||||
#ifdef HAVE_DIRECTX
|
||||
directx::internal::deleteDirectXImpl(&p_directx_impl);
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
@@ -2427,6 +2437,7 @@ public:
|
||||
if (impl)
|
||||
{
|
||||
CV_LOG_INFO(NULL, "OpenCL: reuse context@" << impl->contextId << " for configuration: " << configuration)
|
||||
impl->addref();
|
||||
return impl;
|
||||
}
|
||||
|
||||
@@ -2658,6 +2669,19 @@ public:
|
||||
return *bufferPoolHostPtr_.get();
|
||||
}
|
||||
|
||||
#ifdef HAVE_DIRECTX
|
||||
directx::internal::OpenCLDirectXImpl* p_directx_impl;
|
||||
|
||||
directx::internal::OpenCLDirectXImpl* getDirectXImpl()
|
||||
{
|
||||
if (!p_directx_impl)
|
||||
{
|
||||
p_directx_impl = directx::internal::createDirectXImpl();
|
||||
}
|
||||
return p_directx_impl;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENCL_SVM
|
||||
bool svmInitialized;
|
||||
bool svmAvailable;
|
||||
@@ -7286,4 +7310,15 @@ uint64 Timer::durationNS() const
|
||||
|
||||
}} // namespace
|
||||
|
||||
#ifdef HAVE_DIRECTX
|
||||
namespace cv { namespace directx { namespace internal {
|
||||
OpenCLDirectXImpl* getDirectXImpl(ocl::Context& ctx)
|
||||
{
|
||||
ocl::Context::Impl* i = ctx.getImpl();
|
||||
CV_Assert(i);
|
||||
return i->getDirectXImpl();
|
||||
}
|
||||
}}} // namespace cv::directx::internal
|
||||
#endif
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user