From 6c207703cf5c4f60d888695f881af98bdacd042e Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Tue, 28 Jan 2020 09:41:54 +0200 Subject: [PATCH] Remove compile warnings --- CMakeLists.txt | 9 ++++---- applications/calibration/src/lens.cpp | 2 +- applications/ftl2mkv/src/main.cpp | 6 ++++- applications/reconstruct/src/main.cpp | 3 --- .../reconstruct/src/reconstruction.cpp | 6 ++--- .../reconstruct/src/reconstruction.hpp | 2 +- applications/tools/codec_eval/src/main.cpp | 3 --- components/audio/include/ftl/audio/buffer.hpp | 4 ++-- components/audio/include/ftl/audio/source.hpp | 2 +- components/audio/src/source.cpp | 4 ++-- components/codecs/src/decoder.cpp | 3 +-- components/codecs/src/reader.cpp | 4 ++-- components/codecs/test/nvpipe_codec_unit.cpp | 22 +++++++++---------- components/net/cpp/src/peer.cpp | 6 ++++- .../net/cpp/test/net_configurable_unit.cpp | 2 ++ components/operators/src/depth.cpp | 2 +- components/operators/src/mvmls.cpp | 4 ++-- components/operators/src/operator.cpp | 2 +- components/operators/src/smoothing.cpp | 2 +- .../include/ftl/utility/matrix_conversion.hpp | 4 ++-- components/renderers/cpp/src/tri_render.cpp | 2 +- components/rgbd-sources/CMakeLists.txt | 2 +- .../include/ftl/rgbd/frameset.hpp | 6 ++--- .../rgbd-sources/include/ftl/rgbd/group.hpp | 2 +- .../rgbd-sources/src/cb_segmentation.cpp | 8 +++---- components/rgbd-sources/src/frameset.cpp | 16 +++++++------- components/rgbd-sources/src/group.cpp | 2 +- .../rgbd-sources/src/sources/net/net.cpp | 8 +++---- .../rgbd-sources/src/sources/net/net.hpp | 2 +- .../src/sources/stereovideo/stereovideo.cpp | 1 - .../streams/include/ftl/streams/receiver.hpp | 2 +- components/streams/src/filestream.cpp | 2 +- components/streams/src/netstream.cpp | 4 ++-- components/streams/src/receiver.cpp | 10 ++++----- components/streams/src/sender.cpp | 10 ++++----- components/streams/src/stream.cpp | 16 +++++++------- components/streams/test/receiver_unit.cpp | 2 +- components/streams/test/sender_unit.cpp | 2 +- .../structures/include/ftl/data/frame.hpp | 5 +++++ .../structures/include/ftl/data/frameset.hpp | 2 +- 40 files changed, 101 insertions(+), 95 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b160d9b1..5b08d4d0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,10 +40,11 @@ if (WITH_OPTFLOW) set(HAVE_OPTFLOW true) endif() -find_package( LibArchive ) -if (LibArchive_FOUND) - set(HAVE_LIBARCHIVE true) -endif() +# Enable if the old snapshot is still needed +#find_package( LibArchive ) +#if (LibArchive_FOUND) +# set(HAVE_LIBARCHIVE true) +#endif() if (WITH_OPENVR) ## OpenVR API path diff --git a/applications/calibration/src/lens.cpp b/applications/calibration/src/lens.cpp index c0c44bbe0..bc675d365 100644 --- a/applications/calibration/src/lens.cpp +++ b/applications/calibration/src/lens.cpp @@ -79,7 +79,7 @@ void ftl::calibration::intrinsic(map<string, string> &opt) { Size tmp_size; loadIntrinsics(filename_intrinsics, camera_matrix, tmp, tmp_size); - CHECK(camera_matrix.size() == n_cameras); // (camera_matrix.size() == dist_coeffs.size()) + CHECK(camera_matrix.size() == static_cast<unsigned int>(n_cameras)); // (camera_matrix.size() == dist_coeffs.size()) if ((tmp_size != image_size) && (!tmp_size.empty())) { Mat scale = Mat::eye(Size(3, 3), CV_64FC1); diff --git a/applications/ftl2mkv/src/main.cpp b/applications/ftl2mkv/src/main.cpp index 3e6b0e302..783bacb20 100644 --- a/applications/ftl2mkv/src/main.cpp +++ b/applications/ftl2mkv/src/main.cpp @@ -18,7 +18,7 @@ using ftl::codecs::Channel; static AVStream *add_video_stream(AVFormatContext *oc, const ftl::codecs::Packet &pkt) { - AVCodecContext *c; + //AVCodecContext *c; AVStream *st; st = avformat_new_stream(oc, 0); @@ -29,7 +29,11 @@ static AVStream *add_video_stream(AVFormatContext *oc, const ftl::codecs::Packet AVCodecID codec_id; switch (pkt.codec) { + case codec_t::HEVC_LOSSLESS: case codec_t::HEVC : codec_id = AV_CODEC_ID_HEVC; break; + case codec_t::H264_LOSSLESS: + case codec_t::H264 : codec_id = AV_CODEC_ID_H264; break; + default: LOG(FATAL) << "Codec in FTL file must be HEVC or H264"; } //c = st->codec; diff --git a/applications/reconstruct/src/main.cpp b/applications/reconstruct/src/main.cpp index af7f5cac9..f300b292a 100644 --- a/applications/reconstruct/src/main.cpp +++ b/applications/reconstruct/src/main.cpp @@ -116,9 +116,6 @@ static void run(ftl::Configurable *root) { Universe *net = ftl::create<Universe>(root, "net"); ftl::ctrl::Master ctrl(root, net); - // Controls - auto *controls = ftl::create<ftl::Configurable>(root, "controls"); - net->start(); net->waitConnections(); diff --git a/applications/reconstruct/src/reconstruction.cpp b/applications/reconstruct/src/reconstruction.cpp index 11e3ca653..5fab0496b 100644 --- a/applications/reconstruct/src/reconstruction.cpp +++ b/applications/reconstruct/src/reconstruction.cpp @@ -61,9 +61,9 @@ size_t Reconstruction::size() { } -ftl::rgbd::FrameState &Reconstruction::state(int ix) { +ftl::rgbd::FrameState &Reconstruction::state(size_t ix) { UNIQUE_LOCK(exchange_mtx_, lk); - if (ix >= 0 && ix < fs_align_.frames.size()) { + if (ix < fs_align_.frames.size()) { return *fs_align_.frames[ix].origin(); } throw ftl::exception("State index out-of-bounds"); @@ -154,7 +154,7 @@ bool Reconstruction::render(ftl::rgbd::VirtualSource *vs, ftl::rgbd::Frame &out) // transform.setIdentity(); //} - Eigen::Affine3d sm = Eigen::Affine3d(Eigen::Scaling(double(value("scale", 1.0f)))); + //Eigen::Affine3d sm = Eigen::Affine3d(Eigen::Scaling(double(value("scale", 1.0f)))); bool res = false; //renderer_->render(vs, out, sm.matrix() * transform); //fs_render_.resetFull(); return res; diff --git a/applications/reconstruct/src/reconstruction.hpp b/applications/reconstruct/src/reconstruction.hpp index 5c2648b3e..82cecd9ed 100644 --- a/applications/reconstruct/src/reconstruction.hpp +++ b/applications/reconstruct/src/reconstruction.hpp @@ -34,7 +34,7 @@ class Reconstruction : public ftl::Configurable, public ftl::rgbd::Generator { * Get the persistent state object for a frame. An exception is thrown * for a bad index. */ - ftl::rgbd::FrameState &state(int ix) override; + ftl::rgbd::FrameState &state(size_t ix) override; /** Register a callback to receive new frame sets. */ void onFrameSet(const ftl::rgbd::VideoCallback &) override; diff --git a/applications/tools/codec_eval/src/main.cpp b/applications/tools/codec_eval/src/main.cpp index c1730af50..b4ba4355a 100644 --- a/applications/tools/codec_eval/src/main.cpp +++ b/applications/tools/codec_eval/src/main.cpp @@ -79,9 +79,6 @@ static void run(ftl::Configurable *root) { Universe *net = ftl::create<Universe>(root, "net"); ftl::ctrl::Master ctrl(root, net); - // Controls - auto *controls = ftl::create<ftl::Configurable>(root, "controls"); - net->start(); net->waitConnections(); diff --git a/components/audio/include/ftl/audio/buffer.hpp b/components/audio/include/ftl/audio/buffer.hpp index b96efc339..8fb6d5806 100644 --- a/components/audio/include/ftl/audio/buffer.hpp +++ b/components/audio/include/ftl/audio/buffer.hpp @@ -79,8 +79,8 @@ class FixedBuffer { template <typename T, int CHAN> static T fracIndex(const std::vector<T> &in, float ix, int c) { - const int i1 = static_cast<int>(ix); - const int i2 = static_cast<int>(ix+1.0f); + const auto i1 = static_cast<unsigned int>(ix); + const auto i2 = static_cast<unsigned int>(ix+1.0f); const float alpha = ix - static_cast<float>(i1); return (i2*CHAN+CHAN >= in.size()) ? in[i1*CHAN+c] : in[i1*CHAN+c]*(1.0f-alpha) + in[i2*CHAN+c]*alpha; } diff --git a/components/audio/include/ftl/audio/source.hpp b/components/audio/include/ftl/audio/source.hpp index 87aafadd6..c7ba25608 100644 --- a/components/audio/include/ftl/audio/source.hpp +++ b/components/audio/include/ftl/audio/source.hpp @@ -29,7 +29,7 @@ class Source : public ftl::Configurable, public ftl::audio::Generator { * Get the persistent state object for a frame. An exception is thrown * for a bad index. */ - ftl::audio::FrameState &state(int ix) override; + ftl::audio::FrameState &state(size_t ix) override; /** Register a callback to receive new frame sets. */ void onFrameSet(const ftl::audio::FrameSet::Callback &) override; diff --git a/components/audio/src/source.cpp b/components/audio/src/source.cpp index 97aeac77d..f43caeba2 100644 --- a/components/audio/src/source.cpp +++ b/components/audio/src/source.cpp @@ -175,8 +175,8 @@ size_t Source::size() { return 1; } -ftl::audio::FrameState &Source::state(int ix) { - if (ix < 0 || ix > 1) throw ftl::exception("State index out-of-bounds"); +ftl::audio::FrameState &Source::state(size_t ix) { + if (ix >= 1) throw ftl::exception("State index out-of-bounds"); return state_; } diff --git a/components/codecs/src/decoder.cpp b/components/codecs/src/decoder.cpp index 3396233f1..af02fd7f1 100644 --- a/components/codecs/src/decoder.cpp +++ b/components/codecs/src/decoder.cpp @@ -22,9 +22,8 @@ Decoder *ftl::codecs::allocateDecoder(const ftl::codecs::Packet &pkt) { case codec_t::H264_LOSSLESS: case codec_t::H264 : case codec_t::HEVC : return new ftl::codecs::NvPipeDecoder; + default : return nullptr; } - - return nullptr; } /** diff --git a/components/codecs/src/reader.cpp b/components/codecs/src/reader.cpp index ba68f26c9..00df80e3c 100644 --- a/components/codecs/src/reader.cpp +++ b/components/codecs/src/reader.cpp @@ -71,7 +71,7 @@ bool Reader::read(int64_t ts, const std::function<void(const ftl::codecs::Stream bool partial = false; int64_t extended_ts = ts + 200; // Buffer 200ms ahead - while (playing_ && stream_->good() || buffer_.nonparsed_size() > 0) { + while ((playing_ && stream_->good()) || buffer_.nonparsed_size() > 0) { if (buffer_.nonparsed_size() == 0 || (partial && buffer_.nonparsed_size() < 10000000)) { buffer_.reserve_buffer(10000000); stream_->read(buffer_.buffer(), buffer_.buffer_capacity()); @@ -143,7 +143,7 @@ bool Reader::read(int64_t ts) { } void Reader::onPacket(int streamID, const std::function<void(const ftl::codecs::StreamPacket &, ftl::codecs::Packet &)> &f) { - if (streamID >= handlers_.size()) handlers_.resize(streamID+1); + if (static_cast<unsigned int>(streamID) >= handlers_.size()) handlers_.resize(streamID+1); handlers_[streamID] = f; } diff --git a/components/codecs/test/nvpipe_codec_unit.cpp b/components/codecs/test/nvpipe_codec_unit.cpp index 2b32e2843..9bb72b1a7 100644 --- a/components/codecs/test/nvpipe_codec_unit.cpp +++ b/components/codecs/test/nvpipe_codec_unit.cpp @@ -289,8 +289,8 @@ TEST_CASE( "NvPipeDecoder::decode() - A colour test image" ) { REQUIRE( r ); REQUIRE( decoder.decode(pkt, out) ); - REQUIRE( out.cols == 1920 ); - REQUIRE( out.type() == CV_8UC4 ); + REQUIRE( (out.cols == 1920) ); + REQUIRE( (out.type() == CV_8UC4) ); //} REQUIRE( (cv::cuda::sum(out) != cv::Scalar(0,0,0)) ); @@ -317,9 +317,9 @@ TEST_CASE( "NvPipeDecoder::decode() - A tiled colour image" ) { REQUIRE( r ); REQUIRE( decoder.decode(pkt, out) ); - REQUIRE( out.cols == 2560 ); - REQUIRE( out.type() == CV_8UC4 ); - REQUIRE( pkt.definition == definition_t::HD720 ); + REQUIRE( (out.cols == 2560) ); + REQUIRE( (out.type() == CV_8UC4) ); + REQUIRE( (pkt.definition == definition_t::HD720) ); //} REQUIRE( (cv::cuda::sum(out) != cv::Scalar(0,0,0)) ); @@ -346,9 +346,9 @@ TEST_CASE( "NvPipeDecoder::decode() - A lossless depth image" ) { REQUIRE( r ); REQUIRE( decoder.decode(pkt, out) ); - REQUIRE( out.cols == 1280 ); - REQUIRE( out.type() == CV_16U ); - REQUIRE( pkt.definition == definition_t::HD720 ); + REQUIRE( (out.cols == 1280) ); + REQUIRE( (out.type() == CV_16U) ); + REQUIRE( (pkt.definition == definition_t::HD720) ); //} REQUIRE( (cv::cuda::sum(out) != cv::Scalar(0)) ); @@ -375,9 +375,9 @@ TEST_CASE( "NvPipeDecoder::decode() - A lossy depth image" ) { REQUIRE( r ); REQUIRE( decoder.decode(pkt, out) ); - REQUIRE( out.cols == 1280 ); - REQUIRE( out.type() == CV_16UC4 ); - REQUIRE( pkt.definition == definition_t::HD720 ); + REQUIRE( (out.cols == 1280) ); + REQUIRE( (out.type() == CV_16UC4) ); + REQUIRE( (pkt.definition == definition_t::HD720) ); //} REQUIRE( (cv::cuda::sum(out) != cv::Scalar(0)) ); diff --git a/components/net/cpp/src/peer.cpp b/components/net/cpp/src/peer.cpp index 8f280bad4..24aac7bb3 100644 --- a/components/net/cpp/src/peer.cpp +++ b/components/net/cpp/src/peer.cpp @@ -555,7 +555,11 @@ void Peer::_dispatchResponse(uint32_t id, msgpack::object &res) { lk.unlock(); // Call the callback with unpacked return value - (*cb)(res); + try { + (*cb)(res); + } catch(std::exception &e) { + LOG(ERROR) << "Exception in RPC response: " << e.what(); + } } else { LOG(WARNING) << "Missing RPC callback for result - discarding"; } diff --git a/components/net/cpp/test/net_configurable_unit.cpp b/components/net/cpp/test/net_configurable_unit.cpp index 0b69512f1..183a13fab 100644 --- a/components/net/cpp/test/net_configurable_unit.cpp +++ b/components/net/cpp/test/net_configurable_unit.cpp @@ -33,6 +33,8 @@ SCENARIO( "NetConfigurable::set()" ) { NetConfigurable nc(peer, suri, *controller, jsonTest); nc.set("test_value", 5); REQUIRE( nc.get<int>("test_value") == 5 ); + + delete controller; } // invalid peer UUID diff --git a/components/operators/src/depth.cpp b/components/operators/src/depth.cpp index ac84f668a..c8a48df63 100644 --- a/components/operators/src/depth.cpp +++ b/components/operators/src/depth.cpp @@ -153,7 +153,7 @@ bool DepthChannel::apply(ftl::rgbd::FrameSet &in, ftl::rgbd::FrameSet &out, cuda rbuf_.resize(in.frames.size()); - for (int i=0; i<in.frames.size(); ++i) { + for (size_t i=0; i<in.frames.size(); ++i) { auto &f = in.frames[i]; if (!f.hasChannel(Channel::Depth) && f.hasChannel(Channel::Right)) { _createPipeline(); diff --git a/components/operators/src/mvmls.cpp b/components/operators/src/mvmls.cpp index 3a71dcf4c..52bc22a02 100644 --- a/components/operators/src/mvmls.cpp +++ b/components/operators/src/mvmls.cpp @@ -272,9 +272,9 @@ bool MultiViewMLS::apply(ftl::rgbd::FrameSet &in, ftl::rgbd::FrameSet &out, cuda if (d1.dot(d2) <= 0.0) continue; auto pose1 = MatrixConversion::toCUDA(f1.getPose().cast<float>()); - auto pose1_inv = MatrixConversion::toCUDA(f1.getPose().cast<float>().inverse()); + //auto pose1_inv = MatrixConversion::toCUDA(f1.getPose().cast<float>().inverse()); auto pose2 = MatrixConversion::toCUDA(f2.getPose().cast<float>().inverse()); - auto pose2_inv = MatrixConversion::toCUDA(f2.getPose().cast<float>()); + //auto pose2_inv = MatrixConversion::toCUDA(f2.getPose().cast<float>()); auto transform = pose2 * pose1; diff --git a/components/operators/src/operator.cpp b/components/operators/src/operator.cpp index ff1ebc669..8dbbf168c 100644 --- a/components/operators/src/operator.cpp +++ b/components/operators/src/operator.cpp @@ -62,7 +62,7 @@ bool Graph::apply(FrameSet &in, FrameSet &out, cudaStream_t stream) { i.instances.push_back(i.maker->make()); } - for (int j=0; j<in.frames.size(); ++j) { + for (size_t j=0; j<in.frames.size(); ++j) { auto *instance = i.instances[j&0x1]; if (instance->enabled()) { diff --git a/components/operators/src/smoothing.cpp b/components/operators/src/smoothing.cpp index dd403d4b8..ef9cb58cb 100644 --- a/components/operators/src/smoothing.cpp +++ b/components/operators/src/smoothing.cpp @@ -23,7 +23,7 @@ HFSmoother::~HFSmoother() { bool HFSmoother::apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, cudaStream_t stream) { float var_thresh = config()->value("variance_threshold", 0.0002f); - int levels = max(0, min(config()->value("levels",0), 4)); + //int levels = max(0, min(config()->value("levels",0), 4)); int iters = config()->value("iterations",5); // FIXME: in and out are assumed to be the same diff --git a/components/renderers/cpp/include/ftl/utility/matrix_conversion.hpp b/components/renderers/cpp/include/ftl/utility/matrix_conversion.hpp index 2888e928e..e0b363cce 100644 --- a/components/renderers/cpp/include/ftl/utility/matrix_conversion.hpp +++ b/components/renderers/cpp/include/ftl/utility/matrix_conversion.hpp @@ -98,11 +98,11 @@ namespace MatrixConversion static float4x4 toCUDA(const mat4f& m) { return float4x4(m.ptr()); }*/ - static float4x4 toCUDA(const Eigen::Matrix4f& mat) { + inline float4x4 toCUDA(const Eigen::Matrix4f& mat) { return float4x4(mat.data()).getTranspose(); } - static Eigen::Matrix4f toEigen(const float4x4& m) { + inline Eigen::Matrix4f toEigen(const float4x4& m) { return Eigen::Matrix4f(m.ptr()).transpose(); } diff --git a/components/renderers/cpp/src/tri_render.cpp b/components/renderers/cpp/src/tri_render.cpp index 3f0f2cbd8..c9001bd2d 100644 --- a/components/renderers/cpp/src/tri_render.cpp +++ b/components/renderers/cpp/src/tri_render.cpp @@ -508,7 +508,7 @@ void Triangular::_preprocessColours() { cv::cuda::Stream cvstream = cv::cuda::StreamAccessor::wrapStream(stream_); // Display mask values or otherwise alter colour image - for (int i=0; i<scene_->frames.size(); ++i) { + for (size_t i=0; i<scene_->frames.size(); ++i) { auto &f = scene_->frames[i]; if (colour_sources) { diff --git a/components/rgbd-sources/CMakeLists.txt b/components/rgbd-sources/CMakeLists.txt index 06db227d0..92bab62ac 100644 --- a/components/rgbd-sources/CMakeLists.txt +++ b/components/rgbd-sources/CMakeLists.txt @@ -10,7 +10,7 @@ set(RGBDSRC src/colour.cpp src/group.cpp src/cb_segmentation.cpp - src/abr.cpp + #src/abr.cpp #src/sources/virtual/virtual.cpp #src/sources/ftlfile/file_source.cpp #src/sources/ftlfile/player.cpp diff --git a/components/rgbd-sources/include/ftl/rgbd/frameset.hpp b/components/rgbd-sources/include/ftl/rgbd/frameset.hpp index b85e99be9..6a2efde25 100644 --- a/components/rgbd-sources/include/ftl/rgbd/frameset.hpp +++ b/components/rgbd-sources/include/ftl/rgbd/frameset.hpp @@ -78,7 +78,7 @@ class Generator { * Get the persistent state object for a frame. An exception is thrown * for a bad index. */ - virtual ftl::rgbd::FrameState &state(int ix)=0; + virtual ftl::rgbd::FrameState &state(size_t ix)=0; inline ftl::rgbd::FrameState &operator[](int ix) { return state(ix); } @@ -103,14 +103,14 @@ class Builder : public Generator { size_t size() override; - ftl::rgbd::FrameState &state(int ix) override; + ftl::rgbd::FrameState &state(size_t ix) override; void onFrameSet(const ftl::rgbd::VideoCallback &) override; /** * Add a new frame at a given timestamp. */ - void push(int64_t timestamp, int ix, ftl::rgbd::Frame &f); + void push(int64_t timestamp, size_t ix, ftl::rgbd::Frame &f); void setName(const std::string &name); diff --git a/components/rgbd-sources/include/ftl/rgbd/group.hpp b/components/rgbd-sources/include/ftl/rgbd/group.hpp index a4955d1d8..438d11feb 100644 --- a/components/rgbd-sources/include/ftl/rgbd/group.hpp +++ b/components/rgbd-sources/include/ftl/rgbd/group.hpp @@ -91,7 +91,7 @@ class Group : public ftl::rgbd::Generator { size_t size() override { return builder_.size(); } - ftl::rgbd::FrameState &state(int ix) override { return builder_.state(ix); } + ftl::rgbd::FrameState &state(size_t ix) override { return builder_.state(ix); } void stop() {} diff --git a/components/rgbd-sources/src/cb_segmentation.cpp b/components/rgbd-sources/src/cb_segmentation.cpp index 102524c10..fed4b8806 100644 --- a/components/rgbd-sources/src/cb_segmentation.cpp +++ b/components/rgbd-sources/src/cb_segmentation.cpp @@ -74,9 +74,9 @@ bool CBSegmentation::Codeword::colordiff(CBSegmentation::Pixel &px, float epsilo // bool CBSegmentation::Codeword::brightness(CBSegmentation::Pixel &px, float alpha, float beta) { return true; - float i_low = alpha * i_max; + /*float i_low = alpha * i_max; float i_hi = min(beta * i_max, i_min / alpha); - return (i_low <= px.i) && (px.i <= i_hi); + return (i_low <= px.i) && (px.i <= i_hi);*/ } CBSegmentation::CBSegmentation( @@ -169,7 +169,7 @@ bool CBSegmentation::processPixel(CBSegmentation::Pixel &px, CBSegmentation::Cod // TODO: Should not prefer H codewords over M codewords? if ((size_t)size < (size_ - 1)) { entry = start + size; - size++; + // size++; FIXME: This doesn't do anything (nick) entry->type = H; entry->cw.set(px); } @@ -195,7 +195,7 @@ void CBSegmentation::apply(Mat &in, Mat &out) { } // TODO: thread pool, queue N rows - #pragma omp parallel for + // #pragma omp parallel for - FIXME: Use thread pool. (nick) for (size_t y = 0; y < height_; ++y) { size_t idx = y * width_; uchar *ptr_in = in.ptr<uchar>(y); diff --git a/components/rgbd-sources/src/frameset.cpp b/components/rgbd-sources/src/frameset.cpp index a2d3f57da..c632d0585 100644 --- a/components/rgbd-sources/src/frameset.cpp +++ b/components/rgbd-sources/src/frameset.cpp @@ -49,9 +49,9 @@ void FrameSet::swapTo(ftl::rgbd::FrameSet &fs) { void FrameSet::resetFull() { //count = 0; //stale = false; - for (auto &f : frames) { + //for (auto &f : frames) { //f.resetFull(); - } + //} } // ============================================================================= @@ -81,8 +81,8 @@ Builder::~Builder() { } -void Builder::push(int64_t timestamp, int ix, ftl::rgbd::Frame &frame) { - if (timestamp <= 0 || ix < 0 || ix >= kMaxFramesInSet) return; +void Builder::push(int64_t timestamp, size_t ix, ftl::rgbd::Frame &frame) { + if (timestamp <= 0 || ix >= kMaxFramesInSet) return; UNIQUE_LOCK(mutex_, lk); @@ -185,9 +185,9 @@ void Builder::onFrameSet(const std::function<bool(ftl::rgbd::FrameSet &)> &cb) { }); } -ftl::rgbd::FrameState &Builder::state(int ix) { +ftl::rgbd::FrameState &Builder::state(size_t ix) { UNIQUE_LOCK(mutex_, lk); - if (ix < 0 || ix >= states_.size()) { + if (ix >= states_.size()) { throw ftl::exception("Frame state out-of-bounds"); } if (!states_[ix]) throw ftl::exception("Missing framestate"); @@ -196,7 +196,7 @@ ftl::rgbd::FrameState &Builder::state(int ix) { static void mergeFrameset(ftl::rgbd::FrameSet &f1, ftl::rgbd::FrameSet &f2) { // Prepend all frame encodings in f2 into corresponding frame in f1. - for (int i=0; i<f1.frames.size(); ++i) { + for (size_t i=0; i<f1.frames.size(); ++i) { if (f2.frames.size() <= i) break; f1.frames[i].mergeEncoding(f2.frames[i]); } @@ -239,7 +239,7 @@ ftl::rgbd::FrameSet *Builder::_getFrameset() { for (auto i=framesets_.begin(); i!=framesets_.end(); i++) { auto *f = *i; //LOG(INFO) << "GET: " << f->count << " of " << size_; - if (!f->stale && f->count >= size_) { + if (!f->stale && static_cast<unsigned int>(f->count) >= size_) { //LOG(INFO) << "GET FRAMESET and remove: " << f->timestamp; auto j = framesets_.erase(i); diff --git a/components/rgbd-sources/src/group.cpp b/components/rgbd-sources/src/group.cpp index 409559d58..02f3b6f70 100644 --- a/components/rgbd-sources/src/group.cpp +++ b/components/rgbd-sources/src/group.cpp @@ -78,7 +78,7 @@ void Group::_computeJob(ftl::rgbd::Source *src) { } int Group::streamID(const ftl::rgbd::Source *s) const { - for (int i=0; i<sources_.size(); ++i) { + for (size_t i=0; i<sources_.size(); ++i) { if (sources_[i] == s) return i; } return -1; diff --git a/components/rgbd-sources/src/sources/net/net.cpp b/components/rgbd-sources/src/sources/net/net.cpp index 7b21594cf..3d262aa95 100644 --- a/components/rgbd-sources/src/sources/net/net.cpp +++ b/components/rgbd-sources/src/sources/net/net.cpp @@ -168,8 +168,8 @@ NetSource::NetSource(ftl::rgbd::Source *host) default_quality_ = host->value("quality", 0); }); - abr_.setMaximumBitrate(host->value("max_bitrate", -1)); - abr_.setMinimumBitrate(host->value("min_bitrate", -1)); + //abr_.setMaximumBitrate(host->value("max_bitrate", -1)); + //abr_.setMinimumBitrate(host->value("min_bitrate", -1)); _updateURI(); @@ -390,7 +390,7 @@ void NetSource::_completeFrame(NetFrame &frame, int64_t latency) { frame.tx_latency = latency; // Note: Not used currently - adaptive_ = abr_.selectBitrate(frame); + //adaptive_ = abr_.selectBitrate(frame); frame_.reset(); frame_.setOrigin(&state_); @@ -492,7 +492,7 @@ bool NetSource::compute(int n, int b) { active_ = false; } - abr_.notifyChanged(); + //abr_.notifyChanged(); maxN_ = 1; // Reset to single frame minB_ = 9; // Reset to worst quality diff --git a/components/rgbd-sources/src/sources/net/net.hpp b/components/rgbd-sources/src/sources/net/net.hpp index 299325643..fca089290 100644 --- a/components/rgbd-sources/src/sources/net/net.hpp +++ b/components/rgbd-sources/src/sources/net/net.hpp @@ -60,7 +60,7 @@ class NetSource : public detail::Source { ftl::codecs::Channel prev_chan_; ftl::rgbd::Camera params_right_; - ftl::rgbd::detail::ABRController abr_; + //ftl::rgbd::detail::ABRController abr_; int last_bitrate_; static int64_t last_msg_; diff --git a/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp b/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp index 0a15e0bde..c380a4a21 100644 --- a/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp +++ b/components/rgbd-sources/src/sources/stereovideo/stereovideo.cpp @@ -284,7 +284,6 @@ void StereoVideoSource::swap() { bool StereoVideoSource::compute(int n, int b) { auto &frame = frames_[1]; - const ftl::codecs::Channel chan = host_->getChannel(); if (!frame.hasChannel(Channel::Left) || !frame.hasChannel(Channel::Right)) { return false; } diff --git a/components/streams/include/ftl/streams/receiver.hpp b/components/streams/include/ftl/streams/receiver.hpp index f79f6000e..a4bbfd917 100644 --- a/components/streams/include/ftl/streams/receiver.hpp +++ b/components/streams/include/ftl/streams/receiver.hpp @@ -30,7 +30,7 @@ class Receiver : public ftl::Configurable, public ftl::rgbd::Generator { size_t size() override; - ftl::rgbd::FrameState &state(int ix) override; + ftl::rgbd::FrameState &state(size_t ix) override; /** * Register a callback for received framesets. Sources are automatically diff --git a/components/streams/src/filestream.cpp b/components/streams/src/filestream.cpp index 0d7004dd7..7d7f5d5f4 100644 --- a/components/streams/src/filestream.cpp +++ b/components/streams/src/filestream.cpp @@ -99,7 +99,7 @@ bool File::tick(int64_t ts) { bool partial = false; int64_t extended_ts = timestamp_ + 200; // Buffer 200ms ahead - while (active_ && istream_->good() || buffer_in_.nonparsed_size() > 0) { + while ((active_ && istream_->good()) || buffer_in_.nonparsed_size() > 0u) { if (buffer_in_.nonparsed_size() == 0 || (partial && buffer_in_.nonparsed_size() < 10000000)) { buffer_in_.reserve_buffer(10000000); istream_->read(buffer_in_.buffer(), buffer_in_.buffer_capacity()); diff --git a/components/streams/src/netstream.cpp b/components/streams/src/netstream.cpp index b11fdbb7d..f25983ccd 100644 --- a/components/streams/src/netstream.cpp +++ b/components/streams/src/netstream.cpp @@ -14,7 +14,7 @@ using std::optional; static constexpr int kTallyScale = 10; -Net::Net(nlohmann::json &config, ftl::net::Universe *net) : Stream(config), net_(net), active_(false) { +Net::Net(nlohmann::json &config, ftl::net::Universe *net) : Stream(config), active_(false), net_(net) { // TODO: Install "find_stream" binding if not installed... if (!net_->isBound("find_stream")) { net_->bind("find_stream", [this](const std::string &uri) -> optional<ftl::UUID> { @@ -190,7 +190,7 @@ bool Net::begin() { if (host_ && pkt.data.size() == 0) { // FIXME: Allow unselecting ...? if (spkt.frameSetID() == 255) { - for (int i=0; i<size(); ++i) { + for (size_t i=0; i<size(); ++i) { select(i, selected(i) + spkt.channel); } reqtally_[static_cast<int>(spkt.channel)] = static_cast<int>(pkt.frame_count)*kTallyScale; diff --git a/components/streams/src/receiver.cpp b/components/streams/src/receiver.cpp index 4cb732946..36d321c43 100644 --- a/components/streams/src/receiver.cpp +++ b/components/streams/src/receiver.cpp @@ -65,7 +65,7 @@ Receiver::InternalVideoStates::InternalVideoStates() { } Receiver::InternalVideoStates &Receiver::_getVideoFrame(const StreamPacket &spkt, int ix) { - int fn = spkt.frameNumber()+ix; + uint32_t fn = spkt.frameNumber()+ix; UNIQUE_LOCK(mutex_, lk); while (video_frames_.size() <= fn) { @@ -83,7 +83,7 @@ Receiver::InternalAudioStates::InternalAudioStates() { } Receiver::InternalAudioStates &Receiver::_getAudioFrame(const StreamPacket &spkt, int ix) { - int fn = spkt.frameNumber()+ix; + uint32_t fn = spkt.frameNumber()+ix; UNIQUE_LOCK(mutex_, lk); while (audio_frames_.size() <= fn) { @@ -125,7 +125,7 @@ void Receiver::_processAudio(const StreamPacket &spkt, const Packet &pkt) { size_t size = pkt.data.size()/sizeof(short); audio.data().resize(size); auto *ptr = (short*)pkt.data.data(); - for (int i=0; i<size; i++) audio.data()[i] = ptr[i]; + for (size_t i=0; i<size; i++) audio.data()[i] = ptr[i]; if (audio_cb_) { // Create an audio frameset wrapper. @@ -289,8 +289,6 @@ void Receiver::setStream(ftl::stream::Stream *s) { stream_ = s; s->onPacket([this](const StreamPacket &spkt, const Packet &pkt) { - //const ftl::codecs::Channel chan = second_channel_; - const ftl::codecs::Channel rchan = spkt.channel; const unsigned int channum = (unsigned int)spkt.channel; //LOG(INFO) << "PACKET: " << spkt.timestamp << ", " << (int)spkt.channel << ", " << (int)pkt.codec << ", " << (int)pkt.definition; @@ -321,7 +319,7 @@ size_t Receiver::size() { return builder_.size(); } -ftl::rgbd::FrameState &Receiver::state(int ix) { +ftl::rgbd::FrameState &Receiver::state(size_t ix) { return builder_.state(ix); } diff --git a/components/streams/src/sender.cpp b/components/streams/src/sender.cpp index 0068f5ad3..239597c71 100644 --- a/components/streams/src/sender.cpp +++ b/components/streams/src/sender.cpp @@ -58,7 +58,7 @@ void Sender::post(const ftl::audio::FrameSet &fs) { //if (fs.stale) return; //fs.stale = true; - for (int i=0; i<fs.frames.size(); ++i) { + for (size_t i=0; i<fs.frames.size(); ++i) { if (!fs.frames[i].hasChannel(Channel::Audio)) continue; auto &data = fs.frames[i].get<ftl::audio::Audio>(Channel::Audio); @@ -125,7 +125,7 @@ void Sender::post(const ftl::rgbd::FrameSet &fs) { bool do_inject = !do_inject_.test_and_set(); - for (int i=0; i<fs.frames.size(); ++i) { + for (size_t i=0; i<fs.frames.size(); ++i) { const auto &frame = fs.frames[i]; if (do_inject) { @@ -224,10 +224,10 @@ void Sender::post(const ftl::rgbd::FrameSet &fs) { void Sender::_encodeChannel(const ftl::rgbd::FrameSet &fs, Channel c, bool reset) { bool lossless = value("lossless", false); int max_bitrate = std::max(0, std::min(255, value("max_bitrate", 255))); - int min_bitrate = std::max(0, std::min(255, value("min_bitrate", 0))); + //int min_bitrate = std::max(0, std::min(255, value("min_bitrate", 0))); // TODO: Use this codec_t codec = value("codec", codec_t::Any); - int offset = 0; + uint32_t offset = 0; while (offset < fs.frames.size()) { StreamPacket spkt; spkt.version = 4; @@ -347,7 +347,7 @@ int Sender::_generateTiles(const ftl::rgbd::FrameSet &fs, int offset, Channel c, int width = tx * rwidth; int height = ty * rheight; int tilecount = tx*ty; - int count = 0; + uint32_t count = 0; surface.surface.create(height, width, (lossless && m.type() == CV_32F) ? CV_16U : CV_8UC4); diff --git a/components/streams/src/stream.cpp b/components/streams/src/stream.cpp index 6e8c7770b..2c409d3b4 100644 --- a/components/streams/src/stream.cpp +++ b/components/streams/src/stream.cpp @@ -7,27 +7,27 @@ using ftl::stream::Stream; const ftl::codecs::Channels<0> &Stream::available(int fs) const { SHARED_LOCK(mtx_, lk); - if (fs < 0 || fs >= state_.size()) throw ftl::exception("Frameset index out-of-bounds"); + if (fs < 0 || static_cast<uint32_t>(fs) >= state_.size()) throw ftl::exception("Frameset index out-of-bounds"); return state_[fs].available; } const ftl::codecs::Channels<0> &Stream::selected(int fs) const { SHARED_LOCK(mtx_, lk); - if (fs < 0 || fs >= state_.size()) throw ftl::exception("Frameset index out-of-bounds"); + if (fs < 0 || static_cast<uint32_t>(fs) >= state_.size()) throw ftl::exception("Frameset index out-of-bounds"); return state_[fs].selected; } void Stream::select(int fs, const ftl::codecs::Channels<0> &s, bool make) { UNIQUE_LOCK(mtx_, lk); - if (fs < 0 || (!make && fs >= state_.size())) throw ftl::exception("Frameset index out-of-bounds"); - if (fs >= state_.size()) state_.resize(fs+1); + if (fs < 0 || (!make && static_cast<uint32_t>(fs) >= state_.size())) throw ftl::exception("Frameset index out-of-bounds"); + if (static_cast<uint32_t>(fs) >= state_.size()) state_.resize(fs+1); state_[fs].selected = s; } ftl::codecs::Channels<0> &Stream::available(int fs) { UNIQUE_LOCK(mtx_, lk); if (fs < 0) throw ftl::exception("Frameset index out-of-bounds"); - if (fs >= state_.size()) state_.resize(fs+1); + if (static_cast<uint32_t>(fs) >= state_.size()) state_.resize(fs+1); return state_[fs].available; } @@ -76,7 +76,7 @@ bool Muxer::onPacket(const std::function<void(const ftl::codecs::StreamPacket &, } int Muxer::originStream(int fsid, int fid) { - if (fid < revmap_.size()) { + if (static_cast<uint32_t>(fid) < revmap_.size()) { return std::get<0>(revmap_[fid]); } return -1; @@ -135,11 +135,11 @@ void Muxer::reset() { int Muxer::_lookup(int sid, int ssid) { SHARED_LOCK(mutex_, lk); auto &se = streams_[sid]; - if (ssid >= se.maps.size()) { + if (static_cast<uint32_t>(ssid) >= se.maps.size()) { lk.unlock(); { UNIQUE_LOCK(mutex_, lk2); - if (ssid >= se.maps.size()) { + if (static_cast<uint32_t>(ssid) >= se.maps.size()) { int nid = nid_++; se.maps.push_back(nid); revmap_.push_back({sid,ssid}); diff --git a/components/streams/test/receiver_unit.cpp b/components/streams/test/receiver_unit.cpp index 97e266d68..f3bfe9761 100644 --- a/components/streams/test/receiver_unit.cpp +++ b/components/streams/test/receiver_unit.cpp @@ -27,7 +27,7 @@ class TestStream : public ftl::stream::Stream { available(spkt.streamID) += spkt.channel; if (pkt.data.size() == 0) { if (spkt.frameSetID() == 255) { - for (int i=0; i<size(); ++i) { + for (size_t i=0; i<size(); ++i) { select(i, selected(i) + spkt.channel); } } else { diff --git a/components/streams/test/sender_unit.cpp b/components/streams/test/sender_unit.cpp index e6d945b51..9c7edd6a5 100644 --- a/components/streams/test/sender_unit.cpp +++ b/components/streams/test/sender_unit.cpp @@ -31,7 +31,7 @@ class TestStream : public ftl::stream::Stream { available(spkt.streamID) += spkt.channel; if (pkt.data.size() == 0) { if (spkt.frameSetID() == 255) { - for (int i=0; i<size(); ++i) { + for (size_t i=0; i<size(); ++i) { select(i, selected(i) + spkt.channel); } } else { diff --git a/components/structures/include/ftl/data/frame.hpp b/components/structures/include/ftl/data/frame.hpp index 5d717f6c4..b0fa41922 100644 --- a/components/structures/include/ftl/data/frame.hpp +++ b/components/structures/include/ftl/data/frame.hpp @@ -331,6 +331,7 @@ void ftl::data::Frame<BASE,N,STATE,DATA>::copyTo(ftl::codecs::Channels<BASE> cha } template <int BASE, int N, typename STATE, typename DATA> +// cppcheck-suppress * template <typename T> T& ftl::data::Frame<BASE,N,STATE,DATA>::get(ftl::codecs::Channel channel) { if (channel == ftl::codecs::Channel::None) { @@ -346,6 +347,7 @@ T& ftl::data::Frame<BASE,N,STATE,DATA>::get(ftl::codecs::Channel channel) { } template <int BASE, int N, typename STATE, typename DATA> +// cppcheck-suppress * template <typename T> const T& ftl::data::Frame<BASE,N,STATE,DATA>::get(ftl::codecs::Channel channel) const { if (channel == ftl::codecs::Channel::None) { @@ -370,6 +372,7 @@ const T& ftl::data::Frame<BASE,N,STATE,DATA>::get(ftl::codecs::Channel channel) // Default data channel implementation template <int BASE, int N, typename STATE, typename DATA> +// cppcheck-suppress * template <typename T> void ftl::data::Frame<BASE,N,STATE,DATA>::get(ftl::codecs::Channel channel, T ¶ms) const { if (static_cast<int>(channel) < static_cast<int>(ftl::codecs::Channel::Data)) throw ftl::exception("Cannot use generic type with non data channel"); @@ -383,6 +386,7 @@ void ftl::data::Frame<BASE,N,STATE,DATA>::get(ftl::codecs::Channel channel, T &p } template <int BASE, int N, typename STATE, typename DATA> +// cppcheck-suppress * template <typename T> T &ftl::data::Frame<BASE,N,STATE,DATA>::create(ftl::codecs::Channel c) { if (c == ftl::codecs::Channel::None) { @@ -395,6 +399,7 @@ T &ftl::data::Frame<BASE,N,STATE,DATA>::create(ftl::codecs::Channel c) { } template <int BASE, int N, typename STATE, typename DATA> +// cppcheck-suppress * template <typename T> void ftl::data::Frame<BASE,N,STATE,DATA>::create(ftl::codecs::Channel channel, const T &value) { if (static_cast<int>(channel) < static_cast<int>(ftl::codecs::Channel::Data)) throw ftl::exception("Cannot use generic type with non data channel"); diff --git a/components/structures/include/ftl/data/frameset.hpp b/components/structures/include/ftl/data/frameset.hpp index e33ee2e66..a233b8f9b 100644 --- a/components/structures/include/ftl/data/frameset.hpp +++ b/components/structures/include/ftl/data/frameset.hpp @@ -82,7 +82,7 @@ class Generator { * Get the persistent state object for a frame. An exception is thrown * for a bad index. */ - virtual typename FRAMESET::Frame::State &state(int ix)=0; + virtual typename FRAMESET::Frame::State &state(size_t ix)=0; inline typename FRAMESET::Frame::State &operator[](int ix) { return state(ix); } -- GitLab