diff --git a/core/libs/CMakeLists.txt b/core/libs/CMakeLists.txt index 7230150c0914..90e03222b390 100644 --- a/core/libs/CMakeLists.txt +++ b/core/libs/CMakeLists.txt @@ -226,6 +226,7 @@ target_link_libraries(libSceUsbStorageDialog PRIVATE libSceUserService) add_subdirectory(${CMAKE_SOURCE_DIR}/3rdparty/libfvad ${CMAKE_CURRENT_BINARY_DIR}/webrtc-fvad EXCLUDE_FROM_ALL) set_target_properties(fvad PROPERTIES C_VISIBILITY_PRESET hidden) +target_compile_options(fvad PRIVATE $<$:-fno-sanitize=shift>) target_sources(libwebrtc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/prx/libwebrtc/Vad.cpp) target_include_directories(libwebrtc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/3rdparty/libfvad/src) diff --git a/docs/dev/debt/libwebrtc.md b/docs/dev/debt/libwebrtc.md index 3dedda269aaa..ed9070ceeaee 100644 --- a/docs/dev/debt/libwebrtc.md +++ b/docs/dev/debt/libwebrtc.md @@ -15,6 +15,7 @@ - [WebRtcOpus encoder functions](../../../core/libs/prx/libwebrtc/src/Opus.cpp) (libwebrtc) - the 16 `WebRtcOpus_*` encoder exports are adapted from [opus_interface.cc](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/modules/audio_coding/codecs/opus/opus_interface.cc), with its WebRTC copyright notice and BSD licence at the top of the file. They encode through the bundled libopus 1.6.1, not WebRTC's pinned copy, so packet bytes can differ. Signatures match at both revisions; M127 only adds a DTX change behind the `WebRTC-Audio-OpusAvoidNoisePumpingDuringDtx` field trial, which stays off because `InitFieldTrialsFromString` throws. Frames over 60 ms, up to 120 ms, throw: they depend on `WEBRTC_OPUS_SUPPORT_120MS_PTIME`. A null encoder or buffer in `Encode`, which upstream reads, throws. Closes when: the build flag is known and packets are compared with the console. - [WebRtcVad_Create, WebRtcVad_Free, WebRtcVad_Init, WebRtcVad_set_mode and WebRtcVad_Process](../../../core/libs/prx/libwebrtc/Vad.cpp) use the opaque-handle C API and validation rules from [upstream WebRTC](https://github.com/webrtc-mirror/webrtc/blob/3710345e71ad3a7c1f4ed4efef152fd4fc24869a/common_audio/vad/webrtc_vad.c), with the signal-processing core from [libfvad](https://github.com/dpirch/libfvad/tree/532ab666c20d3cfda38bca63abbb0f152706c369). PS5 signatures and classification parity are not measured; differences between the console core and this WebRTC-derived revision remain unverified. Handles are host allocations and expose no guest-visible object layout. - [webrtc::TaskQueueBase::Current and CurrentTaskQueueSetter](../../../core/libs/prx/libwebrtc/src/TaskQueueBase.cpp) (libwebrtc) - adapted from [task_queue_base.cc](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/task_queue/task_queue_base.cc), with its WebRTC copyright notice and BSD licence at the top of the file. A thread-local pointer starts null on every thread; the 8-byte setter stores the current queue in `previous_`, makes its queue current, and its destructor makes `previous_` current again. The file's `thread_local` and pthread-key variants behave the same. A null setter, which upstream writes through, throws. Closes when: compared with the console. +- [libfvad shift check](../../../core/libs/prx/libwebrtc/Vad.cpp) (libwebrtc) - the bundled libfvad, pinned to its latest upstream commit, left-shifts a negative sample in `resample_by_2_internal.c` line 141, which is undefined in C. The `fvad` target is compiled with `-fno-sanitize=shift` for GCC and Clang in `core/libs/CMakeLists.txt`, so the sanitizer builds do not check shifts in libfvad; its other checks and every other target stay on, and the generated code is unchanged. The upstream has no fix for it. - [rtc::IPAddress::ipv4_address, ipv6_address, v4AddressAsHostOrderInteger, operator== and rtc::CountIPMaskBits](../../../core/libs/prx/libwebrtc/src/IpAddress.cpp) (libwebrtc) - adapted from [ip_address.cc](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/rtc_base/ip_address.cc), with its WebRTC copyright notice and BSD licence at the top of the file, on the 32-byte layout of `ip_address.h`: the vtable pointer at 0, `family_` at 8 and the `in_addr` or `in6_addr` union at 12. `AF_UNSPEC`, `AF_INET` and `AF_INET6` are 0, 2 and 28, as in [FreeBSD's socket.h](https://github.com/freebsd/freebsd-src/blob/55ac3c32b9ddba18b78bb3c58325294ba2e0bf6b/sys/sys/socket.h#L221-L256) and libSceNet. `CountIPMaskBits` counts from the top bit to the lowest set bit of the first word that is not all ones, so a mask with gaps counts them, as upstream does. A null address, which upstream reads, throws. Closes when: compared with the console. - [webrtc::AudioFrame::AudioFrame(), Mute, muted, data, mutable_data and AudioFrameOperations::Mute(AudioFrame*)](../../../core/libs/prx/libwebrtc/src/AudioFrame.cpp) (libwebrtc) - adapted from [audio_frame.cc](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/audio/audio_frame.cc) and [audio_frame_operations.cc](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/audio/utility/audio_frame_operations.cc), with their WebRTC copyright notices and BSD licence at the top of each file, on the 15456-byte layout of `audio_frame.h` with `muted_` at 15432 and the libc++ `std::optional` that abseil's `ABSL_OPTION_USE_STD_OPTIONAL 2` selects. The constructor leaves the samples uninitialized, as upstream does. A muted frame's `data()` points to a shared zeroed buffer. `AudioFrameOperations::Mute` on more than 7680 samples, which only an `RTC_DCHECK_GE` rejects, throws. A null frame throws. Closes when: compared with the console. - [webrtc::ANAStats::ANAStats() and the AudioEncoder GetANAStats, GetDtx, SetTargetBitrate, DisableAudioNetworkAdaptor, OnReceivedRtt, OnReceivedOverhead and SetReceiverFrameLengthRange defaults](../../../core/libs/prx/libwebrtc/src/AudioEncoder.cpp) (libwebrtc) - adapted from [audio_encoder.cc](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/audio_codecs/audio_encoder.cc), with its WebRTC copyright notice and BSD licence at the top of the file. `ANAStats` is the 56-byte struct of seven libc++ `std::optional`s (value, then the engaged flag) that abseil's `ABSL_OPTION_USE_STD_OPTIONAL 2` selects; the constructor and `GetANAStats` leave all of them empty, and `GetANAStats` returns it through the caller's result pointer. `GetDtx` returns false and the other defaults do nothing, as upstream. A null `ANAStats` or result throws. Closes when: compared with the console.