Skip to content

Commit a439edd

Browse files
committed
feat: add ricepp compression and simple FITS categorizer
1 parent a0377f7 commit a439edd

34 files changed

+5100
-33
lines changed

.docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ RUN apt install -y \
4444
liblz4-dev \
4545
liblzma-dev \
4646
libmagic-dev \
47+
librange-v3-dev \
4748
libssl-dev \
4849
libunwind-dev \
4950
libdwarf-dev \

.docker/build-linux.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ if [[ "-$BUILD_TYPE-" == *-coverage-* ]]; then
115115
rm -rf /tmp-runner/coverage
116116
mkdir -p /tmp-runner/coverage
117117
llvm-profdata-17 merge -sparse profile/* -o dwarfs.profdata
118-
for binary in mkdwarfs dwarfs dwarfsck dwarfsextract *_test; do
119-
llvm-cov-17 show -instr-profile=dwarfs.profdata $binary >/tmp-runner/coverage/$binary.txt
118+
for binary in mkdwarfs dwarfs dwarfsck dwarfsextract *_test ricepp/ricepp_test; do
119+
llvm-cov-17 show -instr-profile=dwarfs.profdata $binary >/tmp-runner/coverage/$(basename $binary).txt
120120
done
121121
fi
122122

CMakeLists.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ option(WITH_FUZZ "build with fuzzing binaries" OFF)
3333
option(WITH_MAN_OPTION "build with --man option" ON)
3434
option(ENABLE_PERFMON "enable performance monitor in all tools" ON)
3535
option(ENABLE_FLAC "build with FLAC support" ON)
36+
option(ENABLE_RICEPP "build with RICEPP compression support" ON)
3637
if(WIN32)
3738
set(PREFER_SYSTEM_LIBFMT ON)
3839
set(PREFER_SYSTEM_ZSTD ON)
@@ -218,6 +219,7 @@ else()
218219
endif()
219220

220221
find_package(Boost 1.67 REQUIRED COMPONENTS chrono iostreams program_options)
222+
find_package(range-v3 CONFIG REQUIRED)
221223

222224
if(STATIC_BUILD_DO_NOT_USE)
223225
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
@@ -397,6 +399,10 @@ if(DWARFS_OPTIMIZE)
397399
string(REPLACE "-O3" "-O${DWARFS_OPTIMIZE}" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
398400
endif()
399401

402+
if(ENABLE_RICEPP)
403+
add_subdirectory(ricepp)
404+
endif()
405+
400406
list(APPEND LIBDWARFS_SRC
401407
src/dwarfs/block_cache.cpp
402408
src/dwarfs/block_compressor.cpp
@@ -507,10 +513,15 @@ list(
507513
APPEND
508514
LIBDWARFS_CATEGORIZER_SRC
509515
# src/dwarfs/categorizer/binary_categorizer.cpp
516+
src/dwarfs/categorizer/fits_categorizer.cpp
510517
src/dwarfs/categorizer/incompressible_categorizer.cpp
511518
src/dwarfs/categorizer/pcmaudio_categorizer.cpp
512519
)
513520

521+
if(ENABLE_RICEPP)
522+
list(APPEND LIBDWARFS_COMPRESSION_SRC src/dwarfs/compression/ricepp.cpp)
523+
endif()
524+
514525
# if(LIBMAGIC_FOUND)
515526
# list(APPEND LIBDWARFS_CATEGORIZER_SRC src/dwarfs/categorizer/libmagic_categorizer.cpp)
516527
# endif()
@@ -540,8 +551,11 @@ target_compile_definitions(
540551
PRJ_COMPILER_ID="${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}"
541552
)
542553

543-
target_link_libraries(dwarfs_categorizer folly)
554+
target_link_libraries(dwarfs_categorizer folly range-v3::range-v3)
544555
target_link_libraries(dwarfs_compression folly compression_thrift)
556+
if(ENABLE_RICEPP)
557+
target_link_libraries(dwarfs_compression ricepp)
558+
endif()
545559
target_link_libraries(dwarfs_tool dwarfs)
546560

547561
if(STATIC_BUILD_DO_NOT_USE)
@@ -660,6 +674,7 @@ if(WITH_TESTS)
660674
error_test
661675
file_access_test
662676
filesystem_test
677+
fits_categorizer_test
663678
fragment_category_test
664679
incompressible_categorizer_test
665680
integral_value_parser_test
@@ -683,6 +698,10 @@ if(WITH_TESTS)
683698
list(APPEND DWARFS_TESTS flac_compressor_test)
684699
endif()
685700

701+
if(ENABLE_RICEPP)
702+
list(APPEND DWARFS_TESTS ricepp_compressor_test)
703+
endif()
704+
686705
foreach (test ${DWARFS_TESTS})
687706
add_executable(${test} test/${test}.cpp)
688707
target_link_libraries(
@@ -823,6 +842,7 @@ foreach(tgt dwarfs dwarfs_compression dwarfs_categorizer
823842
$<$<BOOL:${LIBLZMA_FOUND}>:DWARFS_HAVE_LIBLZMA>
824843
$<$<AND:$<BOOL:${LIBBROTLIDEC_FOUND}>,$<BOOL:${LIBBROTLIENC_FOUND}>>:DWARFS_HAVE_LIBBROTLI>
825844
$<$<BOOL:${FLAC_FOUND}>:DWARFS_HAVE_FLAC>
845+
$<$<BOOL:${ENABLE_RICEPP}>:DWARFS_HAVE_RICEPP>
826846
)
827847

828848
if(DWARFS_USE_EXCEPTION_TRACER)
@@ -1068,6 +1088,8 @@ add_custom_target(
10681088
)
10691089

10701090
file(GLOB_RECURSE ALL_SOURCES LIST_DIRECTORIES false
1091+
${CMAKE_CURRENT_SOURCE_DIR}/ricepp/*.h
1092+
${CMAKE_CURRENT_SOURCE_DIR}/ricepp/*.cpp
10711093
${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
10721094
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
10731095
${CMAKE_CURRENT_SOURCE_DIR}/test/*.h

include/dwarfs/compression.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
DWARFS_COMPRESSION_TYPE(LZ4, 3) SEPARATOR \
3232
DWARFS_COMPRESSION_TYPE(LZ4HC, 4) SEPARATOR \
3333
DWARFS_COMPRESSION_TYPE(BROTLI, 5) SEPARATOR \
34-
DWARFS_COMPRESSION_TYPE(FLAC, 6)
34+
DWARFS_COMPRESSION_TYPE(FLAC, 6) SEPARATOR \
35+
DWARFS_COMPRESSION_TYPE(RICEPP, 7)
3536
// clang-format on
3637

3738
namespace dwarfs {

ricepp/.clang-format

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
AlwaysBreakTemplateDeclarations: 'true'
3+
AccessModifierOffset: -1
4+
BreakConstructorInitializersBeforeComma: 'true'
5+
ColumnLimit: '80'
6+
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
7+
ConstructorInitializerIndentWidth: '4'
8+
Cpp11BracedListStyle: 'true'
9+
IndentWidth: '2'
10+
Language: Cpp
11+
MaxEmptyLinesToKeep: '1'
12+
NamespaceIndentation: None
13+
PenaltyReturnTypeOnItsOwnLine: '0'
14+
PointerAlignment: Left
15+
Standard: Cpp11
16+
UseTab: Never
17+
18+
...

ricepp/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/@*
2+
/tmp/
3+
/build*/
4+
*.log
5+
/.gdb_history
6+
7+
*~
8+
.*.swp
9+
10+
# VS build environment
11+
.vs/
12+
out/
13+
CMakeSettings.json

