mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-21 15:56:58 +02:00
Early work on improving format conversion.
This commit is contained in:
@@ -35,6 +35,619 @@ void on_log(mal_context* pContext, mal_device* pDevice, const char* message)
|
||||
}
|
||||
|
||||
|
||||
void* open_and_read_file_data(const char* filePath, size_t* pSizeOut)
|
||||
{
|
||||
// Safety.
|
||||
if (pSizeOut) *pSizeOut = 0;
|
||||
|
||||
if (filePath == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FILE* pFile;
|
||||
#if _MSC_VER
|
||||
if (fopen_s(&pFile, filePath, "rb") != 0) {
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
pFile = fopen(filePath, "rb");
|
||||
if (pFile == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
fseek(pFile, 0, SEEK_END);
|
||||
mal_uint64 fileSize = ftell(pFile);
|
||||
fseek(pFile, 0, SEEK_SET);
|
||||
|
||||
if (fileSize > SIZE_MAX) {
|
||||
fclose(pFile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* pFileData = mal_malloc((size_t)fileSize); // <-- Safe cast due to the check above.
|
||||
if (pFileData == NULL) {
|
||||
fclose(pFile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t bytesRead = fread(pFileData, 1, (size_t)fileSize, pFile);
|
||||
if (bytesRead != fileSize) {
|
||||
mal_free(pFileData);
|
||||
fclose(pFile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fclose(pFile);
|
||||
|
||||
if (pSizeOut) {
|
||||
*pSizeOut = (size_t)fileSize;
|
||||
}
|
||||
|
||||
return pFileData;
|
||||
}
|
||||
|
||||
void* load_raw_audio_data(const char* filePath, mal_format format, mal_uint64* pBenchmarkFrameCount)
|
||||
{
|
||||
mal_assert(pBenchmarkFrameCount != NULL);
|
||||
*pBenchmarkFrameCount = 0;
|
||||
|
||||
size_t fileSize;
|
||||
void* pFileData = open_and_read_file_data(filePath, &fileSize);
|
||||
if (pFileData == NULL) {
|
||||
printf("Cound not open file %s\n", filePath);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*pBenchmarkFrameCount = fileSize / mal_get_sample_size_in_bytes(format);
|
||||
return pFileData;
|
||||
}
|
||||
|
||||
void* load_benchmark_base_data(mal_format format, mal_uint32* pChannelsOut, mal_uint32* pSampleRateOut, mal_uint64* pBenchmarkFrameCount)
|
||||
{
|
||||
mal_assert(pChannelsOut != NULL);
|
||||
mal_assert(pSampleRateOut != NULL);
|
||||
mal_assert(pBenchmarkFrameCount != NULL);
|
||||
|
||||
*pChannelsOut = 1;
|
||||
*pSampleRateOut = 8000;
|
||||
*pBenchmarkFrameCount = 0;
|
||||
|
||||
const char* filePath = NULL;
|
||||
switch (format) {
|
||||
case mal_format_u8: filePath = "res/benchmarks/pcm_u8_to_u8__mono_8000.raw"; break;
|
||||
case mal_format_s16: filePath = "res/benchmarks/pcm_s16_to_s16__mono_8000.raw"; break;
|
||||
case mal_format_s24: filePath = "res/benchmarks/pcm_s24_to_s24__mono_8000.raw"; break;
|
||||
case mal_format_s32: filePath = "res/benchmarks/pcm_s32_to_s32__mono_8000.raw"; break;
|
||||
case mal_format_f32: filePath = "res/benchmarks/pcm_f32_to_f32__mono_8000.raw"; break;
|
||||
default: return NULL;
|
||||
}
|
||||
|
||||
return load_raw_audio_data(filePath, format, pBenchmarkFrameCount);
|
||||
}
|
||||
|
||||
int mal_pcm_compare(const void* a, const void* b, mal_uint64 count, mal_format format, float allowedDifference)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
const mal_uint8* a_u8 = (const mal_uint8*)a;
|
||||
const mal_uint8* b_u8 = (const mal_uint8*)b;
|
||||
const mal_int16* a_s16 = (const mal_int16*)a;
|
||||
const mal_int16* b_s16 = (const mal_int16*)b;
|
||||
const mal_int32* a_s32 = (const mal_int32*)a;
|
||||
const mal_int32* b_s32 = (const mal_int32*)b;
|
||||
const float* a_f32 = (const float* )a;
|
||||
const float* b_f32 = (const float* )b;
|
||||
|
||||
for (mal_uint64 i = 0; i < count; ++i) {
|
||||
switch (format) {
|
||||
case mal_format_u8:
|
||||
{
|
||||
mal_uint8 sampleA = a_u8[i];
|
||||
mal_uint8 sampleB = b_u8[i];
|
||||
if (sampleA != sampleB) {
|
||||
if (abs(sampleA - sampleB) > allowedDifference) { // Allow a difference of 1.
|
||||
printf("Sample %I64u not equal. %d != %d (diff: %d)\n", i, sampleA, sampleB, sampleA - sampleB);
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
case mal_format_s16:
|
||||
{
|
||||
mal_int16 sampleA = a_s16[i];
|
||||
mal_int16 sampleB = b_s16[i];
|
||||
if (sampleA != sampleB) {
|
||||
if (abs(sampleA - sampleB) > allowedDifference) { // Allow a difference of 1.
|
||||
printf("Sample %I64u not equal. %d != %d (diff: %d)\n", i, sampleA, sampleB, sampleA - sampleB);
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
case mal_format_s24:
|
||||
{
|
||||
mal_int32 sampleA = ((mal_int32)(((mal_uint32)(a_u8[i*3+0]) << 8) | ((mal_uint32)(a_u8[i*3+1]) << 16) | ((mal_uint32)(a_u8[i*3+2])) << 24)) >> 8;
|
||||
mal_int32 sampleB = ((mal_int32)(((mal_uint32)(b_u8[i*3+0]) << 8) | ((mal_uint32)(b_u8[i*3+1]) << 16) | ((mal_uint32)(b_u8[i*3+2])) << 24)) >> 8;;
|
||||
if (sampleA != sampleB) {
|
||||
if (abs(sampleA - sampleB) > allowedDifference) { // Allow a difference of 1.
|
||||
printf("Sample %I64u not equal. %d != %d (diff: %d)\n", i, sampleA, sampleB, sampleA - sampleB);
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
case mal_format_s32:
|
||||
{
|
||||
mal_int32 sampleA = a_s32[i];
|
||||
mal_int32 sampleB = b_s32[i];
|
||||
if (sampleA != sampleB) {
|
||||
if (abs(sampleA - sampleB) > allowedDifference) { // Allow a difference of 1.
|
||||
printf("Sample %I64u not equal. %d != %d (diff: %d)\n", i, sampleA, sampleB, sampleA - sampleB);
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
case mal_format_f32:
|
||||
{
|
||||
float sampleA = a_f32[i];
|
||||
float sampleB = b_f32[i];
|
||||
if (sampleA != sampleB) {
|
||||
float difference = sampleA - sampleB;
|
||||
difference = (difference < 0) ? -difference : difference;
|
||||
|
||||
if (difference > allowedDifference) {
|
||||
printf("Sample %I64u not equal. %.8f != %.8f (diff: %.8f)\n", i, sampleA, sampleB, sampleA - sampleB);
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int do_format_conversion_test(mal_format formatIn, mal_format formatOut)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
mal_uint32 channels;
|
||||
mal_uint32 sampleRate;
|
||||
mal_uint64 baseFrameCount;
|
||||
mal_int16* pBaseData = (mal_int16*)load_benchmark_base_data(formatIn, &channels, &sampleRate, &baseFrameCount);
|
||||
if (pBaseData == NULL) {
|
||||
return -1; // Failed to load file.
|
||||
}
|
||||
|
||||
void (* onConvertPCM)(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) = NULL;
|
||||
const char* pBenchmarkFilePath = NULL;
|
||||
|
||||
switch (formatIn) {
|
||||
case mal_format_u8:
|
||||
{
|
||||
switch (formatOut) {
|
||||
case mal_format_u8:
|
||||
{
|
||||
onConvertPCM = mal_pcm_u8_to_u8;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_u8_to_u8__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s16:
|
||||
{
|
||||
onConvertPCM = mal_pcm_u8_to_s16__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_u8_to_s16__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s24:
|
||||
{
|
||||
onConvertPCM = mal_pcm_u8_to_s24__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_u8_to_s24__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s32:
|
||||
{
|
||||
onConvertPCM = mal_pcm_u8_to_s32__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_u8_to_s32__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_f32:
|
||||
{
|
||||
onConvertPCM = mal_pcm_u8_to_f32__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_u8_to_f32__mono_8000.raw";
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
result = -1;
|
||||
} break;
|
||||
}
|
||||
} break;
|
||||
|
||||
case mal_format_s16:
|
||||
{
|
||||
switch (formatOut) {
|
||||
case mal_format_u8:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s16_to_u8__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s16_to_u8__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s16:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s16_to_s16;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s16_to_s16__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s24:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s16_to_s24__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s16_to_s24__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s32:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s16_to_s32__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s16_to_s32__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_f32:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s16_to_f32__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s16_to_f32__mono_8000.raw";
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
result = -1;
|
||||
} break;
|
||||
}
|
||||
} break;
|
||||
|
||||
case mal_format_s24:
|
||||
{
|
||||
switch (formatOut) {
|
||||
case mal_format_u8:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s24_to_u8__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s24_to_u8__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s16:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s24_to_s16__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s24_to_s16__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s24:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s24_to_s24;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s24_to_s24__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s32:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s24_to_s32__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s24_to_s32__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_f32:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s24_to_f32__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s24_to_f32__mono_8000.raw";
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
result = -1;
|
||||
} break;
|
||||
}
|
||||
} break;
|
||||
|
||||
case mal_format_s32:
|
||||
{
|
||||
switch (formatOut) {
|
||||
case mal_format_u8:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s32_to_u8__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s32_to_u8__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s16:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s32_to_s16__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s32_to_s16__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s24:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s32_to_s24__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s32_to_s24__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s32:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s32_to_s32;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s32_to_s32__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_f32:
|
||||
{
|
||||
onConvertPCM = mal_pcm_s32_to_f32__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_s32_to_f32__mono_8000.raw";
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
result = -1;
|
||||
} break;
|
||||
}
|
||||
} break;
|
||||
|
||||
case mal_format_f32:
|
||||
{
|
||||
switch (formatOut) {
|
||||
case mal_format_u8:
|
||||
{
|
||||
onConvertPCM = mal_pcm_f32_to_u8__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_f32_to_u8__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s16:
|
||||
{
|
||||
onConvertPCM = mal_pcm_f32_to_s16__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_f32_to_s16__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s24:
|
||||
{
|
||||
onConvertPCM = mal_pcm_f32_to_s24__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_f32_to_s24__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_s32:
|
||||
{
|
||||
onConvertPCM = mal_pcm_f32_to_s32__reference;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_f32_to_s32__mono_8000.raw";
|
||||
} break;
|
||||
case mal_format_f32:
|
||||
{
|
||||
onConvertPCM = mal_pcm_f32_to_f32;
|
||||
pBenchmarkFilePath = "res/benchmarks/pcm_f32_to_f32__mono_8000.raw";
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
result = -1;
|
||||
} break;
|
||||
}
|
||||
} break;
|
||||
|
||||
default:
|
||||
{
|
||||
result = -1;
|
||||
} break;
|
||||
}
|
||||
|
||||
|
||||
if (result != 0) {
|
||||
mal_free(pBaseData);
|
||||
return result;
|
||||
}
|
||||
|
||||
// We need to allow a very small amount of difference to each sample because the software that generated our testing benchmarks can use slightly
|
||||
// different (but still correct) algorithms which produce slightly different results. I'm allowing for this variability in my basic comparison
|
||||
// tests, but testing things like dithering will require more detailed testing which I'll probably do separate to this test project.
|
||||
mal_bool32 allowSmallDifference = MAL_TRUE;
|
||||
float allowedDifference = 0;
|
||||
if (allowSmallDifference) {
|
||||
if (formatOut == mal_format_f32) {
|
||||
switch (formatIn) {
|
||||
case mal_format_u8: allowedDifference = 1.0f / 255 * 2; break;
|
||||
case mal_format_s16: allowedDifference = 1.0f / 32767 * 2; break;
|
||||
case mal_format_s24: allowedDifference = 1.0f / 8388608 * 2; break;
|
||||
case mal_format_s32: allowedDifference = 1.0f / 2147483647 * 2; break;
|
||||
case mal_format_f32: allowedDifference = 0; break;
|
||||
default: break;
|
||||
}
|
||||
} else {
|
||||
allowedDifference = 1;
|
||||
}
|
||||
}
|
||||
|
||||
mal_uint64 benchmarkFrameCount;
|
||||
void* pBenchmarkData = load_raw_audio_data(pBenchmarkFilePath, formatOut, &benchmarkFrameCount);
|
||||
if (pBenchmarkData != NULL) {
|
||||
if (benchmarkFrameCount == baseFrameCount) {
|
||||
void* pConvertedData = (void*)mal_malloc(benchmarkFrameCount * mal_get_sample_size_in_bytes(formatOut));
|
||||
if (pConvertedData != NULL) {
|
||||
onConvertPCM(pConvertedData, pBaseData, (mal_uint32)benchmarkFrameCount, mal_dither_mode_none);
|
||||
result = mal_pcm_compare(pBenchmarkData, pConvertedData, benchmarkFrameCount, formatOut, allowedDifference);
|
||||
if (result == 0) {
|
||||
printf("PASSED.\n");
|
||||
}
|
||||
} else {
|
||||
printf("FAILED. Out of memory.\n");
|
||||
result = -3;
|
||||
}
|
||||
} else {
|
||||
printf("FAILED. Frame count mismatch.\n");
|
||||
result = -2;
|
||||
}
|
||||
} else {
|
||||
printf("FAILED.");
|
||||
result = -1;
|
||||
}
|
||||
|
||||
|
||||
mal_free(pBaseData);
|
||||
mal_free(pBenchmarkData);
|
||||
return result;
|
||||
}
|
||||
|
||||
int do_format_conversion_tests_u8()
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
printf("PCM u8 -> u8... ");
|
||||
if (do_format_conversion_test(mal_format_u8, mal_format_u8) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM u8 -> s16... ");
|
||||
if (do_format_conversion_test(mal_format_u8, mal_format_s16) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM u8 -> s24... ");
|
||||
if (do_format_conversion_test(mal_format_u8, mal_format_s24) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM u8 -> s32... ");
|
||||
if (do_format_conversion_test(mal_format_u8, mal_format_s32) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM u8 -> f32... ");
|
||||
if (do_format_conversion_test(mal_format_u8, mal_format_f32) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int do_format_conversion_tests_s16()
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
printf("PCM s16 -> u8... ");
|
||||
if (do_format_conversion_test(mal_format_s16, mal_format_u8) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM s16 -> s16... ");
|
||||
if (do_format_conversion_test(mal_format_s16, mal_format_s16) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM s16 -> s24... ");
|
||||
if (do_format_conversion_test(mal_format_s16, mal_format_s24) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM s16 -> s32... ");
|
||||
if (do_format_conversion_test(mal_format_s16, mal_format_s32) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM s16 -> f32... ");
|
||||
if (do_format_conversion_test(mal_format_s16, mal_format_f32) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int do_format_conversion_tests_s24()
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
printf("PCM s24 -> u8... ");
|
||||
if (do_format_conversion_test(mal_format_s24, mal_format_u8) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM s24 -> s16... ");
|
||||
if (do_format_conversion_test(mal_format_s24, mal_format_s16) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM s24 -> s24... ");
|
||||
if (do_format_conversion_test(mal_format_s24, mal_format_s24) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM s24 -> s32... ");
|
||||
if (do_format_conversion_test(mal_format_s24, mal_format_s32) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM s24 -> f32... ");
|
||||
if (do_format_conversion_test(mal_format_s24, mal_format_f32) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int do_format_conversion_tests_s32()
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
printf("PCM s32 -> u8... ");
|
||||
if (do_format_conversion_test(mal_format_s32, mal_format_u8) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM s32 -> s16... ");
|
||||
if (do_format_conversion_test(mal_format_s32, mal_format_s16) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM s32 -> s24... ");
|
||||
if (do_format_conversion_test(mal_format_s32, mal_format_s24) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM s32 -> s32... ");
|
||||
if (do_format_conversion_test(mal_format_s32, mal_format_s32) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM s32 -> f32... ");
|
||||
if (do_format_conversion_test(mal_format_s32, mal_format_f32) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int do_format_conversion_tests_f32()
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
printf("PCM f32 -> u8... ");
|
||||
if (do_format_conversion_test(mal_format_f32, mal_format_u8) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM f32 -> s16... ");
|
||||
if (do_format_conversion_test(mal_format_f32, mal_format_s16) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM f32 -> s24... ");
|
||||
if (do_format_conversion_test(mal_format_f32, mal_format_s24) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM f32 -> s32... ");
|
||||
if (do_format_conversion_test(mal_format_f32, mal_format_s32) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
printf("PCM f32 -> f32... ");
|
||||
if (do_format_conversion_test(mal_format_f32, mal_format_f32) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int do_format_conversion_tests()
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (do_format_conversion_tests_u8() != 0) {
|
||||
result = -1;
|
||||
}
|
||||
if (do_format_conversion_tests_s16() != 0) {
|
||||
result = -1;
|
||||
}
|
||||
if (do_format_conversion_tests_s24() != 0) {
|
||||
result = -1;
|
||||
}
|
||||
if (do_format_conversion_tests_s32() != 0) {
|
||||
result = -1;
|
||||
}
|
||||
if (do_format_conversion_tests_f32() != 0) {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int do_backend_test(mal_backend backend)
|
||||
{
|
||||
mal_result result = MAL_SUCCESS;
|
||||
@@ -264,6 +877,15 @@ int main(int argc, char** argv)
|
||||
|
||||
mal_bool32 hasErrorOccurred = MAL_FALSE;
|
||||
int result = 0;
|
||||
|
||||
printf("=== TESTING FORMAT CONVERSION ===\n");
|
||||
result = do_format_conversion_tests();
|
||||
if (result < 0) {
|
||||
hasErrorOccurred = MAL_TRUE;
|
||||
}
|
||||
printf("=== END TESTING FORMAT CONVERSION ===\n");
|
||||
|
||||
printf("\n");
|
||||
|
||||
printf("=== TESTING BACKENDS ===\n");
|
||||
result = do_backend_tests();
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 320 B |
@@ -0,0 +1 @@
|
||||
€�Ÿ®¼ÈÒÛáåæåáÛÒȼ®Ÿ�€o`QC7-$$-7CQ`o€�Ÿ®¼ÈÒÛáåæåáÛÒȼ®Ÿ�o`QC7-$$-7CQ`p
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 320 B |
@@ -0,0 +1 @@
|
||||
€�Ÿ®¼ÈÒÛáåæåáÛÒȼ®Ÿ�o`QC7-$$-7CQ`o€�Ÿ®¼ÈÒÛáåæåáÛÒȼ®Ÿ�o`QC7-$$-7CQ`p
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 320 B |
@@ -0,0 +1 @@
|
||||
€�Ÿ®¼ÈÒÛáåæåáÛÒȼ®Ÿ�€o`QC7-$$-7CQ`o€�Ÿ®¼ÈÒÛáåæåáÛÒȼ®Ÿ�o`QC7-$$-7CQ`p
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 320 B |
@@ -0,0 +1 @@
|
||||
€�Ÿ®¼ÈÒÛáåæåáÛÒȼ®Ÿ�€o`QC7-$$-7CQ`o€�Ÿ®¼ÈÒÛáåæåáÛÒȼ®Ÿ�o`QC7-$$-7CQ`p
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
€�Ÿ®¼ÈÒÛáåæåáÛÒȼ®Ÿ�o`QC7-$$-7CQ`o€�Ÿ®¼ÈÒÛáåæåáÛÒȼ®Ÿ�o`QC7-$$-7CQ`p
|
||||
Reference in New Issue
Block a user