Windows building.

This commit is contained in:
ssrlive 2020-12-15 00:20:29 +08:00
parent 505f1a87b3
commit cb6d1c8943
14 changed files with 946 additions and 64 deletions

12
.gitignore vendored
View File

@ -1,3 +1,15 @@
build/
Debug/
Release/
x64/
.vs/
.vscode/
*.sdf
*.suo
*.vcxproj.user
*.ipch
*.opensdf
*.la
*.lo
*.o

140
CMakeLists.txt Normal file
View File

@ -0,0 +1,140 @@
project(zbar_qrcode)
cmake_minimum_required(VERSION 3.10)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_THREAD_PREFER_PTHREAD ON)
find_package(Threads QUIET)
find_package(Iconv QUIET)
find_file(HAVE_INTTYPES_H "inttypes.h" DOC "inttypes.h exists")
find_file(HAVE_FEATURES_H "features.h" DOC "features.h exists")
find_file(HAVE_POLL_H "poll.h" DOC "poll.h exists")
find_file(HAVE_SYS_TIME_H "sys/time.h" DOC "sys/time.h exists")
add_library(zbar
zbar/decoder/qr_finder.c
zbar/qrcode/qrdec.c
zbar/qrcode/qrdectxt.c
zbar/qrcode/rs.c
zbar/qrcode/isaac.c
zbar/qrcode/bch15_5.c
zbar/qrcode/binarize.c
zbar/qrcode/util.c
zbar/processor/posix.c
zbar/symbol.c
zbar/image.c
zbar/video.c
zbar/img_scanner.c
zbar/scanner.c
zbar/window.c
zbar/decoder.c
zbar/refcnt.c
zbar/processor/lock.c
zbar/processor.c
zbar/convert.c
zbar/error.c
zbar/video/null.c
zbar/processor/null.c
zbar/window/null.c
include/zbar.h
zbar/decoder/qr_finder.h
zbar/qrcode.h
zbar/qrcode/qrdec.h
zbar/qrcode/rs.h
zbar/qrcode/isaac.h
zbar/qrcode/bch15_5.h
zbar/qrcode/binarize.h
zbar/qrcode/util.h
zbar/error.h
zbar/symbol.h
zbar/image.h
zbar/processor.h
zbar/refcnt.h
zbar/timer.h
zbar/mutex.h
zbar/event.h
zbar/thread.h
zbar/window.h
zbar/video.h
zbar/img_scanner.h
zbar/decoder.h
zbar/processor/posix.h
)
target_compile_definitions(zbar
PRIVATE
ENABLE_QRCODE
ZBAR_VERSION_MAJOR=0
ZBAR_VERSION_MINOR=23
ZBAR_VERSION_PATCH=0
)
if (HAVE_INTTYPES_H)
target_compile_definitions(zbar PRIVATE HAVE_INTTYPES_H=1)
endif()
if (HAVE_FEATURES_H)
target_compile_definitions(zbar PRIVATE HAVE_FEATURES_H=1)
endif()
if (HAVE_POLL_H)
target_compile_definitions(zbar PRIVATE HAVE_POLL_H=1)
endif()
if (HAVE_SYS_TIME_H)
target_compile_definitions(zbar PRIVATE HAVE_SYS_TIME_H=1)
endif()
if(THREADS_FOUND)
target_compile_definitions(zbar PRIVATE HAVE_LIBPTHREAD=1)
target_link_libraries(zbar
PRIVATE
Threads::Threads
)
endif()
if (ICONV_FOUND)
target_link_libraries(zbar
PRIVATE
Iconv::Iconv
)
endif()
target_include_directories(zbar
PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
zbar
zbar/qrcode
zbar/decoder
)
install(TARGETS zbar EXPORT zbarTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(
FILES include/zbar.h
DESTINATION include/zbar
)
# Package configuration
if(THREADS_FOUND)
set(find_pkg_dependencies "find_dependency(Threads)")
else()
set(find_pkg_dependencies "")
endif()
set(configPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/zbar)
set(inputConfigFile "${CMAKE_CURRENT_SOURCE_DIR}/cmake/zbarConfig.cmake.in")
set(outputConfigFile "${CMAKE_CURRENT_BINARY_DIR}/zbarConfig.cmake")
configure_file(${inputConfigFile} ${outputConfigFile} @ONLY)
install(FILES ${outputConfigFile}
DESTINATION ${configPackageLocation}
)
export(EXPORT zbarTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/zbarTargets.cmake"
NAMESPACE zbar::
)
install(EXPORT zbarTargets
NAMESPACE zbar::
DESTINATION ${configPackageLocation}
)

View File

@ -0,0 +1,5 @@
include(CMakeFindDependencyMacro)
@find_pkg_dependencies@
include("${CMAKE_CURRENT_LIST_DIR}/zbarTargets.cmake")

246
win32/config.h Normal file
View File

@ -0,0 +1,246 @@
/* manually customized for iPhone platform */
/* whether to build support for Code 128 symbology */
#define ENABLE_CODE128 1
/* whether to build support for Code 93 symbology */
#define ENABLE_CODE93 1
/* whether to build support for Code 39 symbology */
#define ENABLE_CODE39 1
/* whether to build support for Codabar symbology */
#define ENABLE_CODABAR 1
/* whether to build support for DataBar symbology */
#define ENABLE_DATABAR 1
/* whether to build support for EAN symbologies */
#define ENABLE_EAN 1
/* whether to build support for Interleaved 2 of 5 symbology */
#define ENABLE_I25 1
/* whether to build support for PDF417 symbology */
#undef ENABLE_PDF417
/* whether to build support for QR Code */
#define ENABLE_QRCODE 1
/* Define to 1 if you have the `atexit' function. */
#undef HAVE_ATEXIT
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the <features.h> header file. */
#undef HAVE_FEATURES_H
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
/* Define if you have the iconv() function and it works. */
#undef HAVE_ICONV
/* Define to 1 if you have the <inttypes.h> header file. */
//#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <jpeglib.h> header file. */
#undef HAVE_JPEGLIB_H
/* Define to 1 if you have the `jpeg' library (-ljpeg). */
#undef HAVE_LIBJPEG
/* Define to 1 if you have the `pthread' library (-lpthread). */
#undef HAVE_LIBPTHREAD
/* Define to 1 if you have the <linux/videodev2.h> header file. */
#undef HAVE_LINUX_VIDEODEV2_H
/* Define to 1 if you have the <linux/videodev.h> header file. */
#undef HAVE_LINUX_VIDEODEV_H
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define to 1 if you have the <poll.h> header file. */
#undef HAVE_POLL_H
/* Define to 1 if you have the <pthread.h> header file. */
#undef HAVE_PTHREAD_H
/* Define to 1 if you have the `setenv' function. */
#undef HAVE_SETENV
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H
/* Define to 1 if you have the <sys/ipc.h> header file. */
#undef HAVE_SYS_IPC_H
/* Define to 1 if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
/* Define to 1 if you have the <sys/shm.h> header file. */
#undef HAVE_SYS_SHM_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/times.h> header file. */
//#define HAVE_SYS_TIMES_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
//#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
//#define HAVE_SYS_TYPES_H 1
/* Define to 1 if the system has the type `uintptr_t'. */
#define HAVE_UINTPTR_T 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the <vfw.h> header file. */
#undef HAVE_VFW_H
/* Define to 1 if you have the <X11/extensions/XShm.h> header file. */
#undef HAVE_X11_EXTENSIONS_XSHM_H
/* Define to 1 if you have the <X11/extensions/Xvlib.h> header file. */
#undef HAVE_X11_EXTENSIONS_XVLIB_H
/* Define as const if the declaration of iconv() needs const. */
#undef ICONV_CONST
/* Library major version */
#define LIB_VERSION_MAJOR 0
/* Library minor version */
#define LIB_VERSION_MINOR 2
/* Library revision */
#define LIB_VERSION_REVISION 0
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Define to 1 if assertions should be disabled. */
//#undef NDEBUG
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
/* Name of package */
#define PACKAGE "zbar"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "spadix@users.sourceforge.net"
/* Define to the full name of this package. */
#define PACKAGE_NAME "zbar"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "zbar 0.10"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "zbar"
/* Define to the version of this package. */
#define PACKAGE_VERSION "0.10"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "0.10"
/* Define to 1 if the X Window System is missing or not being used. */
#define X_DISPLAY_MISSING 1
/* Program major version (before the '.') as a number */
#define ZBAR_VERSION_MAJOR 0
/* Program minor version (after '.') as a number */
#define ZBAR_VERSION_MINOR 23
/* Program minor version (after the second '.') as a number */
#define ZBAR_VERSION_PATCH 0
//HAVE_LIBPTHREAD=1
//CMAKE_INTDIR="Debug"
#define PRIX32 "lX"
#define PRIx32 "lx"
#define snprintf _snprintf
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT32_T
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT8_T
/* Minimum Windows API version */
//#undef _WIN32_WINNT
/* used only for pthread debug attributes */
#undef __USE_UNIX98
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline
#define inline __inline
#endif
/* Define to the type of a signed integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
//#undef int32_t
/* Define to the type of an unsigned integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
//#undef uint32_t
/* Define to the type of an unsigned integer type of width exactly 8 bits if
such a type exists and the standard includes do not define it. */
//#undef uint8_t
/* Define to the type of an unsigned integer type wide enough to hold a
pointer, if such a type exists, and if the system does not define it. */
//#undef uintptr_t
#ifndef X_DISPLAY_MISSING
# define HAVE_X
#endif

251
win32/zbar.vcxproj Normal file
View File

@ -0,0 +1,251 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="MinSizeRel|Win32">
<Configuration>MinSizeRel</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="RelWithDebInfo|Win32">
<Configuration>RelWithDebInfo</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E8072FB6-41C5-3D5C-A66F-329FB8A4D760}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<Platform>Win32</Platform>
<ProjectName>zbar</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">C:\Users\Administrator\Desktop\zbar\build\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">zbar.dir\Release\</IntDir>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">zbar</TargetName>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.lib</TargetExt>
<OutDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">C:\Users\Administrator\Desktop\zbar\build\MinSizeRel\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">zbar.dir\MinSizeRel\</IntDir>
<TargetName Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">zbar</TargetName>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">.lib</TargetExt>
<OutDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">C:\Users\Administrator\Desktop\zbar\build\RelWithDebInfo\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">zbar.dir\RelWithDebInfo\</IntDir>
<TargetName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">zbar</TargetName>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">.lib</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\include;..\zbar;..\zbar\qrcode;..\zbar\decoder;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ExceptionHandling>
</ExceptionHandling>
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_WINDOWS;ENABLE_QRCODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;ENABLE_QRCODE;ZBAR_VERSION_MAJOR=0;ZBAR_VERSION_MINOR=23;ZBAR_VERSION_PATCH=0;HAVE_LIBPTHREAD=1;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Midl>
<AdditionalIncludeDirectories>C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
<HeaderFileName>%(Filename).h</HeaderFileName>
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
</Midl>
<Lib>
<AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<ExceptionHandling>
</ExceptionHandling>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<Optimization>MaxSpeed</Optimization>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;ENABLE_QRCODE;ZBAR_VERSION_MAJOR=0;ZBAR_VERSION_MINOR=23;ZBAR_VERSION_PATCH=0;HAVE_LIBPTHREAD=1;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ObjectFileName>$(IntDir)</ObjectFileName>
<DebugInformationFormat>
</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;ENABLE_QRCODE;ZBAR_VERSION_MAJOR=0;ZBAR_VERSION_MINOR=23;ZBAR_VERSION_PATCH=0;HAVE_LIBPTHREAD=1;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Midl>
<AdditionalIncludeDirectories>C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
<HeaderFileName>%(Filename).h</HeaderFileName>
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
</Midl>
<Lib>
<AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<ExceptionHandling>
</ExceptionHandling>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<Optimization>MinSpace</Optimization>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;ENABLE_QRCODE;ZBAR_VERSION_MAJOR=0;ZBAR_VERSION_MINOR=23;ZBAR_VERSION_PATCH=0;HAVE_LIBPTHREAD=1;CMAKE_INTDIR="MinSizeRel";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ObjectFileName>$(IntDir)</ObjectFileName>
<DebugInformationFormat>
</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;ENABLE_QRCODE;ZBAR_VERSION_MAJOR=0;ZBAR_VERSION_MINOR=23;ZBAR_VERSION_PATCH=0;HAVE_LIBPTHREAD=1;CMAKE_INTDIR=\"MinSizeRel\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Midl>
<AdditionalIncludeDirectories>C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
<HeaderFileName>%(Filename).h</HeaderFileName>
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
</Midl>
<Lib>
<AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ExceptionHandling>
</ExceptionHandling>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<Optimization>MaxSpeed</Optimization>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;ENABLE_QRCODE;ZBAR_VERSION_MAJOR=0;ZBAR_VERSION_MINOR=23;ZBAR_VERSION_PATCH=0;HAVE_LIBPTHREAD=1;CMAKE_INTDIR="RelWithDebInfo";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ObjectFileName>$(IntDir)</ObjectFileName>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;ENABLE_QRCODE;ZBAR_VERSION_MAJOR=0;ZBAR_VERSION_MINOR=23;ZBAR_VERSION_PATCH=0;HAVE_LIBPTHREAD=1;CMAKE_INTDIR=\"RelWithDebInfo\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Midl>
<AdditionalIncludeDirectories>C:\Users\Administrator\Desktop\zbar\include;C:\Users\Administrator\Desktop\zbar\zbar;C:\Users\Administrator\Desktop\zbar\zbar\qrcode;C:\Users\Administrator\Desktop\zbar\zbar\decoder;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<OutputDirectory>$(ProjectDir)/$(IntDir)</OutputDirectory>
<HeaderFileName>%(Filename).h</HeaderFileName>
<TypeLibraryName>%(Filename).tlb</TypeLibraryName>
<InterfaceIdentifierFileName>%(Filename)_i.c</InterfaceIdentifierFileName>
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
</Midl>
<Lib>
<AdditionalOptions>%(AdditionalOptions) /machine:X86</AdditionalOptions>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\zbar\decoder\qr_finder.c" />
<ClCompile Include="..\zbar\qrcode\qrdec.c" />
<ClCompile Include="..\zbar\qrcode\qrdectxt.c" />
<ClCompile Include="..\zbar\qrcode\rs.c" />
<ClCompile Include="..\zbar\qrcode\isaac.c" />
<ClCompile Include="..\zbar\qrcode\bch15_5.c" />
<ClCompile Include="..\zbar\qrcode\binarize.c" />
<ClCompile Include="..\zbar\qrcode\util.c" />
<ClCompile Include="..\zbar\processor\posix.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\zbar\symbol.c" />
<ClCompile Include="..\zbar\image.c" />
<ClCompile Include="..\zbar\video.c" />
<ClCompile Include="..\zbar\img_scanner.c" />
<ClCompile Include="..\zbar\scanner.c" />
<ClCompile Include="..\zbar\window.c" />
<ClCompile Include="..\zbar\decoder.c" />
<ClCompile Include="..\zbar\refcnt.c" />
<ClCompile Include="..\zbar\processor\lock.c" />
<ClCompile Include="..\zbar\processor.c" />
<ClCompile Include="..\zbar\convert.c" />
<ClCompile Include="..\zbar\error.c" />
<ClCompile Include="..\zbar\video\null.c">
<ObjectFileName>$(IntDir)/zbar/video/null.c.obj</ObjectFileName>
</ClCompile>
<ClCompile Include="..\zbar\processor\null.c">
<ObjectFileName>$(IntDir)/zbar/processor/null.c.obj</ObjectFileName>
</ClCompile>
<ClCompile Include="..\zbar\window\null.c">
<ObjectFileName>$(IntDir)/zbar/window/null.c.obj</ObjectFileName>
</ClCompile>
<ClInclude Include="..\include\zbar.h" />
<ClInclude Include="..\zbar\decoder\qr_finder.h" />
<ClInclude Include="..\zbar\qrcode.h" />
<ClInclude Include="..\zbar\qrcode\qrdec.h" />
<ClInclude Include="..\zbar\qrcode\rs.h" />
<ClInclude Include="..\zbar\qrcode\isaac.h" />
<ClInclude Include="..\zbar\qrcode\bch15_5.h" />
<ClInclude Include="..\zbar\qrcode\binarize.h" />
<ClInclude Include="..\zbar\qrcode\util.h" />
<ClInclude Include="..\zbar\error.h" />
<ClInclude Include="..\zbar\symbol.h" />
<ClInclude Include="..\zbar\image.h" />
<ClInclude Include="..\zbar\processor.h" />
<ClInclude Include="..\zbar\refcnt.h" />
<ClInclude Include="..\zbar\timer.h" />
<ClInclude Include="..\zbar\mutex.h" />
<ClInclude Include="..\zbar\event.h" />
<ClInclude Include="..\zbar\thread.h" />
<ClInclude Include="..\zbar\window.h" />
<ClInclude Include="..\zbar\video.h" />
<ClInclude Include="..\zbar\img_scanner.h" />
<ClInclude Include="..\zbar\decoder.h" />
<ClInclude Include="..\zbar\processor\posix.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

