56 Commits

Author SHA1 Message Date
Victor Derks
11a4308204
Resolve clang-tidy 19.1 warnings (#341) 2025-02-13 23:23:04 +01:00
Victor Derks
66a3605fd9
Add REUSE compatibility (#338)
- Follow the best practices of https://reuse.software/ to ensure BSD-3 licence is correctly applied.
- Add a badge to README.md
- Note: remove arm build as the CI pipeline is broken for this architecture
2024-12-04 12:33:36 +01:00
Dimitri Papadopoulos Orfanos
5a9b526180
Fix typos found by codespell (#335)
* Fix typos found by codespell

* Add missing >

---------

Co-authored-by: Victor Derks <vbaderks@gmail.com>
2024-09-25 22:59:02 +02:00
Victor Derks
b035a731f7
Rename headers from .h to .hpp to identify CharLS as a C++ project (#322)
To make it more clear to users and tooling that the project is a C++ project use the extension .hpp for pure C++ headers.
Add a new public header file charls.hpp. External C++ projects should this header file, C projects should still use charls.h.
2024-08-23 19:44:39 +02:00
Victor Derks
f2ff4448c2
Improve checked build of Visual Studio 2022 17.9 (#304) 2024-02-13 23:16:58 +01:00
Victor Derks
e48b26c5fd
Suppress warnings introduced with Visual Studio 2022 17.8.0 Preview 3.0 (#283) 2023-10-14 22:21:56 +02:00
Victor Derks
c4f429b900
Enable code coverage in CI pipeline (#279)
The Azure CI Pipeline can analyze code coverage when running the unit tests. Enable this option. It provides an additional tab on the CI status report. On this tab a single code coverage number is displayed. The .coverage file can be downloaded and opened in Visual Studio to get more insights.
Only the debug DLL is code covered as it provided a good report. The release build has too many optimalizations to provide a report that is useful. 

Note 1: The unit test DLL needs to link with the CharLS .obj files to make it possible to unit test low level methods. This means however the the unit test DLL needs to be code covered and not the actual CharLS DLL.

Note 2: the Cobertura format was also tested, but it didn't provide additional details (only more warnings and complexity)
Enable code coverage in CI pipeline
2023-06-16 14:05:51 +02:00
Victor Derks
80285e14e8
Replace uint8_t with std::byte in test projects (#238)
C++17 introduced std::byte. Use it to replace uint8_t that was used as C++14 was lacking a byte type.
2023-03-26 20:20:44 +02:00
Victor Derks
2c4d3f439c
Update version to 3.0.0 and minimum C++ version to 17 (#230)
The release of C++17 has been 5 years ago. The supported period of C++14 has ended and the minimum required C++ version will be increased to C++17 for building the library and using it.
2023-03-24 22:27:26 +01:00
Victor Derks
95b2e3684d
Enable signed returns for ARM64 platform (#215) 2022-12-28 21:25:42 +01:00
Victor Derks
d3fa929a27
Add support for deterministic builds with MSVC (#214) 2022-12-28 16:44:13 +01:00
Victor Derks
1e5b199c0a
Add support for ARM64 to MSBuild projects (#207)
Extend the MSBuild (Visual Studio) project with an ARM64 configuration.
Windows 11 for ARM64 is required to run the created binaries.
2022-12-10 16:08:47 +01:00
Victor Derks
e4e4ef8c3d
Resolve warnings reported by Visual Studio 2022 17.4.0 Preview 4.0 (#203) 2022-10-19 22:56:33 +02:00
Victor Derks
09bce5e65f
Improve the compatibility with VS static analyzers (#200)
Ensure that CharLS can be compiled with zero static analyzer warnings in VS2019 and VS2022.
VS2019 needs more explicit lambda capture.
2022-10-05 13:03:11 +02:00
Victor Derks
ea98d4b8b5
Use explicit ofstream.close() and replace static_cast with uniform initialization (#197)
The destructor of std::ofstream will close the stream, but not report any failures (by design).
Call close to trigger an exception when the close fails.

static_cast for constant values can be replaced with uniform initialization, this allows
to reduce the number of static_casts.

Change the bin+intermediate to be sub-directories of build for MSBuild builds.
This makes it easier to clean.
2022-09-24 20:23:44 +02:00
Victor Derks
4f80953a0d
Update for Visual Studio 2022 17.3 Preview 3.0 (#193)
Visual Studio 2022 17.3 Preview 3.0 comes with an updated clang-tidy and STL headers.
2022-07-14 22:10:39 +02:00
Victor Derks
2613ab21e6
Refactor jpeg_stream_reader (#133)
- Use a span to manage the segment data
- Use a forward iterator
- Parse the SOS segment directly.
- Do a size check when segment size is known, then read without size checks.
- Don't use std::vector to read bytes.
2022-01-08 22:17:02 +01:00
Victor Derks
0b3ac703e0
Backport C++20 countl_zero (#128)
Backport C++20 countl_zero

1) countl_zero can be used in peek_0_bits and is 2X faster.
Note: peek_0_bits is not on a hot path, overall gain is limited.

2) Apply updates for clang-tidy v13 (ships with VS 2022 17.1 Preview 2)

3) Increase upper range of supported CMake to 3.22
2022-01-06 16:06:23 +01:00
Victor Derks
01718e1ad1
Update warnings used by Clang and MSVC (#125)
Reserve the usage of Weverything and EnableAllWarnings for interactive development.
2022-01-03 23:44:58 +01:00
Victor Derks
42c3a585c5
Enable Control-flow Enforcement Technology (CET)
The latest MSVC compiler makes it possible to mark executable images CET compatible. Enable this opt-in option.
Note: CET is only enabled when the CPU, OS and the hosting process supports it.
2021-05-07 23:18:17 +02:00
Victor Derks
49d6a3afd4
Add /ZH:SHA_256 to Directory.Build.props
/ZH:SHA_256 is the recommended option to compute checksums for debug symbols.
2021-04-29 20:36:47 +02:00
Victor Derks
b0a628f385
Add a helper function check_argument
Add the helper function check_argument as a companion to check_operation. This allows also for positive boolean logic, like assert.
2021-04-24 13:12:28 +02:00
Victor Derks
8a7c68b29e
Add /PDBALTPATH:%_PDB% to release builds
/PDBALTPATH:%_PDB% strips the path info from the reference in the DLL to the pdb, makeing the build more deterministic.
2021-04-02 22:29:16 +02:00
Victor Derks
c4d6710f4d
Enable MSVC warnings that are now reliable detected
In the past some compiler warnings were disabled, as there were too many false warnings.
2021-01-10 16:48:17 +01:00
Victor Derks
6a30e19167
Mask high input bits during encoding
When encoding images ensure that only the valid bits are used. For bit size 16 and 8 there is no change and memcpy will be used.
Encoding with masking is not measurable slower.

Setting explicit InlineFunctionExpansion for debug needs to be removed as it prevents debugging.  For release mode it is also not needed as MaxSpeed will already enable it.

Mask high input bits during encoding (interleave_mode::sample)

Mask high input bits during encoding
2021-01-01 23:00:42 +01:00
Victor Derks
6019fbd0f7
Enable Control Flow Guard in CMake script + v3.13
- Control Flow Guard provides more security on the Windows platform.

- To use the add_link_options, the minimum required CMake version needs to be increased to v3.13
2020-12-30 15:27:18 +01:00
Victor Derks
824532797a
Move common project options to Directory.Build.props and enable CFG 2020-12-30 14:32:56 +01:00
Victor Derks
fa363837e0
Remove .NET adapter (moved to its own repository)
The .NET adapter has been moved to its own repository at https://github.com/team-charls/charls-native-dotnet

The .NET adapter in this repository was for .NET standard 2.0, which has been replaced by .net5.0
Having the .NET adapter in its own repository makes releasing easier and many uses case only require the "pure" C++ native library.
2020-11-13 21:42:01 +01:00
Victor Derks
723999ca2a
Introduce CHARLS_C_VOID to handle difference of void in API
C requires void when no parameters are used in a method. Modern  C++ doesn't use it. Use a macro to support both languages.
2020-10-03 12:10:51 +02:00
Victor Derks
9d4c213034
Add the /utf-8 switch to the MSVC compiler options to force reading source as utf-8
All C and C++ source code is encoded as utf-8 without a signature (bom). The GCC and clang compiler will read by default source code files in that format.
The MSVC compiler will look for a signature (bom), if non is found then the default system codepace encoding is used.
/utf-8 ensure that the correct source and executing encoding is used and that conversions are validated.

As no special characters are used in the source code, this is only a technical correction.
2020-09-25 22:35:29 +02:00
Victor Derks
c884847eca Make Checked build compatible with VS2019 16.7.0 Preview 3.1
The latest version of VS checks better if noexcept can be added to a constructor. Update the source for this improved checking.
2020-06-27 22:01:19 +02:00
Victor Derks
5622241242 Move VcpkgConfiguration to Directory.Build.props and static_cast 2020-05-23 18:56:45 +02:00
Victor Derks
03246ce081 Improve the compatibility with clang-tidy
Enable clang-tidy for the MSBuild checked build configuration. The CharLSUnitTest project is excluded as clang-tidy is extreme slow for this project.

The warning clang-diagnostic-sign-conversion requires more planning before this warning can be global enabled.
2020-03-18 08:39:53 +01:00
Victor Derks
9c2511261e Make version.h the single definition for version info
The version number was defined in charls.rc, CMakeLists.txt and version.h. Refactor to make it possible to only have the version number in version.h
Additional:
- convert the .rc file encoding to utf8 (improved git compatibility)
- add an additional DLL build for VS2015
- Remove linker warnings for VS2015 DLL x64 build
2020-01-30 22:03:28 +01:00
Victor Derks
bf0cdc7114 Replace strcpy with safe string_copy (SonarCloud)
Address feedback from the SonarCloud static analyzer, replace strcpy with a safe implementation. As no cross platform solution is available, introduce a #ifdef/#else based solution.

Also get rid of _CRT_SECURE_NO_WARNINGS by removing a not used function and using std::ifstream instead of fopen\fclose.
2019-12-17 14:36:33 +01:00
Victor Derks
839e0d0972 Enable MSVC All warnings that have been disabled in the past
The latest MSVC compiler is more conformant and the warnings have been improved. Enable warnings that have been disabled in the past because there too many false positives.
2019-11-09 13:28:22 +01:00
Victor Derks
e90209e8f2 Introduce an object-oriented C++ API based on a new C ABI
The current C API prevents adding new features and the introduction of an object oriented C++ interface. Every change results directly in a ABI break. To prevent this a new C API is introduced that is easier to extend and to maintain. On top of this API are 2 C++ classes: jpeg_encoder and jpeg_decoder to encode and decode JPEG-LS files.

This commit comes also with the following changes:
- Updated .clang-format
- Switch to Visual Studio 2019 for the CI build pipeline
- Support for reading and writing SPIFF header
- Incomplete support for JFIF header has been removed
- Extended unit test coverage
2019-11-08 21:56:38 +01:00
Victor Derks
d73dc1aba3 Update the projects for side-by-side building with VS 2019 Preview 2 2019-01-25 21:27:13 +01:00
Victor Derks
90f0d2dcda Rename unit test files (stdafx.h -> pch.h, etc)
Use modern C++ file naming convention.
2018-12-15 12:42:17 +01:00
Victor Derks
405426015b Upgrade to C# 7.3 (latest) 2018-12-14 22:00:11 +01:00
Victor Derks
cfb9ba7a7d Update WindowsTargetPlatformVersion to 10.0.17763.0
AppVeyor has updated their CI images, use the latest SDK.
2018-12-14 21:50:06 +01:00
Victor Derks
ca3737f838 Improve the compatibility with Visual Studio 2019 v16.0.0-pre.1.0
<RunCodeAnalysis> cannot be defined globally, as it should not be enabled for .NET projects.
Disable C++ checker C26487 as it generates too many false warnings.
Add missing <string> include
2018-12-05 00:04:19 +01:00
Victor Derks
3fbf361202 Remove legacy definitions from .vcxproj files 2018-11-24 15:17:26 +01:00
Victor Derks
cb6d12271b Replace the CharLSNetTest.csproj format with the new .NET project format.
Note: it is not possible to use .NET Core for this unit test project. Only 1 dotnet.exe can be in the path, and while both the x64 and x86 version can be installed, only 1 can be active. This makes it impossible to test both the x64 and the x86 build.

Other changes:
- Remove JpegLSBitmapDecoder (unsupported by .NET Core)
- Rename solution name from Win32 to x86 to ensure CI build works.
2018-11-21 21:50:48 +01:00
Victor Derks
c391025c82 Update CMake build files from 2.6 to modern CMake 3.9
The modern way of CMake build script has changed. To make CharLS more package friendly, update the overall CMake structure to modern CMake.
For the moment target CMake 3.9 as the minimum, as this version is available on the Travis CI build system.
Visual Studio 2017 15.9 Preview 4 is required on the Windows platform, but the Visual Studio solution file and MSBuild projects is on that platform the supported way to build CharLS.
2018-10-23 23:25:01 +02:00
Victor Derks
694dfa1a4e Move the interface headers to a namespace include folder
Modern practice is to move the interface header files to a include/<lib-name> folder. This prevents that header filenames conflict with other libraries. And it also allows client code to use #include <package-name\header-filename.h> constructions.
2018-10-11 21:12:39 +02:00
Jansen
6564751a3c Use Wall for MSVC and exclude non-useful warnings
W4 is the recommended warning level by Microsoft. Wall however provides some more checking and is useful to detect additional problems. It requires however that some informational warnings are disabled.
2018-08-02 16:23:36 +02:00
Victor Derks
9bb9a316de Correct reference to unit test checked x64 build 2018-05-31 14:15:05 +02:00
Victor Derks
a98ad3aaac Update reference to Win SDK to 10.0.17134.0 + MSBuildThisFileDirectory 2018-05-31 12:44:03 +02:00
Victor Derks
bdc8fd4d4f Update Windows Target platform to 10.0.16299.0 2017-11-01 22:14:17 +01:00