Skip to content

Commit

Permalink
Merge pull request #134 from aous72/dfs_atk_support
Browse files Browse the repository at this point in the history
Adding DFS support and partial support for ATK to support low-latency HTJ2K images.
  • Loading branch information
aous72 committed Apr 14, 2024
2 parents df12e7f + 9345152 commit 4e13575
Show file tree
Hide file tree
Showing 39 changed files with 5,187 additions and 2,603 deletions.
3 changes: 2 additions & 1 deletion src/apps/ojph_compress/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ source_group("others" FILES ${OJPH_IMG_IO})
source_group("common" FILES ${OJPH_IMG_IO_H})

if(EMSCRIPTEN)
add_compile_options(-std=c++11 -O3 -fexceptions -DOJPH_DISABLE_INTEL_SIMD)
add_compile_options(-std=c++11 -O3 -fexceptions)
add_link_options(-sWASM=1 -sASSERTIONS=1 -sALLOW_MEMORY_GROWTH=1 -sNODERAWFS=1 -sENVIRONMENT=node -sEXIT_RUNTIME=1 -sEXCEPTION_CATCHING_ALLOWED=['fake'])
add_executable(ojph_compress ${SOURCES})
add_executable(ojph_compress_simd ${SOURCES} ${OJPH_IMG_IO_SSE4})
target_compile_options(ojph_compress_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1)
Expand Down
98 changes: 49 additions & 49 deletions src/apps/ojph_compress/ojph_compress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,55 +917,55 @@ int main(int argc, char * argv[]) {
}
else if (is_matching(".dpx", v))
{
dpx.open(input_filename);
ojph::param_siz siz = codestream.access_siz();
siz.set_image_extent(ojph::point(image_offset.x + dpx.get_size().w,
image_offset.y + dpx.get_size().h));
ojph::ui32 num_comps = dpx.get_num_components();
siz.set_num_components(num_comps);
//if (num_bit_depths > 0)
// dpx.set_bit_depth(num_bit_depths, bit_depth);
for (ojph::ui32 c = 0; c < num_comps; ++c)
siz.set_component(c, dpx.get_comp_subsampling(c),
dpx.get_bit_depth(c), dpx.get_is_signed(c));
siz.set_image_offset(image_offset);
siz.set_tile_size(tile_size);
siz.set_tile_offset(tile_offset);

ojph::param_cod cod = codestream.access_cod();
cod.set_num_decomposition(num_decompositions);
cod.set_block_dims(block_size.w, block_size.h);
if (num_precincts != -1)
cod.set_precinct_size(num_precincts, precinct_size);
cod.set_progression_order(prog_order);
if (employ_color_transform == -1 && num_comps >= 3)
cod.set_color_transform(true);
else
cod.set_color_transform(employ_color_transform == 1);
cod.set_reversible(reversible);
if (!reversible && quantization_step != -1)
codestream.access_qcd().set_irrev_quant(quantization_step);
codestream.set_planar(false);
if (profile_string[0] != '\0')
codestream.set_profile(profile_string);
codestream.set_tilepart_divisions(tileparts_at_resolutions,
tileparts_at_components);
codestream.request_tlm_marker(tlm_marker);

if (dims.w != 0 || dims.h != 0)
OJPH_WARN(0x01000071,
"-dims option is not needed and was not used\n");
if (num_components != 0)
OJPH_WARN(0x01000072,
"-num_comps is not needed and was not used\n");
if (is_signed[0] != -1)
OJPH_WARN(0x01000073,
"-signed is not needed and was not used\n");
if (comp_downsampling[0].x != 0 || comp_downsampling[0].y != 0)
OJPH_WARN(0x01000075,
"-downsamp is not needed and was not used\n");

base = &dpx;
dpx.open(input_filename);
ojph::param_siz siz = codestream.access_siz();
siz.set_image_extent(ojph::point(image_offset.x + dpx.get_size().w,
image_offset.y + dpx.get_size().h));
ojph::ui32 num_comps = dpx.get_num_components();
siz.set_num_components(num_comps);
//if (num_bit_depths > 0)
// dpx.set_bit_depth(num_bit_depths, bit_depth);
for (ojph::ui32 c = 0; c < num_comps; ++c)
siz.set_component(c, dpx.get_comp_subsampling(c),
dpx.get_bit_depth(c), dpx.get_is_signed(c));
siz.set_image_offset(image_offset);
siz.set_tile_size(tile_size);
siz.set_tile_offset(tile_offset);

ojph::param_cod cod = codestream.access_cod();
cod.set_num_decomposition(num_decompositions);
cod.set_block_dims(block_size.w, block_size.h);
if (num_precincts != -1)
cod.set_precinct_size(num_precincts, precinct_size);
cod.set_progression_order(prog_order);
if (employ_color_transform == -1 && num_comps >= 3)
cod.set_color_transform(true);
else
cod.set_color_transform(employ_color_transform == 1);
cod.set_reversible(reversible);
if (!reversible && quantization_step != -1)
codestream.access_qcd().set_irrev_quant(quantization_step);
codestream.set_planar(false);
if (profile_string[0] != '\0')
codestream.set_profile(profile_string);
codestream.set_tilepart_divisions(tileparts_at_resolutions,
tileparts_at_components);
codestream.request_tlm_marker(tlm_marker);

if (dims.w != 0 || dims.h != 0)
OJPH_WARN(0x01000071,
"-dims option is not needed and was not used\n");
if (num_components != 0)
OJPH_WARN(0x01000072,
"-num_comps is not needed and was not used\n");
if (is_signed[0] != -1)
OJPH_WARN(0x01000073,
"-signed is not needed and was not used\n");
if (comp_downsampling[0].x != 0 || comp_downsampling[0].y != 0)
OJPH_WARN(0x01000075,
"-downsamp is not needed and was not used\n");

base = &dpx;
}
else
#if defined( OJPH_ENABLE_TIFF_SUPPORT)
Expand Down
3 changes: 2 additions & 1 deletion src/apps/ojph_expand/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ source_group("others" FILES ${OJPH_IMG_IO})
source_group("common" FILES ${OJPH_IMG_IO_H})

if(EMSCRIPTEN)
add_compile_options(-std=c++11 -O3 -fexceptions -DOJPH_DISABLE_INTEL_SIMD)
add_compile_options(-std=c++11 -O3 -fexceptions)
add_link_options(-sWASM=1 -sASSERTIONS=1 -sALLOW_MEMORY_GROWTH=1 -sNODERAWFS=1 -sENVIRONMENT=node -sEXIT_RUNTIME=1 -sEXCEPTION_CATCHING_ALLOWED=['fake'])
add_executable(ojph_expand ${SOURCES})
add_executable(ojph_expand_simd ${SOURCES} ${OJPH_IMG_IO_SSE4})
target_compile_options(ojph_expand_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128 -msse4.1)
Expand Down
11 changes: 7 additions & 4 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ file(GLOB TRANSFORM_SSE "transform/*_sse.cpp")
file(GLOB TRANSFORM_SSE2 "transform/*_sse2.cpp")
file(GLOB TRANSFORM_AVX "transform/*_avx.cpp")
file(GLOB TRANSFORM_AVX2 "transform/*_avx2.cpp")
file(GLOB TRANSFORM_AVX512 "transform/*_avx512.cpp")
file(GLOB TRANSFORM_WASM "transform/*_wasm.cpp")

list(REMOVE_ITEM CODESTREAM ${CODESTREAM_SSE} ${CODESTREAM_SSE2} ${CODESTREAM_AVX} ${CODESTREAM_AVX2} ${CODESTREAM_WASM})
list(REMOVE_ITEM CODING ${CODING_SSSE3} ${CODING_WASM} ${CODING_AVX512})
list(REMOVE_ITEM TRANSFORM ${TRANSFORM_SSE} ${TRANSFORM_SSE2} ${TRANSFORM_AVX} ${TRANSFORM_AVX2} ${TRANSFORM_WASM})
list(REMOVE_ITEM TRANSFORM ${TRANSFORM_SSE} ${TRANSFORM_SSE2} ${TRANSFORM_AVX} ${TRANSFORM_AVX2} ${TRANSFORM_AVX512} ${TRANSFORM_WASM})
list(APPEND SOURCES ${CODESTREAM} ${CODING} ${COMMON} ${OTHERS} ${TRANSFORM})

