Skip to content

Commit

Permalink
Add missing #include <optional> to charls.ixx (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
vbaderks authored Jul 25, 2024
1 parent 19afb35 commit 1127459
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 33 deletions.
9 changes: 6 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Team CharLS.
# SPDX-License-Identifier: BSD-3-Clause

# Set default behavior to automatically normalize line endings.
* text=auto

Expand All @@ -17,8 +20,8 @@
*.pgm binary

# Export ignore all files that are only needed for git and CI (used when downloading the repository as a zip file).
.github export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
.appveyor.yml export-ignore
azure-pipelines.yml export-ignore
appveyor.yml export-ignore
azure-pipelines.yml export-ignore
10 changes: 2 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# GIT ignore file for CharLS
# Copyright (c) Team CharLS.
# SPDX-License-Identifier: BSD-3-Clause

.vscode/
.vs/
Expand All @@ -19,12 +20,5 @@ vcpkg_installed/
*.aps
*.sqlite

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/

# Ignore Coverity build folder
cov-int/
29 changes: 15 additions & 14 deletions doc/style_and_design.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,31 +130,32 @@ sense to define a good naming convention. Not all JPEG-LS names are good C++ var

### Supported C++ language

CharLS currently targets C++17 on the main branch. This will be done until December 2025 (5 years after the release of C++20)

#### Features currently not available (C++17)

* nodiscard attribute
* maybe_unused attribute
* Inline variables
* Guaranteed copy elision
* constexpr if-statements
* __has_include
* std::byte
* clamp ?
CharLS currently targets C++17 on the main branch. Upgrading to C++20 will be done when C++20 is used in
mainstream C++ development.

#### Features currently not available (C++20)

The following features are available in C++20 (usable after 2023), or in dual language support mode.
The following features are available in C++20, or in dual language support mode.

* endian
* \<span>
* modules
* [[likely]] and [[unlikely]]
* std::countl_zero

#### Features currently not available (C++23)

The following features are available in C++23, or in dual language support mode.

* std::byteswap
* import std;
* std::to_underlying
* std::unreachable

### Portable Anymap Format

The de facto standard used by the JPEG standard to deliver test files is the Portable Anymap Format.
This format has been made populair by the netpbm project. It is an extreme simple format and only
This format has been made popular by the netpbm project. It is an extreme simple format and only
designed to make it easy to exchange images on many platforms.
It consists of the following variants

Expand Down
1 change: 1 addition & 0 deletions include/charls/charls.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module;
#include <functional>
#include <memory>
#include <utility>
#include <optional>

export module charls;

Expand Down
19 changes: 11 additions & 8 deletions src/jpeg_stream_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,27 +458,28 @@ void jpeg_stream_reader::read_preset_coding_parameters()
void jpeg_stream_reader::read_oversize_image_dimension()
{
// Note: The JPEG-LS standard supports a 2,3 or 4 bytes for the size.
check_minimal_segment_size(2);
constexpr size_t pc_and_dimension_bytes{2};
check_minimal_segment_size(pc_and_dimension_bytes);
const uint8_t dimension_size{read_uint8()};

uint32_t height;
uint32_t width;
switch (dimension_size)
{
case 2:
check_segment_size(sizeof(uint16_t) * 2 + 2);
check_segment_size(pc_and_dimension_bytes + sizeof(uint16_t) * 2);
height = read_uint16();
width = read_uint16();
break;

case 3:
check_segment_size((sizeof(uint16_t) + 1) * 2 + 2);
check_segment_size(pc_and_dimension_bytes + (sizeof(uint16_t) + 1) * 2);
height = read_uint24();
width = read_uint24();
break;

case 4:
check_segment_size(sizeof(uint32_t) * 2 + 2);
check_segment_size(pc_and_dimension_bytes + sizeof(uint32_t) * 2);
height = read_uint32();
width = read_uint32();
break;
Expand All @@ -494,22 +495,24 @@ void jpeg_stream_reader::read_oversize_image_dimension()

void jpeg_stream_reader::read_mapping_table_specification()
{
check_minimal_segment_size(3);
constexpr size_t pc_table_id_entry_size_bytes{3};
check_minimal_segment_size(pc_table_id_entry_size_bytes);
const uint8_t table_id{read_uint8()};
const uint8_t entry_size{read_uint8()};

add_mapping_table(table_id, entry_size, segment_data_.subspan(3));
add_mapping_table(table_id, entry_size, segment_data_.subspan(pc_table_id_entry_size_bytes));
skip_remaining_segment_data();
}


void jpeg_stream_reader::read_mapping_table_continuation()
{
check_minimal_segment_size(3);
constexpr size_t pc_table_id_entry_size_bytes{3};
check_minimal_segment_size(pc_table_id_entry_size_bytes);
const uint8_t table_id{read_uint8()};
const uint8_t entry_size{read_uint8()};

extend_mapping_table(table_id, entry_size, segment_data_.subspan(3));
extend_mapping_table(table_id, entry_size, segment_data_.subspan(pc_table_id_entry_size_bytes));
skip_remaining_segment_data();
}

Expand Down

0 comments on commit 1127459

Please sign in to comment.