Skip to content

Commit

Permalink
This addresses issues #146, #147, and #148.
Browse files Browse the repository at this point in the history
  • Loading branch information
aous72 committed Jul 21, 2024
1 parent 46da3dc commit 987c654
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 32 deletions.
35 changes: 17 additions & 18 deletions src/apps/ojph_compress/ojph_compress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,27 +538,25 @@ int main(int argc, char * argv[]) {
" compression; quantization steps size for all subbands are\n"
" derived from this value. {The default value for 8bit\n"
" images is 0.0039}\n"
" -reversible (false) for irreversible; this should be false to perform\n"
" lossy compression using the 9/7 wavelet transform;\n"
" or true to perform reversible compression, where\n"
" the 5/3 wavelet is employed with lossless compression.\n"
" -colour_trans (true) this option employs a color transform, to\n"
" transform RGB color images into the YUV domain.\n"
" This option should not be used with YUV images, because\n"
" -reversible <true | false> If this is 'false', an irreversible or\n"
" lossy compression is employed, using the 9/7 wavelet\n"
" transform; if 'true', a reversible compression is\n"
" performed, where the 5/3 wavelet is used.\n"
" Default value is 'false'.\n"
" -colour_trans <true | false> This option employs a color transform,\n"
" to transform RGB color images into the YUV domain.\n"
" This option should NOT be used with YUV images, because\n"
" they have already been transformed.\n"
" If there are three color components that are\n"
" downsampled by the same amount then the color transform\n"
" can be true or false. This option is also available\n"
" when there are more than three colour components,\n"
" where it is applied to the first three colour\n"
" components.\n"
" it has already been applied to convert the original RGB\n"
" or whatever the original format to YUV.\n"
" downsampled by the same amount then this option can be\n"
" 'true' or 'false'. This option is also available when\n"
" there are more than three colour components, where it is\n"
" applied to the first three colour components.\n"
" -prog_order (RPCL) is the progression order, and can be one of:\n"
" LRCP, RLCP, RPCL, PCRL, CPRL\n"
" LRCP, RLCP, RPCL, PCRL, CPRL.\n"
" -block_size {x,y} (64,64) where x and y are the height and width of\n"
" a codeblock. In unix-like environment, { and } must be\n"
" preceded by a ""\\""\n"
" preceded by a ""\\"".\n"
" -precincts {x,y},{x,y},...,{x,y} where {x,y} is the precinct size\n"
" starting from the coarsest resolution; the last precinct\n"
" is repeated for all finer resolutions\n"
Expand All @@ -568,14 +566,15 @@ int main(int argc, char * argv[]) {
" -tileparts (None) employ tilepart divisions at each resolution, \n"
" indicated by the letter R, and/or component, indicated \n"
" by the letter C. For both, use \"-tileparts RC\".\n"
" -tlm_marker (false) insert a TLM marker, either \"true\" or \"false\"\n"
" -tlm_marker <true | false> if 'true', a TLM marker is inserted.\n"
" Default value is false.\n"
" -profile (None) is the profile, the code will check if the \n"
" selected options meet the profile. Currently only \n"
" BROADCAST and IMF are supported. This automatically \n"
" sets tlm_marker to true and tileparts to C.\n"
" -com (None) if set, inserts a COM marker with the specified\n"
" string. If the string has spaces, please use\n"
" double quotes, as in -com \"This is a comment\"\n"
" double quotes, as in -com \"This is a comment\".\n"
"\n"

"When the input file is a YUV file, these arguments need to be \n"
Expand Down
6 changes: 4 additions & 2 deletions src/apps/ojph_expand/ojph_expand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,10 @@ int main(int argc, char *argv[]) {
" number of skipped resolution for reconstruction, which is\n"
" either equal to the first or smaller. If the second is not\n"
" specified, it is made to equal to the first.\n"
" -resilient true if you want the decoder to be more tolerant of errors\n"
" in the codestream\n\n"
" -resilient <true | false> if 'true', the decoder will not exit when\n"
" running into recoverable errors in the codestream.\n"
" Default: 'false'.\n"
"\n"
;
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/codestream/ojph_codestream_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ namespace ojph {
{
OJPH_ERROR(0x00030001, "%s", msg);
}
else
else // there is the option of ALL_MSG but it should not be used here
assert(0);
}
return 0;
Expand Down
19 changes: 15 additions & 4 deletions src/core/common/ojph_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ namespace ojph {
*/
enum OJPH_MSG_LEVEL : int
{
NO_MSG = 0,
INFO = 1,
WARN = 2,
ERROR = 3
ALL_MSG = 0, // uninitialized or print all message
INFO = 1, // info message
WARN = 2, // warning message
ERROR = 3, // error message (the highest severity)
NO_MSG = 4, // no message (higher severity for message printing only)
};

//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -251,6 +252,16 @@ namespace ojph {
*/
OJPH_EXPORT
message_error* get_error();

//////////////////////////////////////////////////////////////////////////////
/**
* @brief Sets the minimum severity of the message to be reported.
*
* @param level is the level of the message severity; values are defined in
* OJPH_MSG_LEVEL.
*/
OJPH_EXPORT
void set_message_level(OJPH_MSG_LEVEL level);
}

//////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions src/core/common/ojph_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
//***************************************************************************/

#define OPENJPH_VERSION_MAJOR 0
#define OPENJPH_VERSION_MINOR 14
#define OPENJPH_VERSION_PATCH 2
#define OPENJPH_VERSION_MINOR 15
#define OPENJPH_VERSION_PATCH 0
17 changes: 14 additions & 3 deletions src/core/others/ojph_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
// Date: 29 August 2019
//***************************************************************************/

#include <cassert>
#include <cstdio>
#include <cstdarg>
#include <stdexcept>
Expand All @@ -49,6 +50,7 @@ namespace ojph {
////////////////////////////////////////////////////////////////////////////
message_info info;
message_info* local_info = &info;
OJPH_MSG_LEVEL message_level = OJPH_MSG_LEVEL::ALL_MSG;

////////////////////////////////////////////////////////////////////////////
void configure_info(message_info* info)
Expand All @@ -72,7 +74,7 @@ namespace ojph {
void message_info::operator()(int info_code, const char* file_name,
int line_num, const char* fmt, ...)
{
if (info_stream == NULL)
if (info_stream == NULL || message_level > OJPH_MSG_LEVEL::INFO)
return;

fprintf(info_stream, "ojph info 0x%08X at %s:%d: ",
Expand Down Expand Up @@ -113,7 +115,7 @@ namespace ojph {
void message_warning::operator()(int warn_code, const char* file_name,
int line_num, const char *fmt, ...)
{
if (warning_stream == NULL)
if (warning_stream == NULL || message_level > OJPH_MSG_LEVEL::WARN)
return;

fprintf(warning_stream, "ojph warning 0x%08X at %s:%d: ",
Expand Down Expand Up @@ -154,7 +156,7 @@ namespace ojph {
void message_error::operator()(int error_code, const char* file_name,
int line_num, const char *fmt, ...)
{
if (error_stream != NULL)
if (error_stream != NULL && message_level <= OJPH_MSG_LEVEL::ERROR)
{
fprintf(error_stream, "ojph error 0x%08X at %s:%d: ",
error_code, file_name, line_num);
Expand All @@ -167,4 +169,13 @@ namespace ojph {

throw std::runtime_error("ojph error");
}

////////////////////////////////////////////////////////////////////////////
void set_message_level(OJPH_MSG_LEVEL level)
{
assert(level >= OJPH_MSG_LEVEL::ALL_MSG &&
level <= OJPH_MSG_LEVEL::NO_MSG);
message_level = level;
}

}
4 changes: 2 additions & 2 deletions subprojects/js/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../html)

add_subdirectory("../.." openjph EXCLUDE_FROM_ALL)
add_executable(libopenjph "src/ojph_wrapper.cpp")
set_target_properties(libopenjph PROPERTIES SUFFIX ".js" LINK_FLAGS "-O3 -s WASM=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s ENVIRONMENT=web -s EXPORTED_FUNCTIONS=[_free,_malloc] -s EXPORTED_RUNTIME_METHODS=[ccall,cwrap,writeArrayToMemory] -s NO_EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -s INITIAL_MEMORY=134217728")
set_target_properties(libopenjph PROPERTIES SUFFIX ".js" LINK_FLAGS "-O3 -fexceptions -s WASM=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s ENVIRONMENT=web -s EXPORTED_FUNCTIONS=[_free,_malloc] -s EXPORTED_RUNTIME_METHODS=[ccall,cwrap,writeArrayToMemory] -s NO_EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -s INITIAL_MEMORY=134217728")
target_link_libraries(libopenjph PRIVATE openjph)

add_executable(libopenjph_simd "src/ojph_wrapper.cpp" )
target_compile_options(libopenjph_simd PRIVATE -DOJPH_ENABLE_WASM_SIMD -msimd128)
set_target_properties(libopenjph_simd PROPERTIES SUFFIX ".js" LINK_FLAGS "-O3 -s WASM=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s ENVIRONMENT=web -s EXPORTED_FUNCTIONS=[_free,_malloc] -s EXPORTED_RUNTIME_METHODS=[ccall,cwrap,writeArrayToMemory] -s NO_EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -s INITIAL_MEMORY=134217728")
set_target_properties(libopenjph_simd PROPERTIES SUFFIX ".js" LINK_FLAGS "-O3 -fexceptions -s WASM=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s ENVIRONMENT=web -s EXPORTED_FUNCTIONS=[_free,_malloc] -s EXPORTED_RUNTIME_METHODS=[ccall,cwrap,writeArrayToMemory] -s NO_EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -s INITIAL_MEMORY=134217728")
target_link_libraries(libopenjph_simd PRIVATE openjphsimd)

0 comments on commit 987c654

Please sign in to comment.