Skip to content

Repository files navigation

g729-c

CI Static Analysis Platform Tests

Clean-room C port of the MIT-licensed github.com/hunydev/g729 Go implementation.

This repository is intentionally built from /home/exedev/g729 only. It does not use ITU reference C, bcg729, FFmpeg, Sipro, Asterisk/FreeSWITCH, or other G.729 implementation source.

Current Status

Implemented and tested:

  • Public C header with frame constants, state types, init/reset functions, and documented error codes.
  • Fixed-point foundation tests covering saturating arithmetic, shifts, multiply/accumulate, rounding, normalization, extraction, and division.
  • 10-byte G.729 parameter bitstream pack/unpack helpers with tests.
  • LSP/LSF decoder and LSP-to-LP coefficient pipeline with generated Go-derived tables and tests.
  • Pitch delay/parity decoding, adaptive-codebook vector generation, and fixed-codebook pulse decoding with tests.
  • Gain VQ decoding and MA predictor state with generated Go-derived tables and exact-oracle tests.
  • Synthesis, Annex A postfilter, and output high-pass filtering with Go-derived stage oracle tests.
  • Public g729_decode_frame for 10-byte speech frames, verified sample-for-sample against Go-generated decoder fixture frames.
  • Public g729_encode_frame for 80-sample PCM frames, wired through the Go-equivalent Core encoder path and covered by Go-generated byte-oracle fixtures.
  • g729enc and g729dec raw file CLIs with stdin/stdout support.
  • C encode followed by C decode loopback coverage against Go encode followed by Go decode fixtures.
  • Deterministic stress/load benchmark and release-check target.
  • Encoder front-end PCM preprocessor, LPC analysis, LP-to-LSP/LSF conversion, LSP split-VQ quantization, open-loop pitch search, and closed-loop pitch primitives, fixed-codebook search primitives, and encoder gain quantization helpers with generated Go-derived oracle tests.
  • Go-oracle fixture generator for committed encoder/decoder/loopback fixtures.

The supported surface is the GOAL.md acceptance scope: G.729 Annex A-compatible G729/8000 annexb=no 10-byte speech frames, validated against the local Go oracle fixtures.

Build And Test

For normal source builds:

./configure --prefix=/usr/local
make
make test
make install

For CMake users:

cmake -S . -B build-cmake -DCMAKE_BUILD_TYPE=Release
cmake --build build-cmake
ctest --test-dir build-cmake --output-on-failure
cmake --install build-cmake --prefix /usr/local

Developer targets:

make
make test
make clean test
make loadtest
make platform-check
make release-check
make static-analysis
make fixtures

make fixtures runs the local Go-oracle generator against /home/exedev/g729 and rewrites testdata/oracle/basic_vectors.json.

Developer regeneration targets:

make lsp-tables
make lsp-oracle
make fcb-oracle
make pitch-oracle
make gain-tables
make gain-oracle
make gain-quant-oracle
make synth-oracle
make hp-oracle
make postfilter-oracle
make decode-oracle
make encode-oracle
make pcm-oracle
make lpc-oracle
make lsp-enc-oracle
make openloop-oracle
make closedloop-oracle
make fcb-search-oracle

These rewrite generated C LSP/gain tables plus LSP, pitch, fixed-codebook, and gain, synth, high-pass, postfilter, full decoder, full encoder, PCM preprocessor, LPC, and encoder LSP/open-loop/closed-loop/fixed-codebook search/gain quantization exact-oracle test headers from the local Go source.

Optional sanitizer pass:

make sanitize

make loadtest runs the deterministic benchmark/load tool with BENCH_FRAMES=20000 by default. make platform-check runs the normal suite and a shorter deterministic load test for OS/architecture matrix checks. make release-check runs the normal suite, sanitizers, a final normal suite, the load test, and git diff --check. make static-analysis runs the clang build/test path, clang static analyzer, and cppcheck warning/performance/portability checks.

See docs/build.md for configure options, CMake package usage, shared library builds, install paths, cross-toolchains, and i386 notes. See docs/streaming.md for frame-boundary buffering, partial-input handling, padding/trimming policy, and RTP-style packetization. See docs/compatibility.md for C standard, compiler, libc, platform, API, ABI, and binary-release compatibility policy.

GitHub Actions

Actions currently publish three workflow badges above:

  • ci.yml: release gate on Ubuntu.
  • static-analysis.yml: clang static analyzer and cppcheck.
  • platform-tests.yml: Ubuntu x64, macOS ARM64, Linux ARM64 through Docker/QEMU, and Linux i386 through Docker.

The platform workflow writes a Markdown job summary for each target and uploads per-target Markdown/log artifacts plus one combined platform-test-report artifact for the full run. Each platform job covers ./configure, make, make install, CMake, and CTest.

CLI

g729enc encodes raw signed 16-bit little-endian 8 kHz mono PCM to raw packed G.729 speech frames; g729dec decodes the reverse direction:

build/tools/g729enc input.s16le output.g729
build/tools/g729enc < input.s16le > output.g729
build/tools/g729dec input.g729 output.s16le
build/tools/g729dec < input.g729 > output.s16le

The tools reject trailing partial input frames.

For streaming use, buffer PCM until 80 samples are available before calling the encoder, and read packed input in 10-byte units before calling the decoder. There are no partial G.729 frames. See docs/streaming.md for tail-padding and packetization guidance.

Minimal API Shape

#include <stdint.h>
#include "g729.h"

int main(void) {
    g729_encoder enc;
    g729_decoder dec;
    int16_t pcm[G729_FRAME_SAMPLES] = {0};
    uint8_t bits[G729_FRAME_BYTES] = {0};

    g729_encoder_init(&enc);
    g729_decoder_init(&dec);

    (void)g729_encode_frame(&enc, pcm, bits);
    (void)g729_decode_frame(&dec, bits, pcm);
    return 0;
}

Each encoder or decoder instance is for one stream. Concurrent calls on the same instance are not safe unless the caller serializes access. Separate instances may be used concurrently on supported compilers.

Scope

Target scope is G.729 Annex A-compatible G729/8000 annexb=no speech frames:

  • 8 kHz mono signed 16-bit PCM.
  • 10 ms frames.
  • 80 PCM samples per frame.
  • 10 packed G.729 bytes per frame.

Unsupported scope includes Annex B SID/CNG/DTX, annexb=yes, G.729.1, G.729D, G.729E, ITU certification, and ITU endorsement.

See GOAL.md and docs/clean-room.md for the long-running acceptance criteria and clean-room boundary. See docs/performance.md and docs/release-notes.md for release-candidate checks.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages