Skip to content

Commit

Permalink
Merge branch 'marlam:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ThreeDeeJay authored Sep 23, 2024
2 parents 88180b1 + de6410d commit b228c92
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
15 changes: 14 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
# include <QWindowCapture>
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
# include <QtProcessorDetection>
#endif

#ifdef WITH_QVR
# include <qvr/manager.hpp>
Expand Down Expand Up @@ -641,7 +644,17 @@ int main(int argc, char* argv[])
format.setBlueBufferSize(10);
format.setAlphaBufferSize(0);
format.setStencilBufferSize(0);
if (parser.isSet("opengles"))
bool wantOpenGLES = parser.isSet("opengles");
#if (QT_VERSION >= QT_VERSION_CHECK(6, 5, 0))
# if defined Q_PROCESSOR_ARM
wantOpenGLES = true;
# endif
#else
# if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__)
wantOpenGLES = true;
# endif
#endif
if (wantOpenGLES)
format.setRenderableType(QSurfaceFormat::OpenGLES);
initializeIsOpenGLES(format);
if (IsOpenGLES) {
Expand Down
12 changes: 8 additions & 4 deletions src/videoframe.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Bino, a 3D video player.
*
* Copyright (C) 2022
* Copyright (C) 2022, 2023, 2024
* Martin Lambers <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -27,14 +27,18 @@ VideoFrame::VideoFrame()
update(Input_Unknown, Surround_Unknown, QVideoFrame(), false);
}

bool VideoFrame::isValid() const
{
return (qframe.isValid() && qframe.pixelFormat() != QVideoFrameFormat::Format_Invalid);
}

void VideoFrame::update(InputMode im, SurroundMode sm, const QVideoFrame& frame, bool newSrc)
{
if (qframe.isMapped())
qframe.unmap();
qframe = frame;

bool valid = (qframe.isValid() && qframe.pixelFormat() != QVideoFrameFormat::Format_Invalid);
if (valid) {
if (isValid()) {
subtitle = qframe.subtitleText();
width = qframe.width();
height = qframe.height();
Expand Down Expand Up @@ -172,7 +176,7 @@ void VideoFrame::reUpdate()

void VideoFrame::invalidate()
{
if (qframe.isValid())
if (isValid())
update(Input_Unknown, Surround_Unknown, QVideoFrame(), false);
}

Expand Down
3 changes: 2 additions & 1 deletion src/videoframe.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Bino, a 3D video player.
*
* Copyright (C) 2022
* Copyright (C) 2022, 2023, 2024
* Martin Lambers <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -87,6 +87,7 @@ Q_DECLARE_TR_FUNCTIONS(VideoFrame)

VideoFrame();

bool isValid() const;
void update(InputMode im, SurroundMode ts, const QVideoFrame& frame, bool newSrc);
void reUpdate();
void invalidate();
Expand Down
16 changes: 14 additions & 2 deletions src/videosink.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Bino, a 3D video player.
*
* Copyright (C) 2022
* Copyright (C) 2022, 2023, 2024
* Martin Lambers <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -32,7 +32,8 @@ VideoSink::VideoSink(VideoFrame* frame, VideoFrame* extFrame, bool* frameIsNew)
frameIsNew(frameIsNew),
needExtFrame(false),
inputMode(Input_Unknown),
surroundMode(Surround_Unknown)
surroundMode(Surround_Unknown),
lastFrameWasValid(false)
{
connect(this, SIGNAL(videoFrameChanged(const QVideoFrame&)), this, SLOT(processNewFrame(const QVideoFrame&)));
}
Expand All @@ -42,6 +43,7 @@ void VideoSink::newUrl(const QUrl& url, InputMode im, SurroundMode sm)
{
frameCounter = 0;
fileFormatIsMPO = false;
lastFrameWasValid = false;

LOG_DEBUG("initial input mode for %s: %s", qPrintable(url.toString()), inputModeToString(im));
inputMode = im;
Expand Down Expand Up @@ -116,6 +118,16 @@ void VideoSink::newUrl(const QUrl& url, InputMode im, SurroundMode sm)

void VideoSink::processNewFrame(const QVideoFrame& frame)
{
if (!frame.isValid() && lastFrameWasValid) {
// keep showing the last frame of the current media; ignore that QtMultiMedia
// with the FFmpeg backend gives us an invalid frame as soon as the media stops
// (it does not do this with the GStreamer backend)
LOG_DEBUG("video sink gets invalid frame and ignores it since last frame of current media was valid");
return;
}
if (frame.isValid())
lastFrameWasValid = true;

// Workaround a glitch in the MPO file format:
// Gstreamer reads three frames from such files, the first two being the left
// view and the last one being the right view.
Expand Down
3 changes: 2 additions & 1 deletion src/videosink.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of Bino, a 3D video player.
*
* Copyright (C) 2022
* Copyright (C) 2022, 2023, 2024
* Martin Lambers <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -40,6 +40,7 @@ Q_OBJECT
bool needExtFrame; // flag to set in alternating stereo when extFrame is not filled yet
InputMode inputMode; // input mode of current media
SurroundMode surroundMode; // surround mode of the current media
bool lastFrameWasValid; // last frame of current media was valid

VideoSink(VideoFrame* frame, VideoFrame* extFrame, bool* frameIsNew);

Expand Down

0 comments on commit b228c92

Please sign in to comment.