159
win32/zbar.vcxproj.filters Normal file
View File

@ -0,0 +1,159 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="..\zbar\decoder\qr_finder.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\qrcode\qrdec.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\qrcode\qrdectxt.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\qrcode\rs.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\qrcode\isaac.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\qrcode\bch15_5.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\qrcode\binarize.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\qrcode\util.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\processor\posix.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\symbol.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\image.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\video.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\img_scanner.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\scanner.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\window.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\decoder.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\refcnt.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\processor\lock.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\processor.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\convert.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\error.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\video\null.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\processor\null.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\zbar\window\null.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\zbar.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\decoder\qr_finder.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\qrcode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\qrcode\qrdec.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\qrcode\rs.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\qrcode\isaac.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\qrcode\bch15_5.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\qrcode\binarize.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\qrcode\util.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\error.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\symbol.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\image.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\processor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\refcnt.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\timer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\mutex.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\event.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\thread.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\window.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\video.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\img_scanner.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\decoder.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\zbar\processor\posix.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{D9FB3D00-FC7C-3F8E-9E0B-EFE1A211E8BA}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{138F32C6-425A-3C3C-BAB0-E030755D908D}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

29
win32/zbar_qrcode.sln Normal file
View File

@ -0,0 +1,29 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zbar", "zbar.vcxproj", "{E8072FB6-41C5-3D5C-A66F-329FB8A4D760}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
MinSizeRel|Win32 = MinSizeRel|Win32
Release|Win32 = Release|Win32
RelWithDebInfo|Win32 = RelWithDebInfo|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.Debug|Win32.ActiveCfg = Debug|Win32
{E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.Debug|Win32.Build.0 = Debug|Win32
{E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.MinSizeRel|Win32.ActiveCfg = MinSizeRel|Win32
{E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.MinSizeRel|Win32.Build.0 = MinSizeRel|Win32
{E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.Release|Win32.ActiveCfg = Release|Win32
{E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.Release|Win32.Build.0 = Release|Win32
{E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32
{E8072FB6-41C5-3D5C-A66F-329FB8A4D760}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8D6F4E6E-8DD9-3F7B-A6D2-1CF60CFCBF4B}
EndGlobalSection
EndGlobal

View File

@ -232,9 +232,10 @@ static inline unsigned decode_sortn (zbar_decoder_t *dcode,
unsigned wmin = UINT_MAX;
int jmin = -1, j;
for(j = n - 1; j >= 0; j--) {
unsigned w;
if((mask >> j) & 1)
continue;
unsigned w = get_width(dcode, i0 + j * 2);
w = get_width(dcode, i0 + j * 2);
if(wmin >= w) {
wmin = w;
jmin = j;

View File

@ -24,6 +24,9 @@
#include "error.h"
#include "image.h"
#include "refcnt.h"
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
zbar_image_t *zbar_image_create ()
{
@ -131,13 +134,14 @@ void zbar_image_set_crop (zbar_image_t *img,
unsigned w,
unsigned h)
{
unsigned img_h;
unsigned img_w = img->width;
if(x > img_w) x = img_w;
if(x + w > img_w) w = img_w - x;
img->crop_x = x;
img->crop_w = w;
unsigned img_h = img->height;
img_h = img->height;
if(y > img_h) y = img_h;
if(y + h > img_h) h = img_h - y;
img->crop_y = y;

View File

@ -657,10 +657,11 @@ int zbar_image_scanner_get_config(zbar_image_scanner_t *iscn,
return zbar_decoder_get_config(iscn->dcode, sym, cfg, val);
if(cfg < ZBAR_CFG_POSITION) {
int i;
if(sym == ZBAR_PARTIAL)
return(1);
int i = _zbar_get_symbol_hash(sym);
i = _zbar_get_symbol_hash(sym);
*val = iscn->sym_configs[cfg - ZBAR_CFG_UNCERTAINTY][i];
return 0;
@ -889,6 +890,8 @@ static void *_zbar_scan_image(zbar_image_scanner_t *iscn,
zbar_scanner_t *scn = iscn->scn;
unsigned w, h, cx1, cy1;
int density;
char filter;
int nean = 0, naddon = 0;
/* timestamp image
* FIXME prefer video timestamp
@ -1057,9 +1060,9 @@ static void *_zbar_scan_image(zbar_image_scanner_t *iscn,
/* FIXME tmp hack to filter bad EAN results */
/* FIXME tmp hack to merge simple case EAN add-ons */
char filter = (!iscn->enable_cache &&
filter = (!iscn->enable_cache &&
(density == 1 || CFG(iscn, ZBAR_CFG_Y_DENSITY) == 1));
int nean = 0, naddon = 0;
nean = 0, naddon = 0;
if(syms->nsyms) {
zbar_symbol_t **symp;
for(symp = &syms->head; *symp; ) {
@ -1100,6 +1103,8 @@ static void *_zbar_scan_image(zbar_image_scanner_t *iscn,
}
if(nean == 1 && naddon == 1 && iscn->ean_config) {
int datalen;
zbar_symbol_t *ean_sym;
/* create container symbol for composite result */
zbar_symbol_t *ean = NULL, *addon = NULL;
for(symp = &syms->head; *symp; ) {
@ -1120,8 +1125,8 @@ static void *_zbar_scan_image(zbar_image_scanner_t *iscn,
assert(ean);
assert(addon);
int datalen = ean->datalen + addon->datalen + 1;
zbar_symbol_t *ean_sym =
datalen = ean->datalen + addon->datalen + 1;
ean_sym =
_zbar_image_scanner_alloc_sym(iscn, ZBAR_COMPOSITE, datalen);
ean_sym->orient = ean->orient;
ean_sym->syms = _zbar_symbol_set_create();

View File

@ -54,14 +54,18 @@ static inline int proc_open (zbar_processor_t *proc)
int _zbar_process_image (zbar_processor_t *proc,
zbar_image_t *img)
{
int rc;
uint32_t force_fmt = proc->force_output;
if(img) {
uint32_t format;
zbar_image_t *tmp;
int nsyms;
if(proc->dumping) {
zbar_image_write(proc->window->image, "zbar");
proc->dumping = 0;
}
uint32_t format = zbar_image_get_format(img);
format = zbar_image_get_format(img);
zprintf(16, "processing: %.4s(%08" PRIx32 ") %dx%d @%p\n",
(char*)&format, format,
zbar_image_get_width(img), zbar_image_get_height(img),
@ -70,7 +74,7 @@ int _zbar_process_image (zbar_processor_t *proc,
/* FIXME locking all other interfaces while processing is conservative
* but easier for now and we don't expect this to take long...
*/
zbar_image_t *tmp = zbar_image_convert(img, fourcc('Y','8','0','0'));
tmp = zbar_image_convert(img, fourcc('Y','8','0','0'));
if(!tmp)
goto error;
@ -79,7 +83,7 @@ int _zbar_process_image (zbar_processor_t *proc,
proc->syms = NULL;
}
zbar_image_scanner_recycle_image(proc->scanner, img);
int nsyms = zbar_scan_image(proc->scanner, tmp);
nsyms = zbar_scan_image(proc->scanner, tmp);
_zbar_image_swap_symbols(img, tmp);
zbar_image_destroy(tmp);
@ -128,7 +132,7 @@ int _zbar_process_image (zbar_processor_t *proc,
}
/* display to window if enabled */
int rc = 0;
rc = 0;
if(proc->window) {
if((rc = zbar_window_draw(proc->window, img)))
err_copy(proc, proc->window);
@ -198,6 +202,7 @@ static ZTHREAD proc_video_thread (void *arg)
zprintf(4, "spawned video thread\n");
while(thread->started) {
zbar_image_t *img;
/* wait for video stream to be active */
while(thread->started && !proc->streaming)
_zbar_event_wait(&thread->notify, &proc->mutex, NULL);
@ -206,7 +211,7 @@ static ZTHREAD proc_video_thread (void *arg)
/* blocking capture image from video */
_zbar_mutex_unlock(&proc->mutex);
zbar_image_t *img = zbar_video_next_image(proc->video);
img = zbar_video_next_image(proc->video);
_zbar_mutex_lock(&proc->mutex);
if(!img && !proc->streaming)
@ -237,6 +242,7 @@ static ZTHREAD proc_video_thread (void *arg)
static ZTHREAD proc_input_thread (void *arg)
{
int rc = 0;
zbar_processor_t *proc = arg;
zbar_thread_t *thread = &proc->input_thread;
if(proc->window && proc_open(proc))
@ -247,7 +253,7 @@ static ZTHREAD proc_input_thread (void *arg)
_zbar_event_trigger(&thread->activity);
zprintf(4, "spawned input thread\n");
int rc = 0;
rc = 0;
while(thread->started && rc >= 0) {
_zbar_mutex_unlock(&proc->mutex);
rc = _zbar_processor_input_wait(proc, &thread->notify, -1);
@ -287,6 +293,8 @@ zbar_processor_t *zbar_processor_create (int threaded)
void zbar_processor_destroy (zbar_processor_t *proc)
{
proc_waiter_t *w, *next;
zbar_processor_init(proc, NULL, 0);
if(proc->syms) {
@ -305,7 +313,6 @@ void zbar_processor_destroy (zbar_processor_t *proc)
assert(!proc->wait_tail);
assert(!proc->wait_next);
proc_waiter_t *w, *next;
for(w = proc->free_waiter; w; w = next) {
next = w->next;
_zbar_event_destroy(&w->notify);
@ -320,6 +327,9 @@ int zbar_processor_init (zbar_processor_t *proc,
const char *dev,
int enable_display)
{
int rc = 0;
int video_threaded, input_threaded;
if(proc->video)
zbar_processor_set_active(proc, 0);
@ -338,7 +348,7 @@ int zbar_processor_init (zbar_processor_t *proc,
proc->window = NULL;
}
int rc = 0;
rc = 0;
if(proc->video) {
zbar_video_destroy(proc->video);
proc->video = NULL;
@ -378,7 +388,7 @@ int zbar_processor_init (zbar_processor_t *proc,
}
/* spawn blocking video thread */
int video_threaded = (proc->threaded && proc->video &&
video_threaded = (proc->threaded && proc->video &&
zbar_video_get_fd(proc->video) < 0);
if(video_threaded &&
_zbar_thread_start(&proc->video_thread, proc_video_thread, proc,
@ -389,7 +399,7 @@ int zbar_processor_init (zbar_processor_t *proc,
}
/* spawn input monitor thread */
int input_threaded = (proc->threaded &&
input_threaded = (proc->threaded &&
(proc->window ||
(proc->video && !video_threaded)));
if(input_threaded &&
@ -460,9 +470,10 @@ void zbar_processor_set_userdata (zbar_processor_t *proc,
void *zbar_processor_get_userdata (const zbar_processor_t *proc)
{
void *userdata;
zbar_processor_t *ncproc = (zbar_processor_t*)proc;
_zbar_mutex_lock(&ncproc->mutex);
void *userdata = (void*)ncproc->userdata;
userdata = (void*)ncproc->userdata;
_zbar_mutex_unlock(&ncproc->mutex);
return(userdata);
}
@ -472,8 +483,9 @@ int zbar_processor_set_config (zbar_processor_t *proc,
zbar_config_t cfg,
int val)
{
int rc;
proc_enter(proc);
int rc = zbar_image_scanner_set_config(proc->scanner, sym, cfg, val);
rc = zbar_image_scanner_set_config(proc->scanner, sym, cfg, val);
proc_leave(proc);
return(rc);
}
@ -482,12 +494,13 @@ int zbar_processor_set_control (zbar_processor_t *proc,
const char *control_name,
int value)
{
proc_enter(proc);
int rc;
int value_before, value_after;
proc_enter(proc);
if(_zbar_verbosity >= 4)
if(zbar_video_get_control(proc->video, control_name, &value_before)==0)
zprintf(0, "value of %s before a set: %d\n", control_name, value_before);
int rc = zbar_video_set_control(proc->video, control_name, value);
rc = zbar_video_set_control(proc->video, control_name, value);
if(_zbar_verbosity >= 4)
if(zbar_video_get_control(proc->video, control_name, &value_after)==0)
zprintf(0, "value of %s after a set: %d\n", control_name, value_after);
@ -499,8 +512,9 @@ int zbar_processor_get_control (zbar_processor_t *proc,
const char *control_name,
int *value)
{
int rc;
proc_enter(proc);
int rc = zbar_video_get_control(proc->video, control_name, value);
rc = zbar_video_get_control(proc->video, control_name, value);
proc_leave(proc);
return(rc);
}
@ -547,8 +561,9 @@ int zbar_processor_force_format (zbar_processor_t *proc,
int zbar_processor_is_visible (zbar_processor_t *proc)
{
int visible;
proc_enter(proc);
int visible = proc->window && proc->visible;
visible = proc->window && proc->visible;
proc_leave(proc);
return(visible);
}
@ -556,10 +571,10 @@ int zbar_processor_is_visible (zbar_processor_t *proc)
int zbar_processor_set_visible (zbar_processor_t *proc,
int visible)
{
int rc = 0;
proc_enter(proc);
_zbar_mutex_unlock(&proc->mutex);
int rc = 0;
if(proc->window) {
if(proc->video)
rc = _zbar_processor_set_size(proc,
@ -583,9 +598,10 @@ int zbar_processor_set_visible (zbar_processor_t *proc,
const zbar_symbol_set_t*
zbar_processor_get_results (const zbar_processor_t *proc)
{
const zbar_symbol_set_t *syms;
zbar_processor_t *ncproc = (zbar_processor_t*)proc;
proc_enter(ncproc);
const zbar_symbol_set_t *syms = proc->syms;
syms = proc->syms;
if(syms)
zbar_symbol_set_ref(syms, 1);
proc_leave(ncproc);
@ -595,10 +611,11 @@ zbar_processor_get_results (const zbar_processor_t *proc)
int zbar_processor_user_wait (zbar_processor_t *proc,
int timeout)
{
int rc = -1;
proc_enter(proc);
_zbar_mutex_unlock(&proc->mutex);
int rc = -1;
if(proc->visible || proc->streaming || timeout >= 0) {
zbar_timer_t timer;
rc = _zbar_processor_wait(proc, EVENT_INPUT,
@ -620,9 +637,9 @@ int zbar_processor_user_wait (zbar_processor_t *proc,
int zbar_processor_set_active (zbar_processor_t *proc,
int active)
{
int rc;
proc_enter(proc);
int rc;
if(!proc->video) {
rc = err_capture(proc, SEV_ERROR, ZBAR_ERR_INVALID, __func__,
"video input not initialized");
@ -660,11 +677,14 @@ int zbar_processor_set_active (zbar_processor_t *proc,
int zbar_process_one (zbar_processor_t *proc,
int timeout)
{
int streaming, rc;
zbar_timer_t timer;
proc_enter(proc);
int streaming = proc->streaming;
streaming = proc->streaming;
_zbar_mutex_unlock(&proc->mutex);
int rc = 0;
rc = 0;
if(!proc->video) {
rc = err_capture(proc, SEV_ERROR, ZBAR_ERR_INVALID, __func__,
"video input not initialized");
@ -677,7 +697,6 @@ int zbar_process_one (zbar_processor_t *proc,
goto done;
}
zbar_timer_t timer;
rc = _zbar_processor_wait(proc, EVENT_OUTPUT,
_zbar_timer_init(&timer, timeout));
@ -693,10 +712,11 @@ int zbar_process_one (zbar_processor_t *proc,
int zbar_process_image (zbar_processor_t *proc,
zbar_image_t *img)
{
int rc = 0;
proc_enter(proc);
_zbar_mutex_unlock(&proc->mutex);
int rc = 0;
if(img && proc->window)
rc = _zbar_processor_set_size(proc,
zbar_image_get_width(img),

View File

@ -99,6 +99,7 @@ static inline void proc_waiter_release (zbar_processor_t *proc,
int _zbar_processor_lock (zbar_processor_t *proc)
{
proc_waiter_t *waiter;
if(!proc->lock_level) {
proc->lock_owner = _zbar_thread_self();
proc->lock_level = 1;
@ -110,7 +111,7 @@ int _zbar_processor_lock (zbar_processor_t *proc)
return(0);
}
proc_waiter_t *waiter = proc_waiter_queue(proc);
waiter = proc_waiter_queue(proc);
_zbar_event_wait(&waiter->notify, &proc->mutex, NULL);
assert(proc->lock_level == 1);
@ -142,8 +143,8 @@ int _zbar_processor_unlock (zbar_processor_t *proc,
void _zbar_processor_notify (zbar_processor_t *proc,
unsigned events)
{
proc->wait_next = NULL;
proc_waiter_t *waiter;
proc->wait_next = NULL;
for(waiter = proc->wait_head; waiter; waiter = waiter->next)
waiter->events = ((waiter->events & ~events) |
(events & EVENT_CANCELED));
@ -159,11 +160,13 @@ static inline int proc_wait_unthreaded (zbar_processor_t *proc,
proc_waiter_t *waiter,
zbar_timer_t *timeout)
{
int rc;
int blocking = proc->streaming && zbar_video_get_fd(proc->video) < 0;
_zbar_mutex_unlock(&proc->mutex);
int rc = 1;
rc = 1;
while(rc > 0 && (waiter->events & EVENTS_PENDING)) {
int reltime;
/* FIXME lax w/the locking (though shouldn't matter...) */
if(blocking) {
zbar_image_t *img = zbar_video_next_image(proc->video);
@ -178,7 +181,7 @@ static inline int proc_wait_unthreaded (zbar_processor_t *proc,
zbar_image_destroy(img);
_zbar_mutex_unlock(&proc->mutex);
}
int reltime = _zbar_timer_check(timeout);
reltime = _zbar_timer_check(timeout);
if(blocking && (reltime < 0 || reltime > MAX_INPUT_BLOCK))
reltime = MAX_INPUT_BLOCK;
rc = _zbar_processor_input_wait(proc, NULL, reltime);
@ -191,13 +194,16 @@ int _zbar_processor_wait (zbar_processor_t *proc,
unsigned events,
zbar_timer_t *timeout)
{
int save_level;
proc_waiter_t *waiter;
int rc;
_zbar_mutex_lock(&proc->mutex);
int save_level = proc->lock_level;
proc_waiter_t *waiter = proc_waiter_queue(proc);
save_level = proc->lock_level;
waiter = proc_waiter_queue(proc);
waiter->events = events & EVENTS_PENDING;
_zbar_processor_unlock(proc, 1);
int rc;
if(proc->threaded)
rc = _zbar_event_wait(&waiter->notify, &proc->mutex, timeout);
else

View File

@ -100,33 +100,36 @@ const char *zbar_get_orientation_name (zbar_orientation_t orient)
int _zbar_get_symbol_hash (zbar_symbol_type_t sym)
{
static const signed char hash[ZBAR_CODE128 + 1] = {
[0 ... ZBAR_CODE128] = -1,
int h;
signed char hash[ZBAR_CODE128 + 1] = { 0 };
{
//[0 ... ZBAR_CODE128] = -1,
memset(hash, -1, sizeof(hash));
/* [ZBAR_FOO] = 0, is empty */
[ZBAR_SQCODE] = 1,
[ZBAR_CODE128] = 2,
[ZBAR_EAN13] = 3,
[ZBAR_UPCA] = 4,
[ZBAR_EAN8] = 5,
[ZBAR_UPCE] = 6,
[ZBAR_ISBN13] = 7,
[ZBAR_ISBN10] = 8,
[ZBAR_CODE39] = 9,
[ZBAR_I25] = 10,
[ZBAR_PDF417] = 11,
[ZBAR_QRCODE] = 12,
[ZBAR_DATABAR] = 13,
[ZBAR_DATABAR_EXP] = 14,
[ZBAR_CODE93] = 15,
[ZBAR_EAN2] = 16,
[ZBAR_EAN5] = 17,
[ZBAR_COMPOSITE] = 18,
[ZBAR_CODABAR] = 19,
hash[ZBAR_SQCODE] = 1,
hash[ZBAR_CODE128] = 2,
hash[ZBAR_EAN13] = 3,
hash[ZBAR_UPCA] = 4,
hash[ZBAR_EAN8] = 5,
hash[ZBAR_UPCE] = 6,
hash[ZBAR_ISBN13] = 7,
hash[ZBAR_ISBN10] = 8,
hash[ZBAR_CODE39] = 9,
hash[ZBAR_I25] = 10,
hash[ZBAR_PDF417] = 11,
hash[ZBAR_QRCODE] = 12,
hash[ZBAR_DATABAR] = 13,
hash[ZBAR_DATABAR_EXP] = 14,
hash[ZBAR_CODE93] = 15,
hash[ZBAR_EAN2] = 16,
hash[ZBAR_EAN5] = 17,
hash[ZBAR_COMPOSITE] = 18,
hash[ZBAR_CODABAR] = 19;
/* Please update NUM_SYMS accordingly */
};
int h;
}
assert (sym >= ZBAR_PARTIAL && sym <= ZBAR_CODE128);
@ -295,6 +298,7 @@ char *zbar_symbol_xml (const zbar_symbol_t *sym,
char **buf,
unsigned *len)
{
unsigned int mods, cfgs;
unsigned int datalen, maxlen;
int i, n = 0;
@ -321,10 +325,10 @@ char *zbar_symbol_xml (const zbar_symbol_t *sym,
maxlen = (MAX_STATIC + strlen(type) + strlen(orient) +
datalen + MAX_INT_DIGITS + 1);
unsigned int mods = sym->modifiers;
mods = sym->modifiers;
if(mods)
maxlen += MAX_MOD;
unsigned int cfgs = sym->configs & ~(1 << ZBAR_CFG_ENABLE);
cfgs = sym->configs & ~(1 << ZBAR_CFG_ENABLE);
if(cfgs)
maxlen += MAX_CFG;
if(binary)

View File

@ -35,7 +35,7 @@
# define HAVE_THREADS
# define ZTHREAD DWORD WINAPI
typedef ZTHREAD (zbar_thread_proc_t)(void*);
typedef DWORD (WINAPI zbar_thread_proc_t)(void*);
typedef DWORD zbar_thread_id_t;