source_group("codestream" FILES ${CODESTREAM})
Expand All @@ -32,7 +33,7 @@ source_group("others" FILES ${OTHERS})
source_group("transform" FILES ${TRANSFORM})

if(EMSCRIPTEN)
add_compile_options(-std=c++11 -O3 -fexceptions -DOJPH_DISABLE_INTEL_SIMD)
add_compile_options(-std=c++11 -O3 -fexceptions)
add_library(openjph ${SOURCES})
add_library(openjphsimd ${SOURCES} ${CODESTREAM_WASM} ${CODING_WASM} ${TRANSFORM_WASM})
target_include_directories(openjph PUBLIC common)
Expand All @@ -42,10 +43,10 @@ if(EMSCRIPTEN)
source_group("coding" FILES ${CODING_WASM})
source_group("transform" FILES ${TRANSFORM_WASM})
elseif(NOT OJPH_DISABLE_INTEL_SIMD)
add_library(openjph ${SOURCES} ${CODESTREAM_SSE} ${CODESTREAM_SSE2} ${CODESTREAM_AVX} ${CODESTREAM_AVX2} ${CODING_SSSE3} ${TRANSFORM_SSE} ${TRANSFORM_SSE2} ${TRANSFORM_AVX} ${TRANSFORM_AVX2})
add_library(openjph ${SOURCES} ${CODESTREAM_SSE} ${CODESTREAM_SSE2} ${CODESTREAM_AVX} ${CODESTREAM_AVX2} ${CODING_SSSE3} ${TRANSFORM_SSE} ${TRANSFORM_SSE2} ${TRANSFORM_AVX} ${TRANSFORM_AVX2} ${TRANSFORM_AVX512})
source_group("codestream" FILES ${CODESTREAM_SSE} ${CODESTREAM_SSE2} ${CODESTREAM_AVX} ${CODESTREAM_AVX2})
source_group("coding" FILES ${CODING_SSSE3})
source_group("transform" FILES ${TRANSFORM_SSE} ${TRANSFORM_SSE2} ${TRANSFORM_AVX} ${TRANSFORM_AVX2})
source_group("transform" FILES ${TRANSFORM_SSE} ${TRANSFORM_SSE2} ${TRANSFORM_AVX} ${TRANSFORM_AVX2} ${TRANSFORM_AVX512})
if (OJPH_ENABLE_INTEL_AVX512)
target_sources(openjph PRIVATE ${CODING_AVX512})
source_group("coding" FILES ${CODING_AVX512})
Expand All @@ -71,6 +72,7 @@ if (MSVC)
set_source_files_properties(transform/ojph_colour_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2")
set_source_files_properties(transform/ojph_transform_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX")
set_source_files_properties(transform/ojph_transform_avx2.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX2")
set_source_files_properties(transform/ojph_transform_avx512.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX512")
else()
set_source_files_properties(codestream/ojph_codestream_avx.cpp PROPERTIES COMPILE_FLAGS -mavx)
set_source_files_properties(codestream/ojph_codestream_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2)
Expand All @@ -80,6 +82,7 @@ else()
set_source_files_properties(transform/ojph_colour_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2)
set_source_files_properties(transform/ojph_transform_avx.cpp PROPERTIES COMPILE_FLAGS -mavx)
set_source_files_properties(transform/ojph_transform_avx2.cpp PROPERTIES COMPILE_FLAGS -mavx2)
set_source_files_properties(transform/ojph_transform_avx512.cpp PROPERTIES COMPILE_FLAGS -mavx512f)
endif()

if (MSVC)
Expand Down
12 changes: 7 additions & 5 deletions src/core/codestream/ojph_codeblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,14 @@ namespace ojph {
cb_size.w, cb_size.h, stride, stripe_causal);

if (result == false)
{
if (resilient == true)
zero_block = true;
else
OJPH_ERROR(0x000300A1, "Error decoding a codeblock\n");
{
if (resilient == true) {
OJPH_INFO(0x000300A1, "Error decoding a codeblock");
zero_block = true;
}
else
OJPH_ERROR(0x000300A1, "Error decoding a codeblock");
}
}
else
zero_block = true;
Expand Down

0 comments on commit 4e13575

Please sign in to comment.