feat(libSceVorbisDec): decode Ogg Vorbis with libvorbisfile 1.3.7 #9347
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9347"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-10-21T19:04:04Z.
What
libSceVorbisDecwas 34 parameterless stubs that threwnot implemented. 31 of them now run libvorbisfile from libvorbis 1.3.7 and libogg 1.3.6, which this PR adds as submodules built from source.ov_replaced bysceVorbisDec. For example,OpenCallbacksisov_open_callbacks,Readisov_read,CrossLapisov_crosslapandHalfratePisov_halfrate_p.ReadFloat,ReadFilterandHalfrateexist in libvorbis but not in Tremor (ov_read_filtersince 1.2.2). So the library is taken to be libvorbis: times aredouble, andov_readtakesbigendianp,wordandsgned.vorbisfile.h1.3.7, with every guestlongas 64-bit.docs/dev/debt/libSceVorbisDec.md.longis 32-bit.OggVorbis_File,ov_callbacksandvorbis_infoall containlong.OggVorbis_Fileis never written. The decoder state lives in a host table keyed by the struct's address.ov_*call on a zeroed host struct, so it answers as libvorbisfile does.tellreturning 64 bits) and theReadFilterfilter go through host trampolines.sceVorbisDecInforeturns a 56-byte LP64 copy of each link'svorbis_info, refreshed after every call on the struct.vorbis_commenthas the same layout on every host (static_assert) and is returned as is.tellresult, or an initial byte count with a non-nullinitial, that does not fit a 32-bitlongthrows.vfthrows where libvorbisfile would dereference it.sceVorbisDecClearandsceVorbisDecCrossLapfollow libvorbisfile's checks before any dereference.sceVorbisDecClearfrees the state and then calls the close callback, in the same order asov_clear. A close callback that throws therefore leaves the struct cleared.sceVorbisDecGetDecodePriority,sceVorbisDecSetDecodePriorityandsceVorbisDecGetLastDecodeError. They have no libvorbisfile counterpart and no known signature.ogg,vorbisandvorbisfileare static, position-independent libraries with hidden visibility, linked with--exclude-libs,ALLon MinGW and Linux, so the module exports only its 34 names.-fexceptions. With a DWARF toolchain such as WinLibs GCC 15.2.0, the libraries there are built with-fno-asynchronous-unwind-tables, so without it an exception from a guest callback could not unwind through the libvorbisfile frames. libc'sexception_c_cleanuptest compiles its C file the same way.guest_vorbis_decregistration stays incore/libs/CMakeLists.txtand is changed in place: it addsOV_EXCLUDE_STATIC_CALLBACKS, linksvorbisenc,vorbisfile,vorbisandogg, and sets a 30-second timeout.vorbisenc, which only the test uses, is built in the library'sCMakeLists.txtunderBUILD_TESTING.docs/dev/BUILD.mdlistsoggandvorbiswith the always-bundled submodules.tools/package_release.pyships bothCOPYINGfiles (BSD-3-Clause) aslibs/licenses/ogg.txtandlibs/licenses/vorbis.txt, with a test.docs/dev/debt/libSceVorbisDec.mdis rewritten for the new behaviour. It records:longlimits.libSceVorbisDec,3rdparty/oggor3rdparty/vorbis. #9034 builds Vorbis header packets insidelibSceAjm.nativewith its own code and shares no file or CMake target with this PR. #9212 and #9219 add test registrations directly before and after theguest_vorbis_decblock incore/libs/CMakeLists.txt; this PR changes only lines inside that block, andgit merge-treemerges it cleanly with each of them.Tested
Windows 11 Home 25H2 (10.0.26200) on x86-64 (Intel i7-11800H), WinLibs MinGW-w64 GCC 15.2.0 (
x86_64-ucrt-posix-seh,15.2.0posix-14.0.0-ucrt-r7), CMake 4.3.1, Ninja 1.13.2,-G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DBUILD_TESTING=ON, at d7d0288a7:guest_vorbis_dec_testsbuilds with no compiler warnings. All 23 libogg and libvorbis C files are compiled with-fexceptions.ctest -R "^guest_vorbis_dec$"passes (Test #1493: guest_vorbis_dec ... Passed 0.18 sec,100% tests passed, 0 tests failed out of 1, 1.0 s wall time on the first run of the new binary). This includes the read callback that throws insidesceVorbisDecReadand the close callback that throws insidesceVorbisDecClear, so exceptions unwind through libvorbisfile with the pinned toolchain.objdump -ponlibSceVorbisDec.prxlists the 34sceVorbisDecnames, std typeinfo and twostd::stringmembers (libSceNet and libkernel_sys export the same kind), and noogg_,vorbis_orov_symbol.main'sExport.cppin place of this PR's, the same test aborts withsceVorbisDecOpenCallbacks not implemented.tools/tests/test_package_release.pypasses, includingtest_vorbis_decoder_licenses_in_archives(40 tests, 8 skipped because they need symlink privileges or POSIX).tools/check_conventions.py --base upstream/mainpasses.Ubuntu 24.04.5 LTS on WSL2 (kernel 6.18.54.1-microsoft-standard-WSL2) on the same machine, GCC 13.3.0 (
13.3.0-6ubuntu2~24.04.1), CMake 3.28.3, Ninja 1.11.1,-G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DBUILD_TESTING=ON, with this PR merged intomaina849f2516as the Linux CI job does (merge f98b6466c):guest_vorbis_dec_testsbuilds with no compiler warnings, including the 24 libogg and libvorbis C objects.ctest -R "^guest_vorbis_dec$"passes (Test #1435: guest_vorbis_dec ... Passed 0.05 sec,100% tests passed, 0 tests failed out of 1).nm -D --defined-onlyonlibSceVorbisDec.prxlists the 34sceVorbisDecnames and sixstd::stringmembers (libc, libkernel, libSceNet and others exportstd::stringmembers too), and noogg_,vorbis_orov_symbol.main'sExport.cppin place of this PR's, the same test aborts withsceVorbisDecOpenCallbacks not implemented.tools/tests/test_package_release.pypasses, includingtest_vorbis_decoder_licenses_in_archivesand the symlink tests that Windows skips (40 tests, 5 skipped as Windows-only).tools/check_conventions.py --base origin/mainpasses.The runs above are at d7d0288a7, where the registration was in the library's
CMakeLists.txt. Ata542a13f00, rebased ontomain524398151fwith the registration kept incore/libs/CMakeLists.txtand the sources byte-identical to d7d0288a7, the same machine re-ran:libSceVorbisDecbuild with no warnings.guest_vorbis_decwith--repeat until-fail:3passes 3 of 3 (0.06 to 0.10 s).tools/tests/test_package_release.pypasses (40 tests, 8 skipped).objdump -plists the 34sceVorbisDecnames, std typeinfo and twostd::stringmembers, and noogg_,vorbis_orov_symbol. All 23 libogg, libvorbis and libvorbisfile C files are compiled with-fexceptions.main524398151f: the build has no warnings.guest_vorbis_decwith--repeat until-fail:3passes 3 of 3 (0.06 to 0.07 s).tools/tests/test_package_release.pypasses (40 tests, 5 skipped).nm -D --defined-onlylists the 34 names and sixstd::stringmembers, and noogg_,vorbis_orov_symbol.The checks below were run earlier on macOS 27.0.1 on Apple Silicon, which cannot run x86-64 code.
guest_vorbis_decis rewritten.initialbytes; every seek form, including the page and lap forms; tells, totals, bitrates, serial numbers, info and comments; andReadas little-endian signed 16-bit, big-endian unsigned 16-bit and unsigned 8-bit.ReadFloat,ReadFilterwith a guest filter,HalfrateandCrossLap.tell, noread, null datasource, none of which calls close), a struct that was never opened, the null-pointer cases, a reopen, and read and close callbacks that throw.main's stubs, it aborts at the first call withnot implemented.A native arm64 build of the real
Export.cpp, the test and the three libraries passes with ASan and UBSan. Two mutations each make it fail:sceVorbisDecClear, which ASan reports as a use-after-free when the close callback throws;CrossLappointers to be non-null.psy.c:319,psy.c:347andfloor1.c:820in the encoder that only the test uses, andsharedbook.c:425in decoder setup. They are not changed here.A mock CMake root built
libSceVorbisDecfrom the real libraryCMakeLists.txtin two configurations:sceVorbisDecnames plus std typeinfo, as existing modules do, and noogg_,vorbis_orov_symbol. All 23 C files are compiled with-fexceptions.-arch x86_64:nm -gUlists the 34 exports and nothing else.-fno-asynchronous-unwind-tables. The pinned toolchain's unwinding through libvorbisfile and the throwing-callback checks are covered by the Windows run above.The submodule gitlinks are the
v1.3.6andv1.3.7tag commits.tools/check_conventions.py --base origin/mainandtools/tests/test_package_release.pypass.tools/progress.py --module libSceVorbisDecgoes from 0/34 to 31/34.No title or console was used.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T19:04:57Z.
Progress report (
5243981→a542a13)📈 System libraries: 42.63% (+0.28%, +31 implemented functions)
✅ 31 implemented
sceVorbisDecBitratesceVorbisDecBitrateInstantsceVorbisDecClearsceVorbisDecCommentsceVorbisDecCrossLapsceVorbisDecHalfratesceVorbisDecHalfratePsceVorbisDecInfosceVorbisDecOpenCallbackssceVorbisDecPcmSeeksceVorbisDecPcmSeekLapsceVorbisDecPcmSeekPagesceVorbisDecPcmSeekPageLapsceVorbisDecPcmTellsceVorbisDecPcmTotalsceVorbisDecRawSeeksceVorbisDecRawSeekLapsceVorbisDecRawTellsceVorbisDecRawTotalsceVorbisDecReadsceVorbisDecReadFiltersceVorbisDecReadFloatsceVorbisDecSeekablesceVorbisDecSerialNumbersceVorbisDecStreamssceVorbisDecTimeSeeksceVorbisDecTimeSeekLapsceVorbisDecTimeSeekPagesceVorbisDecTimeSeekPageLapsceVorbisDecTimeTellsceVorbisDecTimeTotalImported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-22T03:14:24Z.
Linux data point for
d7d0288a70(WSL2, Ubuntu 24.04, kernel 6.18 - a virtualised kernel, not bare-metal Linux; Python 3.12.3), this head merged ontomaina6dcea927(clean merge),python3 -I tools/tests/test_package_release.py:test_package_release.pyon top ofmainwithout the PR's source change): FAILED (1 error).Not tested: macOS, Windows.
AI-assisted (Claude Code).