diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2024-11-02 22:21:52 +0100 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2024-11-02 22:21:52 +0100 |
commit | bf225b16dd73d19281970cfc6be76311f0fbf3a6 (patch) | |
tree | 6b8ba99623405dbdd7b37d4062272cfd1e7ccb21 | |
parent | 57ba306db046601b96b5a1943e63574a37c5e96c (diff) | |
parent | d459470e2d8c1cdfc633584b277505ef03565ab1 (diff) | |
download | atracdenc-bf225b16dd73d19281970cfc6be76311f0fbf3a6.tar.gz |
Merge branch 'master' into new_psy
-rw-r--r-- | src/aea.cpp | 18 | ||||
-rw-r--r-- | src/aea.h | 2 | ||||
-rw-r--r-- | src/at3.cpp | 6 | ||||
-rw-r--r-- | src/at3.h | 2 | ||||
-rw-r--r-- | src/atrac/atrac3_bitstream.cpp | 4 | ||||
-rw-r--r-- | src/compressed_io.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 2 | ||||
-rw-r--r-- | src/oma.cpp | 4 | ||||
-rw-r--r-- | src/oma.h | 4 | ||||
-rw-r--r-- | src/pcmengin.h | 12 | ||||
-rw-r--r-- | src/rm.cpp | 10 | ||||
-rw-r--r-- | src/rm.h | 2 | ||||
-rw-r--r-- | src/wav.cpp | 10 | ||||
-rw-r--r-- | src/wav.h | 6 |
14 files changed, 42 insertions, 42 deletions
diff --git a/src/aea.cpp b/src/aea.cpp index 9394677..72d70aa 100644 --- a/src/aea.cpp +++ b/src/aea.cpp @@ -39,12 +39,12 @@ public: TAeaCommon(const TMeta& meta) : Meta(meta) {} - uint8_t GetChannelNum() const; + size_t GetChannelNum() const; string GetName() const; virtual ~TAeaCommon(); }; -uint8_t TAeaCommon::GetChannelNum() const { +size_t TAeaCommon::GetChannelNum() const { return Meta.AeaHeader[264]; } @@ -63,7 +63,7 @@ public: unique_ptr<TFrame> ReadFrame() override; uint64_t GetLengthInSamples() const override; - uint8_t GetChannelNum() const override { + size_t GetChannelNum() const override { return TAeaCommon::GetChannelNum(); } @@ -117,14 +117,14 @@ unique_ptr<ICompressedIO::TFrame> TAeaInput::ReadFrame() { class TAeaOutput : public ICompressedOutput, public TAeaCommon { static TAeaCommon::TMeta CreateMeta(const string& filename, const string& title, - uint8_t numChannel, uint32_t numFrames); + size_t numChannel, uint32_t numFrames); bool FirstWrite = true; public: - TAeaOutput(const string& filename, const string& title, uint8_t numChannel, uint32_t numFrames); + TAeaOutput(const string& filename, const string& title, size_t numChannel, uint32_t numFrames); void WriteFrame(vector<char> data) override; - uint8_t GetChannelNum() const override { + size_t GetChannelNum() const override { return TAeaCommon::GetChannelNum(); } string GetName() const override { @@ -132,12 +132,12 @@ public: } }; -TAeaOutput::TAeaOutput(const string& filename, const string& title, uint8_t numChannels, uint32_t numFrames) +TAeaOutput::TAeaOutput(const string& filename, const string& title, size_t numChannels, uint32_t numFrames) : TAeaCommon(CreateMeta(filename, title, numChannels, numFrames)) {} TAeaCommon::TMeta TAeaOutput::CreateMeta(const string& filename, const string& title, - uint8_t channelsNum, uint32_t numFrames) + size_t channelsNum, uint32_t numFrames) { FILE* fp = fopen(filename.c_str(), "wb"); if (!fp) @@ -191,7 +191,7 @@ TCompressedInputPtr CreateAeaInput(const std::string& filename) { } TCompressedOutputPtr CreateAeaOutput(const string& filename, const string& title, - uint8_t numChannels, uint32_t numFrames) + size_t numChannels, uint32_t numFrames) { return unique_ptr<TAeaOutput>(new TAeaOutput(filename, title, numChannels, numFrames)); } @@ -41,4 +41,4 @@ class TAeaFormatError { TCompressedInputPtr CreateAeaInput(const std::string& filename); TCompressedOutputPtr CreateAeaOutput(const std::string& filename, const std::string& title, - uint8_t numChannel, uint32_t numFrames); + size_t numChannel, uint32_t numFrames); diff --git a/src/at3.cpp b/src/at3.cpp index f4afc4f..35d6121 100644 --- a/src/at3.cpp +++ b/src/at3.cpp @@ -80,7 +80,7 @@ At3WaveHeader { class TAt3 : public ICompressedOutput { public: - TAt3(const std::string &filename, uint8_t numChannels, + TAt3(const std::string &filename, size_t numChannels, uint32_t numFrames, uint32_t frameSize, bool jointStereo) : fp(fopen(filename.c_str(), "wb")) { @@ -146,7 +146,7 @@ public: return {}; } - uint8_t GetChannelNum() const override { + size_t GetChannelNum() const override { return 2; } @@ -157,7 +157,7 @@ private: } //namespace TCompressedOutputPtr -CreateAt3Output(const std::string& filename, uint8_t numChannel, +CreateAt3Output(const std::string& filename, size_t numChannel, uint32_t numFrames, uint32_t framesize, bool jointStereo) { return std::unique_ptr<TAt3>(new TAt3(filename, numChannel, numFrames, framesize, jointStereo)); @@ -21,5 +21,5 @@ #include "compressed_io.h" TCompressedOutputPtr -CreateAt3Output(const std::string& filename, uint8_t numChannel, +CreateAt3Output(const std::string& filename, size_t numChannel, uint32_t numFrames, uint32_t framesize, bool jointStereo); diff --git a/src/atrac/atrac3_bitstream.cpp b/src/atrac/atrac3_bitstream.cpp index 78ecaac..3b8337d 100644 --- a/src/atrac/atrac3_bitstream.cpp +++ b/src/atrac/atrac3_bitstream.cpp @@ -345,7 +345,7 @@ uint16_t TAtrac3BitStreamWriter::EncodeTonalComponents(const TSingleChannelEleme uint8_t tcgnCheck = 0; //for each group of equal quantiser and len - for (uint8_t i = 0; i < 64; ++i) { + for (size_t i = 0; i < 64; ++i) { const TTonalComponentsSubGroup& curGroup = groups[i]; if (curGroup.SubGroupPtr.size() == 0) { ASSERT(curGroup.SubGroupMap.size() == 0); @@ -398,7 +398,7 @@ uint16_t TAtrac3BitStreamWriter::EncodeTonalComponents(const TSingleChannelEleme bitStream->Write(i >> 3, 3); uint8_t lastPos = subGroupStartPos; uint8_t checkPos = 0; - for (uint16_t j = 0; j < 16; ++j) { + for (size_t j = 0; j < 16; ++j) { if (!(bandFlags.i[j >> 2])) { continue; } diff --git a/src/compressed_io.h b/src/compressed_io.h index 511860e..cc6cbf1 100644 --- a/src/compressed_io.h +++ b/src/compressed_io.h @@ -42,7 +42,7 @@ public: char* Get() { return Data; } }; virtual std::string GetName() const = 0; - virtual uint8_t GetChannelNum() const = 0; + virtual size_t GetChannelNum() const = 0; virtual ~ICompressedIO() {} }; diff --git a/src/main.cpp b/src/main.cpp index 2e64aed..4b40024 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -136,7 +136,7 @@ static void PrepareAtrac1Encoder(const string& inFile, CheckInputFormat(wavPtr); wavIO->reset(wavPtr); } - const uint8_t numChannels = (*wavIO)->GetChannelNum(); + const size_t numChannels = (*wavIO)->GetChannelNum(); *totalSamples = (*wavIO)->GetTotalSamples(); //TODO: recheck it const uint64_t numFrames = numChannels * (*totalSamples) / TAtrac1Data::NumSamples; diff --git a/src/oma.cpp b/src/oma.cpp index 78be514..bef90dd 100644 --- a/src/oma.cpp +++ b/src/oma.cpp @@ -24,7 +24,7 @@ using std::string; using std::vector; using std::unique_ptr; -TOma::TOma(const string& filename, const string&, uint8_t /*numChannel*/, +TOma::TOma(const string& filename, const string&, size_t /*numChannel*/, uint32_t /*numFrames*/, int cid, uint32_t framesize, bool jointStereo) { oma_info_t info; info.codec = cid; @@ -52,6 +52,6 @@ string TOma::GetName() const { return {}; } -uint8_t TOma::GetChannelNum() const { +size_t TOma::GetChannelNum() const { return 2; //for ATRAC3 } @@ -25,10 +25,10 @@ class TOma : public ICompressedOutput { OMAFILE* File; public: - TOma(const std::string& filename, const std::string& title, uint8_t numChannel, + TOma(const std::string& filename, const std::string& title, size_t numChannel, uint32_t numFrames, int cid, uint32_t framesize, bool jointStereo); ~TOma(); void WriteFrame(std::vector<char> data) override; std::string GetName() const override; - uint8_t GetChannelNum() const override; + size_t GetChannelNum() const override; }; diff --git a/src/pcmengin.h b/src/pcmengin.h index dcf7d44..69e2899 100644 --- a/src/pcmengin.h +++ b/src/pcmengin.h @@ -50,10 +50,10 @@ class TEndOfRead : public std::exception { template <class T> class TPCMBuffer { std::vector<T> Buf_; - uint16_t NumChannels; + size_t NumChannels; public: - TPCMBuffer(uint16_t bufSize, uint8_t numChannels) + TPCMBuffer(uint16_t bufSize, size_t numChannels) : NumChannels(numChannels) { Buf_.resize((size_t)bufSize * numChannels); @@ -121,21 +121,21 @@ private: TReaderPtr Reader; uint64_t Processed = 0; public: - TPCMEngine(uint16_t bufSize, uint8_t numChannels) + TPCMEngine(uint16_t bufSize, size_t numChannels) : Buffer(bufSize, numChannels) { } - TPCMEngine(uint16_t bufSize, uint8_t numChannels, TWriterPtr&& writer) + TPCMEngine(uint16_t bufSize, size_t numChannels, TWriterPtr&& writer) : Buffer(bufSize, numChannels) , Writer(std::move(writer)) { } - TPCMEngine(uint16_t bufSize, uint8_t numChannels, TReaderPtr&& reader) + TPCMEngine(uint16_t bufSize, size_t numChannels, TReaderPtr&& reader) : Buffer(bufSize, numChannels) , Reader(std::move(reader)) { } - TPCMEngine(uint16_t bufSize, uint8_t numChannels, TWriterPtr&& writer, TReaderPtr&& reader) + TPCMEngine(uint16_t bufSize, size_t numChannels, TWriterPtr&& writer, TReaderPtr&& reader) : Buffer(bufSize, numChannels) , Writer(std::move(writer)) , Reader(std::move(reader)) { @@ -62,7 +62,7 @@ constexpr char RA_DESC[] = "Audio Stream"; static_assert(sizeof(char) == 1, "unexpected char size"); constexpr size_t MDPR_HEADER_SZ = 42 + sizeof(RA_MIME) + sizeof(RA_DESC) + CODEC_DATA_SZ; -void FillCodecData(char* buf, uint32_t frameSize, uint8_t numChannels, bool jointStereo, uint32_t bitrate) { +void FillCodecData(char* buf, uint32_t frameSize, size_t numChannels, bool jointStereo, uint32_t bitrate) { *reinterpret_cast<uint32_t*>(buf + 0) = swapbyte32_on_le(CODEC_DATA_SZ - 4); // -4 - without size of `size` field buf[4] = '.'; buf[5] = 'r'; @@ -147,7 +147,7 @@ void scramble_data(const char* input, char* out, size_t bytes) { class TRm : public ICompressedOutput { public: - TRm(const std::string& filename, const std::string& /*title*/, uint8_t numChannels, + TRm(const std::string& filename, const std::string& /*title*/, size_t numChannels, uint32_t numFrames, uint32_t frameSize, bool jointStereo) : File_(OpenFile(filename)) , FrameDuration_((1000.0 * 1024.0 / 44100.0)) // ms @@ -194,7 +194,7 @@ public: return {}; } - uint8_t GetChannelNum() const override { + size_t GetChannelNum() const override { return 0; } @@ -251,7 +251,7 @@ private: throw std::runtime_error("Can't write PROP header");//, errno); } - void WriteMDPR(uint32_t frameSize, uint32_t numFrames, uint8_t numChannels, bool jointStereo) { + void WriteMDPR(uint32_t frameSize, uint32_t numFrames, size_t numChannels, bool jointStereo) { char buf[MDPR_HEADER_SZ] = { 'M', 'D', 'P', 'R'}; *reinterpret_cast<uint32_t*>(buf + 4) = swapbyte32_on_le(MDPR_HEADER_SZ); @@ -276,7 +276,7 @@ private: } }; -TCompressedOutputPtr CreateRmOutput(const std::string& filename, const std::string& title, uint8_t numChannel, +TCompressedOutputPtr CreateRmOutput(const std::string& filename, const std::string& title, size_t numChannel, uint32_t numFrames, uint32_t framesize, bool jointStereo) { return std::unique_ptr<TRm>(new TRm(filename, title, numChannel, numFrames, framesize, jointStereo)); } @@ -20,5 +20,5 @@ #include "compressed_io.h" -TCompressedOutputPtr CreateRmOutput(const std::string& filename, const std::string& title, uint8_t numChannel, +TCompressedOutputPtr CreateRmOutput(const std::string& filename, const std::string& title, size_t numChannel, uint32_t numFrames, uint32_t framesize, bool jointStereo); diff --git a/src/wav.cpp b/src/wav.cpp index 8750377..c182dbc 100644 --- a/src/wav.cpp +++ b/src/wav.cpp @@ -36,7 +36,7 @@ TWav::TWav(const std::string& path) : Impl(CreatePCMIOReadImpl(path)) { } -TWav::TWav(const std::string& path, uint8_t channels, uint16_t sampleRate) +TWav::TWav(const std::string& path, size_t channels, size_t sampleRate) : Impl(CreatePCMIOWriteImpl(path, channels, sampleRate)) { } @@ -47,12 +47,12 @@ uint64_t TWav::GetTotalSamples() const { return Impl->GetTotalSamples(); } -uint8_t TWav::GetChannelNum() const { - return (uint8_t)Impl->GetChannelsNum(); +size_t TWav::GetChannelNum() const { + return Impl->GetChannelsNum(); } -uint16_t TWav::GetSampleRate() const { - return (uint16_t)Impl->GetSampleRate(); +size_t TWav::GetSampleRate() const { + return Impl->GetSampleRate(); } //bool TWav::IsFormatSupported() const { @@ -76,10 +76,10 @@ public: E_WRITE }; TWav(const std::string& filename); // reading - TWav(const std::string& filename, uint8_t channels, uint16_t sampleRate); //writing + TWav(const std::string& filename, size_t channels, size_t sampleRate); //writing ~TWav(); - uint8_t GetChannelNum() const; - uint16_t GetSampleRate() const; + size_t GetChannelNum() const; + size_t GetSampleRate() const; uint64_t GetTotalSamples() const; template<class T> |