Skip to content

Commit

Permalink
Sub-tile decoding: only allocate tile component buffer of the needed …
Browse files Browse the repository at this point in the history
…dimension

Instead of being the full tile size.

* Use a sparse array mechanism to store code-blocks and intermediate stages of
  IDWT.
* IDWT, DC level shift and MCT stages are done just on that smaller array.
* Improve copy of tile component array to final image, by saving an intermediate
  buffer.
* For full-tile decoding at reduced resolution, only allocate the tile buffer to
  the reduced size, instead of the full-resolution size.
  • Loading branch information
rouault committed Sep 1, 2017
1 parent aa71981 commit f9e9942
Show file tree
Hide file tree
Showing 13 changed files with 1,335 additions and 507 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ if(BUILD_JPIP_SERVER)
endif()
add_subdirectory(src/lib)
option(BUILD_LUTS_GENERATOR "Build utility to generate t1_luts.h" OFF)
option(BUILD_BENCH_DWT "Build bench_dwt utility (development benchmark)" OFF)
option(BUILD_UNIT_TESTS "Build unit tests (bench_dwt, test_sparse_array, etc..)" OFF)

#-----------------------------------------------------------------------------
# Build Applications
Expand Down
18 changes: 14 additions & 4 deletions src/lib/openjp2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ set(OPENJPEG_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/opj_malloc.c
${CMAKE_CURRENT_SOURCE_DIR}/opj_malloc.h
${CMAKE_CURRENT_SOURCE_DIR}/opj_stdint.h
${CMAKE_CURRENT_SOURCE_DIR}/sparse_array.c
${CMAKE_CURRENT_SOURCE_DIR}/sparse_array.h
)
if(BUILD_JPIP)
add_definitions(-DUSE_JPIP)
Expand Down Expand Up @@ -192,12 +194,20 @@ if(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
TARGET_LINK_LIBRARIES(${OPENJPEG_LIBRARY_NAME} ${CMAKE_THREAD_LIBS_INIT})
endif(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)

if(BUILD_BENCH_DWT)
add_executable(bench_dwt bench_dwt.c dwt.c opj_malloc.c thread.c)
if(BUILD_UNIT_TESTS)
add_executable(bench_dwt bench_dwt.c)
if(UNIX)
target_link_libraries(bench_dwt m)
target_link_libraries(bench_dwt m ${OPENJPEG_LIBRARY_NAME})
endif()
if(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
target_link_libraries(bench_dwt ${CMAKE_THREAD_LIBS_INIT})
endif(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
endif(BUILD_BENCH_DWT)

add_executable(test_sparse_array test_sparse_array.c)
if(UNIX)
target_link_libraries(test_sparse_array m ${OPENJPEG_LIBRARY_NAME})
endif()
if(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
target_link_libraries(test_sparse_array ${CMAKE_THREAD_LIBS_INIT})
endif(OPJ_USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
endif(BUILD_UNIT_TESTS)
9 changes: 5 additions & 4 deletions src/lib/openjp2/bench_dwt.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,11 @@ int main(int argc, char** argv)

memset(&tcd, 0, sizeof(tcd));
tcd.thread_pool = tp;
tcd.decoded_x0 = (OPJ_UINT32)tilec.x0;
tcd.decoded_y0 = (OPJ_UINT32)tilec.y0;
tcd.decoded_x1 = (OPJ_UINT32)tilec.x1;
tcd.decoded_y1 = (OPJ_UINT32)tilec.y1;
tcd.whole_tile_decoding = OPJ_TRUE;
tcd.win_x0 = (OPJ_UINT32)tilec.x0;
tcd.win_y0 = (OPJ_UINT32)tilec.y0;
tcd.win_x1 = (OPJ_UINT32)tilec.x1;
tcd.win_y1 = (OPJ_UINT32)tilec.y1;
tcd.tcd_image = &tcd_image;
memset(&tcd_image, 0, sizeof(tcd_image));
tcd_image.tiles = &tcd_tile;
Expand Down
Loading

0 comments on commit f9e9942

Please sign in to comment.