Skip to content

Commit

Permalink
valgrind runs on ojph_expand in WSL
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldsmith committed Jan 15, 2025
1 parent d1c4765 commit 697e626
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
18 changes: 17 additions & 1 deletion src/apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ if( OJPH_ENABLE_TIFF_SUPPORT )
"or disable TIFF support using -DOJPH_ENABLE_TIFF_SUPPORT=OFF.")
endif( TIFF_FOUND )

if(TIFF_FOUND)
message(STATUS " TIFF_INCLUDE_DIR = ${TIFF_INCLUDE_DIR}")
message(STATUS " TIFF_INCLUDE_DIRS = ${TIFF_INCLUDE_DIRS}")
message(STATUS " TIFF_LIBRARY = ${TIFF_LIBRARY}")
message(STATUS " TIFF_LIBRARIES = ${TIFF_LIBRARIES}")
endif(TIFF_FOUND)

endif(OJPH_ENABLE_TIFF_SUPPORT)
############################################################

Expand Down Expand Up @@ -52,7 +59,8 @@ if( OJPH_ENABLE_OPENEXR_SUPPORT )
# "or disable OpenEXR support using -DOJPH_ENABLE_OPENEXR_SUPPORT=OFF.")
# endif( OpenEXR_FOUND )

find_package(OpenEXR 3 CONFIG QUIET)
#find_package(OpenEXR 3 CONFIG QUIET)
find_package(OpenEXR 3 QUIET)
if(OpenEXR_FOUND)
message(STATUS "Found OpenEXR ${OpenEXR_VERSION}")
set(USE_OPENEXR TRUE CACHE BOOL "Add OpenEXR support")
Expand Down Expand Up @@ -85,6 +93,14 @@ if( OJPH_ENABLE_OPENEXR_SUPPORT )

endif(OpenEXR_FOUND)

if(OpenEXR_FOUND)
message(STATUS " OpenEXR_VERSION = ${OpenEXR_VERSION}")
message(STATUS " OpenEXR_INCLUDE_DIR = ${OpenEXR_INCLUDE_DIR}")
message(STATUS " OpenEXR_INCLUDE_DIRS = ${OpenEXR_INCLUDE_DIRS}")
message(STATUS " OpenEXR_LIBRARY = ${OpenEXR_LIBRARY}")
message(STATUS " OpenEXR_LIBRARIES = ${OpenEXR_LIBRARIES}")
endif(OpenEXR_FOUND)

endif(OJPH_ENABLE_OPENEXR_SUPPORT)
############################################################

Expand Down
2 changes: 1 addition & 1 deletion src/apps/common/ojph_img_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ namespace ojph {
}

void open(const char* filename);
void configure(ui32 width, ui32 height, ui32 num_components, bool* has_nlt, ui8* bitdepths, bool* is_signed);
void configure(ui32 width, ui32 height, ui32 num_components, bool* has_nlt, ui32* bitdepths, bool* is_signed);
virtual ui32 write(const line_buf* line, ui32 comp_num);
virtual void close();

Expand Down
6 changes: 3 additions & 3 deletions src/apps/ojph_expand/ojph_expand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,9 @@ int main(int argc, char *argv[]) {
ojph::param_nlt nlt = codestream.access_nlt();
ojph::ui32 num_components = siz.get_num_components();

ojph::ui8 *bitdepths = (ojph::ui8*)calloc(num_components, sizeof(ojph::ui8));
ojph::ui32 *bitdepths = (ojph::ui32*)calloc(num_components, sizeof(ojph::ui32));
if (NULL == bitdepths) {
fprintf(stderr, "Unable to allocate %zd bytes for bitdepths", num_components * sizeof(ojph::ui8));
fprintf(stderr, "Unable to allocate %zd bytes for bitdepths", num_components * sizeof(ojph::ui32));
exit(-1);
}

Expand All @@ -430,7 +430,7 @@ int main(int argc, char *argv[]) {
c, has_nlt[c] ? "true" : "false");
if (true == has_nlt[c])
{
fprintf(stderr, "nlt_bit_depth = %d nlt_is_signed = % s\n",
fprintf(stderr, "nlt_bit_depth = %d nlt_is_signed = %s\n",
nlt_bit_depth,
nlt_is_signed ? "true" : "false");
}
Expand Down
4 changes: 2 additions & 2 deletions src/apps/others/ojph_img_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2266,11 +2266,11 @@ namespace ojph {
rgba_input_file = new Imf::RgbaInputFile(filename);
data_window = rgba_input_file->dataWindow();
int width = data_window.max.x - data_window.min.x + 1;
int height = data_window.max.y - data_window.min.y + 1;

// reserve memory for 1 scanline
pixels.resizeErase(1, width);
// reserve memory for the whole image
//int height = data_window.max.y - data_window.min.y + 1;
//pixels.resizeErase(height, width);

}
Expand Down Expand Up @@ -2384,7 +2384,7 @@ namespace ojph {
return;
}

void exr_out::configure(ui32 width, ui32 height, ui32 num_components, bool *has_nlt, ui8 *bitdepths, bool* is_signed)
void exr_out::configure(ui32 width, ui32 height, ui32 num_components, bool *has_nlt, ui32 *bitdepths, bool* is_signed)
{
this->num_components = num_components;
this->width = width;
Expand Down
8 changes: 5 additions & 3 deletions tests/run_valgrind_ojph_expand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
set -x
set -u

PATH_TO_EXECUTABLE="../bin/"
INPUT_FILENAME="SPARKS_ACES_06822.exr.reversible-true.colour-transf-false.j2c"
OUTPUT_FILENAME="SPARKS_ACES_06822.exr.reversible-true.colour-transf-false.j2c.exr"
PATH_TO_EXECUTABLE="../build/src/apps/ojph_expand/ojph_expand"
#INPUT_FILENAME="/tmp/SPARKS_ACES_06822.exr.reversible-true.colour-transf-true.j2c"
#OUTPUT_FILENAME="/tmp/SPARKS_ACES_06822.exr.reversible-true.colour-transf-true.j2c.exr"
INPUT_FILENAME="/tmp/SPARKS_ACES_06822.exr.reversible-true.colour-transf-false.j2c"
OUTPUT_FILENAME="/tmp/SPARKS_ACES_06822.exr.reversible-true.colour-transf-false.j2c.exr"
ADDITIONAL_COMMAND_LINE_OPTIONS=""

valgrind -s --error-exitcode=1 --leak-check=full --track-origins=yes --show-leak-kinds=all ${PATH_TO_EXECUTABLE} -i ${INPUT_FILENAME} -o ${OUTPUT_FILENAME} ${ADDITIONAL_COMMAND_LINE_OPTIONS}
Expand Down

0 comments on commit 697e626

Please sign in to comment.