forked from marlam/bino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix single-image input with the FFmpeg Qt Media backend
- Loading branch information
Showing
4 changed files
with
26 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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(); | ||
|
@@ -172,7 +176,7 @@ void VideoFrame::reUpdate() | |
|
||
void VideoFrame::invalidate() | ||
{ | ||
if (qframe.isValid()) | ||
if (isValid()) | ||
update(Input_Unknown, Surround_Unknown, QVideoFrame(), false); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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&))); | ||
} | ||
|
@@ -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; | ||
|
@@ -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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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); | ||
|
||
|