Skip to content

Commit

Permalink
Update ffmpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
Megamouse committed Jul 31, 2023
1 parent 6cd5a7e commit 116c232
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 46 deletions.
1 change: 1 addition & 0 deletions .ci/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ cmake .. \
-DCMAKE_RANLIB="$RANLIB" \
-DUSE_SYSTEM_CURL=ON \
-DUSE_SDL=ON \
-DUSE_SYSTEM_FFMPEG=OFF \
-DOpenGL_GL_PREFERENCE=LEGACY \
-DLLVM_DIR=/opt/llvm/lib/cmake/llvm \
-DSTATIC_LINK_LLVM=ON \
Expand Down
2 changes: 2 additions & 0 deletions .ci/build-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ mkdir build && cd build || exit 1
-DUSE_ALSA=OFF \
-DUSE_PULSE=OFF \
-DUSE_AUDIOUNIT=ON \
-DUSE_SYSTEM_FFMPEG=OFF \
-DLLVM_CCACHE_BUILD=OFF \
-DLLVM_BUILD_RUNTIME=OFF \
-DLLVM_BUILD_TOOLS=OFF \
Expand All @@ -91,6 +92,7 @@ mkdir build && cd build || exit 1
$CMAKE_EXTRA_OPTS \
-DLLVM_TARGET_ARCH=X86_64 \
-DCMAKE_OSX_ARCHITECTURES=x86_64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=12.6 \
-DCMAKE_IGNORE_PATH="$BREW_PATH/lib" \
-G Ninja

Expand Down
23 changes: 4 additions & 19 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,32 +267,17 @@ if(USE_SYSTEM_FFMPEG)
target_link_libraries(3rdparty_ffmpeg INTERFACE ${FFMPEG_LIBRARIES})
else()
if (NOT MSVC AND WIN32)
message(STATUS "RPCS3: building ffmpeg submodule")

include(ProcessorCount)
ProcessorCount(N)

ExternalProject_Add(ffmpeg-mingw
DOWNLOAD_COMMAND ""
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/ffmpeg
CONFIGURE_COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg/configure --prefix=./windows/x86_64 --arch=x86_64 --disable-avdevice --disable-programs --disable-avfilter --disable-postproc --disable-doc --disable-pthreads --enable-w32threads --disable-network --disable-everything --disable-encoders --disable-muxers --disable-hwaccels --disable-parsers --disable-protocols --enable-dxva2 --enable-static --disable-shared --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=atrac3 --enable-decoder=atrac3p --enable-decoder=mp3 --enable-decoder=pcm_s16le --enable-decoder=pcm_s8 --enable-decoder=h264 --enable-decoder=mpeg4 --enable-decoder=mpeg2video --enable-decoder=mjpeg --enable-decoder=mjpegb --enable-encoder=pcm_s16le --enable-encoder=ffv1 --enable-encoder=mpeg4 --enable-parser=h264 --enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=mpegvideo --enable-parser=mjpeg --enable-parser=aac --enable-parser=aac_latm --enable-muxer=avi --enable-demuxer=h264 --enable-demuxer=m4v --enable-demuxer=mp3 --enable-demuxer=mpegvideo --enable-demuxer=mpegps --enable-demuxer=mjpeg --enable-demuxer=avi --enable-demuxer=aac --enable-demuxer=pmp --enable-demuxer=oma --enable-demuxer=pcm_s16le --enable-demuxer=pcm_s8 --enable-demuxer=wav --enable-hwaccel=h264_dxva2 --enable-indev=dshow --enable-protocol=file
BUILD_COMMAND make -j ${N}
INSTALL_COMMAND make install
)

