# OpenAVX Derivation & Standards Reference

OpenAVX (`openavx`) is an independent C99 media transport library built from published open standards (IETF RFCs, ISO/IEC, ITU-R, SMPTE, W3C) and standard DSP/color math.

## Subsystems & Standards

* **Discovery ([`src/avx_find.c`](src/avx_find.c), [`src/avx_wire.c`](src/avx_wire.c), [`src/avx_discovery_server.c`](src/avx_discovery_server.c))**: IPv4 mDNS over `224.0.0.251:5353` (`RFC 6762`), DNS-SD `PTR`/`SRV` parsing (`RFC 6763`), uncompressed DNS label encoding (`RFC 1035`), and an optional TCP directory server on port `7959`.
* **Transport ([`src/avx_socket.c`](src/avx_socket.c), [`src/avx_udp.c`](src/avx_udp.c), [`src/avx_send.c`](src/avx_send.c))**: TCP with `TCP_NODELAY` and `SIOCOUTQ`/`TIOCOUTQ` send-queue checks; `1400`-byte UDP fragment framing, `16 MB` UDP socket buffers, `sendmmsg`/`recvmmsg` batching (`32` packets), and RUDP selective NACK retransmission (`8` `(start, count)` ranges per packet).
* **RTSP / RTP / Bitstreams ([`src/avx_rtsp.c`](src/avx_rtsp.c), [`include/avx_rtsp.h`](include/avx_rtsp.h))**: RTSP 1.0 interleaved client/server (`OPTIONS`, `DESCRIBE`, `SETUP`, `PLAY`, `TEARDOWN`, `RFC 2326`), SDP (`RFC 4566`), Base64 (`RFC 4648`), RTCP PLI (`RFC 4585`, `PT=206 FMT=1`), RTP framing for H.264 (`RFC 6184`), HEVC (`RFC 7798`), and raw AV1 OBU chunks, plus Annex B Exp-Golomb and AV1 OBU LEB128 parsing.
* **SpeedHQ Codec ([`src/avx_speedhq.c`](src/avx_speedhq.c))**: Standalone C99 encoder/decoder for `SHQ0`–`SHQ5`, `SHQ7`, and `SHQ9` (plus raw `UYVA` alpha) derived from FFmpeg `libavcodec` (`speedhq.c` / `speedhqenc.c` under `LGPL-2.1-or-later`), using MPEG-2 intra baseline quantization/zig-zag (`ISO/IEC 13818-2`), 10-bit prefix VLC lookups, 4 sequential vertical slices, quality range `20`–`98` (default `96`), and separable even-odd 8x8 integer DCT/IDCT (`181, 251, 213, 142, 49` fixed-point cosines). No runtime `libavcodec` shared library is required for SpeedHQ (`test/openavx_speedhq_test.c` keeps a test-only interoperability check).
* **Color, SIMD & HDR ([`src/avx_color.c`](src/avx_color.c), [`src/avx_simd.c`](src/avx_simd.c), [`src/avx_utilities.c`](src/avx_utilities.c), [`src/avx_hdr.c`](src/avx_hdr.c))**: BT.601 fixed-point conversions (`UYVY`, `UYVA`, `P216`, `RGBA`, `BGRA`, `NV12`, `I420`, `YV12`), Porter-Duff Over alpha blending, SMPTE 292M `V210` <-> `P216` packing, runtime AVX2/FMA and ARM NEON intrinsics with scalar parity fallbacks, and `<oavx_color_info>` XML metadata (`BT.709`, `BT.2020`, `DCI-P3`, `BT.2100` HLG/`PQ` ST 2084, `MaxCLL`/`MaxFALL`).
* **Web Preview ([`src/avx_web.c`](src/avx_web.c))**: Pure C99 ISOBMFF (`ISO/IEC 14496-12`/`14496-15`) `ftyp`+`moov` (`avcC`, `hvcC`, `av1C`) and `moof`+`mdat` fragment muxing streamed unchunked over HTTP/1.1 (`Connection: close`, CORS `*`) to a W3C MSE HTML5 client.
* **Audio Codec & DSP ([`src/avx_audio_codec.c`](src/avx_audio_codec.c), [`src/avx_audio.c`](src/avx_audio.c))**: Built-in IMA DVI4 ADPCM fallback and optional runtime `libopus` (`48 kHz`, `20 ms`/`960` samples, `RFC 6716`/`7587`, RFC 7845 Family 1 speaker remapping); ITU-R BS.775-3 surround downmixes (`INV_SQRT2` symmetric weights, $M \times N$ mixing), `FLTP` <-> `16s`/`32s`/`32f`, 3-term Blackman Sinc and 4-point Catmull-Rom resamplers with `gcd` rational stepping.
* **Forward Error Correction (FEC) ([`src/avx_fec.c`](src/avx_fec.c), [`include/avx_fec.h`](include/avx_fec.h))**: SMPTE ST 2022-1 2D XOR matrix forward error correction for lost UDP fragment recovery over lossy broadcast links, with configurable column ($L$) and row ($D$) matrices and zero-allocation packet reconstruction.
* **End-to-End Encryption (E2EE) ([`src/avx_crypto.c`](src/avx_crypto.c), [`third-party/monocypher/monocypher.c`](third-party/monocypher/monocypher.c), [`include/avx_crypto.h`](include/avx_crypto.h))**: Authenticated stream encryption using ChaCha20 stream cipher with 24-byte extended nonce and 16-byte Poly1305 MAC (`RFC 8439`, Monocypher 4.0.2), zero external crypto dependencies, and constant-time authentication tag verification.
* **Virtual Camera OS Integration ([`src/avx_pipewire_sink.c`](src/avx_pipewire_sink.c), [`src/avx_v4l2_sink.c`](src/avx_v4l2_sink.c), [`src/avx_dshow_filter.c`](src/avx_dshow_filter.c), [`src/avx_dal_plugin.c`](src/avx_dal_plugin.c), [`tools/openavx_virtcam.c`](tools/openavx_virtcam.c))**: Tri-platform virtual webcam pipeline feeding network video directly into Zoom, Teams, Meet, and OBS: Linux PipeWire and Video4Linux2 (`v4l2loopback`), Windows DirectShow COM sink filter, and macOS CoreMediaIO DAL plugin IPC.
* **Sync, Routing & Config ([`src/avx_framesync.c`](src/avx_framesync.c), [`src/avx_routing.c`](src/avx_routing.c), [`src/avx_config.c`](src/avx_config.c))**: Mutex-synchronized FrameSync (`avx_audio_jitter_t` audio ring buffer), crosspoint routing with tally back-propagation, 64-bit `pts_ns`/`dts_ns`/wire `timecode` timestamps, and a standalone `RFC 8259` JSON parser.
* **Test Vector ([`test/fixtures/smpte_h264_pattern.h`](test/fixtures/smpte_h264_pattern.h))**: Static 6,990-byte `g_smpte_h264_1080p[]` SMPTE RP 219 1080p Baseline Profile IDR color bar frame for offline signal generation and decoder tests.

