Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Library:Libogg

From ReverseEngineering.wiki
Library
Developer Xiph.Org Foundation
Platforms any (portable C)
Versions 1.0 (2002) to 1.3.6 (2025)
License BSD-3-Clause
Website https://xiph.org/ogg/
On this wiki Facts · Code · Notes · Topics

The Xiph.Org reference implementation of the Ogg container (C, BSD-3-Clause): page building and parsing (ogg_sync_*, ogg_stream_*, ogg_page_*) and the oggpack bit packer used by Vorbis and Theora, shipped as libogg.dll, libogg_64.dll or libogg.so.0 or linked statically. Its 64 or 66 Windows exports and the layout of its CRC table (one 1 KiB table up to 1.3.3, eight from 1.3.4) date a build.

Overview

libogg is the Xiph.Org reference implementation of the Format:Ogg container (C, BSD-3-Clause): src/framing.c builds and parses pages (ogg_stream_* for one logical stream, ogg_sync_* for finding pages in a byte stream, ogg_page_* accessors) and src/bitwise.c is the bit packer (oggpack_* LSB first, used by Vorbis; oggpackB_* MSB first, used by Theora). Programs ship it as libogg.dll, libogg-0.dll, ogg.dll, libogg_64.dll (Unreal Engine), libogg.so.0 or link it statically, often together with Library:Libvorbis, libFLAC, libtheora or opusfile.

Identification

  • Exports: ogg_sync_init, ogg_sync_buffer, ogg_sync_wrote, ogg_sync_pageseek, ogg_sync_pageout, ogg_stream_init, ogg_stream_pagein, ogg_stream_packetout, ogg_stream_packetin, ogg_stream_pageout, ogg_stream_flush, ogg_page_granulepos, ogg_page_serialno, ogg_page_eos, ogg_packet_clear, oggpack_read, oggpackB_read and the rest of the names of win32/ogg.def. Windows DLLs built with that file export exactly 64 names up to 1.3.2 and 66 from 1.3.3 (ogg_stream_pageout_fill and ogg_stream_flush_fill were added to ogg.def in October 2017, although the functions exist since 1.2.1 and 1.3.0). ogg_stream_check, ogg_sync_check and ogg_stream_iovecin are never in ogg.def, so they are missing from such DLLs.
  • CRC table: framing.c has crc_lookup, the MSB-first CRC table for polynomial 0x04C11DB7 (00 00 00 00 B7 1D C1 04 6E 3B 82 09 D9 26 43 0D little endian). Up to 1.3.3 it is a single 256-entry table; 1.3.4 (2019) moved it to src/crctable.h as crc_lookup[8][256] for slicing-by-8, so the second table (00 00 00 00 DC C1 19 D2 0F 9E F2 A0 D3 5F EB 72) follows the first one directly at +0x400. The first table alone is not specific: it is the table of bzip2, MPEG-2 CRCs, POSIX cksum and FFmpeg's AV_CRC_32_IEEE, and it occurs in binaries without libogg (twice in an FFmpeg 9.0 static Windows build, once in UnrealEditor-Core.dll of Unreal Engine 5.8). The 8-table layout is a stronger hint (libogg 1.3.4 or later, or another slicing-by-8 MSB-first CRC).
  • Strings: libogg has almost none ("OggS" is a 4-byte memcmp constant, often an immediate). Identify it by exports, the tables and the codec libraries next to it.
  • A static copy may lack framing.c: libvorbis needs only bitwise.c, so a program that uses libvorbis with its own Ogg demuxer (FFmpeg) contains no libogg CRC table at all.

Versions

Version Date Changes visible in a binary
1.1.4 2009-06 async error state (ogg_stream_check, ogg_sync_check), allocation checks; ogg.def with 64 exports
1.2.0 2010-03 new page-flushing heuristic (larger pages, at least 4 packets per page)
1.2.1-1.2.2 2010 ogg_stream_pageout_fill
1.3.0 2011-08 ogg_stream_flush_fill
1.3.1-1.3.2 2013-2014 guard against very large packets; oggpack_writecopy fix
1.3.3 2017-11 ogg.def exports the two _fill functions (66 exports)
1.3.4 2019-08 slicing-by-8 CRC (crctable.h, 8 x 1 KiB tables), CMake build, --disable-crc for fuzzing
1.3.5 2020-06 build fixes
1.3.6 2025-06 CMake 4 compatibility, UBSan fixes

API structures

Offsets on Win64 (long = 4 bytes) and LP64 (Linux/macOS x86-64 and ARM64, long = 8 bytes); see the struct facts of this page and export_header with abi "win64" or "lp64":

