Skip to content

Commit

Permalink
Merge pull request #13 from hexops/wrench/update-zig
Browse files Browse the repository at this point in the history
all: update to latest Zig version
  • Loading branch information
emidoots authored Dec 30, 2024
2 parents 475d6fd + 0d4f5a6 commit c15a0c4
Show file tree
Hide file tree
Showing 177 changed files with 17,304 additions and 729 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup Zig
run: |
sudo apt install xz-utils
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-linux-x86_64-0.14.0-dev.1911+3bf89f55c.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-linux-x86_64-0.14.0-dev.2577+271452d22.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: build
run: zig build
x86_64-windows:
Expand All @@ -26,10 +26,10 @@ jobs:
- name: Setup Zig
run: |
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri "https://pkg.machengine.org/zig/zig-windows-x86_64-0.14.0-dev.1911+3bf89f55c.zip" -OutFile "C:\zig.zip"
Invoke-WebRequest -Uri "https://pkg.machengine.org/zig/zig-windows-x86_64-0.14.0-dev.2577+271452d22.zip" -OutFile "C:\zig.zip"
cd C:\
7z x zig.zip
Add-Content $env:GITHUB_PATH "C:\zig-windows-x86_64-0.14.0-dev.1911+3bf89f55c\"
Add-Content $env:GITHUB_PATH "C:\zig-windows-x86_64-0.14.0-dev.2577+271452d22\"
- name: build
run: zig build
x86_64-macos:
Expand All @@ -42,7 +42,7 @@ jobs:
- name: Setup Zig
run: |
brew install xz
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-macos-x86_64-0.14.0-dev.1911+3bf89f55c.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
sudo sh -c 'wget -c https://pkg.machengine.org/zig/zig-macos-x86_64-0.14.0-dev.2577+271452d22.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin'
- name: build
run: zig build
env:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
zig-out/
.zig-cache/
.zig-cache/
Empty file added .gitmodules
Empty file.
4 changes: 2 additions & 2 deletions COPYING
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Copyright 2001-2011 Xiph.Org, Skype Limited, Octasic,
Copyright 2001-2023 Xiph.Org, Skype Limited, Octasic,
Jean-Marc Valin, Timothy B. Terriberry,
CSIRO, Gregory Maxwell, Mark Borgerding,
Erik de Castro Lopo
Erik de Castro Lopo, Mozilla, Amazon

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
Expand Down
22 changes: 22 additions & 0 deletions LICENSE_PLEASE_READ.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Contributions to the collaboration shall not be considered confidential.

Each contributor represents and warrants that it has the right and
authority to license copyright in its contributions to the collaboration.

Each contributor agrees to license the copyright in the contributions
under the Modified (2-clause or 3-clause) BSD License or the Clear BSD License.

Please see the IPR statements submitted to the IETF for the complete
patent licensing details:

Xiph.Org Foundation:
https://datatracker.ietf.org/ipr/1524/

Microsoft Corporation:
https://datatracker.ietf.org/ipr/1914/

Skype Limited:
https://datatracker.ietf.org/ipr/1602/