## Wire Framing & Runtime Plugins

* **Wire Protocol**: Native OpenAVX framing headers define dedicated 32-bit magic numbers (`AVXV`, `AVXA`, `AVXO`, `AVXM`, `AVXU`), resolution, FourCC, frame-rate numerator/denominator, 64-bit `timecode`, and `payload_len`, operating over mDNS service `_openavx._tcp.local` on standard port `7960` (defined in [`include/avx_wire.h`](include/avx_wire.h)).
* **Compile-Time Linkage & Optional Plugins**: [`CMakeLists.txt`](CMakeLists.txt) links `libopenavx` only against OS/runtime libraries (`Threads::Threads`, `m`, `dl` on Linux; `ws2_32` on Windows). Host `libavcodec`/`libavutil` ([`src/avx_video_avcodec.c`](src/avx_video_avcodec.c) via private layout stubs, **H.264/HEVC/AV1 compressed stream decode only**), `libopus` (`src/avx_audio_codec.c`), and `libpulse-simple`/`libasound` (`tools/avx_audio_output.c`) are probed optionally at runtime via `dlopen` / `LoadLibraryA`.

## Attribution

Independent codebase authored by **Saif Mukhtar**. Standards-based FourCC tags and format identifiers are used for native media identification; OpenAVX has no affiliation with any third-party SDK vendor.

For notices and attribution covering vendored compatibility headers (PipeWire/SPA), third-party cryptographic routines (Monocypher), and optional runtime bindings (FFmpeg), see [`THIRD_PARTY_LICENSES.md`](THIRD_PARTY_LICENSES.md).
