Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
89d5699
thirdparty: add option to build libjpeg-turbo
boxerab Feb 10, 2023
bf95078
libtiff: use ExternalProject_Add
boxerab Feb 10, 2023
3222d8a
Revert "libtiff: use ExternalProject_Add"
boxerab Feb 10, 2023
b8f44c9
cleanup
boxerab Feb 10, 2023
11ef0bc
INSTALL: update
boxerab Feb 10, 2023
d3ea45d
libtiff: v4.5.0
boxerab Feb 10, 2023
ec9a081
INSTALL: remove obsolete section on windows libjpeg-turbo builds
boxerab Feb 11, 2023
02588f9
INSTALL: update
boxerab Feb 11, 2023
ff0afeb
build: enable position independant code
boxerab Feb 11, 2023
f82bbaa
CI: install exiftool for ubuntu and macOS
boxerab Feb 11, 2023
f360c26
build: skip turbojpeg build
boxerab Feb 11, 2023
743f435
cmake: opencl
boxerab Feb 11, 2023
5bfa670
cmake: opencl update
boxerab Feb 12, 2023
2bc7461
plugin loader: link to dl libs
boxerab Feb 12, 2023
40ed480
cleanup
boxerab Feb 13, 2023
d5a12e7
compress: disable SOP markers if tile can't be compressed at given ratio
boxerab Feb 13, 2023
f9900d3
use reverse find to find file tag
boxerab Feb 13, 2023
a1f671b
log name of compressed file
boxerab Feb 13, 2023
97dc5da
exif: warn user if tags cannot be transferred
boxerab Feb 13, 2023
be1645a
Revert "compress: disable SOP markers if tile can't be compressed at …
boxerab Feb 14, 2023
6f157c5
compress: pad rate for small tiles with SOP and/or EPH marker overhead
boxerab Feb 14, 2023
066f8f4
cleanup
boxerab Feb 14, 2023
4ecefe6
T2: add debug flag
boxerab Feb 14, 2023
536f39b
compress: fine tune padding for small tiles
boxerab Feb 14, 2023
0613870
compress: handle SOP/EPH padding in simple rate control algorithm
boxerab Feb 14, 2023
4981afa
compress: improve padding calculation for small tiles
boxerab Feb 15, 2023
82fcb0d
rate control: don't recalculate layer if allocation hasn't changed
boxerab Feb 19, 2023
90dc01c
API: grk_image_new: add flag to control buffer allocation
boxerab Feb 19, 2023
2c73985
compress: simplify
boxerab Feb 19, 2023
ac26746
cmake: replace CMAKE_BINARY_DIR with CMAKE_CURRENT_BINARY_DIR
boxerab Feb 20, 2023
c4ba87b
tests
boxerab Feb 20, 2023
b80b2d6
libpng: update
boxerab Feb 20, 2023
83c2534
libz-ng: update
boxerab Feb 20, 2023
e135578
examples: improve
boxerab Feb 21, 2023
afc62ce
API: simplify
boxerab Feb 21, 2023
923ee43
API: initialize returns void
boxerab Feb 21, 2023
87004ce
GrkImage: set default image dimension to first component dimensions
boxerab Feb 21, 2023
8d44c50
examples
boxerab Feb 21, 2023
c9db4e9
fuzzer: fix build
boxerab Feb 21, 2023
4e3a1c4
memstream: only detect format for read stream
boxerab Feb 21, 2023
0d6462a
examples: fix compress to buf
boxerab Feb 21, 2023
d7b9cbf
compress: return length of compressed image
boxerab Feb 21, 2023
9798f10
examples
boxerab Feb 21, 2023
bdde69e
examples: add codec compress
boxerab Feb 22, 2023
2cec38d
codec: allow compress to accept an in-memory image as input
boxerab Feb 22, 2023
bb12104
compress: option to output to buffer
boxerab Feb 22, 2023
6233666
lcms2: update
boxerab Feb 23, 2023
6e659e7
code reformat
boxerab Feb 23, 2023
a221f6b
synch with ojph
boxerab Feb 24, 2023
bab3ddd
OpenHTJ2K: remove
boxerab Feb 24, 2023
5baf9c9
fix windows plugin build
boxerab Feb 25, 2023
b126cee
ensure that format is always initialized
boxerab Feb 25, 2023
3898723
out of scope
boxerab Feb 28, 2023
50cc574
fix plugin single decode crash
boxerab Mar 4, 2023
8ee58f3
rate control: disable if fails on tile with EPH or SOP markers
boxerab Mar 6, 2023
99d3a25
Disable rate control on tiles where rate control fails due to small s…
boxerab Mar 15, 2023
81759b2
refactor to clarify max layers vs layers to decompress
boxerab Mar 15, 2023
cdb3b94
bump version to 10.0.6
boxerab Mar 15, 2023
21982bf
Merge tag 'v10.0.6' into debian-packaging-master-v10.0.6
mgeerdsen Mar 16, 2023
9b68401
do not build libjpeg-turbo library
mgeerdsen Mar 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ jobs:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 \
--slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
echo DATA_BRANCH=linux-release >> $GITHUB_ENV
sudo apt install exiftool