Broadcom Corporation:
https://datatracker.ietf.org/ipr/1526/
84 changes: 29 additions & 55 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ pub fn build(b: *std.Build) void {
.name = "opus",
.target = cross_target,
.optimize = optimize,
.link_libc = true,
});
lib.linkLibC();
lib.defineCMacro("USE_ALLOCA", null);
lib.defineCMacro("OPUS_BUILD", null);
lib.defineCMacro("HAVE_CONFIG_H", null);
lib.root_module.addCMacro("OPUS_BUILD", "1");
lib.root_module.addCMacro("VAR_ARRAYS", "1");
lib.root_module.addCMacro("HAVE_LRINTF", "1");
lib.addIncludePath(b.path("."));
lib.addIncludePath(b.path("include"));
lib.addIncludePath(b.path("celt"));
Expand All @@ -23,57 +23,31 @@ pub fn build(b: *std.Build) void {
lib.addIncludePath(b.path("silk/float"));
lib.addIncludePath(b.path("silk/fixed"));

lib.addCSourceFiles(.{ .files = sources ++ silk_sources_float, .flags = &.{} });
lib.addCSourceFiles(.{ .files = sources ++ silk_sources_float });
if (target.cpu.arch.isX86()) {
const sse = target.cpu.features.isEnabled(@intFromEnum(std.Target.x86.Feature.sse));
const sse2 = target.cpu.features.isEnabled(@intFromEnum(std.Target.x86.Feature.sse2));
const sse4_1 = target.cpu.features.isEnabled(@intFromEnum(std.Target.x86.Feature.sse4_1));

// addConfigHeader is a bit painful to work with when the check is #if defined(FOO)
if (sse and sse2 and sse4_1) {
const config_header = b.addConfigHeader(.{ .style = .blank }, .{
.OPUS_X86_MAY_HAVE_SSE = 1,
.OPUS_X86_MAY_HAVE_SSE2 = 1,
.OPUS_X86_MAY_HAVE_SSE4_1 = 1,
.OPUS_X86_PRESUME_SSE = 1,
.OPUS_X86_PRESUME_SSE2 = 1,
.OPUS_X86_PRESUME_SSE4_1 = 1,
});
lib.addConfigHeader(config_header);
} else if (sse and sse2) {
const config_header = b.addConfigHeader(.{ .style = .blank }, .{
.OPUS_X86_MAY_HAVE_SSE = 1,
.OPUS_X86_MAY_HAVE_SSE2 = 1,
.OPUS_X86_PRESUME_SSE = 1,
.OPUS_X86_PRESUME_SSE2 = 1,
});
lib.addConfigHeader(config_header);
} else if (sse) {
const config_header = b.addConfigHeader(.{ .style = .blank }, .{
.OPUS_X86_MAY_HAVE_SSE = 1,
.OPUS_X86_PRESUME_SSE = 1,
});
lib.addConfigHeader(config_header);
if (std.Target.x86.featureSetHas(target.cpu.features, .sse)) {
lib.root_module.addCMacro("OPUS_X86_MAY_HAVE_SSE", "1");
lib.root_module.addCMacro("OPUS_X86_PRESUME_SSE", "1");
lib.addCSourceFiles(.{ .files = celt_sources_sse });
}
if (std.Target.x86.featureSetHas(target.cpu.features, .sse2)) {
lib.root_module.addCMacro("OPUS_X86_MAY_HAVE_SSE2", "1");
lib.root_module.addCMacro("OPUS_X86_PRESUME_SSE2", "1");
lib.addCSourceFiles(.{ .files = celt_sources_sse2 });
}
if (std.Target.x86.featureSetHas(target.cpu.features, .sse4_1)) {
lib.root_module.addCMacro("OPUS_X86_MAY_HAVE_SSE4_1", "1");
lib.root_module.addCMacro("OPUS_X86_PRESUME_SSE4_1", "1");
lib.addCSourceFiles(.{ .files = celt_sources_sse4_1 ++ silk_sources_sse4_1 });
}

lib.addCSourceFiles(.{ .files = celt_sources_x86 ++ silk_sources_x86, .flags = &.{} });
if (sse) lib.addCSourceFiles(.{ .files = celt_sources_sse, .flags = &.{} });
if (sse2) lib.addCSourceFiles(.{ .files = celt_sources_sse2, .flags = &.{} });
if (sse4_1) lib.addCSourceFiles(.{ .files = celt_sources_sse4_1 ++ silk_sources_sse4_1, .flags = &.{} });
}

if (target.cpu.arch.isAARCH64() or target.cpu.arch.isARM()) {
const neon = target.cpu.features.isEnabled(@intFromEnum(std.Target.aarch64.Feature.neon)) or
target.cpu.features.isEnabled(@intFromEnum(std.Target.arm.Feature.neon));

const config_header = b.addConfigHeader(.{ .style = .blank }, .{
.OPUS_ARM_MAY_HAVE_NEON_INTR = neon,
.OPUS_ARM_PRESUME_NEON_INTR = neon,
});
lib.addConfigHeader(config_header);

lib.addCSourceFiles(.{ .files = celt_sources_arm ++ silk_sources_arm, .flags = &.{} });
if (neon) lib.addCSourceFiles(.{ .files = celt_sources_arm_neon ++ silk_sources_arm_neon, .flags = &.{} });
if (target.cpu.arch.isArm() and std.Target.arm.featureSetHas(target.cpu.features, .neon) or
target.cpu.arch.isAARCH64() and std.Target.aarch64.featureSetHas(target.cpu.features, .neon))
{
lib.root_module.addCMacro("OPUS_ARM_MAY_HAVE_NEON_INTR", "1");
lib.root_module.addCMacro("OPUS_ARM_PRESUME_NEON_INTR", "1");
lib.addCSourceFiles(.{ .files = celt_sources_arm_neon ++ silk_sources_arm_neon });
}

lib.installHeadersDirectory(b.path("include"), "", .{});
Expand Down Expand Up @@ -193,7 +167,7 @@ const sources = &[_][]const u8{
"silk/LPC_fit.c",
};

const celt_sources_x86 = &[_][]const u8{
const celt_sources_x86_rtcd = &[_][]const u8{
"celt/x86/x86_celt_map.c",
"celt/x86/x86cpu.c",
};
Expand All @@ -212,7 +186,7 @@ const celt_sources_sse4_1 = &[_][]const u8{
"celt/x86/pitch_sse4_1.c",
};

const celt_sources_arm = &[_][]const u8{
const celt_sources_arm_rtcd = &[_][]const u8{
"celt/arm/arm_celt_map.c",
"celt/arm/armcpu.c",
};
Expand All @@ -231,7 +205,7 @@ const celt_sources_arm_ne10 = &[_][]const u8{
"celt/arm/celt_mdct_ne10.c",
};

const silk_sources_x86 = &[_][]const u8{
const silk_sources_x86_rtcd = &[_][]const u8{
"silk/x86/x86_silk_map.c",
};

Expand All @@ -242,7 +216,7 @@ const silk_sources_sse4_1 = &[_][]const u8{
"silk/x86/VQ_WMat_EC_sse4_1.c",
};

const silk_sources_arm = &[_][]const u8{
const silk_sources_arm_rtcd = &[_][]const u8{
"silk/arm/arm_silk_map.c",
};

Expand Down
31 changes: 21 additions & 10 deletions celt/arm/arm_celt_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, c
celt_inner_prod_c, /* ARMv4 */
celt_inner_prod_c, /* EDSP */
celt_inner_prod_c, /* Media */
celt_inner_prod_neon /* NEON */
celt_inner_prod_neon,/* NEON */
celt_inner_prod_neon /* DOTPROD */
};

void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02,
int N, opus_val32 *xy1, opus_val32 *xy2) = {
dual_inner_prod_c, /* ARMv4 */
dual_inner_prod_c, /* EDSP */
dual_inner_prod_c, /* Media */
dual_inner_prod_neon /* NEON */
dual_inner_prod_neon,/* NEON */
dual_inner_prod_neon /* DOTPROD */
};
# endif

Expand All @@ -61,7 +63,8 @@ opus_val32 (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
celt_pitch_xcorr_c, /* ARMv4 */
MAY_HAVE_EDSP(celt_pitch_xcorr), /* EDSP */
MAY_HAVE_MEDIA(celt_pitch_xcorr), /* Media */
MAY_HAVE_NEON(celt_pitch_xcorr) /* NEON */
MAY_HAVE_NEON(celt_pitch_xcorr), /* NEON */
MAY_HAVE_NEON(celt_pitch_xcorr) /* DOTPROD */
};

# endif
Expand All @@ -72,7 +75,8 @@ void (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
celt_pitch_xcorr_c, /* ARMv4 */
celt_pitch_xcorr_c, /* EDSP */
celt_pitch_xcorr_c, /* Media */
celt_pitch_xcorr_float_neon /* Neon */
celt_pitch_xcorr_float_neon, /* Neon */
celt_pitch_xcorr_float_neon /* DOTPROD */
};
# endif
# endif /* FIXED_POINT */
Expand All @@ -90,6 +94,7 @@ void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])(
xcorr_kernel_c, /* EDSP */
xcorr_kernel_c, /* Media */
xcorr_kernel_neon_fixed, /* Neon */
xcorr_kernel_neon_fixed /* DOTPROD */
};

#endif
Expand All @@ -101,14 +106,16 @@ int (*const OPUS_FFT_ALLOC_ARCH_IMPL[OPUS_ARCHMASK+1])(kiss_fft_state *st) = {
opus_fft_alloc_arch_c, /* ARMv4 */
opus_fft_alloc_arch_c, /* EDSP */
opus_fft_alloc_arch_c, /* Media */
opus_fft_alloc_arm_neon /* Neon with NE10 library support */
opus_fft_alloc_arm_neon, /* Neon with NE10 library support */
opus_fft_alloc_arm_neon /* DOTPROD with NE10 library support */
};

void (*const OPUS_FFT_FREE_ARCH_IMPL[OPUS_ARCHMASK+1])(kiss_fft_state *st) = {
opus_fft_free_arch_c, /* ARMv4 */
opus_fft_free_arch_c, /* EDSP */
opus_fft_free_arch_c, /* Media */
opus_fft_free_arm_neon /* Neon with NE10 */
opus_fft_free_arm_neon, /* Neon with NE10 */
opus_fft_free_arm_neon /* DOTPROD with NE10 */
};
# endif /* CUSTOM_MODES */

Expand All @@ -118,7 +125,8 @@ void (*const OPUS_FFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg,
opus_fft_c, /* ARMv4 */
opus_fft_c, /* EDSP */
opus_fft_c, /* Media */
opus_fft_neon /* Neon with NE10 */
opus_fft_neon, /* Neon with NE10 */
opus_fft_neon /* DOTPROD with NE10 */
};

void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg,
Expand All @@ -127,7 +135,8 @@ void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg,
opus_ifft_c, /* ARMv4 */
opus_ifft_c, /* EDSP */
opus_ifft_c, /* Media */
opus_ifft_neon /* Neon with NE10 */
opus_ifft_neon, /* Neon with NE10 */
opus_ifft_neon /* DOTPROD with NE10 */
};

void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
Expand All @@ -139,7 +148,8 @@ void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
clt_mdct_forward_c, /* ARMv4 */
clt_mdct_forward_c, /* EDSP */
clt_mdct_forward_c, /* Media */
clt_mdct_forward_neon /* Neon with NE10 */
clt_mdct_forward_neon, /* Neon with NE10 */
clt_mdct_forward_neon /* DOTPROD with NE10 */
};

void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
Expand All @@ -151,7 +161,8 @@ void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l,
clt_mdct_backward_c, /* ARMv4 */
clt_mdct_backward_c, /* EDSP */
clt_mdct_backward_c, /* Media */
clt_mdct_backward_neon /* Neon with NE10 */
clt_mdct_backward_neon, /* Neon with NE10 */
clt_mdct_backward_neon /* DOTPROD with NE10 */
};

# endif /* HAVE_ARM_NE10 */
Expand Down
Loading

0 comments on commit c15a0c4

Please sign in to comment.