Skip to content

Commit

Permalink
remove jpegint.h dependency from rocAL (#115)
Browse files Browse the repository at this point in the history
* remove jpegint.h dependancy

* added libjpeg as dependancy for partial decoding

* remove competitor ref from Readme
  • Loading branch information
rrawther authored Mar 19, 2024
1 parent 92fc82c commit 78fae9a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
31 changes: 30 additions & 1 deletion cmake/FindTurboJpeg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,32 @@ find_library(TurboJpeg_LIBRARIES
)
mark_as_advanced(TurboJpeg_LIBRARIES)

if(TurboJpeg_LIBRARIES AND TurboJpeg_INCLUDE_DIRS)
# Libjpeg
find_path(LIBJPEG_INCLUDE_DIR
NAMES jpeglib.h
HINTS
$ENV{TURBO_JPEG_PATH}/include
PATHS
${TURBO_JPEG_PATH}/include
/usr/include
/opt/libjpeg-turbo/include
)
mark_as_advanced(LIBJPEG_INCLUDE_DIR)

find_library(LIBJPEG_LIBRARIES
NAMES libjpeg${SHARED_LIB_TYPE}
HINTS
$ENV{TURBO_JPEG_PATH}/lib
$ENV{TURBO_JPEG_PATH}/lib64
PATHS
${TURBO_JPEG_PATH}/lib
${TURBO_JPEG_PATH}/lib64
/usr/lib
/opt/libjpeg-turbo/lib
)
mark_as_advanced(LIBJPEG_LIBRARIES)

if(TurboJpeg_LIBRARIES AND TurboJpeg_INCLUDE_DIRS AND LIBJPEG_INCLUDE_DIR AND LIBJPEG_LIBRARIES)
set(TurboJpeg_FOUND TRUE)
endif( )

Expand All @@ -63,11 +88,15 @@ find_package_handle_standard_args( TurboJpeg
REQUIRED_VARS
TurboJpeg_LIBRARIES
TurboJpeg_INCLUDE_DIRS
LIBJPEG_INCLUDE_DIR
LIBJPEG_LIBRARIES
)

set(TurboJpeg_FOUND ${TurboJpeg_FOUND} CACHE INTERNAL "")
set(TurboJpeg_LIBRARIES ${TurboJpeg_LIBRARIES} CACHE INTERNAL "")
set(TurboJpeg_INCLUDE_DIRS ${TurboJpeg_INCLUDE_DIRS} CACHE INTERNAL "")
set(LIBJPEG_LIBRARIES ${LIBJPEG_LIBRARIES} CACHE INTERNAL "")
set(LIBJPEG_INCLUDE_DIR ${LIBJPEG_INCLUDE_DIR} CACHE INTERNAL "")

if(TurboJpeg_FOUND)
message("-- ${White}Using Turbo JPEG -- \n\tLibraries:${TurboJpeg_LIBRARIES} \n\tIncludes:${TurboJpeg_INCLUDE_DIRS}${ColourReset}")
Expand Down
1 change: 0 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Refer [rocAL build instructions](https://github.com/ROCmSoftwarePlatform/rocAL#b
## rocAL Python

* rocAL Python package has been created using Pybind11 which enables data transfer between rocAL C++ API and Python API.
* Module imports are made similar to other data loaders like NVidia's DALI.
* rocal_pybind package has both PyTorch and TensorFlow framework support.
* Various reader format support including FileReader, COCOReader, and TFRecordReader.
* example folder contains sample implementations for each reader variation as well as sample training script for PyTorch
Expand Down
4 changes: 2 additions & 2 deletions rocAL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ if(${BUILD_ROCAL})
# Threads
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} Threads::Threads)
# TurboJPEG
include_directories(${TurboJpeg_INCLUDE_DIRS})
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} ${TurboJpeg_LIBRARIES})
include_directories(${TurboJpeg_INCLUDE_DIRS} {LIBJPEG_INCLUDE_DIR})
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} ${TurboJpeg_LIBRARIES} ${LIBJPEG_LIBRARIES})
# Protobuf
include_directories(${PROTOBUF_INCLUDE_DIRS})
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} ${PROTOBUF_LIBRARIES})
Expand Down
1 change: 0 additions & 1 deletion rocAL/include/decoders/libjpeg/libjpeg_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ THE SOFTWARE.
extern "C" {
#include "jerror.h"
#include "jpeglib.h"
#include "jpegint.h"
}
10 changes: 5 additions & 5 deletions rocAL/source/decoders/libjpeg/libjpeg_extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int tjDecompress2_partial(tjhandle handle, const unsigned char *jpegBuf,
jerr.pub.error_exit = my_error_exit;
if (setjmp(jerr.setjmp_buffer)) {
/* If we get here, the JPEG code has signaled an error. */
retval = -1; goto bailout;
return -1;
}

// set up, read header, set image parameters, save size
Expand Down Expand Up @@ -144,8 +144,8 @@ int tjDecompress2_partial(tjhandle handle, const unsigned char *jpegBuf,
jpeg_skip_scanlines(&cinfo, cinfo.output_height - crop_y - crop_height);
jpeg_finish_decompress(&cinfo);

bailout:
if (cinfo.global_state > DSTATE_START) jpeg_abort_decompress(&cinfo);
bailout:
jpeg_destroy_decompress(&cinfo);
if (row_pointer) free(row_pointer);
return retval;
}
Expand Down Expand Up @@ -178,7 +178,7 @@ int tjDecompress2_partial_scale(tjhandle handle, const unsigned char *jpegBuf,
jerr.pub.error_exit = my_error_exit;
if (setjmp(jerr.setjmp_buffer)) {
/* If we get here, the JPEG code has signaled an error. */
retval = -1; goto bailout;
return -1;
}

jpeg_mem_src(&cinfo, jpegBuf, jpegSize);
Expand Down Expand Up @@ -259,7 +259,7 @@ int tjDecompress2_partial_scale(tjhandle handle, const unsigned char *jpegBuf,
jpeg_finish_decompress(&cinfo);

bailout:
if (cinfo.global_state > DSTATE_START) jpeg_abort_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
if (row_pointer) free(row_pointer);
if (tmp_row) free(tmp_row);
return retval;
Expand Down

0 comments on commit 78fae9a

Please sign in to comment.