Skip to content

Commit be15850

Browse files
committed
Allow disabling codecs at compile time
- Replace hard-coded defines in of_openfec_profile.h and some other files with of_build_config.h configured by cmake. - Add relevant cmake options. - If needed codecs are disabled, exclude corresponding tests. - Add minimal build to CI.
1 parent 8d3cc97 commit be15850

File tree

16 files changed

+250
-105
lines changed

16 files changed

+250
-105
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ on:
1818

1919
jobs:
2020

21-
build:
21+
default-build:
2222
strategy:
2323
matrix:
2424
image: [ubuntu-latest, macos-latest]
@@ -53,9 +53,46 @@ jobs:
5353
cd build
5454
make DESTDIR=../dist install
5555
56+
minimal-build:
57+
runs-on: ubuntu-latest
58+
name: minimal-build
59+
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v4
63+
with:
64+
fetch-depth: 0
65+
66+
- name: CMake
67+
run: |
68+
mkdir build
69+
cd build
70+
cmake \
71+
-DOF_USE_REED_SOLOMON_CODEC=OFF \
72+
-DOF_USE_REED_SOLOMON_2_M_CODEC=ON \
73+
-DOF_USE_LDPC_STAIRCASE_CODEC=OFF \
74+
-DOF_USE_2D_PARITY_MATRIX_CODEC=OFF \
75+
-DOF_USE_LDPC_FROM_FILE_CODEC=OFF \
76+
..
77+
78+
- name: Make
79+
run: |
80+
cd build
81+
make -j2
82+
83+
- name: Make test
84+
run: |
85+
cd build
86+
make test
87+
88+
- name: Make install
89+
run: |
90+
cd build
91+
make DESTDIR=../dist install
92+
5693
release:
5794
if: startsWith(github.ref, 'refs/tags/v')
58-
needs: [build]
95+
needs: [default-build, minimal-build]
5996

6097
runs-on: ubuntu-latest
6198
steps:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
/dist
44
/perf_eval/descr_stats
55
/pc/openfec.pc
6+
/src/lib_common/of_build_config.h
67
._*
8+
.justfile

applis/eperftool/sender.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ encode (void)
327327
* is above a certain threshold), so do not sent it since the codec already knows it.
328328
*/
329329
blk->ldpc_dont_send_last_repair = false; /* by default */
330+
#ifdef OF_USE_LDPC_STAIRCASE_CODEC
330331
if (codec_id == OF_CODEC_LDPC_STAIRCASE_STABLE) {
331332
bool lib_says_its_null; /* boolean */
332333

@@ -356,6 +357,7 @@ encode (void)
356357
}
357358
#endif
358359
}
360+
#endif
359361
if (of_release_codec_instance(ses) != OF_STATUS_OK) {
360362
OF_PRINT_ERROR(("ERROR: of_release_codec_instance() failed\n"))
361363
goto error;
@@ -378,4 +380,3 @@ encode (void)
378380
error:
379381
return OF_STATUS_ERROR;
380382
}
381-
Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
file (GLOB simple_server_sources ./simple_server.c)
1+
if(OF_USE_REED_SOLOMON_2_M_CODEC AND OF_USE_LDPC_STAIRCASE_CODEC)
2+
# simple_server
3+
file (GLOB simple_server_sources ./simple_server.c)
24

3-
set(SIMPLE_SERVER_BIN ${EXECUTABLE_OUTPUT_PATH}/simple_server CACHE STRING "simple_server exe")
4-
add_executable(simple_server ${simple_server_sources})
5+
set(SIMPLE_SERVER_BIN ${EXECUTABLE_OUTPUT_PATH}/simple_server CACHE STRING "simple_server exe")
6+
add_executable(simple_server ${simple_server_sources})
57

6-
target_link_libraries(simple_server openfec m)
8+
target_link_libraries(simple_server openfec m)
79

10+
# simple_client
11+
file (GLOB simple_client_sources ./simple_client.c)
812

9-
file (GLOB simple_client_sources ./simple_client.c)
13+
set(SIMPLE_SERVER_BIN ${EXECUTABLE_OUTPUT_PATH}/simple_client CACHE STRING "simple_client exe")
14+
add_executable(simple_client ${simple_client_sources})
1015

11-
set(SIMPLE_SERVER_BIN ${EXECUTABLE_OUTPUT_PATH}/simple_client CACHE STRING "simple_client exe")
12-
add_executable(simple_client ${simple_client_sources})
16+
target_link_libraries(simple_client openfec m)
1317

14-
target_link_libraries(simple_client openfec m)
15-
16-
if(INSTALL_DEVTOOLS)
17-
install(TARGETS simple_server simple_client
18-
RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
19-
COMPONENT applis)
20-
endif()
18+
# install
19+
if(INSTALL_DEVTOOLS)
20+
install(TARGETS simple_server simple_client
21+
RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
22+
COMPONENT applis)
23+
endif()
24+
endif(OF_USE_REED_SOLOMON_2_M_CODEC AND OF_USE_LDPC_STAIRCASE_CODEC)

