mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-21 21:41:33 +00:00
Merge branch 'vcpkg_deps_github' into 'master'
Add github workflow job to build openmw on windows using vcpkg deps See merge request OpenMW/openmw!4200
This commit is contained in:
commit
e32bcb4ba0
10 changed files with 269 additions and 95 deletions
142
.github/workflows/openmw.yml
vendored
142
.github/workflows/openmw.yml
vendored
|
@ -6,6 +6,7 @@ on:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
BUILD_TYPE: RelWithDebInfo
|
BUILD_TYPE: RelWithDebInfo
|
||||||
|
VCPKG_DEPS_REVISION: 14f130a69c29d10ecd31305db45979cf12f0c162
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Ubuntu:
|
Ubuntu:
|
||||||
|
@ -89,3 +90,144 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
cd build
|
cd build
|
||||||
make -j $(sysctl -n hw.logicalcpu) package
|
make -j $(sysctl -n hw.logicalcpu) package
|
||||||
|
|
||||||
|
Windows:
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
image:
|
||||||
|
- windows-2019
|
||||||
|
- windows-2022
|
||||||
|
|
||||||
|
name: ${{ matrix.image }}
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.image }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Create directories for dependencies
|
||||||
|
run: |
|
||||||
|
mkdir -p ${{ github.workspace }}/deps
|
||||||
|
mkdir -p ${{ github.workspace }}/deps/Qt
|
||||||
|
|
||||||
|
- name: Download prebuilt vcpkg packages
|
||||||
|
working-directory: ${{ github.workspace }}/deps
|
||||||
|
run: >
|
||||||
|
curl --fail --retry 3 -L
|
||||||
|
-o vcpkg-x64-${{ matrix.image }}-${{ env.VCPKG_DEPS_REVISION }}.7z
|
||||||
|
https://gitlab.com/OpenMW/openmw-deps/-/raw/main/windows/vcpkg-x64-${{ matrix.image }}-${{ env.VCPKG_DEPS_REVISION }}.7z
|
||||||
|
|
||||||
|
- name: Extract archived prebuilt vcpkg packages
|
||||||
|
working-directory: ${{ github.workspace }}/deps
|
||||||
|
run: 7z x -y -ovcpkg-x64-${{ matrix.image }}-${{ env.VCPKG_DEPS_REVISION }} vcpkg-x64-${{ matrix.image }}-${{ env.VCPKG_DEPS_REVISION }}.7z
|
||||||
|
|
||||||
|
- name: Cache Qt
|
||||||
|
id: qt-cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ github.workspace }}/deps/Qt/6.6.3/msvc2019_64
|
||||||
|
key: qt-cache-6.6.3-msvc2019_64-v1
|
||||||
|
|
||||||
|
- name: Download aqt
|
||||||
|
if: steps.qt-cache.outputs.cache-hit != 'true'
|
||||||
|
working-directory: ${{ github.workspace }}/deps/Qt
|
||||||
|
run: >
|
||||||
|
curl --fail --retry 3 -L
|
||||||
|
-o aqt_x64.exe
|
||||||
|
https://github.com/miurahr/aqtinstall/releases/download/v3.1.15/aqt_x64.exe
|
||||||
|
|
||||||
|
- name: Install Qt with aqt
|
||||||
|
if: steps.qt-cache.outputs.cache-hit != 'true'
|
||||||
|
working-directory: ${{ github.workspace }}/deps/Qt
|
||||||
|
run: .\aqt_x64.exe install-qt windows desktop 6.6.3 win64_msvc2019_64
|
||||||
|
|
||||||
|
- uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
|
||||||
|
- uses: seanmiddleditch/gha-setup-ninja@master
|
||||||
|
|
||||||
|
- name: Configure OpenMW
|
||||||
|
run: >
|
||||||
|
cmake
|
||||||
|
-S .
|
||||||
|
-B ${{ github.workspace }}/build
|
||||||
|
-G Ninja
|
||||||
|
-D CMAKE_BUILD_TYPE=RelWithDebInfo
|
||||||
|
-D CMAKE_TOOLCHAIN_FILE='${{ github.workspace }}/deps/vcpkg-x64-${{ matrix.image }}-${{ env.VCPKG_DEPS_REVISION }}/scripts/buildsystems/vcpkg.cmake'
|
||||||
|
-D CMAKE_PREFIX_PATH='${{ github.workspace }}/deps/Qt/6.6.3/msvc2019_64'
|
||||||
|
-D LuaJit_INCLUDE_DIR='${{ github.workspace }}/deps/vcpkg-x64-${{ matrix.image }}-${{ env.VCPKG_DEPS_REVISION }}/installed/x64-windows/include/luajit'
|
||||||
|
-D LuaJit_LIBRARY='${{ github.workspace }}/deps/vcpkg-x64-${{ matrix.image }}-${{ env.VCPKG_DEPS_REVISION }}/installed/x64-windows/lib/lua51.lib'
|
||||||
|
-D BUILD_BENCHMARKS=ON
|
||||||
|
-D BUILD_COMPONENTS_TESTS=ON
|
||||||
|
-D BUILD_OPENMW_TESTS=ON
|
||||||
|
-D BUILD_OPENCS_TESTS=ON
|
||||||
|
-D OPENMW_USE_SYSTEM_SQLITE3=OFF
|
||||||
|
-D OPENMW_USE_SYSTEM_YAML_CPP=OFF
|
||||||
|
-D OPENMW_LTO_BUILD=ON
|
||||||
|
|
||||||
|
- name: Build OpenMW
|
||||||
|
working-directory: ${{ github.workspace }}
|
||||||
|
run: cmake --build ${{ github.workspace }}/build
|
||||||
|
|
||||||
|
- name: Install OpenMW
|
||||||
|
working-directory: ${{ github.workspace }}
|
||||||
|
run: cmake --install ${{ github.workspace }}/build --prefix ${{ github.workspace }}/install
|
||||||
|
|
||||||
|
- name: Copy missing DLLs
|
||||||
|
run: |
|
||||||
|
cp ${{ github.workspace }}/deps/vcpkg-x64-${{ matrix.image }}-${{ env.VCPKG_DEPS_REVISION }}/installed/x64-windows/bin/Release/MyGUIEngine.dll ${{ github.workspace }}/install
|
||||||
|
cp -Filter *.dll -Recurse ${{ github.workspace }}/deps/vcpkg-x64-${{ matrix.image }}-${{ env.VCPKG_DEPS_REVISION }}/installed/x64-windows/bin/osgPlugins-3.6.5 ${{ github.workspace }}/install
|
||||||
|
cp ${{ github.workspace }}/deps/vcpkg-x64-${{ matrix.image }}-${{ env.VCPKG_DEPS_REVISION }}/installed/x64-windows/bin/*.dll ${{ github.workspace }}/install
|
||||||
|
|
||||||
|
- name: Copy Qt DLLs
|
||||||
|
working-directory: ${{ github.workspace }}/deps/Qt/6.6.3/msvc2019_64
|
||||||
|
run: |
|
||||||
|
cp bin/Qt6Core.dll ${{ github.workspace }}/install
|
||||||
|
cp bin/Qt6Gui.dll ${{ github.workspace }}/install
|
||||||
|
cp bin/Qt6Network.dll ${{ github.workspace }}/install
|
||||||
|
cp bin/Qt6OpenGL.dll ${{ github.workspace }}/install
|
||||||
|
cp bin/Qt6OpenGLWidgets.dll ${{ github.workspace }}/install
|
||||||
|
cp bin/Qt6Widgets.dll ${{ github.workspace }}/install
|
||||||
|
cp bin/Qt6Svg.dll ${{ github.workspace }}/install
|
||||||
|
mkdir ${{ github.workspace }}/install/styles
|
||||||
|
cp plugins/styles/qwindowsvistastyle.dll ${{ github.workspace }}/install/styles
|
||||||
|
mkdir ${{ github.workspace }}/install/platforms
|
||||||
|
cp plugins/platforms/qwindows.dll ${{ github.workspace }}/install/platforms
|
||||||
|
mkdir ${{ github.workspace }}/install/imageformats
|
||||||
|
cp plugins/imageformats/qsvg.dll ${{ github.workspace }}/install/imageformats
|
||||||
|
mkdir ${{ github.workspace }}/install/iconengines
|
||||||
|
cp plugins/iconengines/qsvgicon.dll ${{ github.workspace }}/install/iconengines
|
||||||
|
|
||||||
|
- name: Move pdb files
|
||||||
|
run: |
|
||||||
|
robocopy install pdb *.pdb /MOVE
|
||||||
|
if ($lastexitcode -lt 8) {
|
||||||
|
$global:LASTEXITCODE = $null
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Remove extra pdb files
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
rm -rf install/bin
|
||||||
|
rm -rf install/_deps
|
||||||
|
|
||||||
|
- name: Generate CI-ID.txt
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
job_url=$(gh run --repo ${{ github.repository }} view ${{ github.run_id }} --json jobs --jq '.jobs[] | select(.name == "${{ matrix.image }}") | .url')
|
||||||
|
printf "Ref ${{ github.ref }}\nJob ${job_url}\nCommit ${{ github.sha }}\n" > install/CI-ID.txt
|
||||||
|
cp install/CI-ID.txt pdb/CI-ID.txt
|
||||||
|
|
||||||
|
- name: Store OpenMW archived pdb files
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: openmw-${{ matrix.image }}-pdb-${{ github.sha }}
|
||||||
|
path: ${{ github.workspace }}/pdb/*
|
||||||
|
|
||||||
|
- name: Store OpenMW build artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: openmw-${{ matrix.image }}-${{ github.sha }}
|
||||||
|
path: ${{ github.workspace }}/install/*
|
||||||
|
|
|
@ -8,7 +8,10 @@
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
#include <components/vfs/manager.hpp>
|
#include <components/vfs/manager.hpp>
|
||||||
|
|
||||||
#if FFMPEG_5_OR_GREATER
|
#include <extern/osg-ffmpeg-videoplayer/libavformatdefines.hpp>
|
||||||
|
#include <extern/osg-ffmpeg-videoplayer/libavutildefines.hpp>
|
||||||
|
|
||||||
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
#include <libavutil/channel_layout.h>
|
#include <libavutil/channel_layout.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -61,7 +64,7 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FFMPEG_CONST_WRITEPACKET
|
#if OPENMW_FFMPEG_CONST_WRITEPACKET
|
||||||
int FFmpeg_Decoder::writePacket(void*, const uint8_t*, int)
|
int FFmpeg_Decoder::writePacket(void*, const uint8_t*, int)
|
||||||
#else
|
#else
|
||||||
int FFmpeg_Decoder::writePacket(void*, uint8_t*, int)
|
int FFmpeg_Decoder::writePacket(void*, uint8_t*, int)
|
||||||
|
@ -160,7 +163,7 @@ namespace MWSound
|
||||||
if (!mDataBuf || mDataBufLen < mFrame->nb_samples)
|
if (!mDataBuf || mDataBufLen < mFrame->nb_samples)
|
||||||
{
|
{
|
||||||
av_freep(&mDataBuf);
|
av_freep(&mDataBuf);
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
if (av_samples_alloc(&mDataBuf, nullptr, mOutputChannelLayout.nb_channels,
|
if (av_samples_alloc(&mDataBuf, nullptr, mOutputChannelLayout.nb_channels,
|
||||||
#else
|
#else
|
||||||
if (av_samples_alloc(&mDataBuf, nullptr, av_get_channel_layout_nb_channels(mOutputChannelLayout),
|
if (av_samples_alloc(&mDataBuf, nullptr, av_get_channel_layout_nb_channels(mOutputChannelLayout),
|
||||||
|
@ -201,7 +204,7 @@ namespace MWSound
|
||||||
if (!getAVAudioData())
|
if (!getAVAudioData())
|
||||||
break;
|
break;
|
||||||
mFramePos = 0;
|
mFramePos = 0;
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
mFrameSize = mFrame->nb_samples * mOutputChannelLayout.nb_channels
|
mFrameSize = mFrame->nb_samples * mOutputChannelLayout.nb_channels
|
||||||
#else
|
#else
|
||||||
mFrameSize = mFrame->nb_samples * av_get_channel_layout_nb_channels(mOutputChannelLayout)
|
mFrameSize = mFrame->nb_samples * av_get_channel_layout_nb_channels(mOutputChannelLayout)
|
||||||
|
@ -293,7 +296,7 @@ namespace MWSound
|
||||||
else
|
else
|
||||||
mOutputSampleFormat = AV_SAMPLE_FMT_S16;
|
mOutputSampleFormat = AV_SAMPLE_FMT_S16;
|
||||||
|
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
mOutputChannelLayout = (*stream)->codecpar->ch_layout; // sefault
|
mOutputChannelLayout = (*stream)->codecpar->ch_layout; // sefault
|
||||||
if (mOutputChannelLayout.u.mask == 0)
|
if (mOutputChannelLayout.u.mask == 0)
|
||||||
av_channel_layout_default(&mOutputChannelLayout, codecCtxPtr->ch_layout.nb_channels);
|
av_channel_layout_default(&mOutputChannelLayout, codecCtxPtr->ch_layout.nb_channels);
|
||||||
|
@ -356,7 +359,7 @@ namespace MWSound
|
||||||
*type = SampleType_Int16;
|
*type = SampleType_Int16;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
switch (mOutputChannelLayout.u.mask)
|
switch (mOutputChannelLayout.u.mask)
|
||||||
#else
|
#else
|
||||||
switch (mOutputChannelLayout)
|
switch (mOutputChannelLayout)
|
||||||
|
@ -379,7 +382,7 @@ namespace MWSound
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
char str[1024];
|
char str[1024];
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
av_channel_layout_describe(&mCodecCtx->ch_layout, str, sizeof(str));
|
av_channel_layout_describe(&mCodecCtx->ch_layout, str, sizeof(str));
|
||||||
Log(Debug::Error) << "Unsupported channel layout: " << str;
|
Log(Debug::Error) << "Unsupported channel layout: " << str;
|
||||||
|
|
||||||
|
@ -412,7 +415,7 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
|
|
||||||
*samplerate = mCodecCtx->sample_rate;
|
*samplerate = mCodecCtx->sample_rate;
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
AVChannelLayout ch_layout = mCodecCtx->ch_layout;
|
AVChannelLayout ch_layout = mCodecCtx->ch_layout;
|
||||||
if (ch_layout.u.mask == 0)
|
if (ch_layout.u.mask == 0)
|
||||||
av_channel_layout_default(&ch_layout, mCodecCtx->ch_layout.nb_channels);
|
av_channel_layout_default(&ch_layout, mCodecCtx->ch_layout.nb_channels);
|
||||||
|
@ -427,7 +430,7 @@ namespace MWSound
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
swr_alloc_set_opts2(&mSwr, // SwrContext
|
swr_alloc_set_opts2(&mSwr, // SwrContext
|
||||||
&mOutputChannelLayout, // output ch layout
|
&mOutputChannelLayout, // output ch layout
|
||||||
mOutputSampleFormat, // output sample format
|
mOutputSampleFormat, // output sample format
|
||||||
|
@ -476,7 +479,7 @@ namespace MWSound
|
||||||
|
|
||||||
while (getAVAudioData())
|
while (getAVAudioData())
|
||||||
{
|
{
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
size_t got = mFrame->nb_samples * mOutputChannelLayout.nb_channels
|
size_t got = mFrame->nb_samples * mOutputChannelLayout.nb_channels
|
||||||
#else
|
#else
|
||||||
size_t got = mFrame->nb_samples * av_get_channel_layout_nb_channels(mOutputChannelLayout)
|
size_t got = mFrame->nb_samples * av_get_channel_layout_nb_channels(mOutputChannelLayout)
|
||||||
|
@ -489,7 +492,7 @@ namespace MWSound
|
||||||
|
|
||||||
size_t FFmpeg_Decoder::getSampleOffset()
|
size_t FFmpeg_Decoder::getSampleOffset()
|
||||||
{
|
{
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
std::size_t delay = (mFrameSize - mFramePos) / mOutputChannelLayout.nb_channels
|
std::size_t delay = (mFrameSize - mFramePos) / mOutputChannelLayout.nb_channels
|
||||||
#else
|
#else
|
||||||
std::size_t delay = (mFrameSize - mFramePos) / av_get_channel_layout_nb_channels(mOutputChannelLayout)
|
std::size_t delay = (mFrameSize - mFramePos) / av_get_channel_layout_nb_channels(mOutputChannelLayout)
|
||||||
|
@ -506,7 +509,7 @@ namespace MWSound
|
||||||
, mNextPts(0.0)
|
, mNextPts(0.0)
|
||||||
, mSwr(nullptr)
|
, mSwr(nullptr)
|
||||||
, mOutputSampleFormat(AV_SAMPLE_FMT_NONE)
|
, mOutputSampleFormat(AV_SAMPLE_FMT_NONE)
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
, mOutputChannelLayout({})
|
, mOutputChannelLayout({})
|
||||||
#else
|
#else
|
||||||
, mOutputChannelLayout(0)
|
, mOutputChannelLayout(0)
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include <extern/osg-ffmpeg-videoplayer/libavformatdefines.hpp>
|
||||||
|
#include <extern/osg-ffmpeg-videoplayer/libavutildefines.hpp>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4244)
|
#pragma warning(disable : 4244)
|
||||||
|
@ -30,9 +33,6 @@ extern "C"
|
||||||
|
|
||||||
#include "sound_decoder.hpp"
|
#include "sound_decoder.hpp"
|
||||||
|
|
||||||
#define FFMPEG_5_OR_GREATER (LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 28, 100))
|
|
||||||
#define FFMPEG_CONST_WRITEPACKET (LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(60, 12, 100))
|
|
||||||
|
|
||||||
namespace MWSound
|
namespace MWSound
|
||||||
{
|
{
|
||||||
struct AVIOContextDeleter
|
struct AVIOContextDeleter
|
||||||
|
@ -80,7 +80,7 @@ namespace MWSound
|
||||||
|
|
||||||
SwrContext* mSwr;
|
SwrContext* mSwr;
|
||||||
enum AVSampleFormat mOutputSampleFormat;
|
enum AVSampleFormat mOutputSampleFormat;
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
AVChannelLayout mOutputChannelLayout;
|
AVChannelLayout mOutputChannelLayout;
|
||||||
#else
|
#else
|
||||||
int64_t mOutputChannelLayout;
|
int64_t mOutputChannelLayout;
|
||||||
|
@ -94,7 +94,7 @@ namespace MWSound
|
||||||
Files::IStreamPtr mDataStream;
|
Files::IStreamPtr mDataStream;
|
||||||
|
|
||||||
static int readPacket(void* user_data, uint8_t* buf, int buf_size);
|
static int readPacket(void* user_data, uint8_t* buf, int buf_size);
|
||||||
#if FFMPEG_CONST_WRITEPACKET
|
#if OPENMW_FFMPEG_CONST_WRITEPACKET
|
||||||
static int writePacket(void* user_data, const uint8_t* buf, int buf_size);
|
static int writePacket(void* user_data, const uint8_t* buf, int buf_size);
|
||||||
#else
|
#else
|
||||||
static int writePacket(void* user_data, uint8_t* buf, int buf_size);
|
static int writePacket(void* user_data, uint8_t* buf, int buf_size);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "movieaudiofactory.hpp"
|
#include "movieaudiofactory.hpp"
|
||||||
|
|
||||||
#include <extern/osg-ffmpeg-videoplayer/audiodecoder.hpp>
|
#include <extern/osg-ffmpeg-videoplayer/audiodecoder.hpp>
|
||||||
|
#include <extern/osg-ffmpeg-videoplayer/libavutildefines.hpp>
|
||||||
#include <extern/osg-ffmpeg-videoplayer/videostate.hpp>
|
#include <extern/osg-ffmpeg-videoplayer/videostate.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
@ -46,7 +47,7 @@ namespace MWSound
|
||||||
|
|
||||||
size_t getSampleOffset()
|
size_t getSampleOffset()
|
||||||
{
|
{
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
ssize_t clock_delay = (mFrameSize - mFramePos) / mOutputChannelLayout.nb_channels
|
ssize_t clock_delay = (mFrameSize - mFramePos) / mOutputChannelLayout.nb_channels
|
||||||
#else
|
#else
|
||||||
ssize_t clock_delay = (mFrameSize - mFramePos) / av_get_channel_layout_nb_channels(mOutputChannelLayout)
|
ssize_t clock_delay = (mFrameSize - mFramePos) / av_get_channel_layout_nb_channels(mOutputChannelLayout)
|
||||||
|
|
24
extern/osg-ffmpeg-videoplayer/audiodecoder.cpp
vendored
24
extern/osg-ffmpeg-videoplayer/audiodecoder.cpp
vendored
|
@ -1,5 +1,7 @@
|
||||||
#include "audiodecoder.hpp"
|
#include "audiodecoder.hpp"
|
||||||
|
|
||||||
|
#include <extern/osg-ffmpeg-videoplayer/libavutildefines.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -18,7 +20,7 @@ extern "C"
|
||||||
#pragma warning (pop)
|
#pragma warning (pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
#include <libavutil/channel_layout.h>
|
#include <libavutil/channel_layout.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -57,7 +59,7 @@ MovieAudioDecoder::MovieAudioDecoder(VideoState* videoState)
|
||||||
: mVideoState(videoState)
|
: mVideoState(videoState)
|
||||||
, mAVStream(*videoState->audio_st)
|
, mAVStream(*videoState->audio_st)
|
||||||
, mOutputSampleFormat(AV_SAMPLE_FMT_NONE)
|
, mOutputSampleFormat(AV_SAMPLE_FMT_NONE)
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
, mOutputChannelLayout({})
|
, mOutputChannelLayout({})
|
||||||
#else
|
#else
|
||||||
, mOutputChannelLayout(0)
|
, mOutputChannelLayout(0)
|
||||||
|
@ -117,7 +119,7 @@ void MovieAudioDecoder::setupFormat()
|
||||||
|
|
||||||
AVSampleFormat inputSampleFormat = mAudioContext->sample_fmt;
|
AVSampleFormat inputSampleFormat = mAudioContext->sample_fmt;
|
||||||
|
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
AVChannelLayout inputChannelLayout = mAudioContext->ch_layout;
|
AVChannelLayout inputChannelLayout = mAudioContext->ch_layout;
|
||||||
if (inputChannelLayout.u.mask != 0)
|
if (inputChannelLayout.u.mask != 0)
|
||||||
mOutputChannelLayout = inputChannelLayout;
|
mOutputChannelLayout = inputChannelLayout;
|
||||||
|
@ -134,7 +136,7 @@ void MovieAudioDecoder::setupFormat()
|
||||||
mOutputSampleRate = inputSampleRate;
|
mOutputSampleRate = inputSampleRate;
|
||||||
mOutputSampleFormat = inputSampleFormat;
|
mOutputSampleFormat = inputSampleFormat;
|
||||||
|
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
adjustAudioSettings(mOutputSampleFormat, mOutputChannelLayout.u.mask, mOutputSampleRate);
|
adjustAudioSettings(mOutputSampleFormat, mOutputChannelLayout.u.mask, mOutputSampleRate);
|
||||||
#else
|
#else
|
||||||
mOutputChannelLayout = inputChannelLayout;
|
mOutputChannelLayout = inputChannelLayout;
|
||||||
|
@ -142,14 +144,14 @@ void MovieAudioDecoder::setupFormat()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (inputSampleFormat != mOutputSampleFormat
|
if (inputSampleFormat != mOutputSampleFormat
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
|| inputChannelLayout.u.mask != mOutputChannelLayout.u.mask
|
|| inputChannelLayout.u.mask != mOutputChannelLayout.u.mask
|
||||||
#else
|
#else
|
||||||
|| inputChannelLayout != mOutputChannelLayout
|
|| inputChannelLayout != mOutputChannelLayout
|
||||||
#endif
|
#endif
|
||||||
|| inputSampleRate != mOutputSampleRate)
|
|| inputSampleRate != mOutputSampleRate)
|
||||||
{
|
{
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
swr_alloc_set_opts2(&mAudioResampler->mSwr,
|
swr_alloc_set_opts2(&mAudioResampler->mSwr,
|
||||||
&mOutputChannelLayout,
|
&mOutputChannelLayout,
|
||||||
mOutputSampleFormat,
|
mOutputSampleFormat,
|
||||||
|
@ -196,7 +198,7 @@ int MovieAudioDecoder::synchronize_audio()
|
||||||
if(fabs(avg_diff) >= mAudioDiffThreshold)
|
if(fabs(avg_diff) >= mAudioDiffThreshold)
|
||||||
{
|
{
|
||||||
int n = av_get_bytes_per_sample(mOutputSampleFormat) *
|
int n = av_get_bytes_per_sample(mOutputSampleFormat) *
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
mOutputChannelLayout.nb_channels;
|
mOutputChannelLayout.nb_channels;
|
||||||
#else
|
#else
|
||||||
av_get_channel_layout_nb_channels(mOutputChannelLayout);
|
av_get_channel_layout_nb_channels(mOutputChannelLayout);
|
||||||
|
@ -246,7 +248,7 @@ int MovieAudioDecoder::audio_decode_frame(AVFrame *frame, int &sample_skip)
|
||||||
if(!mDataBuf || mDataBufLen < frame->nb_samples)
|
if(!mDataBuf || mDataBufLen < frame->nb_samples)
|
||||||
{
|
{
|
||||||
av_freep(&mDataBuf);
|
av_freep(&mDataBuf);
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
if(av_samples_alloc(&mDataBuf, nullptr, mOutputChannelLayout.nb_channels,
|
if(av_samples_alloc(&mDataBuf, nullptr, mOutputChannelLayout.nb_channels,
|
||||||
#else
|
#else
|
||||||
if(av_samples_alloc(&mDataBuf, nullptr, av_get_channel_layout_nb_channels(mOutputChannelLayout),
|
if(av_samples_alloc(&mDataBuf, nullptr, av_get_channel_layout_nb_channels(mOutputChannelLayout),
|
||||||
|
@ -267,7 +269,7 @@ int MovieAudioDecoder::audio_decode_frame(AVFrame *frame, int &sample_skip)
|
||||||
else
|
else
|
||||||
mFrameData = &frame->data[0];
|
mFrameData = &frame->data[0];
|
||||||
|
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
int result = frame->nb_samples * mOutputChannelLayout.nb_channels *
|
int result = frame->nb_samples * mOutputChannelLayout.nb_channels *
|
||||||
#else
|
#else
|
||||||
int result = frame->nb_samples * av_get_channel_layout_nb_channels(mOutputChannelLayout) *
|
int result = frame->nb_samples * av_get_channel_layout_nb_channels(mOutputChannelLayout) *
|
||||||
|
@ -348,7 +350,7 @@ size_t MovieAudioDecoder::read(char *stream, size_t len)
|
||||||
len1 = std::min<size_t>(len1, -mFramePos);
|
len1 = std::min<size_t>(len1, -mFramePos);
|
||||||
|
|
||||||
int n = av_get_bytes_per_sample(mOutputSampleFormat)
|
int n = av_get_bytes_per_sample(mOutputSampleFormat)
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
* mOutputChannelLayout.nb_channels;
|
* mOutputChannelLayout.nb_channels;
|
||||||
#else
|
#else
|
||||||
* av_get_channel_layout_nb_channels(mOutputChannelLayout);
|
* av_get_channel_layout_nb_channels(mOutputChannelLayout);
|
||||||
|
@ -402,7 +404,7 @@ int MovieAudioDecoder::getOutputSampleRate() const
|
||||||
|
|
||||||
uint64_t MovieAudioDecoder::getOutputChannelLayout() const
|
uint64_t MovieAudioDecoder::getOutputChannelLayout() const
|
||||||
{
|
{
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
return mOutputChannelLayout.u.mask;
|
return mOutputChannelLayout.u.mask;
|
||||||
#else
|
#else
|
||||||
return mOutputChannelLayout;
|
return mOutputChannelLayout;
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include <extern/osg-ffmpeg-videoplayer/libavutildefines.hpp>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#pragma warning (push)
|
#pragma warning (push)
|
||||||
#pragma warning (disable : 4244)
|
#pragma warning (disable : 4244)
|
||||||
|
@ -29,8 +31,6 @@ extern "C"
|
||||||
typedef SSIZE_T ssize_t;
|
typedef SSIZE_T ssize_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FFMPEG_5_OR_GREATER (LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 28, 100))
|
|
||||||
|
|
||||||
namespace Video
|
namespace Video
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ protected:
|
||||||
AVCodecContext* mAudioContext;
|
AVCodecContext* mAudioContext;
|
||||||
AVStream *mAVStream;
|
AVStream *mAVStream;
|
||||||
enum AVSampleFormat mOutputSampleFormat;
|
enum AVSampleFormat mOutputSampleFormat;
|
||||||
#if FFMPEG_5_OR_GREATER
|
#if OPENMW_FFMPEG_5_OR_GREATER
|
||||||
AVChannelLayout mOutputChannelLayout;
|
AVChannelLayout mOutputChannelLayout;
|
||||||
#else
|
#else
|
||||||
uint64_t mOutputChannelLayout;
|
uint64_t mOutputChannelLayout;
|
||||||
|
|
13
extern/osg-ffmpeg-videoplayer/libavformatdefines.hpp
vendored
Normal file
13
extern/osg-ffmpeg-videoplayer/libavformatdefines.hpp
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef OPENMW_EXTERN_OSG_FFMPEG_VIDEOPLAYER_LIBAVFORMATDEFINES_H
|
||||||
|
#define OPENMW_EXTERN_OSG_FFMPEG_VIDEOPLAYER_LIBAVFORMATDEFINES_H
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
|
||||||
|
#include <libavformat/version.h>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OPENMW_FFMPEG_CONST_WRITEPACKET (LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(61, 0, 100))
|
||||||
|
|
||||||
|
#endif
|
13
extern/osg-ffmpeg-videoplayer/libavutildefines.hpp
vendored
Normal file
13
extern/osg-ffmpeg-videoplayer/libavutildefines.hpp
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef OPENMW_EXTERN_OSG_FFMPEG_VIDEOPLAYER_LIBAVUTILDEFINES_H
|
||||||
|
#define OPENMW_EXTERN_OSG_FFMPEG_VIDEOPLAYER_LIBAVUTILDEFINES_H
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
|
||||||
|
#include <libavutil/version.h>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OPENMW_FFMPEG_5_OR_GREATER (LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 28, 100))
|
||||||
|
|
||||||
|
#endif
|
3
extern/osg-ffmpeg-videoplayer/videostate.cpp
vendored
3
extern/osg-ffmpeg-videoplayer/videostate.cpp
vendored
|
@ -43,6 +43,7 @@ static FlushPacket flush_pkt;
|
||||||
#include "videoplayer.hpp"
|
#include "videoplayer.hpp"
|
||||||
#include "audiodecoder.hpp"
|
#include "audiodecoder.hpp"
|
||||||
#include "audiofactory.hpp"
|
#include "audiofactory.hpp"
|
||||||
|
#include "libavformatdefines.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -243,7 +244,7 @@ int VideoState::istream_read(void *user_data, uint8_t *buf, int buf_size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FFMPEG_CONST_WRITEPACKET
|
#if OPENMW_FFMPEG_CONST_WRITEPACKET
|
||||||
int VideoState::istream_write(void *, const unsigned char *, int)
|
int VideoState::istream_write(void *, const unsigned char *, int)
|
||||||
#else
|
#else
|
||||||
int VideoState::istream_write(void *, uint8_t *, int)
|
int VideoState::istream_write(void *, uint8_t *, int)
|
||||||
|
|
7
extern/osg-ffmpeg-videoplayer/videostate.hpp
vendored
7
extern/osg-ffmpeg-videoplayer/videostate.hpp
vendored
|
@ -11,6 +11,7 @@
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
|
||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
|
|
||||||
namespace osg
|
namespace osg
|
||||||
{
|
{
|
||||||
class Texture2D;
|
class Texture2D;
|
||||||
|
@ -39,12 +40,10 @@ extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "videodefs.hpp"
|
#include "videodefs.hpp"
|
||||||
|
#include "libavformatdefines.hpp"
|
||||||
|
|
||||||
#define VIDEO_PICTURE_QUEUE_SIZE 50
|
#define VIDEO_PICTURE_QUEUE_SIZE 50
|
||||||
|
|
||||||
#define FFMPEG_5_OR_GREATER (LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 28, 100))
|
|
||||||
#define FFMPEG_CONST_WRITEPACKET (LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(60, 12, 100))
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
struct SwsContext;
|
struct SwsContext;
|
||||||
|
@ -159,7 +158,7 @@ struct VideoState {
|
||||||
|
|
||||||
static int istream_read(void *user_data, uint8_t *buf, int buf_size);
|
static int istream_read(void *user_data, uint8_t *buf, int buf_size);
|
||||||
|
|
||||||
#if FFMPEG_CONST_WRITEPACKET
|
#if OPENMW_FFMPEG_CONST_WRITEPACKET
|
||||||
static int istream_write(void *, const unsigned char *, int);
|
static int istream_write(void *, const unsigned char *, int);
|
||||||
#else
|
#else
|
||||||
static int istream_write(void *, uint8_t *, int);
|
static int istream_write(void *, uint8_t *, int);
|
||||||
|
|
Loading…
Reference in a new issue