target_link_directories(3rdparty_ffmpeg INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/ffmpeg/windows/x86_64/lib")
target_link_libraries(3rdparty_ffmpeg INTERFACE avformat avcodec avutil swscale swresample iconv)
message(FATAL_ERROR "-- RPCS3: building ffmpeg submodule is currently not supported")
else()
message(STATUS "RPCS3: using builtin ffmpeg")

if (WIN32)
set(FFMPEG_LIB_DIR "ffmpeg/windows/x86_64")
set(FFMPEG_LIB_DIR "ffmpeg/lib/windows/x86_64")
target_link_libraries(3rdparty_ffmpeg INTERFACE "Bcrypt.lib")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(FFMPEG_LIB_DIR "ffmpeg/linux/x86_64")
set(FFMPEG_LIB_DIR "ffmpeg/lib/linux/ubuntu-20.04/x86_64")
elseif(APPLE)
set(FFMPEG_LIB_DIR "ffmpeg/macos/x86_64")
set(FFMPEG_LIB_DIR "ffmpeg/lib/macos/x86_64")
else()
message(FATAL_ERROR "Prebuilt ffmpeg is not available on this platform! Try USE_SYSTEM_FFMPEG=ON.")
endif()
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/ffmpeg
Submodule ffmpeg updated 7252 files
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ option(USE_VULKAN "Vulkan render backend" ON)
option(USE_PRECOMPILED_HEADERS "Use precompiled headers" OFF)
option(USE_SDL "Enables SDL input handler" OFF)
option(USE_SYSTEM_SDL "Prefer system SDL instead of the builtin one" OFF)
option(USE_SYSTEM_FFMPEG "Prefer system ffmpeg instead of the prebuild one" OFF)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/buildfiles/cmake")

Expand Down
2 changes: 1 addition & 1 deletion buildfiles/msvc/rpcs3_default.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ClCompile>
<Link>
<AdditionalDependencies>xxhash.lib;ws2_32.lib;Iphlpapi.lib;Bcrypt.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>..\3rdparty\ffmpeg\windows\x86_64</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>..\3rdparty\ffmpeg\lib\windows\x86_64</AdditionalLibraryDirectories>
<StackReserveSize>8388608</StackReserveSize>
<StackCommitSize>1048576</StackCommitSize>
</Link>
Expand Down
43 changes: 22 additions & 21 deletions rpcs3/Emu/Cell/Modules/cellAdec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,10 @@ class AudioDecoder : public ppu_thread
frame.auAddr = task.au.addr;
frame.auSize = task.au.size;
frame.userdata = task.au.userdata;
frame.size = frame.data->nb_samples * frame.data->channels * nbps;
frame.size = frame.data->nb_samples * frame.data->ch_layout.nb_channels * nbps;

//cellAdec.notice("got audio frame (pts=0x%llx, nb_samples=%d, ch=%d, sample_rate=%d, nbps=%d)",
//frame.pts, frame.data->nb_samples, frame.data->channels, frame.data->sample_rate, nbps);
//frame.pts, frame.data->nb_samples, frame.data->ch_layout.nb_channels, frame.data->sample_rate, nbps);

if (frames.push(frame, &is_closed))
{
Expand Down Expand Up @@ -944,15 +944,15 @@ error_code cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
if (outBuffer)
{
// reverse byte order:
if (frame->format == AV_SAMPLE_FMT_FLTP && frame->channels == 1)
if (frame->format == AV_SAMPLE_FMT_FLTP && frame->ch_layout.nb_channels == 1)
{
float* in_f = reinterpret_cast<float*>(frame->extended_data[0]);
for (u32 i = 0; i < af.size / 4; i++)
{
outBuffer[i] = in_f[i];
}
}
else if (frame->format == AV_SAMPLE_FMT_FLTP && frame->channels == 2)
else if (frame->format == AV_SAMPLE_FMT_FLTP && frame->ch_layout.nb_channels == 2)
{
float* in_f[2];
in_f[0] = reinterpret_cast<float*>(frame->extended_data[0]);
Expand All @@ -963,7 +963,7 @@ error_code cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
outBuffer[i * 2 + 1] = in_f[1][i];
}
}
else if (frame->format == AV_SAMPLE_FMT_FLTP && frame->channels == 6)
else if (frame->format == AV_SAMPLE_FMT_FLTP && frame->ch_layout.nb_channels == 6)
{
float* in_f[6];
in_f[0] = reinterpret_cast<float*>(frame->extended_data[0]);
Expand All @@ -982,7 +982,7 @@ error_code cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
outBuffer[i * 6 + 5] = in_f[5][i];
}
}
else if (frame->format == AV_SAMPLE_FMT_FLTP && frame->channels == 8)
else if (frame->format == AV_SAMPLE_FMT_FLTP && frame->ch_layout.nb_channels == 8)
{
float* in_f[8];
in_f[0] = reinterpret_cast<float*>(frame->extended_data[0]);
Expand All @@ -1005,15 +1005,15 @@ error_code cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
outBuffer[i * 8 + 7] = in_f[7][i];
}
}
else if (frame->format == AV_SAMPLE_FMT_S16P && frame->channels == 1)
else if (frame->format == AV_SAMPLE_FMT_S16P && frame->ch_layout.nb_channels == 1)
{
s16* in_i = reinterpret_cast<s16*>(frame->extended_data[0]);
for (u32 i = 0; i < af.size / 2; i++)
{
outBuffer[i] = in_i[i] / 32768.f;
}
}
else if (frame->format == AV_SAMPLE_FMT_S16P && frame->channels == 2)
else if (frame->format == AV_SAMPLE_FMT_S16P && frame->ch_layout.nb_channels == 2)
{
s16* in_i[2];
in_i[0] = reinterpret_cast<s16*>(frame->extended_data[0]);
Expand All @@ -1026,7 +1026,7 @@ error_code cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
}
else
{
fmt::throw_exception("Unsupported frame format (channels=%d, format=%d)", frame->channels, frame->format);
fmt::throw_exception("Unsupported frame format (channels=%d, format=%d)", frame->ch_layout.nb_channels, frame->format);
}
}