- name: macos-dependencies
if: startsWith(matrix.os, 'macos')
run: |
echo DATA_BRANCH=osx >> $GITHUB_ENV
brew upgrade
brew install exiftool
#perl -MImage::ExifTool -e ""

- name: windows-dependencies
if: startsWith(matrix.os, 'windows')
Expand Down
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ project(GROK)
# GROK version
set(GROK_VERSION_MAJOR 10)
set(GROK_VERSION_MINOR 0)
set(GROK_VERSION_BUILD 5)
set(GROK_VERSION_BUILD 6)
set(GROK_VERSION
"${GROK_VERSION_MAJOR}.${GROK_VERSION_MINOR}.${GROK_VERSION_BUILD}")
set(PACKAGE_VERSION
Expand Down Expand Up @@ -58,11 +58,18 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"MinSizeRel" "RelWithDebInfo")
endif()

include(CheckPIESupported OPTIONAL RESULT_VARIABLE CHECK_PIE_SUPPORTED)
check_pie_supported(LANGUAGES CXX)
if(CMAKE_CXX_LINK_PIE_SUPPORTED)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
endif()

# Path to additional CMake modules
set(CMAKE_MODULE_PATH
${GROK_SOURCE_DIR}/cmake
${CMAKE_MODULE_PATH})

include (ExternalProject)
# Install directories
include(GNUInstallDirs)
string(TOLOWER ${PROJECT_NAME} projectname)
Expand All @@ -80,8 +87,8 @@ endif()

