Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
push:
branches: [ main, feat/demo-wav ]
pull_request:
branches: [ main ]

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install build deps
run: |
sudo apt-get update
sudo apt-get install -y git autoconf automake libtool gcc make pkg-config
- name: Prepare build
run: |
./autogen.sh
./configure
- name: Build
run: |
make -j2
- name: Run tests
run: |
make check -j2
34 changes: 34 additions & 0 deletions .github/workflows/clang-sanitizers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Clang/ASAN/UBSAN

on:
push:
branches: [ main, wip/** ]
pull_request:
branches: [ main ]

jobs:
build-and-test-sanitizers:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang llvm-dev libclang-dev build-essential autotools-dev automake autoconf libtool pkg-config

- name: Configure with sanitizers
env:
CC: clang
CFLAGS: "-g -O1 -fsanitize=address,undefined -fno-omit-frame-pointer"
LDFLAGS: "-fsanitize=address,undefined"
run: |
./autogen.sh || true
./configure CC=$CC CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"

- name: Build
run: make -j$(nproc)

- name: Run tests
run: make check -j2
23 changes: 23 additions & 0 deletions .github/workflows/dnn-generator-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: DNN generator lint

on:
push:
paths:
- 'dnn/**'
- '.github/workflows/dnn-generator-lint.yml'
pull_request:
paths:
- 'dnn/**'

jobs:
msvc-compat-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Run DNN MSVC compatibility linter
run: |
python3 dnn/torch/check_msvc_compat.py
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ if (MSVC)
endif()
endif()

# Workaround: MSVC's cl (not clang-cl) struggles compiling generated DNN sources (large initializers and some constructs).
# Disable DNN-related features on MSVC as a temporary mitigation until the generated sources are made MSVC-friendly.
if(MSVC AND NOT MSVC_CLANG_CL)
if(OAC_DNN)
message(WARNING "Disabling OAC_DNN on MSVC because generated DNN sources may be incompatible with MSVC.")
set(OAC_DNN FALSE CACHE BOOL "Disable DNN on MSVC" FORCE)
endif()
if(OAC_DRED)
message(WARNING "Disabling OAC_DRED on MSVC because generated DNN sources may be incompatible with MSVC.")
set(OAC_DRED FALSE CACHE BOOL "Disable DRED on MSVC" FORCE)
endif()
if(OAC_OSCE)
message(WARNING "Disabling OAC_OSCE on MSVC because generated DNN sources may be incompatible with MSVC.")
set(OAC_OSCE FALSE CACHE BOOL "Disable OSCE on MSVC" FORCE)
endif()
endif()

set(OAC_BUILD_SHARED_LIBRARY_HELP_STR "build shared library.")
option(OAC_BUILD_SHARED_LIBRARY ${OAC_BUILD_SHARED_LIBRARY_HELP_STR} OFF)
if(OAC_BUILD_SHARED_LIBRARY OR BUILD_SHARED_LIBS OR OAC_BUILD_FRAMEWORK)
Expand Down Expand Up @@ -273,7 +290,8 @@ set(Oac_PUBLIC_HEADER
${CMAKE_CURRENT_SOURCE_DIR}/include/oac_defines.h
${CMAKE_CURRENT_SOURCE_DIR}/include/oac_multistream.h
${CMAKE_CURRENT_SOURCE_DIR}/include/oac_projection.h
${CMAKE_CURRENT_SOURCE_DIR}/include/oac_types.h)
${CMAKE_CURRENT_SOURCE_DIR}/include/oac_types.h
${CMAKE_CURRENT_SOURCE_DIR}/include/opus_types.h)

if(OAC_CUSTOM_MODES)
list(APPEND Oac_PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/oac_custom.h)
Expand Down
35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Contributing
============

Thank you for contributing to OAC! This document explains how to run the test
suite locally and what to expect from CI when opening a pull request.

Running tests locally
---------------------

After building the project (see `README`), run the integrated tests:

% make check

On recent systems the test suite should complete quickly and report the
number of passing tests. For example:

Testsuite summary for oac
# TOTAL: 17
# PASS: 17

Continuous Integration
----------------------

The repository includes GitHub Actions workflows that build the project and
run `make -f Makefile.unix check` on push and pull requests. Please make
sure tests pass locally before opening a PR; the CI will run the test
suite and must succeed before merging.

Tips
----

- If a test fails locally, run `make clean` and rebuild before investigating.
- Some tests require a POSIX-like environment (e.g., Linux or macOS).

If you have questions, open an issue or discuss on the PR.
19 changes: 17 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ if OAC_ARM_EXTERNAL_ASM
liboac_la_LIBADD += libarmasm.la
endif

pkginclude_HEADERS = include/oac.h include/oac_multistream.h include/oac_types.h include/oac_defines.h include/oac_projection.h
pkginclude_HEADERS = include/oac.h include/oac_multistream.h include/oac_types.h include/opus_types.h include/oac_defines.h include/oac_projection.h

noinst_HEADERS = $(OAC_HEAD) $(SILK_HEAD) $(CELT_HEAD) $(LPCNET_HEAD)

Expand All @@ -174,6 +174,8 @@ noinst_PROGRAMS = celt/tests/test_unit_cwrs32 \
tests/test_oac_extensions \
tests/test_oac_padding \
tests/test_oac_projection \
tests/test_oac_demo_wav \
tests/test_oac_demo_input_wav \
trivial_example

TESTS = celt/tests/test_unit_cwrs32 \
Expand All @@ -191,7 +193,8 @@ TESTS = celt/tests/test_unit_cwrs32 \
tests/test_oac_encode \
tests/test_oac_extensions \
tests/test_oac_padding \
tests/test_oac_projection
tests/test_oac_projection \
tests/test_oac_demo_input_wav

oac_demo_SOURCES = src/oac_demo.c
if ENABLE_LOSSGEN
Expand Down Expand Up @@ -247,6 +250,18 @@ if OAC_ARM_EXTERNAL_ASM
tests_test_oac_projection_LDADD += libarmasm.la
endif

# Test for oac_demo WAV output
TESTS += \
tests/test_oac_demo_wav \
tests/test_oac_demo_encode_only

tests_test_oac_demo_wav_SOURCES = tests/test_oac_demo_wav.c
tests_test_oac_demo_wav_LDADD = liboac.la $(NE10_LIBS) $(LIBM)

# Test for oac_demo encode-only + decode-to-wav
tests_test_oac_demo_encode_only_SOURCES = tests/test_oac_demo_encode_only.c
tests_test_oac_demo_encode_only_LDADD = liboac.la $(NE10_LIBS) $(LIBM)

silk_tests_test_unit_LPC_inv_pred_gain_SOURCES = silk/tests/test_unit_LPC_inv_pred_gain.c
silk_tests_test_unit_LPC_inv_pred_gain_LDADD = $(SILK_OBJ) $(LPCNET_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM)
if OAC_ARM_EXTERNAL_ASM
Expand Down
20 changes: 19 additions & 1 deletion Makefile.unix
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,25 @@ TESTOACPADDING_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOACPADDING_SRCS_C))
OACCOMPARE_SRCS_C = src/oac_compare.c
OACCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OACCOMPARE_SRCS_C))

TESTS := test_oac_api test_oac_decode test_oac_encode test_oac_extensions test_oac_padding
TESTS := test_oac_api test_oac_decode test_oac_encode test_oac_extensions test_oac_padding test_oac_demo_wav test_oac_demo_input_wav test_oac_demo_encode_only

TESTOACDEMOWAV_SRCS_C = tests/test_oac_demo_wav.c
TESTOACDEMOWAV_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOACDEMOWAV_SRCS_C))

TESTOACDEMOINPUTWAV_SRCS_C = tests/test_oac_demo_input_wav.c
TESTOACDEMOINPUTWAV_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOACDEMOINPUTWAV_SRCS_C))

TESTOACDEMOENCODEONLY_SRCS_C = tests/test_oac_demo_encode_only.c
TESTOACDEMOENCODEONLY_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOACDEMOENCODEONLY_SRCS_C))

test_oac_demo_wav$(EXESUFFIX): $(TESTOACDEMOWAV_OBJS) $(TARGET)
$(LINK.o.cmdline)

test_oac_demo_input_wav$(EXESUFFIX): $(TESTOACDEMOINPUTWAV_OBJS) $(TARGET)
$(LINK.o.cmdline)

test_oac_demo_encode_only$(EXESUFFIX): $(TESTOACDEMOENCODEONLY_OBJS) $(TARGET)
$(LINK.o.cmdline)

# Rules
all: lib oac_demo oac_compare $(TESTS)
Expand Down
7 changes: 6 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ options:
-inbandfec : enable SILK inband FEC
-forcemono : force mono encoding, even for stereo input
-dtx : enable SILK DTX
-wav : write output as WAV file (with header) when decoding
-wav_in : read input as WAV file and use header (sample rate, channels, format)
-loss <perc> : simulate packet loss, in percent (0-100); default: 0

input and output are little-endian signed 16-bit PCM files or OAC
bitstreams with simple oac_demo custom framing.
bitstreams with simple oac_demo custom framing. Use -wav to produce a
standard WAV file (with header) for decoded PCM output, and use -wav_in
when encoding to read standard WAV files as input (the WAV header will
be used to determine sample rate, channels and sample format).

== Testing ==

Expand Down
26 changes: 13 additions & 13 deletions dnn/adaconvtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include <math.h>


extern const WeightArray lacelayers_arrays[];
extern const WeightArray nolacelayers_arrays[];
extern const WeightArray oaci_lacelayers_arrays[];
extern const WeightArray oaci_nolacelayers_arrays[];

void adaconv_compare(
const char * prefix,
Expand Down Expand Up @@ -40,8 +40,8 @@ void adaconv_compare(
float x_out[512];
float window[40];

init_adaconv_state(hAdaConv);
compute_overlap_window(window, 40);
oaci_init_adaconv_state(hAdaConv);
oaci_compute_overlap_window(window, 40);

FILE *f_features, *f_x_in, *f_x_out;

Expand Down Expand Up @@ -88,7 +88,7 @@ void adaconv_compare(
exit(1);
}

adaconv_process_frame(hAdaConv, x_out, x_in, features, kernel_layer, gain_layer, feature_dim,
oaci_adaconv_process_frame(hAdaConv, x_out, x_in, features, kernel_layer, gain_layer, feature_dim,
frame_size, overlap_size, in_channels, out_channels, kernel_size, left_padding,
filter_gain_a, filter_gain_b, shape_gain, window, 0);

Expand Down Expand Up @@ -132,8 +132,8 @@ void adacomb_compare(
int pitch_lag;
float window[40];

init_adacomb_state(hAdaComb);
compute_overlap_window(window, 40);
oaci_init_adacomb_state(hAdaComb);
oaci_compute_overlap_window(window, 40);

FILE *f_features, *f_x_in, *f_p_in, *f_x_out;

Expand Down Expand Up @@ -194,7 +194,7 @@ void adacomb_compare(
exit(1);
}

adacomb_process_frame(hAdaComb, x_out, x_in, features, kernel_layer, gain_layer, global_gain_layer,
oaci_adacomb_process_frame(hAdaComb, x_out, x_in, features, kernel_layer, gain_layer, global_gain_layer,
pitch_lag, feature_dim, frame_size, overlap_size, kernel_size, left_padding, filter_gain_a, filter_gain_b,
log_gain_limit, window, 0);

Expand Down Expand Up @@ -229,7 +229,7 @@ void adashape_compare(
float x_out_ref[512];
float x_out[512];

init_adashape_state(hAdaShape);
oaci_init_adashape_state(hAdaShape);

FILE *f_features, *f_x_in, *f_x_out;

Expand Down Expand Up @@ -276,7 +276,7 @@ void adashape_compare(
exit(1);
}

adashape_process_frame(hAdaShape, x_out, x_in, features, alpha1, alpha2, feature_dim,
oaci_adashape_process_frame(hAdaShape, x_out, x_in, features, alpha1, alpha2, feature_dim,
frame_size, avg_pool_k, 0);

mse = 0;
Expand All @@ -298,10 +298,10 @@ int main() {
AdaCombState hAdaComb;
AdaShapeState hAdaShape;

init_adaconv_state(&hAdaConv);
oaci_init_adaconv_state(&hAdaConv);

init_lacelayers(&hLACE, lacelayers_arrays);
init_nolacelayers(&hNoLACE, nolacelayers_arrays);
oaci_init_lacelayers(&hLACE, oaci_lacelayers_arrays);
oaci_init_nolacelayers(&hNoLACE, oaci_nolacelayers_arrays);

printf("\ntesting lace.af1 (1 in, 1 out)...\n");
adaconv_compare(
Expand Down
36 changes: 18 additions & 18 deletions dnn/arm/arm_dnn_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,36 @@

# if (defined(OAC_ARM_MAY_HAVE_DOTPROD) && !defined(OAC_ARM_PRESUME_DOTPROD))

void (*const DNN_COMPUTE_LINEAR_IMPL[OAC_ARCHMASK + 1])(
void (*const oaci_DNN_COMPUTE_LINEAR_IMPL[OAC_ARCHMASK + 1])(
const LinearLayer *linear,
float *out,
const float *in
) = {
compute_linear_c, /* default */
compute_linear_c,
compute_linear_c,
MAY_HAVE_NEON(compute_linear), /* neon */
MAY_HAVE_DOTPROD(compute_linear) /* dotprod */
oaci_compute_linear_c, /* default */
oaci_compute_linear_c,
oaci_compute_linear_c,
MAY_HAVE_NEON(oaci_compute_linear), /* neon */
MAY_HAVE_DOTPROD(oaci_compute_linear) /* dotprod */
};