Expand Down Expand Up @@ -1078,25 +1078,26 @@ error_code cellAdecGetPcmItem(u32 handle, vm::pptr<CellAdecPcmItem> pcmItem)

atx->samplingFreq = frame->sample_rate;
atx->nbytes = frame->nb_samples * u32{sizeof(float)};
if (frame->channels == 1)

switch (frame->ch_layout.nb_channels)
{
atx->channelConfigIndex = 1;
}
else if (frame->channels == 2)
case 1:
case 2:
case 6:
{
atx->channelConfigIndex = 2;
}
else if (frame->channels == 6)
{
atx->channelConfigIndex = 6;
atx->channelConfigIndex = frame->ch_layout.nb_channels;
break;
}
else if (frame->channels == 8)
case 8:
{
atx->channelConfigIndex = 7;
break;
}
else
default:
{
cellAdec.fatal("cellAdecGetPcmItem(): unsupported channel count (%d)", frame->channels);
cellAdec.fatal("cellAdecGetPcmItem(): unsupported channel count (%d)", frame->ch_layout.nb_channels);
break;
}
}
}
else if (adec->type == CELL_ADEC_TYPE_MP3)
Expand Down
8 changes: 4 additions & 4 deletions rpcs3/util/media_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,14 @@ namespace utils
}

const int dst_channels = 2;
const u64 dst_channel_layout = AV_CH_LAYOUT_STEREO;
const AVChannelLayout dst_channel_layout = AV_CHANNEL_LAYOUT_STEREO;
const AVSampleFormat dst_format = AV_SAMPLE_FMT_FLT;

int set_err = 0;
if ((set_err = av_opt_set_int(av.swr, "in_channel_count", stream->codecpar->channels, 0)) ||
if ((set_err = av_opt_set_int(av.swr, "in_channel_count", stream->codecpar->ch_layout.nb_channels, 0)) ||
(set_err = av_opt_set_int(av.swr, "out_channel_count", dst_channels, 0)) ||
(set_err = av_opt_set_channel_layout(av.swr, "in_channel_layout", stream->codecpar->channel_layout, 0)) ||
(set_err = av_opt_set_channel_layout(av.swr, "out_channel_layout", dst_channel_layout, 0)) ||
(set_err = av_opt_set_chlayout(av.swr, "in_channel_layout", &stream->codecpar->ch_layout, 0)) ||
(set_err = av_opt_set_chlayout(av.swr, "out_channel_layout", &dst_channel_layout, 0)) ||
(set_err = av_opt_set_int(av.swr, "in_sample_rate", stream->codecpar->sample_rate, 0)) ||
(set_err = av_opt_set_int(av.swr, "out_sample_rate", sample_rate, 0)) ||
(set_err = av_opt_set_sample_fmt(av.swr, "in_sample_fmt", static_cast<AVSampleFormat>(stream->codecpar->format), 0)) ||
Expand Down

0 comments on commit 116c232

Please sign in to comment.