Skip to content

Commit 62030e1

Browse files
committed
[qtAliceVision] SequenceCache: Remove useless includes and fix warnings
1 parent d304d86 commit 62030e1

File tree

5 files changed

+24
-35
lines changed

5 files changed

+24
-35
lines changed

src/qtAliceVision/AsyncFetcher.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void AsyncFetcher::run()
6060
_isAsynchronous = true;
6161
_requestSynchronous = false;
6262

63-
int previousCacheSize = getDiskLoads();
63+
std::size_t previousCacheSize = getDiskLoads();
6464

6565
while (1)
6666
{
@@ -76,7 +76,7 @@ void AsyncFetcher::run()
7676
}
7777
else
7878
{
79-
const std::string& lpath = _sequence[_currentIndex];
79+
const std::string& lpath = _sequence[static_cast<std::size_t>(_currentIndex)];
8080

8181
// Load in cache
8282
if (_cache)
@@ -87,12 +87,12 @@ void AsyncFetcher::run()
8787
ratio = _resizeRatio;
8888
}
8989

90-
_cache->get<image::RGBAfColor>(lpath, _currentIndex, ratio, false);
90+
_cache->get<image::RGBAfColor>(lpath, static_cast<unsigned int>(_currentIndex), ratio, false);
9191
}
9292

9393
_currentIndex++;
9494

95-
int size = _sequence.size();
95+
int size = static_cast<int>(_sequence.size());
9696
if (_currentIndex >= size)
9797
{
9898
_currentIndex = 0;
@@ -101,7 +101,7 @@ void AsyncFetcher::run()
101101
std::this_thread::sleep_for(1ms);
102102
}
103103

104-
int cacheSize = getDiskLoads();
104+
std::size_t cacheSize = getDiskLoads();
105105
if (cacheSize != previousCacheSize)
106106
{
107107
previousCacheSize = cacheSize;
@@ -118,22 +118,22 @@ void AsyncFetcher::stopAsync()
118118
_requestSynchronous = true;
119119
}
120120

121-
void AsyncFetcher::updateCacheMemory(size_t maxMemory)
121+
void AsyncFetcher::updateCacheMemory(std::size_t maxMemory)
122122
{
123123
if (_cache)
124124
{
125125
_cache->updateMaxMemory(maxMemory);
126126
}
127127
}
128128

129-
size_t AsyncFetcher::getCacheSize() const
129+
std::size_t AsyncFetcher::getCacheSize() const
130130
{
131-
return (_cache) ? _cache->info().getContentSize() : 0.0f;
131+
return (_cache) ? static_cast<std::size_t>(_cache->info().getContentSize()) : 0;
132132
}
133133

134-
size_t AsyncFetcher::getDiskLoads() const
134+
std::size_t AsyncFetcher::getDiskLoads() const
135135
{
136-
return (_cache) ? _cache->info().getLoadFromDisk() : 0.0f;
136+
return (_cache) ? static_cast<std::size_t>(_cache->info().getLoadFromDisk()) : 0;
137137
}
138138

139139
QVariantList AsyncFetcher::getCachedFrames() const
@@ -209,11 +209,11 @@ bool AsyncFetcher::getFrame(const std::string& path,
209209
bool onlyCache = _isAsynchronous;
210210

211211
// Upgrade the thread with the current Index
212-
for (int idx = 0; idx < _sequence.size(); ++idx)
212+
for (std::size_t idx = 0; idx < _sequence.size(); ++idx)
213213
{
214214
if (_sequence[idx] == path)
215215
{
216-
_currentIndex = idx;
216+
_currentIndex = static_cast<int>(idx);
217217
break;
218218
}
219219
}

src/qtAliceVision/AsyncFetcher.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class AsyncFetcher : public QObject, public QRunnable
5151
bool getFrame(const std::string& path,
5252
std::shared_ptr<aliceVision::image::Image<aliceVision::image::RGBAfColor>>& image,
5353
oiio::ParamValueList& metadatas,
54-
size_t& originalWidth,
55-
size_t& originalHeight);
54+
std::size_t& originalWidth,
55+
std::size_t& originalHeight);
5656

5757
/**
5858
* @brief Internal function for QT to start the asynchronous mode
@@ -71,19 +71,19 @@ class AsyncFetcher : public QObject, public QRunnable
7171
* @brief get the cache content size in bytes
7272
* @return the cache content size in bytes
7373
*/
74-
size_t getCacheSize() const;
74+
std::size_t getCacheSize() const;
7575