applis/howto_examples/simple_client_server/simple_client.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,20 @@
3131
* knowledge of the CeCILL-C license and that you accept its terms.
3232
*/
3333

34-
/* this is the decoder */
35-
#define OF_USE_DECODER
36-
3734
#include "simple_client_server.h"
3835

36+
#ifndef OF_USE_DECODER
37+
#error "OF_USE_DECODER undefined"
38+
#endif
39+
40+
#ifndef OF_USE_REED_SOLOMON_2_M_CODEC
41+
#error "OF_USE_REED_SOLOMON_2_M_CODEC undefined"
42+
#endif
43+
44+
#ifndef OF_USE_LDPC_STAIRCASE_CODEC
45+
#error "OF_USE_LDPC_STAIRCASE_CODEC undefined"
46+
#endif
47+
3948

4049
/*
4150
* Chose which decoding method to use... Both should be equivalent.
@@ -480,4 +489,3 @@ dump_buffer_32 (void *buf,
480489
}
481490
printf("\n");
482491
}
483-

applis/howto_examples/simple_client_server/simple_server.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,20 @@
3131
* knowledge of the CeCILL-C license and that you accept its terms.
3232
*/
3333

34-
/* this is the encoder */
35-
#define OF_USE_ENCODER
36-
3734
#include "simple_client_server.h"
3835

36+
#ifndef OF_USE_ENCODER
37+
#error "OF_USE_ENCODER undefined"
38+
#endif
39+
40+
#ifndef OF_USE_REED_SOLOMON_2_M_CODEC
41+
#error "OF_USE_REED_SOLOMON_2_M_CODEC undefined"
42+
#endif
43+
44+
#ifndef OF_USE_LDPC_STAIRCASE_CODEC
45+
#error "OF_USE_LDPC_STAIRCASE_CODEC undefined"
46+
#endif
47+
3948

4049
/* Prototypes */
4150

@@ -373,4 +382,3 @@ dump_buffer_32 (void *buf,
373382
}
374383
printf("\n");
375384
}
376-

src/CMakeLists.txt

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
file (GLOB_RECURSE openfec_sources *)
1+
file(GLOB_RECURSE openfec_sources *)
2+
3+
option(OF_USE_REED_SOLOMON_CODEC "Enable Reed-Solomon 2_8 codec" ON)
4+
option(OF_USE_REED_SOLOMON_2_M_CODEC "Enable Reed-Solomon 2_M codec" ON)
5+
option(OF_USE_LDPC_STAIRCASE_CODEC "Enable LDPC-Staircase codec" ON)
6+
option(OF_USE_2D_PARITY_MATRIX_CODEC "Enable 2d parity matrix codec" ON)
7+
option(OF_USE_LDPC_FROM_FILE_CODEC "Enable ldpc_from_file codec" OFF)
8+
9+
option(ASSEMBLY_SSE_OPT "Enable SSE optimizations for XOR operations" OFF)
10+
11+
configure_file(lib_common/of_build_config.h.in
12+
${CMAKE_CURRENT_SOURCE_DIR}/lib_common/of_build_config.h)
213

314
# Use -DBUILD_STATIC_LIBS=ON to build static libraries instead of shared.
415
option(BUILD_STATIC_LIBS "Build the static library" OFF)
@@ -10,14 +21,14 @@ else(BUILD_STATIC_LIBS)
1021
endif(BUILD_STATIC_LIBS)
1122

1223
# From: $cmake --help-property SOVERSION
13-
# For shared libraries VERSION and SOVERSION can be used to specify
14-
# the build version and api version respectively.
24+
# For shared libraries VERSION and SOVERSION can be used to specify
25+
# the build version and api version respectively.
1526
#
1627
# Edit it as appropriate to be in line with the src/lib_common/of_openfec_api.c::more_about() version
1728
#
1829
set_target_properties(openfec PROPERTIES
19-
VERSION 1.4.2
20-
SOVERSION 1)
30+
VERSION 1.4.2
31+
SOVERSION 1)
2132

2233
# Feel free to edit as appropriate the "target_link_libraries".
2334
#
@@ -40,7 +51,7 @@ install(TARGETS openfec DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
4051
install(
4152
DIRECTORY ${PROJECT_SOURCE_DIR}/src/
4253
DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/openfec
43-
FILES_MATCHING PATTERN "*.h*")
54+
FILES_MATCHING PATTERN "*.h")
4455

4556
include(TestBigEndian)
4657
test_big_endian(BIG_ENDIAN)

src/lib_advanced/ldpc_from_file/of_codec_profile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
/****** GENERAL SETUP OPTIONS; EDIT AS APPROPRIATE ****************************/
3535

