Skip to content

Commit 385f75e

Browse files
Merge branch 'aous72:master' into feature/add-openexr-support
2 parents ae77a31 + 51c736f commit 385f75e

20 files changed

+957
-525
lines changed

.github/workflows/ccp-workflow.yml

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# taken from https://github.com/onqtam/doctest/blob/master/.github/workflows/main.yml
22

33
name: C/C++ CI
4-
on:
4+
on:
55
push:
66
pull_request:
77
types: [opened, reopened]
@@ -64,6 +64,42 @@ jobs:
6464
run: cmake --build . --config Release
6565
working-directory: build
6666

67+
build_mingw:
68+
strategy:
69+
fail-fast: false
70+
matrix:
71+
include: [
72+
{ system: Windows-MinGW, runner: windows-latest },
73+
]
74+
name: ${{ matrix.system }} Build
75+
runs-on: ${{ matrix.runner }}
76+
steps:
77+
- uses: actions/checkout@v4
78+
- name: cmake
79+
run: cmake -G "MinGW Makefiles" -DOJPH_ENABLE_TIFF_SUPPORT=OFF -DOJPH_BUILD_STREAM_EXPAND=ON ..
80+
working-directory: build
81+
- name: build
82+
run: cmake --build . --config Release
83+
working-directory: build
84+
85+
build_windows_on_arm:
86+
strategy:
87+
fail-fast: false
88+
matrix:
89+
include: [
90+
{ system: WindowsOnARM, runner: windows-11-arm },
91+
]
92+
name: ${{ matrix.system }} Build
93+
runs-on: ${{ matrix.runner }}
94+
steps:
95+
- uses: actions/checkout@v4
96+
- name: cmake
97+
run: cmake -G "Visual Studio 17 2022" -A ARM64 -DOJPH_ENABLE_TIFF_SUPPORT=OFF -DOJPH_BUILD_STREAM_EXPAND=ON ..
98+
working-directory: build
99+
- name: build
100+
run: cmake --build . --config Release
101+
working-directory: build
102+
67103
test:
68104
strategy:
69105
fail-fast: false
@@ -86,7 +122,7 @@ jobs:
86122
- name: test
87123
run: ctest --output-on-failure
88124
working-directory: build
89-
125+
90126
test_windows:
91127
strategy:
92128
fail-fast: false
@@ -108,6 +144,50 @@ jobs:
108144
run: ctest --output-on-failure -C Release
109145
working-directory: build
110146

147+
# # MinGW tests needs debugging, as they are failing to pass in my test
148+
# test_MinGW:
149+
# strategy:
150+
# fail-fast: false
151+
# matrix:
152+
# include: [
153+
# { system: Windows, runner: windows-latest },
154+
# ]
155+
# name: ${{ matrix.system }} Test
156+
# runs-on: ${{ matrix.runner }}
157+
# steps:
158+
# - uses: actions/checkout@v4
159+
# - name: cmake
160+
# run: cmake -G "MinGW Makefiles" -DOJPH_ENABLE_TIFF_SUPPORT=OFF -DOJPH_BUILD_TESTS=ON ..
161+
# working-directory: build
162+
# - name: build
163+
# run: cmake --build . --config Release
164+
# working-directory: build
165+
# - name: test
166+
# run: ctest --output-on-failure -C Release
167+
# working-directory: build
168+
169+
test_windows_on_arm:
170+
strategy:
171+
fail-fast: false
172+
matrix:
173+
include: [
174+
{ system: WindowsOnARM, runner: windows-11-arm },
175+
]
176+
name: ${{ matrix.system }} Test
177+
runs-on: ${{ matrix.runner }}
178+
steps:
179+
- uses: actions/checkout@v4
180+
- name: cmake
181+
run: cmake -G "Visual Studio 17 2022" -A ARM64 -DOJPH_ENABLE_TIFF_SUPPORT=OFF -DOJPH_BUILD_TESTS=ON ..
182+
working-directory: build
183+
- name: build
184+
run: cmake --build . --config Release
185+
working-directory: build
186+
- name: test
187+
run: ctest --output-on-failure -C Release
188+
working-directory: build
189+
190+
111191
#jobs:
112192
# ci:
113193
# name: ${{ matrix.name }}

