fix windows compile

This commit is contained in:
孙羽
2026-05-27 21:34:09 +08:00
parent 6b94ceea14
commit 116a4b8368
8 changed files with 48 additions and 44 deletions
+1 -3
View File
@@ -248,9 +248,7 @@ else()
endif() endif()
endif() endif()
if (WIN32) if (APPLE)
list(APPEND OLIVE_DEFINITIONS "-DUNICODE -D_UNICODE")
elseif (APPLE)
list(APPEND OLIVE_LIBRARIES "-framework IOKit") list(APPEND OLIVE_LIBRARIES "-framework IOKit")
elseif(UNIX) elseif(UNIX)
list(APPEND OLIVE_LIBRARIES Qt${QT_VERSION_MAJOR}::DBus) list(APPEND OLIVE_LIBRARIES Qt${QT_VERSION_MAJOR}::DBus)
+17 -20
View File
@@ -21,6 +21,23 @@
#include "ffmpegdecoder.h" #include "ffmpegdecoder.h"
namespace olive {
static VideoParams::Interlacing FFmpegFieldOrderToOlive(AVFieldOrder fo)
{
switch (fo) {
case AV_FIELD_TT:
return VideoParams::kInterlacedTopFirst;
case AV_FIELD_BB:
return VideoParams::kInterlacedBottomFirst;
case AV_FIELD_PROGRESSIVE:
default:
return VideoParams::kInterlaceNone;
}
}
}
extern "C" { extern "C" {
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
@@ -349,18 +366,6 @@ TexturePtr FFmpegDecoder::RetrieveVideoInternal(const RetrieveVideoParams &p)
return nullptr; return nullptr;
} }
// Diagnostic: check if decoded frame is all black
bool all_black = true;
if (f->data[0]) {
int check_rows = std::min(f->height, 8);
int check_bytes = check_rows * f->linesize[0];
for (int i = 0; i < check_bytes; ++i) {
if (f->data[0][i] != 0) {
all_black = false;
break;
}
}
}
// Finally, perform any GPU processing required // Finally, perform any GPU processing required
TexturePtr texture = ProcessFrameIntoTexture(f, p, original); TexturePtr texture = ProcessFrameIntoTexture(f, p, original);
@@ -454,14 +459,6 @@ FootageDescription FFmpegDecoder::Probe(const QString &filename,
avstream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || avstream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO ||
avstream->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)) { avstream->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
if (avstream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { if (avstream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
AVPixelFormat compatible_pix_fmt = AV_PIX_FMT_NONE;
bool image_is_still = false;
rational pixel_aspect_ratio;
rational frame_rate;
VideoParams::Interlacing interlacing =
VideoParams::kInterlaceNone;
{ {
// Read at least two frames to get more information about this video stream // Read at least two frames to get more information about this video stream
AVPacket *pkt = av_packet_alloc(); AVPacket *pkt = av_packet_alloc();
-14
View File
@@ -43,20 +43,6 @@ extern "C" {
namespace olive namespace olive
{ {
// 头文件里先备好枚举映射
static VideoParams::Interlacing FFmpegFieldOrderToOlive(AVFieldOrder fo)
{
switch (fo) {
case AV_FIELD_TT: // 隔行,顶场在前
return VideoParams::kInterlacedTopFirst;
case AV_FIELD_BB: // 隔行,底场在前
return VideoParams::kInterlacedBottomFirst;
case AV_FIELD_PROGRESSIVE:
default:
return VideoParams::kInterlaceNone;
}
}
/** /**
* @brief A Decoder derivative that wraps FFmpeg functions as on Olive decoder * @brief A Decoder derivative that wraps FFmpeg functions as on Olive decoder
*/ */
+9
View File
@@ -21,6 +21,11 @@
#include "ffmpegencoder.h" #include "ffmpegencoder.h"
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
extern "C" { extern "C" {
#include <libavfilter/buffersink.h> #include <libavfilter/buffersink.h>
#include <libavfilter/buffersrc.h> #include <libavfilter/buffersrc.h>
@@ -1038,4 +1043,8 @@ const AVCodec *FFmpegEncoder::GetEncoder(ExportCodec::Codec c,
return nullptr; return nullptr;
} }
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
} }
+4
View File
@@ -33,8 +33,10 @@
#include <QStyleFactory> #include <QStyleFactory>
#include "window/mainwindow/mainwindowundo.h" #include "window/mainwindow/mainwindowundo.h"
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QtPlatformHeaders/QWindowsWindowFunctions> #include <QtPlatformHeaders/QWindowsWindowFunctions>
#endif #endif
#endif
#include "audio/audiomanager.h" #include "audio/audiomanager.h"
#include "cli/clitask/clitaskdialog.h" #include "cli/clitask/clitaskdialog.h"
@@ -910,10 +912,12 @@ void Core::StartGUI(bool full_screen)
} }
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
// Workaround for Qt bug where menus don't appear in full screen mode // Workaround for Qt bug where menus don't appear in full screen mode
// See: https://doc.qt.io/qt-5/windows-issues.html // See: https://doc.qt.io/qt-5/windows-issues.html
QWindowsWindowFunctions::setHasBorderInFullScreen( QWindowsWindowFunctions::setHasBorderInFullScreen(
main_window_->windowHandle(), true); main_window_->windowHandle(), true);
#endif
#endif #endif
// Start autorecovery timer using the config value as its interval // Start autorecovery timer using the config value as its interval
+5
View File
@@ -498,8 +498,13 @@ void MainWindow::closeEvent(QCloseEvent *e)
} }
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool MainWindow::nativeEvent(const QByteArray &eventType, void *message,
qintptr *result)
#else
bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, bool MainWindow::nativeEvent(const QByteArray &eventType, void *message,
long *result) long *result)
#endif
{ {
if (static_cast<MSG *>(message)->message == taskbar_btn_id_) { if (static_cast<MSG *>(message)->message == taskbar_btn_id_) {
// Attempt to create taskbar button progress handle // Attempt to create taskbar button progress handle
+6 -1
View File
@@ -109,8 +109,13 @@ protected:
virtual void closeEvent(QCloseEvent *e) override; virtual void closeEvent(QCloseEvent *e) override;
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
virtual bool nativeEvent(const QByteArray &eventType, void *message, virtual bool nativeEvent(const QByteArray &eventType, void *message,
long *result); qintptr *result) override;
#else
virtual bool nativeEvent(const QByteArray &eventType, void *message,
long *result) override;
#endif
#endif #endif
private: private:
+2 -2
View File
@@ -307,7 +307,7 @@ namespace OFX {
// get multiple values // get multiple values
void getValueN(APIType *value, int count) const; void getValueN(APIType *value, int count) const;
#ifdef WINDOWS #ifdef _MSC_VER
#pragma warning( disable : 4181 ) #pragma warning( disable : 4181 )
#endif #endif
/// get one value /// get one value
@@ -316,7 +316,7 @@ namespace OFX {
/// get one value, without going through the getHook /// get one value, without going through the getHook
const ReturnType getValueRaw(int index=0) const; const ReturnType getValueRaw(int index=0) const;
#ifdef WINDOWS #ifdef _MSC_VER
#pragma warning( default : 4181 ) #pragma warning( default : 4181 )
#endif #endif
// get multiple values, without going through the getHook // get multiple values, without going through the getHook