test in-memory decoding of ogg

magic-numbers
dimitri 8 years ago
parent 6640c054cf
commit c8e8eda859

@ -89,6 +89,7 @@
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -121,6 +122,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup>

@ -42,7 +42,7 @@ int main(int argc, const char **argv) try
//loader.Load(fileData.get(), "test_data/1ch/44100/8/test.wav");
//loader.Load(fileData.get(), "test_data/1ch/44100/16/test.wav");
//loader.Load(fileData.get(), "test_data/1ch/44100/24/test.wav");
loader.Load(fileData.get(), "test_data/1ch/44100/32/test.wav");
//loader.Load(fileData.get(), "test_data/1ch/44100/32/test.wav");
//loader.Load(fileData.get(), "test_data/1ch/44100/64/test.wav");
// 2-channel wave
@ -85,6 +85,10 @@ int main(int argc, const char **argv) try
// 1 + 2 channel musepack
//loader.Load(fileData.get(), "test_data/ad_hoc/44_16_stereo.mpc");
//loader.Load(fileData.get(), "test_data/ad_hoc/44_16_mono.mpc");
// In-memory ogg
auto memory = ReadFile("test_data/ad_hoc/BlockWoosh_Stereo.ogg");
loader.Load(fileData.get(), "ogg", memory.buffer);
}
/*

@ -63,7 +63,7 @@ typedef std::pair<std::string, std::shared_ptr<nqr::BaseDecoder>> DecoderPair;
class NyquistIO
{
std::string ParsePathForExtension(const std::string & path) const;
std::shared_ptr<nqr::BaseDecoder> GetDecoderForExtension(const std::string ext);
std::shared_ptr<nqr::BaseDecoder> GetDecoderForExtension(const std::string & ext);
void BuildDecoderTable();
void AddDecoderToTable(std::shared_ptr<nqr::BaseDecoder> decoder);
std::map<std::string, std::shared_ptr<BaseDecoder>> decoderTable;
@ -72,8 +72,8 @@ public:
NyquistIO();
~NyquistIO();
void Load(AudioData * data, const std::string & path);
void Load(AudioData *data, std::string extension, const std::vector<uint8_t> & buffer);
bool IsFileSupported(const std::string path) const;
void Load(AudioData * data, const std::string & extension, const std::vector<uint8_t> & buffer);
bool IsFileSupported(const std::string & path) const;
};
} // end namespace nqr

@ -284,7 +284,7 @@ struct NyquistFileBuffer
size_t size;
};
NyquistFileBuffer ReadFile(std::string pathToFile);
NyquistFileBuffer ReadFile(const std::string & pathToFile);
int GetFormatBitsPerSample(PCMFormat f);
PCMFormat MakeFormatForBits(int bits, bool floatingPt, bool isSigned);

@ -69,7 +69,7 @@ void NyquistIO::Load(AudioData * data, const std::string & path)
}
}
void NyquistIO::Load(AudioData * data, std::string extension, const std::vector<uint8_t> & buffer)
void NyquistIO::Load(AudioData * data, const std::string & extension, const std::vector<uint8_t> & buffer)
{
if (decoderTable.find(extension) == decoderTable.end())
{
@ -94,7 +94,7 @@ void NyquistIO::Load(AudioData * data, std::string extension, const std::vector<
}
}
bool NyquistIO::IsFileSupported(const std::string path) const
bool NyquistIO::IsFileSupported(const std::string & path) const
{
auto fileExtension = ParsePathForExtension(path);
if (decoderTable.find(fileExtension) == decoderTable.end()) return false;
@ -107,7 +107,7 @@ std::string NyquistIO::ParsePathForExtension(const std::string & path) const
return std::string("");
}
std::shared_ptr<BaseDecoder> NyquistIO::GetDecoderForExtension(const std::string ext)
std::shared_ptr<BaseDecoder> NyquistIO::GetDecoderForExtension(const std::string & ext)
{
if (decoderTable.size()) return decoderTable[ext];
else throw std::runtime_error("No available decoders.");

@ -27,7 +27,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace nqr;
NyquistFileBuffer nqr::ReadFile(std::string pathToFile)
NyquistFileBuffer nqr::ReadFile(const std::string & pathToFile)
{
//std::cout << "[Debug] Open: " << pathToFile << std::endl;
FILE * audioFile = fopen(pathToFile.c_str(), "rb");
@ -55,7 +55,6 @@ NyquistFileBuffer nqr::ReadFile(std::string pathToFile)
fclose(audioFile);
// Copy out to user
return data;
}

Loading…
Cancel
Save