diff --git a/CMakeLists.txt b/CMakeLists.txt index b5bdb90..1f12610 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ find_package(lz4 REQUIRED) find_package(Threads REQUIRED) find_package(Tesseract CONFIG REQUIRED) -find_package(harfbuzz CONFIG REQUIRED) +find_library(HARFBUZZ_LIBRARIES harfbuzz) find_package(OpenJPEG CONFIG REQUIRED) find_package(JPEG REQUIRED) find_package(LibXml2 REQUIRED) @@ -37,29 +37,8 @@ find_package(FFMPEG REQUIRED) #find_package(OpenSSL REQUIRED) find_package(LibLZMA REQUIRED) find_package(ZLIB REQUIRED) - - -include(ExternalProject) -find_program(MAKE_EXE NAMES gmake nmake make) -set(MUPDF_CFLAGS "-fPIC -DFZ_ENABLE_JS=0 -DFZ_ENABLE_ICC=0") -ExternalProject_Add( - mupdf - # TODO: use master branch ? - URL https://mupdf.com/downloads/archive/mupdf-1.16.1-source.tar.xz - - UPDATE_COMMAND "" - PATCH_COMMAND "" - TEST_COMMAND "" - CONFIGURE_COMMAND "" - INSTALL_COMMAND "" - - PREFIX "third-party/ext_mupdf" - BINARY_DIR "third-party/ext_mupdf/src/mupdf" - - BUILD_COMMAND export CFLAGS=${MUPDF_CFLAGS} && HAVE_CURL=no HAVE_GLUT=no USE_SYSTEM_LIBJPEG=yes ${MAKE_EXE} -j 3 --silent -) -SET(MUPDF_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party/ext_mupdf/src/mupdf/build/release/) -SET(MUPDF_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party/ext_mupdf/src/mupdf/include/) +find_package(freetype CONFIG REQUIRED) +find_library(JBIG2DEC_LIB NAMES jbig2decd jbig2dec) target_compile_options( @@ -69,11 +48,6 @@ target_compile_options( -g ) -add_dependencies( - scan - mupdf -) - SET(CMAKE_C_LINK_EXECUTABLE "g++ -o ") string(REGEX REPLACE "-lvdpau" "" FFMPEG_LIBRARIES "${FFMPEG_LIBRARIES}") @@ -90,8 +64,12 @@ target_link_libraries( lzo2 LibLZMA::LibLZMA - freetype + ${HARFBUZZ_LIBRARIES} + libmupdf + freetype + ${HARFBUZZ_LIBRARIES} + ${JBIG2DEC_LIB} # OpenSSL::SSL OpenSSL::Crypto stdc++ @@ -100,9 +78,6 @@ target_link_libraries( m -Wl,--no-whole-archive - "${MUPDF_LIB_DIR}/libmupdf.a" - "${MUPDF_LIB_DIR}/libmupdf-third.a" - ${JPEG_LIBRARIES} ${Tesseract_LIBRARIES} ${LIBXML2_LIBRARIES} diff --git a/libscan/ebook/ebook.c b/libscan/ebook/ebook.c index b59eb27..6adba8c 100644 --- a/libscan/ebook/ebook.c +++ b/libscan/ebook/ebook.c @@ -327,4 +327,5 @@ void parse_ebook(scan_ebook_ctx_t *ctx, vfile_t *f, const char* mime_str, docum size_t buf_len; void * buf = read_all(f, &buf_len); parse_ebook_mem(ctx, buf, buf_len, mime_str, doc); + free(buf); } diff --git a/libscan/media/media.c b/libscan/media/media.c index ba8ae78..4ee633f 100644 --- a/libscan/media/media.c +++ b/libscan/media/media.c @@ -424,3 +424,7 @@ void parse_media(scan_media_ctx_t *ctx, vfile_t *f, document_t *doc) { parse_media_vfile(ctx, f, doc); } } + +void init_media() { + av_log_set_level(AV_LOG_QUIET); +} diff --git a/libscan/media/media.h b/libscan/media/media.h index 71cf3b1..236c623 100644 --- a/libscan/media/media.h +++ b/libscan/media/media.h @@ -15,5 +15,6 @@ typedef struct { } scan_media_ctx_t; void parse_media(scan_media_ctx_t *ctx, vfile_t *f, document_t *doc); +void init_media(); #endif diff --git a/libscan/ooxml/ooxml.c b/libscan/ooxml/ooxml.c index 5da6e0a..f7e6122 100644 --- a/libscan/ooxml/ooxml.c +++ b/libscan/ooxml/ooxml.c @@ -106,6 +106,7 @@ void parse_ooxml(scan_ooxml_ctx_t *ctx, vfile_t *f, document_t *doc) { if (ret != ARCHIVE_OK) { CTX_LOG_ERRORF(doc->filepath, "Could not read archive: %s", archive_error_string(a)) archive_read_free(a); + free(buf); return; } @@ -137,4 +138,5 @@ void parse_ooxml(scan_ooxml_ctx_t *ctx, vfile_t *f, document_t *doc) { archive_read_close(a); archive_read_free(a); text_buffer_destroy(&tex); + free(buf); } diff --git a/libscan/text/text.c b/libscan/text/text.c index 1662c7e..7e84c40 100644 --- a/libscan/text/text.c +++ b/libscan/text/text.c @@ -8,6 +8,7 @@ scan_code_t parse_text(scan_text_ctx_t *ctx, struct vfile *f, document_t *doc) { int ret = f->read(f, buf, to_read); if (ret < 0) { CTX_LOG_ERRORF(doc->filepath, "read() returned error code: [%d]", ret) + free(buf); return SCAN_ERR_READ; }