diff --git a/tools/ld-disc-stacker/stackingpool.cpp b/tools/ld-disc-stacker/stackingpool.cpp index 4440530a5..ad4256d31 100644 --- a/tools/ld-disc-stacker/stackingpool.cpp +++ b/tools/ld-disc-stacker/stackingpool.cpp @@ -23,6 +23,7 @@ ************************************************************************/ #include "stackingpool.h" +#include "vbidecoder.h" StackingPool::StackingPool(QString _outputFilename, QString _outputJsonFilename, qint32 _maxThreads, QVector &_ldDecodeMetaData, QVector &_sourceVideos, diff --git a/tools/ld-dropout-correct/correctorpool.cpp b/tools/ld-dropout-correct/correctorpool.cpp index ee98b5e15..81317eef5 100644 --- a/tools/ld-dropout-correct/correctorpool.cpp +++ b/tools/ld-dropout-correct/correctorpool.cpp @@ -24,6 +24,7 @@ ************************************************************************/ #include "correctorpool.h" +#include "vbidecoder.h" CorrectorPool::CorrectorPool(QString _outputFilename, QString _outputJsonFilename, qint32 _maxThreads, QVector &_ldDecodeMetaData, QVector &_sourceVideos, diff --git a/tools/library/tbc/jsonio.cpp b/tools/library/tbc/jsonio.cpp index 451c69473..45f6c30a9 100644 --- a/tools/library/tbc/jsonio.cpp +++ b/tools/library/tbc/jsonio.cpp @@ -24,8 +24,12 @@ #include "jsonio.h" -#include #include +#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) +#include +#else +#include +#endif // Recognise JSON space characters static bool isAsciiSpace(char c) @@ -46,10 +50,12 @@ JsonReader::JsonReader(std::istream &_input) void JsonReader::read(int &value) { - // Round to the nearest integer - double d; - readNumber(d); - value = static_cast(std::lround(d)); + readSignedInteger(value); +} + +void JsonReader::read(qint64 &value) +{ + readSignedInteger(value); } void JsonReader::read(double &value) @@ -331,8 +337,13 @@ void JsonReader::readNumber(double &value) } } - // XXX In C++17 we could use std::from_chars instead, which is slightly more efficient - value = std::stod(buf); +#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) + // Use the faster C++17 method if available. + std::from_chars(buf.data(), buf.data() + buf.size(), value); +#else + std::istringstream(buf) >> value; +#endif + // We've read one character beyond the end of the number (there's no way to // tell where the end is otherwise), so we must unget the last char @@ -351,6 +362,11 @@ void JsonWriter::write(int value) output << value; } +void JsonWriter::write(qint64 value) +{ + output << value; +} + void JsonWriter::write(double value) { output << value; diff --git a/tools/library/tbc/jsonio.h b/tools/library/tbc/jsonio.h index 24b1d529d..87e30c991 100644 --- a/tools/library/tbc/jsonio.h +++ b/tools/library/tbc/jsonio.h @@ -32,6 +32,7 @@ #include #include #include +#include class JsonReader { @@ -51,6 +52,7 @@ class JsonReader } // Numbers + void read(qint64 &value); void read(int &value); void read(double &value); @@ -81,6 +83,12 @@ class JsonReader void readString(std::string &value); void readNumber(double &value); + template void readSignedInteger(T& value) { + // Round to the nearest integer + double d; + readNumber(d); + value = static_cast(std::llround(d)); + } // The input stream std::istream &input; @@ -101,6 +109,7 @@ class JsonWriter // Numbers void write(int value); + void write(qint64 value); void write(double value); // Booleans diff --git a/tools/library/tbc/lddecodemetadata.h b/tools/library/tbc/lddecodemetadata.h index 7a3102b49..c6930fe48 100644 --- a/tools/library/tbc/lddecodemetadata.h +++ b/tools/library/tbc/lddecodemetadata.h @@ -33,7 +33,6 @@ #include #include -#include "vbidecoder.h" #include "dropouts.h" class JsonReader; @@ -202,8 +201,8 @@ class LdDecodeMetaData DropOuts dropOuts; bool pad = false; - qint32 diskLoc = -1; - qint32 fileLoc = -1; + double diskLoc = -1; + qint64 fileLoc = -1; qint32 decodeFaults = -1; qint32 efmTValues = -1;