ricepp/CMakeLists.txt

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#
2+
# Copyright (c) Marcus Holland-Moritz
3+
#
4+
# This file is part of ricepp.
5+
#
6+
# ricepp is free software: you can redistribute it and/or modify it under the
7+
# terms of the GNU General Public License as published by the Free Software
8+
# Foundation, either version 3 of the License, or (at your option) any later
9+
# version.
10+
#
11+
# ricepp is distributed in the hope that it will be useful, but WITHOUT ANY
12+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License along with
16+
# ricepp. If not, see <https://www.gnu.org/licenses/>.
17+
#
18+
19+
cmake_minimum_required(VERSION 3.25.0)
20+
21+
project(ricepp)
22+
23+
include(FetchContent)
24+
25+
if(NOT TARGET range-v3)
26+
FetchContent_Declare(
27+
range-v3
28+
GIT_REPOSITORY https://github.com/ericniebler/range-v3
29+
GIT_TAG 0.12.0
30+
)
31+
FetchContent_MakeAvailable(range-v3)
32+
endif()
33+
34+
add_library(ricepp ricepp.cpp)
35+
36+
target_include_directories(ricepp PUBLIC include)
37+
target_link_libraries(ricepp PUBLIC range-v3)
38+
target_compile_features(ricepp PUBLIC cxx_std_20)
39+
40+
# # TODO: remove/rework
41+
# add_executable(ricepp_demo ricepp_demo.cpp)
42+
# target_link_libraries(ricepp_demo PRIVATE ricepp fmt)
43+
44+
if(WITH_TESTS)
45+
if(NOT TARGET gtest)
46+
FetchContent_Declare(
47+
googletest
48+
GIT_REPOSITORY https://github.com/google/googletest.git
49+
GIT_TAG v1.14.0
50+
)
51+
FetchContent_MakeAvailable(googletest)
52+
endif()
53+
54+
enable_testing()
55+
include(GoogleTest)
56+
57+
add_executable(ricepp_test
58+
test/bitstream_test.cpp
59+
test/byteorder_test.cpp
60+
test/codec_test.cpp
61+
)
62+
63+
target_link_libraries(ricepp_test PRIVATE ricepp gtest gmock gtest_main)
64+
65+
if(ENABLE_COVERAGE)
66+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
67+
foreach(target ricepp ricepp_test)
68+
target_compile_options(
69+
${target} PRIVATE -fprofile-instr-generate -fcoverage-mapping
70+
-fno-omit-frame-pointer)
71+
target_link_options(${target} PRIVATE -fprofile-instr-generate
72+
-fcoverage-mapping)
73+
endforeach()
74+
endif()
75+
endif()
76+
77+
if(NOT CMAKE_CROSSCOMPILING)
78+
gtest_discover_tests(ricepp_test DISCOVERY_TIMEOUT 120)
79+
endif()
80+
endif()

0 commit comments

Comments
 (0)