7676
/**
7777
* @brief get the number of images loaded
7878
* @return the count of images loaded since the creation of the cache object
7979
*/
80-
size_t getDiskLoads() const;
80+
std::size_t getDiskLoads() const;
8181

8282
/**
8383
* @brief update maxMemory for the cache
8484
* @param maxMemory the number of bytes allowed in the cache
8585
*/
86-
void updateCacheMemory(size_t maxMemory);
86+
void updateCacheMemory(std::size_t maxMemory);
8787

8888
/**
8989
* @brief get a list of regions containing the image frames

src/qtAliceVision/ImageCache.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include "ImageCache.hpp"
22

3-
#include <aliceVision/system/Logger.hpp>
4-
53
namespace qtAliceVision {
64

75
ImageCache::ImageCache(unsigned long maxSize, const aliceVision::image::ImageReadOptions& options)

src/qtAliceVision/ImageCache.hpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010

1111
#include <boost/functional/hash.hpp>
1212

13-
#include <filesystem>
14-
#include <memory>
15-
#include <unordered_map>
16-
#include <functional>
17-
#include <list>
18-
#include <mutex>
19-
#include <thread>
20-
#include <algorithm>
2113

2214
namespace qtAliceVision {
2315
/**
@@ -187,7 +179,7 @@ class CacheInfo
187179
}
188180
}
189181

190-
size_t getAvailableSize() const
182+
std::size_t getAvailableSize() const
191183
{
192184
const std::scoped_lock<std::mutex> lock(_mutex);
193185

@@ -199,7 +191,7 @@ class CacheInfo
199191
return _maxSize - _contentSize;
200192
}
201193

202-
bool isSmallEnough(size_t value) const
194+
bool isSmallEnough(std::size_t value) const
203195
{
204196
const std::scoped_lock<std::mutex> lock(_mutex);
205197

@@ -288,7 +280,7 @@ class ImageCache
288280
* @param requestedSize the required size for the new image
289281
* @param toAdd the key of the image to add after cleanup
290282
*/
291-
void cleanup(size_t requestedSize, const CacheKey& toAdd);
283+
void cleanup(std::size_t requestedSize, const CacheKey& toAdd);
292284

293285
/**
294286
* @return information on the current cache state and usage
@@ -397,7 +389,7 @@ std::optional<CacheValue> ImageCache::load(const CacheKey& key, unsigned frameId
397389
int th = static_cast<int>(std::max(1, int(std::ceil(dh))));
398390

399391
using TInfo = aliceVision::image::ColorTypeInfo<TPix>;
400-
cleanup(tw * th * size_t(TInfo::size), key);
392+
cleanup(tw * th * std::size_t(TInfo::size), key);
401393

402394
// apply downscale
403395
aliceVision::imageAlgo::resizeImage(tw, th, img, *resized);

src/qtAliceVision/SequenceCache.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "SequenceCache.hpp"
22

33
#include <aliceVision/system/MemoryInfo.hpp>
4-
#include <aliceVision/image/Image.hpp>
54

65
using namespace aliceVision;
76

@@ -68,7 +67,7 @@ void SequenceCache::setMemoryLimit(int memory)
6867
{
6968
// Convert parameter in gigabytes to bytes
7069
const double gigaBytesToBytes = 1024. * 1024. * 1024.;
71-
_maxMemory = static_cast<double>(memory) * gigaBytesToBytes;
70+
_maxMemory = static_cast<std::size_t>(static_cast<double>(memory) * gigaBytesToBytes);
7271
_fetcher.updateCacheMemory(_maxMemory);
7372
}
7473

@@ -95,7 +94,7 @@ QPointF SequenceCache::getRamInfo() const
9594
// Get available RAM in bytes and cache occupied memory
9695
const auto memInfo = aliceVision::system::getMemoryInfo();
9796

98-
double availableRam = memInfo.availableRam / (1024. * 1024. * 1024.);
97+
double availableRam = static_cast<double>(memInfo.availableRam) / (1024. * 1024. * 1024.);
9998
double contentSize = static_cast<double>(_fetcher.getCacheSize()) / (1024. * 1024. * 1024. * 1024.);
10099

101100
// Return in GB
@@ -119,7 +118,7 @@ ResponseData SequenceCache::request(const RequestData& reqData)
119118

120119
response.metadata.clear();
121120
response.img = image;
122-
response.dim = QSize(originalWidth, originalHeight);
121+
response.dim = QSize(static_cast<int>(originalWidth), static_cast<int>(originalHeight));
123122

124123
// Convert metadatas
125124
for (const auto& item : metadatas)

0 commit comments

Comments
 (0)