CMakeLists.txt

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set(CMAKE_MODULE_PATH
1818

1919
## Target architecture
2020
# We use the target architecture to help with arranging files in "source_group" commands.
21-
# The code does not use the results provided by target_arch.cmake, and relies, instead,
21+
# The code does not use the results provided by target_arch.cmake, and relies, instead,
2222
# on its own logic, which matches that in target_arch.cmake, to identify the architecture
2323
include(target_arch.cmake)
2424
target_architecture(OJPH_TARGET_ARCH)
@@ -64,8 +64,8 @@ if (DEFINED OJPH_DISABLE_INTEL_SIMD)
6464
"which is architecture agnostic. If you do not specify any, the default is "
6565
"OJPH_DISABLE_SIMD=OFF.")
6666
set(OJPH_DISABLE_SIMD ${OJPH_DISABLE_INTEL_SIMD})
67-
message(STATUS "OJPH_DISABLE_SIMD is set to ${OJPH_DISABLE_SIMD}")
68-
unset(OJPH_DISABLE_INTEL_SIMD)
67+
message(STATUS "OJPH_DISABLE_SIMD is set to ${OJPH_DISABLE_SIMD}")
68+
unset(OJPH_DISABLE_INTEL_SIMD)
6969
endif()
7070
if (DEFINED OJPH_ENABLE_INTEL_AVX512)
7171
message(STATUS "OJPH_ENABLE_INTEL_AVX512 is being deprecated, use \"OJPH_DISABLE_AVX512\" instead."
@@ -75,21 +75,21 @@ if (DEFINED OJPH_ENABLE_INTEL_AVX512)
7575
else()
7676
set(OJPH_DISABLE_AVX512 ON)
7777
endif()
78-
message(STATUS "OJPH_DISABLE_AVX512 is set to ${OJPH_DISABLE_AVX512}")
78+
message(STATUS "OJPH_DISABLE_AVX512 is set to ${OJPH_DISABLE_AVX512}")
7979
unset(OJPH_ENABLE_INTEL_AVX512)
8080
endif()
8181

8282
## Setting some of the options if EMSCRIPTEN is the compiler
83-
# In previous releases, the cmake script used to produce both non-SIMD and
84-
# SIMD builds in one go. At the time of this writing, all interpreters and
85-
# compilers of WASM code, such as web-browser and node, support SIMD, therefore
86-
# it is time to make the SIMD build the default. In other words, this cmake
83+
# In previous releases, the cmake script used to produce both non-SIMD and
84+
# SIMD builds in one go. At the time of this writing, all interpreters and
85+
# compilers of WASM code, such as web-browser and node, support SIMD, therefore
86+
# it is time to make the SIMD build the default. In other words, this cmake
8787
# script builds only WASM SIMD code by default, if desired, a non-SIMD build
88-
# can be generated using the OJPH_DISABLE_SIMD option (in this case, the
88+
# can be generated using the OJPH_DISABLE_SIMD option (in this case, the
8989
# WASM SIMD code is not generated).
9090
# It is worth remembering that the SIMD/non-SIMD issue arose because it is
9191
# NOT possible to have multiple execution paths in the code, one for non-SIMD
92-
# and one for SIMD, as we do for CPUs, letting the program select, at run-time,
92+
# and one for SIMD, as we do for CPUs, letting the program select, at run-time,
9393
# the best path to follow.
9494
if(EMSCRIPTEN)
9595
set(BUILD_SHARED_LIBS OFF)
@@ -126,16 +126,20 @@ message(STATUS "Building ${CMAKE_BUILD_TYPE}")
126126

127127
## C++ version and flags
128128
# C++14 is needed for gtest, otherwise, C++11 is sufficient for the library
129-
set(CMAKE_CXX_STANDARD 14)
129+
if (NOT CMAKE_CXX_STANDARD)
130+
set(CMAKE_CXX_STANDARD 14)
131+
endif()
132+
message(STATUS "C++ Standard is set to ${CMAKE_CXX_STANDARD}")
133+
130134
if (MSVC)
131135
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
132136
endif()
133137
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
134138
add_compile_options(
135-
-fexceptions
136-
-Wall
137-
-Wextra
138-
-Wconversion
139+
-fexceptions
140+
-Wall
141+
-Wextra
142+
-Wconversion
139143
-Wunused-parameter
140144
)
141145
endif()
@@ -177,6 +181,7 @@ else()
177181
endif()
178182

179183
## Build library and applications
184+
include(GNUInstallDirs)
180185
add_subdirectory(src/core)
181186
if (OJPH_BUILD_EXECUTABLES)
182187
add_subdirectory(src/apps)
@@ -186,8 +191,6 @@ endif()
186191
# Install
187192
################################################################################################
188193

189-
include(GNUInstallDirs)
190-
191194
install(EXPORT openjph-targets
192195
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/openjph
193196
)

docs/usage_examples.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ Here are some usage examples:
1616
* On Linux and MacOS, but NOT Windows, { and } need to be escaped; i.e, we need to write \\\{ and \\\}. So, -block\_size {64,64} must be written as -block\_size \\\{64,64\\\}.
1717
* When the source is a .yuv file, use -downsamp {1,1} for 4:4:4 sources. For 4:2:2 downsampling, specify -downsamp {1,1},{2,1}, and for 4:2:0 subsampling specify -downsamp {1,1},{2,2}. The source must have already been downsampled (i.e., OpenJPH does not downsample the source before compression, but can compress downsampled sources).
1818
* In Kakadu, pairs of data in command line arguments represent columns,rows. Here, a pair represents x,y information.
19+
* It came to my realization (See https://github.com/aous72/OpenJPH/issues/187) that there is an issue with files with `.raw` extension. Kakadu and OpenJPEG use `.raw` for big-endian data and `.rawl` for little-endian data -- This is only meaningful for data samples that are more than 1 byte. OpenJPH uses `.raw` for little-endian and there is no support for big-endian. I need to transition to the convention adopted by Kakadu and OpenJPEG; the plan to is to support `.rawl` first, and warning that `.raw` is currently little-endian, but the plan is to move to big-endian. Then, at a future point, the warning for `.raw` becomes that it is for big-endian. Then after a while this warning can be removed.
1920

src/apps/ojph_stream_expand/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## building ojph_stream_expand
22
##############################
33

4-
set(CMAKE_CXX_STANDARD 14)
4+
find_package(Threads)
55

66
file(GLOB OJPH_STREAM_EXPAND "*.cpp" "*.h")
77
file(GLOB OJPH_SOCKETS "../others/ojph_sockets.cpp")
@@ -17,10 +17,9 @@ source_group("common" FILES ${OJPH_SOCKETS_H} ${OJPH_THREADS_H})
1717

1818
add_executable(ojph_stream_expand ${SOURCES})
1919
target_include_directories(ojph_stream_expand PRIVATE ../common)
20-
if(MSVC)
21-
target_link_libraries(ojph_stream_expand PUBLIC openjph ws2_32)
22-
else()
23-
target_link_libraries(ojph_stream_expand PUBLIC openjph pthread)
24-
endif(MSVC)
20+
target_link_libraries(ojph_stream_expand PRIVATE openjph Threads::Threads)
21+
if(WIN32)
22+
target_link_libraries(ojph_stream_expand PRIVATE ws2_32)
23+
endif()
2524

2625
install(TARGETS ojph_stream_expand)

src/apps/others/ojph_sockets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ namespace ojph
127127
--ojph_socket_manager_counter;
128128
if (ojph_socket_manager_counter == 0)
129129
{
130-
#ifdef _MSC_VER
130+
#ifdef OJPH_OS_WINDOWS
131131
WSACleanup();
132132
#endif
133133
}

src/core/CMakeLists.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ else()
116116

117117
endif()
118118

119+
## Set debug postfix for different platforms
120+
if (MSVC)
121+
if (NOT DEFINED CMAKE_DEBUG_POSTFIX)
122+
set(CMAKE_DEBUG_POSTFIX "d")
123+
endif()
124+
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
125+
if (NOT DEFINED CMAKE_DEBUG_POSTFIX)
126+
set(CMAKE_DEBUG_POSTFIX "_d")
127+
endif()
128+
endif()
129+
119130
add_library(openjph ${SOURCES})
120131

121132
## The option BUILD_SHARED_LIBS
@@ -124,11 +135,9 @@ if (BUILD_SHARED_LIBS AND WIN32)
124135
endif()
125136

126137
## include library version/name
127-
if (NOT MSVC)
128-
target_compile_options(openjph PRIVATE -fPIC)
129-
endif()
138+
set_target_properties(openjph PROPERTIES POSITION_INDEPENDENT_CODE ON)
130139
target_compile_definitions(openjph PUBLIC _FILE_OFFSET_BITS=64)
131-
target_include_directories(openjph PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common> $<INSTALL_INTERFACE:include/openjph>)
140+
target_include_directories(openjph PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/common> $<INSTALL_INTERFACE:include>)
132141

133142
if (MSVC)
134143
set(OJPH_LIB_NAME_STRING "openjph.${OPENJPH_VERSION_MAJOR}.${OPENJPH_VERSION_MINOR}")

src/core/codestream/ojph_codestream.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
// This software is released under the 2-Clause BSD license, included
33
// below.
44
//
5-
// Copyright (c) 2019, Aous Naman
5+
// Copyright (c) 2019, Aous Naman
66
// Copyright (c) 2019, Kakadu Software Pty Ltd, Australia
77
// Copyright (c) 2019, The University of New South Wales, Australia
8-
//
8+
//
99
// Redistribution and use in source and binary forms, with or without
1010
// modification, are permitted provided that the following conditions are
1111
// met:
12-
//
12+
//
1313
// 1. Redistributions of source code must retain the above copyright
1414
// notice, this list of conditions and the following disclaimer.
15-
//
15+
//
1616
// 2. Redistributions in binary form must reproduce the above copyright
1717
// notice, this list of conditions and the following disclaimer in the
1818
// documentation and/or other materials provided with the distribution.
19-
//
19+
//
2020
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
2121
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2222
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
@@ -57,7 +57,9 @@ namespace ojph {
5757
////////////////////////////////////////////////////////////////////////////
5858
codestream::~codestream()
5959
{
60-
if (state) delete state;
60+
if (state)
61+
delete state;
62+
state = NULL;
6163
}
6264

6365
////////////////////////////////////////////////////////////////////////////
@@ -66,6 +68,13 @@ namespace ojph {
6668
state = new local::codestream;
6769
}
6870

71+
////////////////////////////////////////////////////////////////////////////
72+
void codestream::restart()
73+
{
74+
assert(state != NULL);
75+
state->restart();
76+
}
77+
6978
////////////////////////////////////////////////////////////////////////////
7079
param_siz codestream::access_siz()
7180
{
@@ -103,7 +112,7 @@ namespace ojph {
103112
}
104113

105114
////////////////////////////////////////////////////////////////////////////
106-
void codestream::set_tilepart_divisions(bool at_resolutions,
115+
void codestream::set_tilepart_divisions(bool at_resolutions,
107116
bool at_components)
108117
{
109118
ui32 value = 0;
@@ -147,7 +156,7 @@ namespace ojph {
147156
}
148157

149158
////////////////////////////////////////////////////////////////////////////
150-
void codestream::write_headers(outfile_base *file,
159+
void codestream::write_headers(outfile_base *file,
151160
const comment_exchange* comments,
152161
ui32 num_comments)
153162
{

0 commit comments

Comments
 (0)