Skip to content

Commit af80bc6

Browse files
author
Christian Feldmann
committed
Fix compilation error
1 parent 8e18556 commit af80bc6

File tree

8 files changed

+367
-228
lines changed

8 files changed

+367
-228
lines changed

YUViewLib/src/ui/Mainwindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
#include <handler/UpdateHandler.h>
4040
#include <ui/SeparateWindow.h>
41-
#include <video/VideoCache.h>
41+
#include <video/caching/VideoCache.h>
4242

4343
#include "ui_mainwindow.h"
4444

YUViewLib/src/ui/views/SplitViewWidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include <playlistitem/playlistItem.h>
3636
#include <ui/PlaybackController.h>
3737
#include <video/FrameHandler.h>
38-
#include <video/VideoCache.h>
38+
#include <video/caching/VideoCache.h>
3939

4040
#include <QActionGroup>
4141
#include <QBackingStore>

YUViewLib/src/ui/widgets/VideoCacheInfoWidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include <QWidget>
3636

3737
#include "PlaylistTreeWidget.h"
38-
#include <video/VideoCache.h>
38+
#include <video/caching/VideoCache.h>
3939

4040
namespace VideoCacheStatusWidgetNamespace
4141
{
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/* This file is part of YUView - The YUV player with advanced analytics toolset
2+
* <https://github.com/IENT/YUView>
3+
* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* In addition, as a special exception, the copyright holders give
11+
* permission to link the code of portions of this program with the
12+
* OpenSSL library under certain conditions as described in each
13+
* individual source file, and distribute linked combinations including
14+
* the two.
15+
*
16+
* You must obey the GNU General Public License in all respects for all
17+
* of the code used other than OpenSSL. If you modify file(s) with this
18+
* exception, you may extend this exception to your version of the
19+
* file(s), but you are not obligated to do so. If you do not wish to do
20+
* so, delete this exception statement from your version. If you delete
21+
* this exception statement from all source files in the program, then
22+
* also delete it here.
23+
*
24+
* This program is distributed in the hope that it will be useful,
25+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
26+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+
* GNU General Public License for more details.
28+
*
29+
* You should have received a copy of the GNU General Public License
30+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
31+
*/
32+
33+
#pragma once
34+
35+
#include <QThread>
36+
37+
#include "LoadingWorker.h"
38+
39+
namespace video
40+
{
41+
42+
#define LOADINGTHREAD_DEBUG_LOADING 0
43+
#if LOADINGTHREAD_DEBUG_LOADING && !NDEBUG
44+
#define DEBUG_THREAD qDebug
45+
#else
46+
#define DEBUG_THREAD(fmt, ...) ((void)0)
47+
#endif
48+
49+
class LoadingThread : public QThread
50+
{
51+
Q_OBJECT
52+
public:
53+
LoadingThread(QObject *parent) : QThread(parent)
54+
{
55+
// Create a new worker and move it to this thread
56+
this->threadWorker.reset(new LoadingWorker(nullptr));
57+
this->threadWorker->moveToThread(this);
58+
}
59+
~LoadingThread() {}
60+
61+
void quitWhenDone()
62+
{
63+
this->quitting = true;
64+
if (this->threadWorker->isWorking())
65+
{
66+
// We must wait until the worker is done.
67+
DEBUG_THREAD("loadingThread::quitWhenDone waiting for worker to finish...");
68+
connect(worker(),
69+
&LoadingWorker::loadingFinished,
70+
this,
71+
[=]
72+
{
73+
DEBUG_THREAD("loadingThread::quitWhenDone worker done -> quit");
74+
quit();
75+
});
76+
}
77+
else
78+
{
79+
DEBUG_THREAD("loadingThread::quitWhenDone quit now");
80+
quit();
81+
}
82+
}
83+
84+
LoadingWorker *worker() { return this->threadWorker.get(); }
85+
bool isQuitting() { return this->quitting; }
86+
87+
private:
88+
std::unique_ptr<LoadingWorker> threadWorker{};
89+
bool quitting{}; // Are er quitting the job? If yes, do not push new jobs to it.
90+
};
91+
92+
} // namespace video
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/* This file is part of YUView - The YUV player with advanced analytics toolset
2+
* <https://github.com/IENT/YUView>
3+
* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* In addition, as a special exception, the copyright holders give
11+
* permission to link the code of portions of this program with the
12+
* OpenSSL library under certain conditions as described in each
13+
* individual source file, and distribute linked combinations including
14+
* the two.
15+
*
16+
* You must obey the GNU General Public License in all respects for all
17+
* of the code used other than OpenSSL. If you modify file(s) with this
18+
* exception, you may extend this exception to your version of the
19+
* file(s), but you are not obligated to do so. If you do not wish to do
20+
* so, delete this exception statement from your version. If you delete
21+
* this exception statement from all source files in the program, then
22+
* also delete it here.
23+
*
24+
* This program is distributed in the hope that it will be useful,
25+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
26+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+
* GNU General Public License for more details.
28+
*
29+
* You should have received a copy of the GNU General Public License
30+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
31+
*/
32+
33+
#include "LoadingWorker.h"
34+
35+
namespace video
36+
{
37+
38+
#define LOADINGWORKER_DEBUG_LOADING 0
39+
#if LOADINGWORKER_DEBUG_LOADING && !NDEBUG
40+
#define DEBUG_WORKER qDebug
41+
#else
42+
#define DEBUG_WORKER(fmt, ...) ((void)0)
43+
#endif
44+
45+
LoadingWorker::LoadingWorker(QObject *parent) : QObject(parent)
46+
{
47+
static int idCounter = 0;
48+
id = idCounter++;
49+
}
50+
51+
QString LoadingWorker::getStatus()
52+
{
53+
return QString("T%1: %2").arg(id).arg(this->working ? QString::number(this->currentFrame)
54+
: QString("-"));
55+
}
56+
57+
void LoadingWorker::setJob(playlistItem *item, int frame, bool test)
58+
{
59+
Q_ASSERT_X(item != nullptr, Q_FUNC_INFO, "Given item is nullptr");
60+
Q_ASSERT_X(
61+
frame >= 0 || !item->properties().isIndexedByFrame(), Q_FUNC_INFO, "Given frame index invalid");
62+
this->currentCacheItem = item;
63+
this->currentFrame = frame;
64+
this->testMode = test;
65+
}
66+
67+
void LoadingWorker::processCacheJob()
68+
{
69+
DEBUG_WORKER("LoadingWorker::processCacheJob invoke processCacheJobInternal");
70+
QMetaObject::invokeMethod(this, "processCacheJobInternal");
71+
}
72+
73+
void LoadingWorker::processLoadingJob(bool playing, bool loadRawData)
74+
{
75+
DEBUG_WORKER("LoadingWorker::processLoadingJob invoke processLoadingJobInternal");
76+
QMetaObject::invokeMethod(
77+
this, "processLoadingJobInternal", Q_ARG(bool, playing), Q_ARG(bool, loadRawData));
78+
}
79+
80+
void LoadingWorker::processCacheJobInternal()
81+
{
82+
Q_ASSERT_X(this->currentCacheItem != nullptr, Q_FUNC_INFO, "Invalid Job - Item is nullptr");
83+
Q_ASSERT_X(this->currentFrame >= 0 || !this->currentCacheItem->properties().isIndexedByFrame(),
84+
Q_FUNC_INFO,
85+
"Given frame index invalid");
86+
DEBUG_WORKER("LoadingWorker::processCacheJobInternal");
87+
88+
// Just cache the frame that was given to us.
89+
// This is performed in the thread that this worker is currently placed in.
90+
this->currentCacheItem->cacheFrame(currentFrame, testMode);
91+
92+
this->currentCacheItem = nullptr;
93+
DEBUG_WORKER("LoadingWorker::processCacheJobInternal emit loadingFinished");
94+
emit loadingFinished();
95+
}
96+
97+
void LoadingWorker::processLoadingJobInternal(bool playing, bool loadRawData)
98+
{
99+
Q_ASSERT_X(this->currentCacheItem != nullptr, Q_FUNC_INFO, "The set job is nullptr");
100+
Q_ASSERT_X((!this->currentCacheItem->properties().isIndexedByFrame() || currentFrame >= 0),
101+
Q_FUNC_INFO,
102+
"The set frame index is invalid");
103+
Q_ASSERT_X(!this->currentCacheItem->taggedForDeletion(),
104+
Q_FUNC_INFO,
105+
"The set job was tagged for deletion");
106+
DEBUG_WORKER(Q_FUNC_INFO);
107+
108+
// Load the frame of the item that was given to us.
109+
// This is performed in the thread (the loading thread with higher priority.
110+
this->currentCacheItem->loadFrame(currentFrame, playing, loadRawData);
111+
112+
this->currentCacheItem = nullptr;
113+
emit loadingFinished();
114+
DEBUG_WORKER("LoadingWorker::processLoadingJobInternal emit loadingFinished");
115+
}
116+
117+
} // namespace video
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/* This file is part of YUView - The YUV player with advanced analytics toolset
2+
* <https://github.com/IENT/YUView>
3+
* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* In addition, as a special exception, the copyright holders give
11+
* permission to link the code of portions of this program with the
12+
* OpenSSL library under certain conditions as described in each
13+
* individual source file, and distribute linked combinations including
14+
* the two.
15+
*
16+
* You must obey the GNU General Public License in all respects for all
17+
* of the code used other than OpenSSL. If you modify file(s) with this
18+
* exception, you may extend this exception to your version of the
19+
* file(s), but you are not obligated to do so. If you do not wish to do
20+
* so, delete this exception statement from your version. If you delete
21+
* this exception statement from all source files in the program, then
22+
* also delete it here.
23+
*
24+
* This program is distributed in the hope that it will be useful,
25+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
26+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+
* GNU General Public License for more details.
28+
*
29+
* You should have received a copy of the GNU General Public License
30+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
31+
*/
32+
33+
#pragma once
34+
35+
#include "playlistitem/playlistItem.h"
36+
37+
#include <QObject>
38+
#include <QString>
39+
40+
namespace video
41+
{
42+
43+
class LoadingWorker : public QObject
44+
{
45+
Q_OBJECT
46+
public:
47+
LoadingWorker(QObject *parent);
48+
~LoadingWorker() {}
49+
50+
playlistItem *getCacheItem() { return this->currentCacheItem; }
51+
int getCacheFrame() { return this->currentFrame; }
52+
void setJob(playlistItem *item, int frame, bool test = false);
53+
void setWorking(bool state) { this->working = state; }
54+
bool isWorking() { return this->working; }
55+
QString getStatus();
56+
57+
// Process the job in the thread that this worker was moved to. This function can be directly
58+
// called from the main thread. It will still process the call in the separate thread.
59+
void processCacheJob();
60+
void processLoadingJob(bool playing, bool loadRawData);
61+
signals:
62+
void loadingFinished();
63+
private slots:
64+
void processCacheJobInternal();
65+
void processLoadingJobInternal(bool playing, bool loadRawData);
66+
67+
private:
68+
playlistItem *currentCacheItem{};
69+
int currentFrame{};
70+
bool working{};
71+
bool testMode{};
72+
int id{}; // A static ID of the thread. Only used in getStatus().
73+
};
74+
75+
} // namespace video

0 commit comments

Comments
 (0)