# endif

# if (defined(OAC_ARM_MAY_HAVE_DOTPROD) || defined(OAC_ARM_MAY_HAVE_NEON)) && !defined(OAC_ARM_PRESUME_NEON)

void (*const DNN_COMPUTE_ACTIVATION_IMPL[OAC_ARCHMASK + 1])(
void (*const oaci_DNN_COMPUTE_ACTIVATION_IMPL[OAC_ARCHMASK + 1])(
float *output,
const float *input,
int N,
int activation
) = {
compute_activation_c, /* default */
compute_activation_c,
compute_activation_c,
MAY_HAVE_NEON(compute_activation), /* neon */
MAY_HAVE_DOTPROD(compute_activation) /* dotprod */
oaci_compute_activation_c, /* default */
oaci_compute_activation_c,
oaci_compute_activation_c,
MAY_HAVE_NEON(oaci_compute_activation), /* neon */
MAY_HAVE_DOTPROD(oaci_compute_activation) /* dotprod */
};

void (*const DNN_COMPUTE_CONV2D_IMPL[OAC_ARCHMASK + 1])(
void (*const oaci_DNN_COMPUTE_CONV2D_IMPL[OAC_ARCHMASK + 1])(
const Conv2dLayer *conv,
float *out,
float *mem,
Expand All @@ -74,11 +74,11 @@ void (*const DNN_COMPUTE_CONV2D_IMPL[OAC_ARCHMASK + 1])(
int hstride,
int activation
) = {
compute_conv2d_c, /* default */
compute_conv2d_c,
compute_conv2d_c,
MAY_HAVE_NEON(compute_conv2d), /* neon */
MAY_HAVE_DOTPROD(compute_conv2d) /* dotprod */
oaci_compute_conv2d_c, /* default */
oaci_compute_conv2d_c,
oaci_compute_conv2d_c,
MAY_HAVE_NEON(oaci_compute_conv2d), /* neon */
MAY_HAVE_DOTPROD(oaci_compute_conv2d) /* dotprod */
};


Expand Down
Loading
Loading