Structure Win64 size LP64 size Notes
ogg_page 0x20 0x20 header, header_len, body, body_len (same offsets, the longs are 4 or 8 bytes)
ogg_packet 0x28 0x30 packet, bytes, b_o_s, e_o_s, granulepos, packetno
ogg_sync_state 0x20 0x20 data pointer + six ints (storage, fill, returned, unsynced, headerbytes, bodybytes)
oggpack_buffer 0x20 0x28 endbyte, endbit, buffer, ptr, storage
ogg_stream_state 0x178 0x198 body and lacing FIFOs, header[282] work area (27 + 255), e_o_s, b_o_s, serialno, pageno, packetno, granulepos

The Win64 offsets were checked in Unreal Engine's libogg_64.dll: ogg_stream_eos reads [rcx+0x158] (e_o_s) and ogg_stream_reset_serialno writes [rcx+0x160] (serialno) and -1 to [rcx+0x164] (pageno).

Behaviour

  • ogg_sync_pageseek checks only the capture pattern and the CRC; it does not check the version byte. A bad CRC loses sync: the page is skipped and the search continues at the next 'O' (unless built with --disable-crc, 1.3.4+).
  • ogg_stream_pagein returns -1 for a page of another serial number or with stream_structure_version > 0.
  • The encoder puts the first packet alone on the first page (granule 0), then flushes a page when it holds more than 4096 body bytes and at least 4 packets ended on it, or when 255 lacing values are used (ogg_stream_pageout; ogg_stream_pageout_fill and ogg_stream_flush_fill take another byte target).

Where it appears

Checked here: Unreal Engine 5.8 ships a 2015 build of libogg_64.dll (PE timestamp 0x559D20D5, folder libogg-1.2.2, 64 exports, single CRC table) that UE games repeat; The Binding of Isaac: Rebirth ships a 32-bit libogg.dll (2013, 64 exports, single table) with libvorbis 1.3.2; Unreal Engine's libsndfile-1.dll (libsndfile 1.2.2) has a static libogg 1.3.4 or later (the 8-table CRC at RVA 0x17E260) next to libvorbis 1.3.7, libopus 1.4 and libFLAC 1.4.2; Software:VLC media player 3.0.23 x64 has a static libogg 1.3.4+ in plugins/demux/libogg_plugin.dll and in plugins/codec/libflac_plugin.dll (Ogg FLAC), but none in libvorbis_plugin.dll.

Code & repositories

  • https://github.com/xiph/ogg @ 06a5e0262cdc28aa4ae6797627a783b5010440f0 · license: BSD-3-Clause
    libogg source: src/framing.c (pages, streams, CRC, self-test vectors), src/bitwise.c (oggpack/oggpackB), src/crctable.h (slicing-by-8 tables since 1.3.4), win32/ogg.def (Windows export list), CHANGES and release tags v1.1.1-v1.3.6 to diff a binary against.
    Tested on: Read at this commit and at tags v1.1.4, v1.2.0, v1.2.2, v1.3.0, v1.3.2, v1.3.3, v1.3.4, v1.3.6; compared with libogg DLLs of Unreal Engine 5.8 (2015 build) and The Binding of Isaac: Rebirth (2013, x86) and the static copy in libsndfile 1.2.2. Not built. · checked 2026-10-17; last activity 2026-03-03; Note: the latest release ships binaries; the wiki links only the source, never the binaries
  • Ogg page and packet dumper (Python) — Dependency-free Ogg reader: lists pages (flags, granule, serial, sequence), verifies every page CRC, rebuilds the packets of each logical stream across pages, identifies the codec of each stream…

Pitfalls

  • Do not name a function "libogg CRC" from the first CRC table alone (see Identification).
  • long fields make every structure but ogg_sync_state differ between Win64 and LP64; 32-bit builds differ again (int64 alignment is 8 with MSVC and 4 on i386 System V).

Evidence & references

  • https://github.com/xiph/ogg at 06a5e0262cdc28aa4ae6797627a783b5010440f0: include/ogg/ogg.h lines 26-113 (structures), src/crctable.h lines 15 and 48 (tables 0 and 1), src/framing.c (see Format:Ogg#Evidence & references), win32/ogg.def, CHANGES; tags v1.1.4 to v1.3.6 (ogg.def export counts; v1.3.3 still has the single crc_lookup[256] in framing.c line 121).
  • Binaries read with a small Python PE reader (exports, tables, function bytes), nothing executed.