# Grok build configuration options.
option(BUILD_SHARED_LIBS "Build Grok shared library and link executables against it." ON)
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
set (LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
set (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
set (LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
mark_as_advanced(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)

# Compiler specific flags:
Expand Down Expand Up @@ -111,6 +118,7 @@ include(CheckSymbolExists)
option(GRK_BUILD_LIBPNG "Build libpng library" ON)
option(GRK_BUILD_LIBTIFF "Build libtiff library" ON)
option(GRK_BUILD_LCMS2 "Build lcms2 library" ON)
option(GRK_BUILD_JPEG "Build jpeg library" ON)
add_subdirectory(thirdparty)

# Build Library
Expand Down
35 changes: 11 additions & 24 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@

If the `-V` flag is used to transfer ExIF tags to the output file, [ExifTool](https://exiftool.org/) must be installed.

### Linux/MacOS
### Linux

Follow installation instructions on the ExifTool site.
Use your package manager to install ExifTool. This will ensure that the ExifTool Perl modules
are correctly installed

### Windows
### MacOS

Use [brew](https://brew.sh/) package manager to install ExifTool. This will ensure that the ExifTool Perl modules are correctly installed

1. install [Strawberry Perl](https://strawberryperl.com/)
1. download and extract platform-independant [ExifTool tarball](https://exiftool.org)
1. open `lib` folder inside extracted folder and copy `Image` and `Exiftool` folders to `C:\Strawberry\perl\site\lib`
1. to validate that the ExifTool Perl modules were installed correctly, open a command line shell and run `perl -MImage::ExifTool -e " "`. If there is no output, then installation succeeded.
### Windows

`-V` is not supported on Windows. To transfer tags, simply run
`$ exiftool -TagsFromFile $SOURCE_FILE "-all:all>all:all" $DEST_FILE`
after running Grok.

# Install from Package Manager

Expand Down Expand Up @@ -210,20 +213,4 @@ Type `cmake --help` for available generators on your platform.
Third party libraries such as `libtiff` are built by default. To disable
`libtiff` library build and use the version installed on your system, set :

`-DGRK_BUILD_LiBTIFF:BOOL=OFF`

#### JPEG Support

To encode and decode JPEG files, a `libjpeg`-compatible library
(`-dev` version) must be installed.
Recommended library : [libjpeg-turbo](https://github.com/libjpeg-turbo/libjpeg-turbo)
On Debian systems, the `libjpeg-turbo8-dev` package will provide a development
version of this library.

##### Grok dynamic build with JPEG support (Windows)

`libjpeg-turbo` must be built with the `WITH_CRT_DLL` flag on, to ensure that the dynamic version of the C runtime libraries is used. Also, if Grok is linking with dynamic build of `libjpeg-turbo`, (`cmake` flag `JPEG_LIBRARY` is set to `LIBJPEG_INSTALL_DIRECTORY/jpeg.lib`), then make sure that `LIBJPEG_INSTALL_DIRECTORY/bin` is on the path.

##### Grok static build with JPEG support (Windows)

`libjpeg-turbo` must be built with the `WITH_CRT_DLL` flag off, to ensure that the static version of the C runtime libraries is used.
`-DGRK_BUILD_LiBTIFF:BOOL=OFF`
3 changes: 2 additions & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ CMAKE_EXTRA_FLAGS += -DCMAKE_SKIP_RPATH=ON \
-DGRK_BUILD_DOC:BOOL=ON \
-DGRK_BUILD_LCMS2:BOOL=OFF \
-DGRK_BUILD_LIBPNG:BOOL=OFF \
-DGRK_BUILD_LIBTIFF:BOOL=OFF
-DGRK_BUILD_LIBTIFF:BOOL=OFF \
-DGRK_BUILD_JPEG:BOOL=OFF

override_dh_auto_configure:
dh_auto_configure -- $(CMAKE_EXTRA_FLAGS)
Expand Down
14 changes: 7 additions & 7 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ find_package(Doxygen)
if(DOXYGEN_FOUND)
# Configure the doxygen config file with variable from CMake and move it
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.dox.cmake.in
${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox @ONLY)
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-html.dox @ONLY)

# Configure the html mainpage file of the doxygen documentation with variable
# from CMake and move it
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mainpage.dox.in
${CMAKE_BINARY_DIR}/doc/mainpage.dox @ONLY)
${CMAKE_CURRENT_BINARY_DIR}/mainpage.dox @ONLY)

file(GLOB headers
${GROK_SOURCE_DIR}/src/lib/core/*.h
Expand All @@ -22,18 +22,18 @@ if(DOXYGEN_FOUND)
# Generate new target to build the html documentation
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/index.html
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox
DEPENDS ${CMAKE_BINARY_DIR}/doc/Doxyfile-html.dox
${CMAKE_BINARY_DIR}/doc/mainpage.dox
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-html.dox
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile-html.dox
${CMAKE_CURRENT_BINARY_DIR}/mainpage.dox
${headers}
)
add_custom_target(doc ALL
DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html/index.html
COMMENT "Building doxygen documentation"
)

# install HTML documentation (install png files too):
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/html
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
DESTINATION ${CMAKE_INSTALL_DOCDIR}
)
else()
Expand Down
4 changes: 2 additions & 2 deletions doc/Doxyfile.dox.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = Grok
PROJECT_NUMBER = @GROK_VERSION@
OUTPUT_DIRECTORY = @CMAKE_BINARY_DIR@/doc
OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
Expand Down Expand Up @@ -97,7 +97,7 @@ WARN_LOGFILE =
#---------------------------------------------------------------------------
INPUT = @GROK_SOURCE_DIR@/src/lib/core \
@GROK_SOURCE_DIR@/src/lib/plugin \
@CMAKE_BINARY_DIR@/doc
@CMAKE_CURRENT_BINARY_DIR@/doc
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.h \
*.c \
Expand Down
8 changes: 5 additions & 3 deletions examples/codec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
include_directories(
${GROK_SOURCE_DIR}/src/lib/codec
${CMAKE_BINARY_DIR}/src/lib/core
${CMAKE_CURRENT_BINARY_DIR}/../../src/lib/core
${GROK_SOURCE_DIR}/src/lib/core
${CMAKE_CURRENT_BINARY_DIR}/../
)

foreach(exe codec_decompress_from_file_to_tiff)
foreach(exe codec_decompress_from_file
codec_compress
)
add_executable(${exe} ${exe}.cpp)
target_compile_options(${exe} PRIVATE ${GROK_COMPILE_OPTIONS})
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
Expand All @@ -18,7 +20,7 @@ foreach(exe codec_decompress_from_file_to_tiff)
target_compile_options(${exe} PUBLIC -matomics)
endif()

target_link_libraries(${exe} ${GROK_CODEC_NAME})
target_link_libraries(${exe} ${GROK_CODEC_NAME} ${GROK_CORE_NAME})

if(URING)
target_link_libraries(${exe} uring)
Expand Down
167 changes: 167 additions & 0 deletions examples/codec/codec_compress.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/*
* Copyright (C) 2016-2023 Grok Image Compression Inc.
*
* This source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <string>
#include <cstring>
#include <vector>
#include <filesystem>

#include "grok.h"
#include "grok_codec.h"
#include "grk_examples_config.h"

const std::string dataRoot = GRK_DATA_ROOT;

int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
{
const uint32_t dimX = 640;
const uint32_t dimY = 480;
const uint32_t numComps = 3;
const uint32_t precision = 8;
grk_image_comp* compParams = nullptr;
grk_image *image = nullptr;
grk_stream_params out_buffer;
memset(&out_buffer,0,sizeof(out_buffer));

bool inputFromImage = true;
bool outputToBuffer = true;

if (outputToBuffer) {
out_buffer.len = (size_t)numComps * (precision/8) * dimX * dimY;
out_buffer.buf = new uint8_t[out_buffer.len];
}

std::vector<std::string> argString;
std::vector<char *> args;

std::string inputFile, outputFile;
int rc = 1;

if (inputFromImage) {
// create blank image
compParams = new grk_image_comp[numComps];
for (uint32_t i = 0; i < numComps; ++i){
auto c = compParams + i;
c->w = dimX;
c->h = dimY;
c->dx = 1;
c->dy = 1;
c->prec = precision;
c->sgnd = false;
}
image = grk_image_new(numComps, compParams, GRK_CLRSPC_SRGB, true);

// fill in component data
// see grok.h header for full details of image structure
for (uint16_t compno = 0; compno < image->numcomps; ++compno){
auto comp = image->comps + compno;
auto compWidth = comp->w;
auto compHeight = comp->h;
auto compData = comp->data;
if (!compData){
fprintf(stderr, "Image has null data for component %d\n",compno);
goto beach;
}
// fill in component data, taking component stride into account
auto srcData = new int32_t[compWidth * compHeight];
auto srcPtr = srcData;
for (uint32_t j = 0; j < compHeight; ++j) {
memcpy(compData, srcPtr, compWidth * sizeof(int32_t));
srcPtr += compWidth;
compData += comp->stride;
}
delete[] srcData;
}
}

//1. form vector of command line args

// first entry must always be the name of the program, as is
// required by argv/argc variables in main method
argString.push_back("codec_compress");

// verbose output
argString.push_back("-v");

// a file can be passed in as a command line argument
// example:
// $ codec_compress foo.tif
// otherwise a file from the Grok test suite, specified below, will be used.

inputFile = dataRoot + std::filesystem::path::preferred_separator +
"input" + std::filesystem::path::preferred_separator +
"nonregression" + std::filesystem::path::preferred_separator + "basn6a08.tif";
outputFile = "basn6a08.jp2";
if (argc > 1) {
inputFile = argv[1];
outputFile = inputFile + ".tif";
}
if (!inputFromImage) {
argString.push_back("-i " + inputFile);
}

if (outputToBuffer) {
argString.push_back("-out_fmt jp2");
} else {
argString.push_back("-o " + outputFile);
}

// 2. convert to array of C strings
for (auto& s : argString){
char *arg = new char[s.size() + 1];
copy(s.begin(), s.end(), arg);
arg[s.size()] = '\0';
args.push_back(arg);
}

// 3. decompress
rc = grk_codec_compress((int)args.size(),&args[0], image,
outputToBuffer ? &out_buffer : nullptr);
if (rc)
fprintf(stderr, "Failed to compress\n");

if (outputToBuffer)
printf("Compressed to memory : %ld bytes\n",out_buffer.buf_compressed_len);

// write buffer to file
if (outputToBuffer) {
auto fp = fopen(outputFile.c_str(), "wb");
if(!fp)
{
fprintf(stderr,"Buffer compress: failed to open file %s for writing", outputFile.c_str());
}
else
{
size_t written = fwrite(out_buffer.buf, 1, out_buffer.buf_compressed_len, fp);
if(written != out_buffer.buf_compressed_len)
{
fprintf(stderr,"Buffer compress: only %ld bytes written out of %ld total", out_buffer.buf_compressed_len,
written);
}
fclose(fp);
}
}

beach:
//4. cleanup
for (auto& s : args)
delete[] s;
delete[] compParams;
delete[] out_buffer.buf;
grk_object_unref(&image->obj);

return rc;
}
Loading