]> gitweb.hhaalo.de Git - sane-kds-s2000w-net.git/commitdiff
Revert "remove math lib with bit shift"
authorBastian Dehn <hhaalo@arcor.de>
Thu, 20 Nov 2025 15:49:17 +0000 (16:49 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Thu, 20 Nov 2025 15:49:17 +0000 (16:49 +0100)
This reverts commit 1a9a58fd22f8426e72db2c8457680cff434b24f5.

readme.md
src/CMakeLists.txt
src/kds_s2000w_handler.c

index 2e02926d0854ee6e9c7fc53ccfafa2dc91c2d3fe..e846f739e6055f617719162e4cd60c2254dc457c 100644 (file)
--- a/readme.md
+++ b/readme.md
@@ -39,6 +39,7 @@ https://www.kodakalaris.com/en/scanners/s2080w-scanner
 - [tiff](https://libtiff.gitlab.io/libtiff) - read bw tiff
 - [netpbm](https://netpbm.sourceforge.net) - write pnm image
 - [imagemagick](https://imagemagick.org/script/magick-core.php) - convert jpg to pnm
+- math - calc bytes per line
 - pthread - heartbeat interval sleep
 
 ### Test dependencies
index a8ce8e8f872c736e5e30421e8a8b09e6d32c4d01..33089800bdf181f9077979f88647e0b22574ac5c 100644 (file)
@@ -27,6 +27,8 @@ message(STATUS "IMAGEMAGICK: ${IMAGEMAGICK}")
 
 find_library(SANE NAMES sane REQUIRED ONLY_CMAKE_FIND_ROOT_PATH)
 message(STATUS "find sane: ${SANE}")
+find_library(MATH NAMES m REQUIRED)
+message(STATUS "find math: ${MATH}")
 find_library(PTHREAD NAMES pthread REQUIRED)
 message(STATUS "find pthread: ${PTHREAD}")
 find_library(CONFUSE NAMES confuse REQUIRED)
@@ -94,6 +96,7 @@ target_include_directories(sane-kds_s2000w_net
        PRIVATE
        ${CMAKE_CURRENT_BINARY_DIR})
 target_link_libraries(sane-kds_s2000w_net
+       ${MATH}
        ${PTHREAD}
        ${CONFUSE}
        ${CURL_LIBRARY}
@@ -120,6 +123,7 @@ target_include_directories(sane-kds_s2000w_net-static
        PRIVATE
        ${CMAKE_CURRENT_BINARY_DIR})
 target_link_libraries(sane-kds_s2000w_net-static
+       ${MATH}
        ${PTHREAD}
        ${CONFUSE}
        ${CURL_LIBRARY}
index 60a5629c066c12241eccd12b23d329b8c0c52fb2..4113be05da96deb2e65e3b88c83993970f6de677 100644 (file)
@@ -1,5 +1,6 @@
 #include <string.h>
 #include <unistd.h>
+#include <math.h>
 #include "config.h"
 #include "kds_s2000w_config.h"
 #include "kds_s2000w_handler.h"
@@ -115,9 +116,9 @@ uint32_t _kds_s2000w_handler_calc_bytes_per_line(const metadata_t* params)
                channels = 3;
 
        if (params->depth == 1)
-               return channels * (params->pixels_per_line + 7) >> 3;
+               return channels * floor((params->pixels_per_line + 7) / 8);
 
-       return channels * params->pixels_per_line * params->depth >> 3;
+       return channels * params->pixels_per_line * params->depth / 8;
 }
 
 void _kds_s2000w_handler_set_default_metadata(metadata_t* params)