Commit 71078112 authored by Wieland Morgenstern's avatar Wieland Morgenstern

replace vector<map<id, Audio::Samples>> with list<...>

Audio::Samples are a move-only class, they can't be copied.

Using this non-copyable class in a std::vector<std::map<..>> does not
compile in Visual Studio 2017, see e.g.:

https://stackoverflow.com/questions/58700780/vector-of-maps-of-non-copyable-objects-fails-to-compile-in-msvc

Replacing the use of vector with list, which does compile.
parent 95a624f8
...@@ -619,7 +619,7 @@ template <typename VideoPipeline> ...@@ -619,7 +619,7 @@ template <typename VideoPipeline>
ControllerStatus ControllerImpl<VideoPipeline>::extract(ExtractOutput* extract, bool readFrame) { ControllerStatus ControllerImpl<VideoPipeline>::extract(ExtractOutput* extract, bool readFrame) {
// load the acquisition data // load the acquisition data
std::map<readerid_t, Input::PotentialFrame> inputBuffers; std::map<readerid_t, Input::PotentialFrame> inputBuffers;
std::vector<Audio::audioBlockGroupMap_t> audioBlocks; std::list<Audio::audioBlockGroupMap_t> audioBlocks;
Input::MetadataChunk metadata; Input::MetadataChunk metadata;
mtime_t date; mtime_t date;
...@@ -644,7 +644,7 @@ ControllerStatus ControllerImpl<VideoPipeline>::extract(std::vector<ExtractOutpu ...@@ -644,7 +644,7 @@ ControllerStatus ControllerImpl<VideoPipeline>::extract(std::vector<ExtractOutpu
bool readFrame) { bool readFrame) {
// load the acquisition data // load the acquisition data
std::map<readerid_t, Input::PotentialFrame> inputBuffers; std::map<readerid_t, Input::PotentialFrame> inputBuffers;
std::vector<Audio::audioBlockGroupMap_t> audioBlocks; std::list<Audio::audioBlockGroupMap_t> audioBlocks;
Input::MetadataChunk metadata; Input::MetadataChunk metadata;
mtime_t date; mtime_t date;
...@@ -734,7 +734,7 @@ ControllerStatus ControllerImpl<VideoPipeline>::stitchAndExtract(Output* output, ...@@ -734,7 +734,7 @@ ControllerStatus ControllerImpl<VideoPipeline>::stitchAndExtract(Output* output,
// load the acquisition data // load the acquisition data
std::map<readerid_t, Input::PotentialFrame> inputBuffers; std::map<readerid_t, Input::PotentialFrame> inputBuffers;
mtime_t date; mtime_t date;
std::vector<Audio::audioBlockGroupMap_t> audioBlocks; std::list<Audio::audioBlockGroupMap_t> audioBlocks;
Input::MetadataChunk metadata; Input::MetadataChunk metadata;
if (readFrame) { if (readFrame) {
......
...@@ -82,7 +82,7 @@ Status ControllerInputFrames<destinationColor, readbackType>::load( ...@@ -82,7 +82,7 @@ Status ControllerInputFrames<destinationColor, readbackType>::load(
std::map<readerid_t, PotentialValue<GPU::HostBuffer<readbackType>>>& processedFrames, mtime_t* date) { std::map<readerid_t, PotentialValue<GPU::HostBuffer<readbackType>>>& processedFrames, mtime_t* date) {
std::map<readerid_t, Input::PotentialFrame> framesFromReader; std::map<readerid_t, Input::PotentialFrame> framesFromReader;
processedFrames.clear(); processedFrames.clear();
std::vector<Audio::audioBlockGroupMap_t> audioBlocks; std::list<Audio::audioBlockGroupMap_t> audioBlocks;
mtime_t tempDate = 0; mtime_t tempDate = 0;
Input::MetadataChunk metadata; Input::MetadataChunk metadata;
auto loadStatus = readerController->load(tempDate, framesFromReader, audioBlocks, metadata); auto loadStatus = readerController->load(tempDate, framesFromReader, audioBlocks, metadata);
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "libvideostitch/logging.hpp" #include "libvideostitch/logging.hpp"
#include <future> #include <future>
#include <list>
#include <vector> #include <vector>
#include <unordered_set> #include <unordered_set>
#include <cstdlib> #include <cstdlib>
...@@ -185,7 +186,7 @@ ReaderController::~ReaderController() { ...@@ -185,7 +186,7 @@ ReaderController::~ReaderController() {
std::tuple<Input::ReadStatus, Input::ReadStatus, Input::ReadStatus> ReaderController::load( std::tuple<Input::ReadStatus, Input::ReadStatus, Input::ReadStatus> ReaderController::load(
mtime_t& date, std::map<readerid_t, Input::PotentialFrame>& frames, mtime_t& date, std::map<readerid_t, Input::PotentialFrame>& frames,
std::vector<Audio::audioBlockGroupMap_t>& audioBlocks, Input::MetadataChunk& metadata) { std::list<Audio::audioBlockGroupMap_t>& audioBlocks, Input::MetadataChunk& metadata) {
// protect from concurrent seeks // protect from concurrent seeks
std::lock_guard<std::mutex> lock(inputMutex); std::lock_guard<std::mutex> lock(inputMutex);
...@@ -369,8 +370,8 @@ Input::ReadStatus ReaderController::loadVideo(mtime_t& date, std::map<readerid_t ...@@ -369,8 +370,8 @@ Input::ReadStatus ReaderController::loadVideo(mtime_t& date, std::map<readerid_t
/// \param audioBlocks First dimension is the block, second index the input /// \param audioBlocks First dimension is the block, second index the input
/// (e.g. audioIn[1][0] => second block of the input 0) /// (e.g. audioIn[1][0] => second block of the input 0)
/// \return Code::Ok on success, else an error code /// \return Code::Ok on success, else an error code
Input::ReadStatus ReaderController::loadAudio(std::vector<Audio::audioBlockGroupMap_t>& audioBlocks, groupid_t gr) { Input::ReadStatus ReaderController::loadAudio(std::list<Audio::audioBlockGroupMap_t>& audioBlocks, groupid_t gr) {
std::vector<std::map<readerid_t, Audio::Samples>> audioIn; std::list<std::map<readerid_t, Audio::Samples>> audioIn;
size_t nbSamples = audioPipeDef->getBlockSize(); size_t nbSamples = audioPipeDef->getBlockSize();
...@@ -488,9 +489,9 @@ Input::ReadStatus ReaderController::loadAudio(std::vector<Audio::audioBlockGroup ...@@ -488,9 +489,9 @@ Input::ReadStatus ReaderController::loadAudio(std::vector<Audio::audioBlockGroup
Audio::AudioBlock blk; Audio::AudioBlock blk;
// First dimension is the block, second dimension the input (e.g. audioIn[1][0] => second block of the first input) // First dimension is the block, second dimension the input (e.g. audioIn[1][0] => second block of the first input)
for (size_t i = 0; i < audioIn.size(); ++i) { // for each block for (auto& samplesByReader : audioIn) { // for each block
Audio::audioBlockReaderMap_t audioBlockPerReader; Audio::audioBlockReaderMap_t audioBlockPerReader;
for (auto& readerData : audioIn[i]) { // for each reader for (auto& readerData : samplesByReader) { // for each reader
readerData.second.setTimestamp(readerData.second.getTimestamp() + audioTimestampOffsets.at(gr)); readerData.second.setTimestamp(readerData.second.getTimestamp() + audioTimestampOffsets.at(gr));
// find the audio reader corresponding to this block // find the audio reader corresponding to this block
for (size_t j = 0; j < audioAsyncReaders.at(gr).size(); ++j) { for (size_t j = 0; j < audioAsyncReaders.at(gr).size(); ++j) {
...@@ -502,17 +503,13 @@ Input::ReadStatus ReaderController::loadAudio(std::vector<Audio::audioBlockGroup ...@@ -502,17 +503,13 @@ Input::ReadStatus ReaderController::loadAudio(std::vector<Audio::audioBlockGroup
audioBlockPerReader[readerData.first] = std::move(blk); audioBlockPerReader[readerData.first] = std::move(blk);
} }
if (i < audioBlocks.size()) { Audio::audioBlockGroupMap_t audioBlockPerGroup;
audioBlocks.at(i)[gr] = std::move(audioBlockPerReader); audioBlockPerGroup[gr] = std::move(audioBlockPerReader);
} else { audioBlocks.push_back(std::move(audioBlockPerGroup));
Audio::audioBlockGroupMap_t audioBlockPerGroup;
audioBlockPerGroup[gr] = std::move(audioBlockPerReader);
audioBlocks.push_back(std::move(audioBlockPerGroup));
}
} }
Logger::verbose(CTRLtag) << "read group " << gr << " " << audioIn.size() << " audio blocks starting at timestamp " Logger::verbose(CTRLtag) << "read group " << gr << " " << audioIn.size() << " audio blocks starting at timestamp "
<< audioIn[0].begin()->second.getTimestamp() << std::endl; << audioIn.front().begin()->second.getTimestamp() << std::endl;
return Input::ReadStatus::OK(); return Input::ReadStatus::OK();
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "libvideostitch/inputDef.hpp" #include "libvideostitch/inputDef.hpp"
#include "libvideostitch/panoDef.hpp" #include "libvideostitch/panoDef.hpp"
#include <list>
#include <mutex> #include <mutex>
namespace VideoStitch { namespace VideoStitch {
...@@ -54,7 +55,7 @@ class ReaderController { ...@@ -54,7 +55,7 @@ class ReaderController {
std::tuple<Input::ReadStatus, Input::ReadStatus, Input::ReadStatus> load( std::tuple<Input::ReadStatus, Input::ReadStatus, Input::ReadStatus> load(
mtime_t&, std::map<readerid_t, Input::PotentialFrame>& frames, mtime_t&, std::map<readerid_t, Input::PotentialFrame>& frames,
std::vector<Audio::audioBlockGroupMap_t>& audioBlocks, Input::MetadataChunk& imu_metadata); std::list<Audio::audioBlockGroupMap_t>& audioBlocks, Input::MetadataChunk& imu_metadata);
mtime_t reload(std::map<readerid_t, Input::PotentialFrame>& frames); mtime_t reload(std::map<readerid_t, Input::PotentialFrame>& frames);
void releaseBuffer(std::map<readerid_t, Input::PotentialFrame>& frames); void releaseBuffer(std::map<readerid_t, Input::PotentialFrame>& frames);
...@@ -147,7 +148,7 @@ class ReaderController { ...@@ -147,7 +148,7 @@ class ReaderController {
private: private:
Input::ReadStatus loadVideo(mtime_t& date, std::map<readerid_t, Input::PotentialFrame>& frames); Input::ReadStatus loadVideo(mtime_t& date, std::map<readerid_t, Input::PotentialFrame>& frames);
Input::ReadStatus loadAudio(std::vector<Audio::audioBlockGroupMap_t>& audioIn, groupid_t gr); Input::ReadStatus loadAudio(std::list<Audio::audioBlockGroupMap_t>& audioIn, groupid_t gr);
Input::ReadStatus loadMetadata(Input::MetadataChunk& Measure); Input::ReadStatus loadMetadata(Input::MetadataChunk& Measure);
/** /**
......
...@@ -59,7 +59,7 @@ ControllerStatus DepthControllerImpl::estimateDepth(std::vector<ExtractOutput*> ...@@ -59,7 +59,7 @@ ControllerStatus DepthControllerImpl::estimateDepth(std::vector<ExtractOutput*>
// load the acquisition data // load the acquisition data
std::map<readerid_t, Input::PotentialFrame> inputBuffers; std::map<readerid_t, Input::PotentialFrame> inputBuffers;
mtime_t date; mtime_t date;
std::vector<Audio::audioBlockGroupMap_t> audioBlocks; std::list<Audio::audioBlockGroupMap_t> audioBlocks;
Input::MetadataChunk metadata; Input::MetadataChunk metadata;
std::tie(statusVideo, statusAudio, statusMetadata) = std::tie(statusVideo, statusAudio, statusMetadata) =
......
...@@ -59,7 +59,7 @@ ControllerStatus UndistortControllerImpl::undistort(std::vector<ExtractOutput*> ...@@ -59,7 +59,7 @@ ControllerStatus UndistortControllerImpl::undistort(std::vector<ExtractOutput*>
// load the acquisition data // load the acquisition data
std::map<readerid_t, Input::PotentialFrame> inputBuffers; std::map<readerid_t, Input::PotentialFrame> inputBuffers;
mtime_t date; mtime_t date;
std::vector<Audio::audioBlockGroupMap_t> audioBlocks; std::list<Audio::audioBlockGroupMap_t> audioBlocks;
Input::MetadataChunk metadata; Input::MetadataChunk metadata;
std::tie(statusVideo, statusAudio, statusMetadata) = std::tie(statusVideo, statusAudio, statusMetadata) =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment