Skip to content

Commit 2815ae3

Browse files
SunrisepeakSunrisepeak
andauthored
compat.ogg 1.3.6, compat.opus 1.6.1, compat.opusfile 0.12: Opus audio (BSD-3-Clause) (#612)
The three Xiph.Org libraries an application decodes .opus files with, as one change because they are one feature: libogg (the container), libopus (the codec) and opusfile (Ogg Opus files over both). All BSD-3-Clause, each built from upstream's release tarball as a static library. compat.ogg: src/framing.c and src/bitwise.c; <ogg/config_types.h> is generated as libogg's CMake writes it (int16_t..uint64_t), and included by <ogg/os_types.h> on Linux (Windows and macOS have their own typedefs). compat.opus: upstream's default floating-point library from its own source lists (celt_sources.mk, silk_sources.mk, opus_sources.mk): encoder and decoder, multistream, ambisonics projection, the repacketizer. Deep PLC, DRED, OSCE and QEXT stay off, as upstream's defaults have them; plain C, without the per-file x86 intrinsics or run-time CPU detection. A generated config.h (OPUS_BUILD, PACKAGE_VERSION "1.6.1", VAR_ARRAYS, HAVE_LRINT[F], ENABLE_HARDENING) and the internal header directories are private include directories of each platform block; consumers see include/ only (<opus.h>). -fvisibility=hidden on Linux and macOS, as upstream's configure. The tarball is downloads.xiph.org's (GitHub has the tag but no 1.6.1 release, and the tag archive lacks package_version and the DNN data). compat.opusfile: libopusfile (info.c, internal.c, opusfile.c, stream.c) over compat.ogg and compat.opus; libopusurl (HTTP over OpenSSL) is not built. GLOBAL is upstream's release asset, CN the gitcode mcpp-res mirror of the same bytes; autoupdate follows the v${version} tags. The member tests/examples/opus runs on all three platforms: CELT and SILK round trips with their signal-to-noise ratio, the packet parsers, 5.1 multistream, ambisonics, the repacketizer, and an Ogg Opus stream paged with libogg and read back through opusfile (OpusHead, OpusTags, the exact length after end trimming, sample-accurate seeking). Co-authored-by: Sunrisepeak <speakshen@outlook.com>
1 parent 731d80a commit 2815ae3

7 files changed

Lines changed: 771 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@
99

1010
### Added
1111

12+
- **compat.ogg 1.3.6、compat.opus 1.6.1、compat.opusfile 0.12(新包)。** Opus 音频的三个 Xiph.Org 库,均为
13+
BSD-3-Clause,均以上游发布 tarball 从源码构建为静态库。compat.ogg:Ogg 容器的分页与位打包(`src/framing.c`、
14+
`src/bitwise.c`),`<ogg/config_types.h>` 按上游 CMake 的结果由 `generated_files` 生成(int16_t…uint64_t)。
15+
compat.opus:Opus 编解码器(RFC 6716)的编码器与解码器、multistream、ambisonics projection 与 repacketizer;
16+
上游默认的浮点构建(源文件取自 `celt_sources.mk` / `silk_sources.mk` / `opus_sources.mk`),deep PLC、DRED、
17+
OSCE 与 QEXT 关闭(上游默认),纯 C、不启用 SIMD 内建函数与运行时 CPU 检测(x86 内建函数需要逐文件 `-m` 标志);
18+
生成的 `config.h`(`OPUS_BUILD`、`PACKAGE_VERSION "1.6.1"`、`VAR_ARRAYS`、`ENABLE_HARDENING`)与内部头文件目录
19+
是私有包含目录,使用者只看到 `include/`(`#include <opus.h>`);Linux/macOS 以 `-fvisibility=hidden` 编译,
20+
与上游 configure 一致。compat.opusfile:Ogg Opus 文件(RFC 7845)的解码与精确定位,依赖 compat.ogg 与
21+
compat.opus;只构建 libopusfile(不含需要 OpenSSL 的 libopusurl / HTTP)。GLOBAL 为上游发布资产
22+
(opus 为 downloads.xiph.org,GitHub 无 1.6.1 发布;ogg 与 opusfile 为 GitHub 发布资产),CN 为 GitCode
23+
`mcpp-res/opus`、`mcpp-res/ogg`、`mcpp-res/opusfile` 镜像,sha256 一致;声明 `extensions.autoupdate`(`v${version}`
24+
标签)。新增测试成员 `tests/examples/opus`(三平台):CELT 与 SILK 往返(信噪比)、包解析、5.1 multistream、
25+
ambisonics、repacketizer,以 libogg 生成的 Ogg Opus 流经 opusfile 读取(OpusHead、OpusTags、精确长度、定位)。
1226
- **mcpplibs.mwrap.box2d 3.2.0(新包)。** box2d-m:以 C++23 模块(`import mcpplibs.mwrap.box2d;`)使用
1327
compat.box2d 3.2.0。按上游全局名导出已安装头文件的 110 个类型、3 个不透明结构体、176 个枚举值、506 个 `B2_API` 函数、
1428
91 个内联函数、8 个 C++ 向量运算符与 `b2_lengthUnitsPerMeter`;头文件的 13 个 `static const` 对象(内部链接)以同类型、

‎mcpp.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ members = [
115115
"tests/examples/openblas",
116116
"tests/examples/openmp",
117117
"tests/examples/openssl",
118+
"tests/examples/opus",
118119
"tests/examples/recastnavigation",
119120
"tests/examples/recastnavigation-features",
120121
"tests/examples/richdem",

‎pkgs/c/compat.ogg.lua‎

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
-- compat.ogg — libogg, the Ogg container's bitstream and framing library
2+
-- (Xiph.Org), BSD-3-Clause.
3+
--
4+
-- Ogg is the container Opus (RFC 7845), Vorbis, FLAC-in-Ogg and Theora travel
5+
-- in: libogg packs packets into pages and back (ogg_stream_* / ogg_sync_*),
6+
-- and carries the bit packer the codecs use (oggpack_* / oggpackB_*). It is
7+
-- the container half of compat.opusfile.
8+
--
9+
-- ─────────────────────────────────────────────────────────────────────────
10+
-- THE RELEASE TARBALL AND TWO SOURCES
11+
--
12+
-- The archive is upstream's release tarball (libogg-1.3.6.tar.gz, attached to
13+
-- the v1.3.6 GitHub release, whose notes give this sha256; the same bytes as
14+
-- downloads.xiph.org). The library is two files, src/framing.c and
15+
-- src/bitwise.c — upstream's whole `ogg` target.
16+
--
17+
-- ─────────────────────────────────────────────────────────────────────────
18+
-- THE ONE GENERATED HEADER
19+
--
20+
-- <ogg/os_types.h> picks the ogg_int*_t typedefs itself on Windows (MinGW,
21+
-- MSVC/clang-cl) and on Apple, and on every other system includes
22+
-- <ogg/config_types.h> — the file configure / CMake generate from
23+
-- include/ogg/config_types.h.in. It is generated here
24+
-- (mcpp_generated/ogg/config_types.h) as CMake writes it: <stdint.h>,
25+
-- <inttypes.h> and <sys/types.h> present, int16_t…uint64_t for the six
26+
-- typedefs. That is the answer on Linux and on Emscripten; Windows and macOS
27+
-- never include it. `mcpp_generated` is a public include directory because
28+
-- the public <ogg/os_types.h> includes it.
29+
--
30+
-- kind = "lib": a static library. ogg.h declares no import/export attributes,
31+
-- so nothing is needed on Windows.
32+
package = {
33+
spec = "1",
34+
namespace = "compat",
35+
name = "ogg",
36+
description = "libogg 1.3.6 — the Ogg container's framing and bit-packing library (Xiph.Org), BSD-3-Clause",
37+
licenses = {"BSD-3-Clause"},
38+
repo = "https://github.com/xiph/ogg",
39+
type = "package",
40+
41+
extensions = {
42+
autoupdate = {
43+
tag = "v${version}",
44+
url = "https://github.com/xiph/ogg/releases/download/${tag}/libogg-${version}.tar.gz",
45+
},
46+
},
47+
48+
xpm = {
49+
linux = {
50+
["1.3.6"] = {
51+
url = {
52+
GLOBAL = "https://github.com/xiph/ogg/releases/download/v1.3.6/libogg-1.3.6.tar.gz",
53+
CN = "https://gitcode.com/mcpp-res/ogg/releases/download/1.3.6/libogg-1.3.6.tar.gz",
54+
},
55+
sha256 = "83e6704730683d004d20e21b8f7f55dcb3383cdf84c0daedf30bde175f774638",
56+
},
57+
},
58+
macosx = {
59+
["1.3.6"] = {
60+
url = {
61+
GLOBAL = "https://github.com/xiph/ogg/releases/download/v1.3.6/libogg-1.3.6.tar.gz",
62+
CN = "https://gitcode.com/mcpp-res/ogg/releases/download/1.3.6/libogg-1.3.6.tar.gz",
63+
},
64+
sha256 = "83e6704730683d004d20e21b8f7f55dcb3383cdf84c0daedf30bde175f774638",
65+
},
66+
},
67+
windows = {
68+
["1.3.6"] = {
69+
url = {
70+
GLOBAL = "https://github.com/xiph/ogg/releases/download/v1.3.6/libogg-1.3.6.tar.gz",
71+
CN = "https://gitcode.com/mcpp-res/ogg/releases/download/1.3.6/libogg-1.3.6.tar.gz",
72+
},
73+
sha256 = "83e6704730683d004d20e21b8f7f55dcb3383cdf84c0daedf30bde175f774638",
74+
},
75+
},
76+
},
77+
78+
mcpp = {
79+
language = "c++23",
80+
import_std = false,
81+
c_standard = "c99",
82+
83+
-- <ogg/ogg.h>, <ogg/os_types.h>; <ogg/config_types.h> from mcpp_generated.
84+
include_dirs = { "*/include", "mcpp_generated" },
85+
86+
sources = { "*/src/framing.c", "*/src/bitwise.c" },
87+
88+
generated_files = {
89+
["mcpp_generated/ogg/config_types.h"] = [==[
90+
#ifndef __CONFIG_TYPES_H__
91+
#define __CONFIG_TYPES_H__
92+
93+
/* include/ogg/config_types.h.in of libogg 1.3.6, filled in as its CMake
94+
build fills it in on a C99 system (stdint.h, inttypes.h, sys/types.h). */
95+
#define INCLUDE_INTTYPES_H 1
96+
#define INCLUDE_STDINT_H 1
97+
#define INCLUDE_SYS_TYPES_H 1
98+
99+
#if INCLUDE_INTTYPES_H
100+
# include <inttypes.h>
101+
#endif
102+
#if INCLUDE_STDINT_H
103+
# include <stdint.h>
104+
#endif
105+
#if INCLUDE_SYS_TYPES_H
106+
# include <sys/types.h>
107+
#endif
108+
109+
typedef int16_t ogg_int16_t;
110+
typedef uint16_t ogg_uint16_t;
111+
typedef int32_t ogg_int32_t;
112+
typedef uint32_t ogg_uint32_t;
113+
typedef int64_t ogg_int64_t;
114+
typedef uint64_t ogg_uint64_t;
115+
116+
#endif
117+
]==],
118+
},
119+
120+
linux = { cflags = { "-fPIC" } },
121+
macosx = { cflags = { "-fPIC" } },
122+
123+
targets = { ogg = { kind = "lib" } },
124+
deps = {},
125+
},
126+
}

‎pkgs/c/compat.opus.lua‎

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
-- compat.opus — libopus, the Opus audio codec (RFC 6716; Xiph.Org, Skype,
2+
-- Mozilla, Amazon and others), BSD-3-Clause.
3+
--
4+
-- The reference encoder and decoder of Opus: SILK for speech, CELT for music,
5+
-- and the hybrid of both, at 8–48 kHz, mono to 255 channels (multistream and
6+
-- ambisonic projection), with the repacketizer and the packet parsers. The
7+
-- codec half of compat.opusfile, which reads Ogg Opus files over it.
8+
--
9+
-- ─────────────────────────────────────────────────────────────────────────
10+
-- THE RELEASE TARBALL, NOT THE TAG ARCHIVE
11+
--
12+
-- 1.6.1 is published on downloads.xiph.org (its SHA256SUMS.txt gives this
13+
-- sha256); the GitHub repository has the v1.6.1 tag but no release. The
14+
-- tarball is what a build without autotools needs: `package_version`, and
15+
-- the DNN model data (dnn/*_data.c) that the tag archive leaves to
16+
-- `autogen.sh` to download. This build compiles none of dnn/, but a future
17+
-- deep-PLC / DRED / OSCE feature could, from the same bytes.
18+
--
19+
-- ─────────────────────────────────────────────────────────────────────────
20+
-- WHAT IS BUILT: UPSTREAM'S DEFAULT FLOATING-POINT LIBRARY, IN PLAIN C
21+
--
22+
-- The sources are the lists of upstream's own makefiles for a float build
23+
-- (CMake and meson read the same .mk files):
24+
--
25+
-- celt_sources.mk CELT_SOURCES (18 files; mini_kfft.c is QEXT-only)
26+
-- silk_sources.mk SILK_SOURCES (every silk/*.c) + SILK_SOURCES_FLOAT
27+
-- (every silk/float/*.c)
28+
-- opus_sources.mk OPUS_SOURCES + OPUS_SOURCES_FLOAT (14 files; the
29+
-- demos and comparison tools in src/ are not library code)
30+
--
31+
-- The features are upstream's defaults in configure, CMake and meson alike:
32+
-- floating point (not FIXED_POINT), the float API, hardening on, assertions,
33+
-- custom modes, fuzzing and FLOAT_APPROX off, and the four optional
34+
-- extensions OFF — deep PLC, DRED and OSCE (the DNN features, `dnn/`) and
35+
-- QEXT (the 96 kHz quality extension). Stack arrays are C99 VLAs
36+
-- (VAR_ARRAYS, which CMake picks on every compiler that has them, as clang
37+
-- and gcc do on all three platforms here).
38+
--
39+
-- No SIMD and no run-time CPU detection. Upstream's x86 intrinsics are per
40+
-- file: pitch_sse4_1.c needs -msse4.1, NSQ_del_dec_avx2.c -mavx2, and so on,
41+
-- each behind OPUS_X86_MAY_HAVE_* and the RTCD tables. A descriptor's flags
42+
-- are per package and its platform blocks per OS, not per architecture, so
43+
-- neither those files nor the aarch64-only NEON files can be selected
44+
-- correctly here; the C paths they replace are the reference implementation
45+
-- and are what upstream's own --disable-intrinsics builds run. The one
46+
-- architecture-specific line left is upstream's: celt/float_cast.h converts
47+
-- float to int with cvtss2si under __SSE__ and with vcvtns on __aarch64__,
48+
-- from the compiler's own predefined macros.
49+
--
50+
-- ─────────────────────────────────────────────────────────────────────────
51+
-- A GENERATED config.h, AND ONLY PUBLIC HEADERS FOR CONSUMERS
52+
--
53+
-- Every source includes "config.h" under HAVE_CONFIG_H. The one here
54+
-- (mcpp_generated/config.h) defines what configure would: OPUS_BUILD,
55+
-- PACKAGE_VERSION "1.6.1" (so opus_get_version_string() reads
56+
-- "libopus 1.6.1"), VAR_ARRAYS, HAVE_LRINT/HAVE_LRINTF and ENABLE_HARDENING.
57+
-- It and the internal header directories (the tarball root, celt, silk,
58+
-- silk/float — "arch.h", "debug.h", "config.h"…) are PRIVATE include
59+
-- directories of each platform block, the shape compat.sheenbidi uses: the
60+
-- -I reaches this package's translation units and not its consumers', whose
61+
-- include path gets only `*/include` — <opus.h>, <opus_multistream.h>,
62+
-- <opus_projection.h>, <opus_defines.h>, <opus_types.h>, the spelling
63+
-- upstream's pkg-config gives (-I${includedir}/opus) and opusfile.h uses.
64+
--
65+
-- On Linux and macOS the library is compiled with -fvisibility=hidden, as
66+
-- upstream's configure does: OPUS_EXPORT marks the public functions visible
67+
-- when OPUS_BUILD is defined, so a shared object linking this archive exports
68+
-- opus_* and not the codec's internal celt_* / silk_* symbols.
69+
--
70+
-- kind = "lib": a static library. OPUS_EXPORT is dllexport only under
71+
-- DLL_EXPORT, which is not defined, so Windows consumers need no define.
72+
package = {
73+
spec = "1",
74+
namespace = "compat",
75+
name = "opus",
76+
description = "libopus 1.6.1 — the Opus audio codec (RFC 6716), encoder and decoder, floating point, BSD-3-Clause",
77+
licenses = {"BSD-3-Clause"},
78+
repo = "https://github.com/xiph/opus",
79+
type = "package",
80+
81+
extensions = {
82+
autoupdate = {
83+
tag = "v${version}",
84+
url = "https://downloads.xiph.org/releases/opus/opus-${version}.tar.gz",
85+
},
86+
},
87+
88+
xpm = {
89+
linux = {
90+
["1.6.1"] = {
91+
url = {
92+
GLOBAL = "https://downloads.xiph.org/releases/opus/opus-1.6.1.tar.gz",
93+
CN = "https://gitcode.com/mcpp-res/opus/releases/download/1.6.1/opus-1.6.1.tar.gz",
94+
},
95+
sha256 = "6ffcb593207be92584df15b32466ed64bbec99109f007c82205f0194572411a1",
96+
},
97+
},
98+
macosx = {
99+
["1.6.1"] = {
100+
url = {
101+
GLOBAL = "https://downloads.xiph.org/releases/opus/opus-1.6.1.tar.gz",
102+
CN = "https://gitcode.com/mcpp-res/opus/releases/download/1.6.1/opus-1.6.1.tar.gz",
103+
},
104+
sha256 = "6ffcb593207be92584df15b32466ed64bbec99109f007c82205f0194572411a1",
105+
},
106+
},
107+
windows = {
108+
["1.6.1"] = {
109+
url = {
110+
GLOBAL = "https://downloads.xiph.org/releases/opus/opus-1.6.1.tar.gz",
111+
CN = "https://gitcode.com/mcpp-res/opus/releases/download/1.6.1/opus-1.6.1.tar.gz",
112+
},
113+
sha256 = "6ffcb593207be92584df15b32466ed64bbec99109f007c82205f0194572411a1",
114+
},
115+
},
116+
},
117+
118+
mcpp = {
119+
language = "c++23",
120+
import_std = false,
121+
c_standard = "c99",
122+
123+
-- The public headers: <opus.h>, <opus_multistream.h>, <opus_projection.h>.
124+
include_dirs = { "*/include" },
125+
126+
sources = {
127+
"*/celt/bands.c",
128+
"*/celt/celt.c",
129+
"*/celt/celt_encoder.c",
130+
"*/celt/celt_decoder.c",
131+
"*/celt/cwrs.c",
132+
"*/celt/entcode.c",
133+
"*/celt/entdec.c",
134+
"*/celt/entenc.c",
135+
"*/celt/kiss_fft.c",
136+
"*/celt/laplace.c",
137+
"*/celt/mathops.c",
138+
"*/celt/mdct.c",
139+
"*/celt/modes.c",
140+
"*/celt/pitch.c",
141+
"*/celt/celt_lpc.c",
142+
"*/celt/quant_bands.c",
143+
"*/celt/rate.c",
144+
"*/celt/vq.c",
145+
"*/silk/*.c",
146+
"*/silk/float/*.c",
147+
"*/src/opus.c",
148+
"*/src/opus_decoder.c",
149+
"*/src/opus_encoder.c",
150+
"*/src/extensions.c",
151+
"*/src/opus_multistream.c",
152+
"*/src/opus_multistream_encoder.c",
153+
"*/src/opus_multistream_decoder.c",
154+
"*/src/repacketizer.c",
155+
"*/src/opus_projection_encoder.c",
156+
"*/src/opus_projection_decoder.c",
157+
"*/src/mapping_matrix.c",
158+
"*/src/analysis.c",
159+
"*/src/mlp.c",
160+
"*/src/mlp_data.c",
161+
},
162+
cflags = { "-DHAVE_CONFIG_H" },
163+
164+
generated_files = {
165+
["mcpp_generated/config.h"] = [==[
166+
/* config.h for libopus 1.6.1 — what upstream's configure defines for its
167+
default floating-point build without intrinsics. */
168+
#ifndef MCPP_COMPAT_OPUS_CONFIG_H
169+
#define MCPP_COMPAT_OPUS_CONFIG_H
170+
171+
#define OPUS_BUILD 1
172+
#define PACKAGE_VERSION "1.6.1"
173+
174+
/* C99 variable-length arrays for the codec's stack buffers. */
175+
#define VAR_ARRAYS 1
176+
177+
#define HAVE_LRINT 1
178+
#define HAVE_LRINTF 1
179+
180+
/* Run-time checks that are cheap and safe for use in production (default on). */
181+
#define ENABLE_HARDENING 1
182+
183+
#endif
184+
]==],
185+
},
186+
187+
linux = {
188+
include_dirs = { "*", "*/celt", "*/silk", "*/silk/float", "mcpp_generated" },
189+
private_include_dirs = { "*", "*/celt", "*/silk", "*/silk/float", "mcpp_generated" },
190+
-- Linked into shared objects by its consumers: position independent;
191+
-- only the OPUS_EXPORT functions visible, as upstream's configure does.
192+
cflags = { "-fPIC", "-fvisibility=hidden" },
193+
ldflags = { "-lm" },
194+
},
195+
macosx = {
196+
include_dirs = { "*", "*/celt", "*/silk", "*/silk/float", "mcpp_generated" },
197+
private_include_dirs = { "*", "*/celt", "*/silk", "*/silk/float", "mcpp_generated" },
198+
cflags = { "-fPIC", "-fvisibility=hidden" },
199+
},
200+
-- No -fPIC: PE/COFF has no such distinction, and clang rejects it for
201+
-- the MSVC target.
202+
windows = {
203+
include_dirs = { "*", "*/celt", "*/silk", "*/silk/float", "mcpp_generated" },
204+
private_include_dirs = { "*", "*/celt", "*/silk", "*/silk/float", "mcpp_generated" },
205+
},
206+
207+
targets = { opus = { kind = "lib" } },
208+
deps = {},
209+
},
210+
}

0 commit comments

Comments
 (0)