36-
#define OF_USE_LDPC_FROM_FILE_CODEC
36+
#include "../../lib_common/of_build_config.h"
3737

3838
#define READ_MATRIX_FILE
3939

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* OpenFEC.org AL-FEC Library.
3+
* (c) Copyright 2009 - 2012 INRIA - All rights reserved
4+
* (c) Copyright 2024 Roc Streaming authors
5+
*
6+
* This software is governed by the CeCILL-C license under French law and
7+
* abiding by the rules of distribution of free software. You can use,
8+
* modify and/ or redistribute the software under the terms of the CeCILL-C
9+
* license as circulated by CEA, CNRS and INRIA at the following URL
10+
* "http://www.cecill.info".
11+
*
12+
* As a counterpart to the access to the source code and rights to copy,
13+
* modify and redistribute granted by the license, users are provided only
14+
* with a limited warranty and the software's author, the holder of the
15+
* economic rights, and the successive licensors have only limited
16+
* liability.
17+
*
18+
* In this respect, the user's attention is drawn to the risks associated
19+
* with loading, using, modifying and/or developing or reproducing the
20+
* software by the user in light of its specific status of free software,
21+
* that may mean that it is complicated to manipulate, and that also
22+
* therefore means that it is reserved for developers and experienced
23+
* professionals having in-depth computer knowledge. Users are therefore
24+
* encouraged to load and test the software's suitability as regards their
25+
* requirements in conditions enabling the security of their systems and/or
26+
* data to be ensured and, more generally, to use and operate it in the
27+
* same conditions as regards security.
28+
*
29+
* The fact that you are presently reading this means that you have had
30+
* knowledge of the CeCILL-C license and that you accept its terms.
31+
*/
32+
33+
#ifndef OF_BUILD_CONFIG_H
34+
#define OF_BUILD_CONFIG_H
35+
36+
/*
37+
* Here we enable or disable encoder and decoder support.
38+
*/
39+
#define OF_USE_ENCODER
40+
#define OF_USE_DECODER
41+
42+
/*
43+
* Here we enable or disable certain codecs (a.k.a. FEC schemes).
44+
*
45+
* By default most codecs are enabled.
46+
*
47+
* Disabling codecs prevents the compiler to read associated code
48+
* during compilation.
49+
*
50+
* Removing codecs known to be useless can be important for highly
51+
* specialized usage of OpenFEC, like embedded systems.
52+
*
53+
* Removing codecs may be also needed due to licensing issues.
54+
*/
55+
#cmakedefine OF_USE_REED_SOLOMON_CODEC
56+
#cmakedefine OF_USE_REED_SOLOMON_2_M_CODEC
57+
#cmakedefine OF_USE_LDPC_STAIRCASE_CODEC
58+
#cmakedefine OF_USE_2D_PARITY_MATRIX_CODEC
59+
#cmakedefine OF_USE_LDPC_FROM_FILE_CODEC
60+
61+
/*
62+
* Here we enable or disable certain solving systems.
63+
*
64+
* By default all systems are considered.
65+
*
66+
* Note that the above codecs require certain solving systems.
67+
* For instance, LDPC-staircase requires IT decoding, and ML
68+
* decoding is highly recommended for improved performances.
69+
*
70+
* Removing solving systems known to be useless can be important
71+
* for highly specialized usage of OpenFEC, like embedded systems.
72+
*/
73+
#define OF_USE_LINEAR_BINARY_CODES_UTILS
74+
#define OF_USE_GALOIS_FIELD_CODES_UTILS
75+
76+
/*
77+
* Define if you want to enable the use of the ML (Maximum Likelyhood) decoding.
78+
* If enabled, in practice decoding will start with IT decoding and end with ML
79+
* decoding (in this case a Gaussian Elimination) if needed.
80+
*
81+
* Warning: ML decoding enables to reach the best erasure recovery capabilities,
82+
* at the expense of potentially significant computation loads, depending on
83+
* the size and complexity of the simplified system at the end of IT decoding.
84+
*
85+
* See the MAX_NB_SOURCE_SYMBOLS_DEFAULT/MAX_NB_ENCODING_SYMBOLS_DEFAULT
86+
* constants that enable to limit the computation overheads.
87+
*/
88+
#define ML_DECODING
89+
90+
/*
91+
* Define if you need SSE optimizations for XOR operations.
92+
* This is useful for PC usage, with processors that support this
93+
* extension (i.e. all the processors except the very old ones).
94+
*
95+
* NB: if SSE is not defined, then we'll use regular XOR operations,
96+
* either on 32 bit or 64 bit integers depending on the operating
97+
* system.
98+
*/
99+
#cmakedefine ASSEMBLY_SSE_OPT
100+
101+
#endif // OF_BUILD_CONFIG_H

0 commit comments

Comments
 (0)