Restricted Win32 API was fixed in Highgui and some 3rd party libs. Patch
authorAlexander Smorkalov <alexander.smorkalov@itseez.com>
Mon, 12 Aug 2013 13:30:40 +0000 (06:30 -0700)
committerAlexander Smorkalov <alexander.smorkalov@itseez.com>
Thu, 15 Aug 2013 13:42:00 +0000 (06:42 -0700)
for libpng added.

3rdparty/libpng/CMakeLists.txt
3rdparty/libpng/opencv-libpng.path [new file with mode: 0644]
3rdparty/libpng/pngpriv.h
modules/core/include/opencv2/core/version.hpp
modules/highgui/src/cap_ffmpeg.cpp
modules/highgui/src/cap_ffmpeg_impl.hpp

index d47dd53fcdc0e835a424f27236831c75150165af..59dca6990e71e34742a3e532739bd10babc4ca49 100644 (file)
@@ -29,6 +29,10 @@ if(MSVC)
   add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
 endif(MSVC)
 
+if (HAVE_WINRT)
+  add_definitions(-DHAVE_WINRT)
+endif()
+
 add_library(${PNG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
 target_link_libraries(${PNG_LIBRARY} ${ZLIB_LIBRARY})
 
diff --git a/3rdparty/libpng/opencv-libpng.path b/3rdparty/libpng/opencv-libpng.path
new file mode 100644 (file)
index 0000000..6ca9639
--- /dev/null
@@ -0,0 +1,22 @@
+diff --git a/3rdparty/libpng/pngpriv.h b/3rdparty/libpng/pngpriv.h
+index 07b2b0b..e7824b8 100644
+--- a/3rdparty/libpng/pngpriv.h
++++ b/3rdparty/libpng/pngpriv.h
+@@ -360,7 +360,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
+ /* Memory model/platform independent fns */
+ #ifndef PNG_ABORT
+-#  ifdef _WINDOWS_
++#  if defined(_WINDOWS_) && !defined(HAVE_WINRT)
+ #    define PNG_ABORT() ExitProcess(0)
+ #  else
+ #    define PNG_ABORT() abort()
+@@ -378,7 +378,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
+ #  define png_memcpy  _fmemcpy
+ #  define png_memset  _fmemset
+ #else
+-#  ifdef _WINDOWS_  /* Favor Windows over C runtime fns */
++#  if defined(_WINDOWS_) && !defined(HAVE_WINRT)  /* Favor Windows over C runtime fns */
+ #    define CVT_PTR(ptr)         (ptr)
+ #    define CVT_PTR_NOCHECK(ptr) (ptr)
+ #    define png_strlen  lstrlenA
index 07b2b0b05beb93ac0b46324c524bd3094d55f8bb..e7824b839e777fc7a5653990a2fd739917f53919 100644 (file)
@@ -360,7 +360,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
 
 /* Memory model/platform independent fns */
 #ifndef PNG_ABORT
-#  ifdef _WINDOWS_
+#  if defined(_WINDOWS_) && !defined(HAVE_WINRT)
 #    define PNG_ABORT() ExitProcess(0)
 #  else
 #    define PNG_ABORT() abort()
@@ -378,7 +378,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
 #  define png_memcpy  _fmemcpy
 #  define png_memset  _fmemset
 #else
-#  ifdef _WINDOWS_  /* Favor Windows over C runtime fns */
+#  if defined(_WINDOWS_) && !defined(HAVE_WINRT)  /* Favor Windows over C runtime fns */
 #    define CVT_PTR(ptr)         (ptr)
 #    define CVT_PTR_NOCHECK(ptr) (ptr)
 #    define png_strlen  lstrlenA
index ba71a8259264b68016efc779420cc377f5b1188c..bd95e6359b55dbd566b7a232952b39a970e1ce96 100644 (file)
@@ -55,6 +55,9 @@
 #define CVAUX_STR_EXP(__A)  #__A
 #define CVAUX_STR(__A)      CVAUX_STR_EXP(__A)
 
+#define CVAUX_STRW_EXP(__A)  L#__A
+#define CVAUX_STRW(__A)      CVAUX_STRW_EXP(__A)
+
 #if CV_VERSION_REVISION
 #  define CV_VERSION        CVAUX_STR(CV_VERSION_EPOCH) "." CVAUX_STR(CV_VERSION_MAJOR) "." CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(CV_VERSION_REVISION)
 #else
index bf73c0810ffbb18ef80f78f1af85044bf9eab5e7..00f0494d89e630767aae5658db9c5da9804c56b6 100644 (file)
@@ -85,6 +85,16 @@ private:
     icvInitFFMPEG()
     {
     #if defined WIN32 || defined _WIN32
+    # ifdef HAVE_WINRT
+        const wchar_t* module_name = L"opencv_ffmpeg"
+            CVAUX_STRW(CV_MAJOR_VERSION) CVAUX_STRW(CV_MINOR_VERSION) CVAUX_STRW(CV_SUBMINOR_VERSION)
+        #if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__)
+            L"_64"
+        #endif
+            L".dll";
+
+        icvFFOpenCV = LoadPackagedLibrary( module_name, 0 );
+    # else
         const char* module_name = "opencv_ffmpeg"
             CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) CVAUX_STR(CV_SUBMINOR_VERSION)
         #if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__)
@@ -93,6 +103,8 @@ private:
             ".dll";
 
         icvFFOpenCV = LoadLibrary( module_name );
+    # endif
+
         if( icvFFOpenCV )
         {
             icvCreateFileCapture_FFMPEG_p =
index d494948f969d1be8a5e887e640affeeaad4a727b..5da449618dc58f5c0d95330200948cc46eb4ae71 100644 (file)
@@ -366,7 +366,15 @@ private:
 
 struct ImplMutex::Impl
 {
-    void init() { InitializeCriticalSection(&cs); refcount = 1; }
+    void init()
+    {
+#if (_WIN32_WINNT >= 0x0600)
+        ::InitializeCriticalSectionEx(&cs, 1000, 0);
+#else
+        ::InitializeCriticalSection(&cs);
+#endif
+        refcount = 1;
+    }
     void destroy() { DeleteCriticalSection(&cs); }
 
     void lock() { EnterCriticalSection(&cs); }