[PR #400] [MERGED] Basic AvPlayer implementation #1541

Closed
opened 2026-02-27 21:12:59 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/400
Author: @roamic
Created: 8/11/2024
Status: Merged
Merged: 8/16/2024
Merged by: @georgemoralis

Base: mainHead: basic-av-player


📝 Commits (6)

  • b5c6918 avplayer WIP
  • e33ff10 Added some logs, fixed some crashes, fixed align.
  • 0d6e8e2 Fixed some sound and threading issues.
  • 5c4ac98 fixing build on linux and mac
  • b3ef959 Fixed threading, migrated to CVs, added looping
  • 23dddca last minute fixes

📊 Changes

25 files changed (+2616 additions, -104 deletions)

View changed files

📝 .gitmodules (+3 -0)
📝 CMakeLists.txt (+11 -1)
📝 externals/CMakeLists.txt (+5 -0)
externals/ffmpeg-core (+1 -0)
📝 src/audio_core/sdl_audio.cpp (+12 -8)
📝 src/audio_core/sdl_audio.h (+2 -2)
📝 src/common/logging/filter.cpp (+1 -1)
📝 src/core/file_sys/fs.cpp (+2 -2)
📝 src/core/file_sys/fs.h (+1 -1)
📝 src/core/libraries/audio/audioout.cpp (+1 -2)
📝 src/core/libraries/avplayer/avplayer.cpp (+192 -57)
📝 src/core/libraries/avplayer/avplayer.h (+277 -28)
src/core/libraries/avplayer/avplayer_common.cpp (+61 -0)
src/core/libraries/avplayer/avplayer_common.h (+91 -0)
src/core/libraries/avplayer/avplayer_data_streamer.h (+20 -0)
src/core/libraries/avplayer/avplayer_file_streamer.cpp (+86 -0)
src/core/libraries/avplayer/avplayer_file_streamer.h (+37 -0)
src/core/libraries/avplayer/avplayer_impl.cpp (+200 -0)
src/core/libraries/avplayer/avplayer_impl.h (+68 -0)
src/core/libraries/avplayer/avplayer_source.cpp (+730 -0)

...and 5 more files

📄 Description

Basic implementation of sceLibAvPlayer.

Details:
This library is used to demux and decode audio and video data from various sources.

The game provides the number of Video Frame Buffers and this library allocates the memory for them using the provided memory callbacks. The alignment of 0x100 for Video Frame Buffers was chosen by trial and error and might not be correct. I could not find the correct alignment in RE.

There are 4 total working threads per AV Player instance:

  1. Controller thread. Used to perform costly operations by pushing an operation event into this thread. This allows the calling thread to do some other tasks in the meantime.
  2. Demuxer thread. Used to demux the container and create packets for the enabled audio and video streams. If more than 8 audio frames and more than 30 video frames are produced it waits for them to be drained before continuing to save memory and CPU.
  3. Video Decoder thread. Decodes the video packets and produces video frames in the Video Frame Buffers. If no Frame Buffers are available it waits for one.
  4. Audio Decoder thread. Same, but for audio.

Missing Features:

  • Jump To Time
  • Pause/Resume
  • HTTP Live Streaming - easy to implement with AVIO later if needed.
  • Trick Mode
  • AV Sync Mode - currently it syncs to audio and video, which is not correct, need to re-evaluate.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/400 **Author:** [@roamic](https://github.com/roamic) **Created:** 8/11/2024 **Status:** ✅ Merged **Merged:** 8/16/2024 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `basic-av-player` --- ### 📝 Commits (6) - [`b5c6918`](https://github.com/shadps4-emu/shadPS4/commit/b5c69189e56d8813b10adb2d2bcf17426b3bdac0) avplayer WIP - [`e33ff10`](https://github.com/shadps4-emu/shadPS4/commit/e33ff10212113a4756d88f125a325e1a55168f68) Added some logs, fixed some crashes, fixed align. - [`0d6e8e2`](https://github.com/shadps4-emu/shadPS4/commit/0d6e8e227a7c71223ad5d154538a1e1213a661d3) Fixed some sound and threading issues. - [`5c4ac98`](https://github.com/shadps4-emu/shadPS4/commit/5c4ac98d499ac10392dfda4e4559c0db659a1fb5) fixing build on linux and mac - [`b3ef959`](https://github.com/shadps4-emu/shadPS4/commit/b3ef959b25a25f4657fc761d0ca27dde50dbfec5) Fixed threading, migrated to CVs, added looping - [`23dddca`](https://github.com/shadps4-emu/shadPS4/commit/23dddca1f0febc085d0254064a60c5a526575576) last minute fixes ### 📊 Changes **25 files changed** (+2616 additions, -104 deletions) <details> <summary>View changed files</summary> 📝 `.gitmodules` (+3 -0) 📝 `CMakeLists.txt` (+11 -1) 📝 `externals/CMakeLists.txt` (+5 -0) ➕ `externals/ffmpeg-core` (+1 -0) 📝 `src/audio_core/sdl_audio.cpp` (+12 -8) 📝 `src/audio_core/sdl_audio.h` (+2 -2) 📝 `src/common/logging/filter.cpp` (+1 -1) 📝 `src/core/file_sys/fs.cpp` (+2 -2) 📝 `src/core/file_sys/fs.h` (+1 -1) 📝 `src/core/libraries/audio/audioout.cpp` (+1 -2) 📝 `src/core/libraries/avplayer/avplayer.cpp` (+192 -57) 📝 `src/core/libraries/avplayer/avplayer.h` (+277 -28) ➕ `src/core/libraries/avplayer/avplayer_common.cpp` (+61 -0) ➕ `src/core/libraries/avplayer/avplayer_common.h` (+91 -0) ➕ `src/core/libraries/avplayer/avplayer_data_streamer.h` (+20 -0) ➕ `src/core/libraries/avplayer/avplayer_file_streamer.cpp` (+86 -0) ➕ `src/core/libraries/avplayer/avplayer_file_streamer.h` (+37 -0) ➕ `src/core/libraries/avplayer/avplayer_impl.cpp` (+200 -0) ➕ `src/core/libraries/avplayer/avplayer_impl.h` (+68 -0) ➕ `src/core/libraries/avplayer/avplayer_source.cpp` (+730 -0) _...and 5 more files_ </details> ### 📄 Description Basic implementation of sceLibAvPlayer. Details: This library is used to demux and decode audio and video data from various sources. The game provides the number of Video Frame Buffers and this library allocates the memory for them using the provided memory callbacks. The alignment of `0x100` for Video Frame Buffers was chosen by trial and error and might not be correct. I could not find the correct alignment in RE. There are 4 total working threads per AV Player instance: 1. Controller thread. Used to perform costly operations by pushing an operation event into this thread. This allows the calling thread to do some other tasks in the meantime. 2. Demuxer thread. Used to demux the container and create packets for the enabled audio and video streams. If more than 8 audio frames and more than 30 video frames are produced it waits for them to be drained before continuing to save memory and CPU. 3. Video Decoder thread. Decodes the video packets and produces video frames in the Video Frame Buffers. If no Frame Buffers are available it waits for one. 4. Audio Decoder thread. Same, but for audio. Missing Features: * Jump To Time * Pause/Resume * HTTP Live Streaming - easy to implement with AVIO later if needed. * Trick Mode * AV Sync Mode - currently it syncs to audio **and** video, which is not correct, need to re-evaluate. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 21:12:59 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shadPS4#1541
No description provided.