mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 08:44:04 +02:00
Use the term "deinterleaved" instead of "separated".
This commit is contained in:
@@ -694,8 +694,8 @@ typedef struct
|
||||
|
||||
|
||||
typedef struct mal_format_converter mal_format_converter;
|
||||
typedef mal_uint32 (* mal_format_converter_read_proc) (mal_format_converter* pConverter, mal_uint32 frameCount, void* pFramesOut, void* pUserData);
|
||||
typedef mal_uint32 (* mal_format_converter_read_separated_proc)(mal_format_converter* pConverter, mal_uint32 frameCount, void** ppSamplesOut, void* pUserData);
|
||||
typedef mal_uint32 (* mal_format_converter_read_proc) (mal_format_converter* pConverter, mal_uint32 frameCount, void* pFramesOut, void* pUserData);
|
||||
typedef mal_uint32 (* mal_format_converter_read_deinterleaved_proc)(mal_format_converter* pConverter, mal_uint32 frameCount, void** ppSamplesOut, void* pUserData);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -711,7 +711,7 @@ struct mal_format_converter
|
||||
{
|
||||
mal_format_converter_config config;
|
||||
mal_format_converter_read_proc onRead;
|
||||
mal_format_converter_read_separated_proc onReadSeparated;
|
||||
mal_format_converter_read_deinterleaved_proc onReadDeinterleaved;
|
||||
void* pUserData;
|
||||
void (* onConvertPCM)(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode);
|
||||
void (* onInterleavePCM)(void* dst, const void** src, mal_uint64 frameCount, mal_uint32 channels);
|
||||
@@ -721,8 +721,8 @@ struct mal_format_converter
|
||||
|
||||
|
||||
typedef struct mal_channel_router mal_channel_router;
|
||||
//typedef mal_uint32 (* mal_channel_router_read_proc) (mal_channel_router* pRouter, mal_uint32 frameCount, void* pFramesOut, void* pUserData);
|
||||
typedef mal_uint32 (* mal_channel_router_read_separated_proc)(mal_channel_router* pRouter, mal_uint32 frameCount, void** ppSamplesOut, void* pUserData);
|
||||
//typedef mal_uint32 (* mal_channel_router_read_proc) (mal_channel_router* pRouter, mal_uint32 frameCount, void* pFramesOut, void* pUserData);
|
||||
typedef mal_uint32 (* mal_channel_router_read_deinterleaved_proc)(mal_channel_router* pRouter, mal_uint32 frameCount, void** ppSamplesOut, void* pUserData);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -737,7 +737,7 @@ struct mal_channel_router
|
||||
{
|
||||
mal_channel_router_config config;
|
||||
//mal_channel_router_read_proc onRead;
|
||||
mal_channel_router_read_separated_proc onReadSeparated;
|
||||
mal_channel_router_read_deinterleaved_proc onReadDeinterleaved;
|
||||
void* pUserData;
|
||||
mal_bool32 isPassthrough : 1;
|
||||
mal_bool32 isSimpleShuffle : 1;
|
||||
@@ -1835,13 +1835,13 @@ mal_bool32 mal_channel_map_contains_channel_position(mal_uint32 channels, const
|
||||
mal_result mal_format_converter_init(const mal_format_converter_config* pConfig, mal_format_converter_read_proc onRead, void* pUserData, mal_format_converter* pConverter);
|
||||
|
||||
// Initializes a format converter when the input data is non-interleaved.
|
||||
mal_result mal_format_converter_init_separated(const mal_format_converter_config* pConfig, mal_format_converter_read_separated_proc onRead, void* pUserData, mal_format_converter* pConverter);
|
||||
mal_result mal_format_converter_init_deinterleaved(const mal_format_converter_config* pConfig, mal_format_converter_read_deinterleaved_proc onRead, void* pUserData, mal_format_converter* pConverter);
|
||||
|
||||
// Reads data from the format converter as interleaved channels.
|
||||
mal_uint64 mal_format_converter_read_frames(mal_format_converter* pConverter, mal_uint64 frameCount, void* pFramesOut);
|
||||
|
||||
// Reads data from the format converter as separated channels.
|
||||
mal_uint64 mal_format_converter_read_frames_separated(mal_format_converter* pConverter, mal_uint64 frameCount, void** ppSamplesOut);
|
||||
// Reads data from the format converter as deinterleaved channels.
|
||||
mal_uint64 mal_format_converter_read_frames_deinterleaved(mal_format_converter* pConverter, mal_uint64 frameCount, void** ppSamplesOut);
|
||||
|
||||
|
||||
|
||||
@@ -1855,10 +1855,10 @@ mal_uint64 mal_format_converter_read_frames_separated(mal_format_converter* pCon
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Initializes a channel router where it is assumed that the input data is non-interleaved.
|
||||
mal_result mal_channel_router_init_separated(const mal_channel_router_config* pConfig, mal_channel_router_read_separated_proc onRead, void* pUserData, mal_channel_router* pRouter);
|
||||
mal_result mal_channel_router_init_deinterleaved(const mal_channel_router_config* pConfig, mal_channel_router_read_deinterleaved_proc onRead, void* pUserData, mal_channel_router* pRouter);
|
||||
|
||||
// Reads data from the channel router as separated channels.
|
||||
mal_uint64 mal_channel_router_read_frames_separated(mal_channel_router* pRouter, mal_uint64 frameCount, void** ppSamplesOut);
|
||||
// Reads data from the channel router as deinterleaved channels.
|
||||
mal_uint64 mal_channel_router_read_frames_deinterleaved(mal_channel_router* pRouter, mal_uint64 frameCount, void** ppSamplesOut);
|
||||
|
||||
|
||||
|
||||
@@ -10741,7 +10741,7 @@ int mal_device__jack_process_callback(mal_jack_nframes_t frameCount, void* pUser
|
||||
if (pDevice->type == mal_device_type_playback) {
|
||||
mal_device__read_frames_from_client(pDevice, frameCount, pDevice->jack.pIntermediaryBuffer);
|
||||
|
||||
// Channels need to be separated.
|
||||
// Channels need to be deinterleaved.
|
||||
for (mal_uint32 iChannel = 0; iChannel < pDevice->internalChannels; ++iChannel) {
|
||||
float* pDst = (float*)((mal_jack_port_get_buffer_proc)pContext->jack.jack_port_get_buffer)((mal_jack_port_t*)pDevice->jack.pPorts[iChannel], frameCount);
|
||||
if (pDst != NULL) {
|
||||
@@ -16861,14 +16861,14 @@ mal_result mal_format_converter_init(const mal_format_converter_config* pConfig,
|
||||
return MAL_SUCCESS;
|
||||
}
|
||||
|
||||
mal_result mal_format_converter_init_separated(const mal_format_converter_config* pConfig, mal_format_converter_read_separated_proc onRead, void* pUserData, mal_format_converter* pConverter)
|
||||
mal_result mal_format_converter_init_deinterleaved(const mal_format_converter_config* pConfig, mal_format_converter_read_deinterleaved_proc onRead, void* pUserData, mal_format_converter* pConverter)
|
||||
{
|
||||
mal_result result = mal_format_converter_init__common(pConfig, pUserData, pConverter);
|
||||
if (result != MAL_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
pConverter->onReadSeparated = onRead;
|
||||
pConverter->onReadDeinterleaved = onRead;
|
||||
|
||||
return MAL_SUCCESS;
|
||||
}
|
||||
@@ -16931,7 +16931,7 @@ mal_uint64 mal_format_converter_read_frames(mal_format_converter* pConverter, ma
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Input data is separated. If a conversion is required we need to do an intermediary step.
|
||||
// Input data is deinterleaved. If a conversion is required we need to do an intermediary step.
|
||||
mal_uint8 tempSamplesOfOutFormat[MAL_MAX_CHANNELS][MAL_MAX_PCM_SAMPLE_SIZE_IN_BYTES * 128];
|
||||
mal_assert(sizeof(tempSamplesOfOutFormat[0]) <= 0xFFFFFFFFF);
|
||||
|
||||
@@ -16953,7 +16953,7 @@ mal_uint64 mal_format_converter_read_frames(mal_format_converter* pConverter, ma
|
||||
|
||||
if (pConverter->config.formatIn == pConverter->config.formatOut) {
|
||||
// Only interleaving.
|
||||
framesJustRead = (mal_uint32)pConverter->onReadSeparated(pConverter, (mal_uint32)framesToReadRightNow, ppTempSampleOfOutFormat, pConverter->pUserData);
|
||||
framesJustRead = (mal_uint32)pConverter->onReadDeinterleaved(pConverter, (mal_uint32)framesToReadRightNow, ppTempSampleOfOutFormat, pConverter->pUserData);
|
||||
if (framesJustRead == 0) {
|
||||
break;
|
||||
}
|
||||
@@ -16967,7 +16967,7 @@ mal_uint64 mal_format_converter_read_frames(mal_format_converter* pConverter, ma
|
||||
}
|
||||
|
||||
|
||||
framesJustRead = (mal_uint32)pConverter->onReadSeparated(pConverter, (mal_uint32)framesToReadRightNow, ppTempSampleOfInFormat, pConverter->pUserData);
|
||||
framesJustRead = (mal_uint32)pConverter->onReadDeinterleaved(pConverter, (mal_uint32)framesToReadRightNow, ppTempSampleOfInFormat, pConverter->pUserData);
|
||||
if (framesJustRead == 0) {
|
||||
break;
|
||||
}
|
||||
@@ -16987,7 +16987,7 @@ mal_uint64 mal_format_converter_read_frames(mal_format_converter* pConverter, ma
|
||||
return totalFramesRead;
|
||||
}
|
||||
|
||||
mal_uint64 mal_format_converter_read_frames_separated(mal_format_converter* pConverter, mal_uint64 frameCount, void** ppSamplesOut)
|
||||
mal_uint64 mal_format_converter_read_frames_deinterleaved(mal_format_converter* pConverter, mal_uint64 frameCount, void** ppSamplesOut)
|
||||
{
|
||||
if (pConverter == NULL || ppSamplesOut == NULL) {
|
||||
return 0;
|
||||
@@ -17042,7 +17042,7 @@ mal_uint64 mal_format_converter_read_frames_separated(mal_format_converter* pCon
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Input data is separated.
|
||||
// Input data is deinterleaved.
|
||||
if (pConverter->config.formatIn == pConverter->config.formatOut) {
|
||||
// Pass through.
|
||||
while (totalFramesRead < frameCount) {
|
||||
@@ -17052,7 +17052,7 @@ mal_uint64 mal_format_converter_read_frames_separated(mal_format_converter* pCon
|
||||
framesToReadRightNow = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
mal_uint32 framesJustRead = (mal_uint32)pConverter->onReadSeparated(pConverter, (mal_uint32)framesToReadRightNow, (void**)ppNextSamplesOut, pConverter->pUserData);
|
||||
mal_uint32 framesJustRead = (mal_uint32)pConverter->onReadDeinterleaved(pConverter, (mal_uint32)framesToReadRightNow, (void**)ppNextSamplesOut, pConverter->pUserData);
|
||||
if (framesJustRead == 0) {
|
||||
break;
|
||||
}
|
||||
@@ -17081,7 +17081,7 @@ mal_uint64 mal_format_converter_read_frames_separated(mal_format_converter* pCon
|
||||
framesToReadRightNow = maxFramesToReadAtATime;
|
||||
}
|
||||
|
||||
mal_uint32 framesJustRead = (mal_uint32)pConverter->onReadSeparated(pConverter, (mal_uint32)framesToReadRightNow, ppTemp, pConverter->pUserData);
|
||||
mal_uint32 framesJustRead = (mal_uint32)pConverter->onReadDeinterleaved(pConverter, (mal_uint32)framesToReadRightNow, ppTemp, pConverter->pUserData);
|
||||
if (framesJustRead == 0) {
|
||||
break;
|
||||
}
|
||||
@@ -17654,7 +17654,7 @@ mal_result mal_channel_router_init__common(const mal_channel_router_config* pCon
|
||||
return MAL_SUCCESS;
|
||||
}
|
||||
|
||||
mal_result mal_channel_router_init_separated(const mal_channel_router_config* pConfig, mal_channel_router_read_separated_proc onRead, void* pUserData, mal_channel_router* pRouter)
|
||||
mal_result mal_channel_router_init_deinterleaved(const mal_channel_router_config* pConfig, mal_channel_router_read_deinterleaved_proc onRead, void* pUserData, mal_channel_router* pRouter)
|
||||
{
|
||||
mal_result result = mal_channel_router_init__common(pConfig, pUserData, pRouter);
|
||||
if (result != MAL_SUCCESS) {
|
||||
@@ -17665,7 +17665,7 @@ mal_result mal_channel_router_init_separated(const mal_channel_router_config* pC
|
||||
return MAL_INVALID_ARGS;
|
||||
}
|
||||
|
||||
pRouter->onReadSeparated = onRead;
|
||||
pRouter->onReadDeinterleaved = onRead;
|
||||
|
||||
return MAL_SUCCESS;
|
||||
}
|
||||
@@ -17701,7 +17701,7 @@ void mal_channel_router__do_routing(mal_channel_router* pRouter, mal_uint64 fram
|
||||
}
|
||||
}
|
||||
|
||||
mal_uint64 mal_channel_router_read_frames_separated(mal_channel_router* pRouter, mal_uint64 frameCount, void** ppSamplesOut)
|
||||
mal_uint64 mal_channel_router_read_frames_deinterleaved(mal_channel_router* pRouter, mal_uint64 frameCount, void** ppSamplesOut)
|
||||
{
|
||||
if (pRouter == NULL || ppSamplesOut == NULL) {
|
||||
return 0;
|
||||
@@ -17710,7 +17710,7 @@ mal_uint64 mal_channel_router_read_frames_separated(mal_channel_router* pRouter,
|
||||
// Fast path for a passthrough.
|
||||
if (pRouter->isPassthrough) {
|
||||
if (frameCount <= 0xFFFFFFFF) {
|
||||
return (mal_uint32)pRouter->onReadSeparated(pRouter, (mal_uint32)frameCount, ppSamplesOut, pRouter->pUserData);
|
||||
return (mal_uint32)pRouter->onReadDeinterleaved(pRouter, (mal_uint32)frameCount, ppSamplesOut, pRouter->pUserData);
|
||||
} else {
|
||||
float* ppNextSamplesOut[MAL_MAX_CHANNELS];
|
||||
mal_copy_memory(ppNextSamplesOut, ppSamplesOut, sizeof(float*) * pRouter->config.channelsOut);
|
||||
@@ -17723,7 +17723,7 @@ mal_uint64 mal_channel_router_read_frames_separated(mal_channel_router* pRouter,
|
||||
framesToReadRightNow = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
mal_uint32 framesJustRead = (mal_uint32)pRouter->onReadSeparated(pRouter, (mal_uint32)framesToReadRightNow, (void**)ppNextSamplesOut, pRouter->pUserData);
|
||||
mal_uint32 framesJustRead = (mal_uint32)pRouter->onReadDeinterleaved(pRouter, (mal_uint32)framesToReadRightNow, (void**)ppNextSamplesOut, pRouter->pUserData);
|
||||
if (framesJustRead == 0) {
|
||||
break;
|
||||
}
|
||||
@@ -17758,7 +17758,7 @@ mal_uint64 mal_channel_router_read_frames_separated(mal_channel_router* pRouter,
|
||||
framesToReadRightNow = maxFramesToReadEachIteration;
|
||||
}
|
||||
|
||||
mal_uint32 framesJustRead = pRouter->onReadSeparated(pRouter, (mal_uint32)framesToReadRightNow, (void**)ppTemp, pRouter->pUserData);
|
||||
mal_uint32 framesJustRead = pRouter->onReadDeinterleaved(pRouter, (mal_uint32)framesToReadRightNow, (void**)ppTemp, pRouter->pUserData);
|
||||
if (framesJustRead == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
+65
-65
@@ -657,20 +657,20 @@ int do_format_conversion_tests()
|
||||
}
|
||||
|
||||
|
||||
int compare_interleaved_and_separated_buffers(const void* interleaved, const void** separated, mal_uint32 frameCount, mal_uint32 channels, mal_format format)
|
||||
int compare_interleaved_and_deinterleaved_buffers(const void* interleaved, const void** deinterleaved, mal_uint32 frameCount, mal_uint32 channels, mal_format format)
|
||||
{
|
||||
mal_uint32 bytesPerSample = mal_get_bytes_per_sample(format);
|
||||
|
||||
const mal_uint8* interleaved8 = (const mal_uint8*)interleaved;
|
||||
const mal_uint8** separated8 = (const mal_uint8**)separated;
|
||||
const mal_uint8** deinterleaved8 = (const mal_uint8**)deinterleaved;
|
||||
|
||||
for (mal_uint32 iFrame = 0; iFrame < frameCount; iFrame += 1) {
|
||||
const mal_uint8* interleavedFrame = interleaved8 + iFrame*channels*bytesPerSample;
|
||||
|
||||
for (mal_uint32 iChannel = 0; iChannel < channels; iChannel += 1) {
|
||||
const mal_uint8* separatedFrame = separated8[iChannel] + iFrame*bytesPerSample;
|
||||
const mal_uint8* deinterleavedFrame = deinterleaved8[iChannel] + iFrame*bytesPerSample;
|
||||
|
||||
int result = memcmp(interleavedFrame + iChannel*bytesPerSample, separatedFrame, bytesPerSample);
|
||||
int result = memcmp(interleavedFrame + iChannel*bytesPerSample, deinterleavedFrame, bytesPerSample);
|
||||
if (result != 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -715,16 +715,16 @@ int do_interleaving_test(mal_format format)
|
||||
|
||||
// Interleave.
|
||||
mal_pcm_interleave_u8__reference(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration);
|
||||
if (compare_interleaved_and_separated_buffers(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Separated to Interleaved (Channels = %u)\n", i);
|
||||
if (compare_interleaved_and_deinterleaved_buffers(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Deinterleaved to Interleaved (Channels = %u)\n", i);
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
// Deinterleave.
|
||||
mal_pcm_deinterleave_u8__reference((void**)ppDst, dsti, frameCount, channelCountForThisIteration);
|
||||
if (compare_interleaved_and_separated_buffers(dsti, (const void**)ppDst, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Interleaved to Separated (Channels = %u)\n", i);
|
||||
if (compare_interleaved_and_deinterleaved_buffers(dsti, (const void**)ppDst, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Interleaved to Deinterleaved (Channels = %u)\n", i);
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
@@ -756,16 +756,16 @@ int do_interleaving_test(mal_format format)
|
||||
|
||||
// Interleave.
|
||||
mal_pcm_interleave_s16__reference(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration);
|
||||
if (compare_interleaved_and_separated_buffers(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Separated to Interleaved (Channels = %u)\n", i);
|
||||
if (compare_interleaved_and_deinterleaved_buffers(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Deinterleaved to Interleaved (Channels = %u)\n", i);
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
// Deinterleave.
|
||||
mal_pcm_deinterleave_s16__reference((void**)ppDst, dsti, frameCount, channelCountForThisIteration);
|
||||
if (compare_interleaved_and_separated_buffers(dsti, (const void**)ppDst, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Interleaved to Separated (Channels = %u)\n", i);
|
||||
if (compare_interleaved_and_deinterleaved_buffers(dsti, (const void**)ppDst, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Interleaved to Deinterleaved (Channels = %u)\n", i);
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
@@ -799,16 +799,16 @@ int do_interleaving_test(mal_format format)
|
||||
|
||||
// Interleave.
|
||||
mal_pcm_interleave_s24__reference(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration);
|
||||
if (compare_interleaved_and_separated_buffers(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Separated to Interleaved (Channels = %u)\n", channelCountForThisIteration);
|
||||
if (compare_interleaved_and_deinterleaved_buffers(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Deinterleaved to Interleaved (Channels = %u)\n", channelCountForThisIteration);
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
// Deinterleave.
|
||||
mal_pcm_deinterleave_s24__reference((void**)ppDst, dsti, frameCount, channelCountForThisIteration);
|
||||
if (compare_interleaved_and_separated_buffers(dsti, (const void**)ppDst, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Interleaved to Separated (Channels = %u)\n", channelCountForThisIteration);
|
||||
if (compare_interleaved_and_deinterleaved_buffers(dsti, (const void**)ppDst, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Interleaved to Deinterleaved (Channels = %u)\n", channelCountForThisIteration);
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
@@ -840,16 +840,16 @@ int do_interleaving_test(mal_format format)
|
||||
|
||||
// Interleave.
|
||||
mal_pcm_interleave_s32__reference(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration);
|
||||
if (compare_interleaved_and_separated_buffers(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Separated to Interleaved (Channels = %u)\n", i);
|
||||
if (compare_interleaved_and_deinterleaved_buffers(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Deinterleaved to Interleaved (Channels = %u)\n", i);
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
// Deinterleave.
|
||||
mal_pcm_deinterleave_s32__reference((void**)ppDst, dsti, frameCount, channelCountForThisIteration);
|
||||
if (compare_interleaved_and_separated_buffers(dsti, (const void**)ppDst, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Interleaved to Separated (Channels = %u)\n", i);
|
||||
if (compare_interleaved_and_deinterleaved_buffers(dsti, (const void**)ppDst, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Interleaved to Deinterleaved (Channels = %u)\n", i);
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
@@ -881,16 +881,16 @@ int do_interleaving_test(mal_format format)
|
||||
|
||||
// Interleave.
|
||||
mal_pcm_interleave_f32__reference(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration);
|
||||
if (compare_interleaved_and_separated_buffers(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Separated to Interleaved (Channels = %u)\n", i);
|
||||
if (compare_interleaved_and_deinterleaved_buffers(dsti, (const void**)ppSrc, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Deinterleaved to Interleaved (Channels = %u)\n", i);
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
// Deinterleave.
|
||||
mal_pcm_deinterleave_f32__reference((void**)ppDst, dsti, frameCount, channelCountForThisIteration);
|
||||
if (compare_interleaved_and_separated_buffers(dsti, (const void**)ppDst, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Interleaved to Separated (Channels = %u)\n", i);
|
||||
if (compare_interleaved_and_deinterleaved_buffers(dsti, (const void**)ppDst, frameCount, channelCountForThisIteration, format) != 0) {
|
||||
printf("FAILED. Interleaved to Deinterleaved (Channels = %u)\n", i);
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
@@ -964,7 +964,7 @@ mal_uint32 converter_test_interleaved_callback(mal_format_converter* pConverter,
|
||||
return frameCount;
|
||||
}
|
||||
|
||||
mal_uint32 converter_test_separated_callback(mal_format_converter* pConverter, mal_uint32 frameCount, void** ppSamplesOut, void* pUserData)
|
||||
mal_uint32 converter_test_deinterleaved_callback(mal_format_converter* pConverter, mal_uint32 frameCount, void** ppSamplesOut, void* pUserData)
|
||||
{
|
||||
mal_sine_wave* pSineWave = (mal_sine_wave*)pUserData;
|
||||
mal_assert(pSineWave != NULL);
|
||||
@@ -1034,13 +1034,13 @@ int do_format_converter_tests()
|
||||
return -1;
|
||||
}
|
||||
|
||||
mal_int16 separatedFrames[MAL_MAX_CHANNELS][1024];
|
||||
void* ppSeparatedFrames[MAL_MAX_CHANNELS];
|
||||
mal_int16 deinterleavedFrames[MAL_MAX_CHANNELS][1024];
|
||||
void* ppDeinterleavedFrames[MAL_MAX_CHANNELS];
|
||||
for (mal_uint32 iChannel = 0; iChannel < converter.config.channels; iChannel += 1) {
|
||||
ppSeparatedFrames[iChannel] = &separatedFrames[iChannel];
|
||||
ppDeinterleavedFrames[iChannel] = &deinterleavedFrames[iChannel];
|
||||
}
|
||||
|
||||
mal_uint64 framesRead = mal_format_converter_read_frames_separated(&converter, 1024, ppSeparatedFrames);
|
||||
mal_uint64 framesRead = mal_format_converter_read_frames_deinterleaved(&converter, 1024, ppDeinterleavedFrames);
|
||||
if (framesRead != 1024) {
|
||||
printf("Failed to read interleaved data from converter.\n");
|
||||
return -1;
|
||||
@@ -1057,7 +1057,7 @@ int do_format_converter_tests()
|
||||
return -1;
|
||||
}
|
||||
|
||||
fwrite(ppSeparatedFrames[iChannel], sizeof(mal_int16), framesRead, pFile);
|
||||
fwrite(ppDeinterleavedFrames[iChannel], sizeof(mal_int16), framesRead, pFile);
|
||||
fclose(pFile);
|
||||
}
|
||||
}
|
||||
@@ -1065,7 +1065,7 @@ int do_format_converter_tests()
|
||||
// Deinterleaved/Interleaved f32 to s16.
|
||||
{
|
||||
mal_sine_wave_init(amplitude, periodsPerSecond, sampleRate, &sineWave);
|
||||
result = mal_format_converter_init_separated(&config, converter_test_separated_callback, &sineWave, &converter);
|
||||
result = mal_format_converter_init_deinterleaved(&config, converter_test_deinterleaved_callback, &sineWave, &converter);
|
||||
if (result != MAL_SUCCESS) {
|
||||
printf("Failed to initialize converter.\n");
|
||||
return -1;
|
||||
@@ -1091,19 +1091,19 @@ int do_format_converter_tests()
|
||||
// Deinterleaved/Deinterleaved f32 to s16.
|
||||
{
|
||||
mal_sine_wave_init(amplitude, periodsPerSecond, sampleRate, &sineWave);
|
||||
result = mal_format_converter_init_separated(&config, converter_test_separated_callback, &sineWave, &converter);
|
||||
result = mal_format_converter_init_deinterleaved(&config, converter_test_deinterleaved_callback, &sineWave, &converter);
|
||||
if (result != MAL_SUCCESS) {
|
||||
printf("Failed to initialize converter.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
mal_int16 separatedFrames[MAL_MAX_CHANNELS][1024];
|
||||
void* ppSeparatedFrames[MAL_MAX_CHANNELS];
|
||||
mal_int16 deinterleavedFrames[MAL_MAX_CHANNELS][1024];
|
||||
void* ppDeinterleavedFrames[MAL_MAX_CHANNELS];
|
||||
for (mal_uint32 iChannel = 0; iChannel < converter.config.channels; iChannel += 1) {
|
||||
ppSeparatedFrames[iChannel] = &separatedFrames[iChannel];
|
||||
ppDeinterleavedFrames[iChannel] = &deinterleavedFrames[iChannel];
|
||||
}
|
||||
|
||||
mal_uint64 framesRead = mal_format_converter_read_frames_separated(&converter, 1024, ppSeparatedFrames);
|
||||
mal_uint64 framesRead = mal_format_converter_read_frames_deinterleaved(&converter, 1024, ppDeinterleavedFrames);
|
||||
if (framesRead != 1024) {
|
||||
printf("Failed to read interleaved data from converter.\n");
|
||||
return -1;
|
||||
@@ -1120,7 +1120,7 @@ int do_format_converter_tests()
|
||||
return -1;
|
||||
}
|
||||
|
||||
fwrite(ppSeparatedFrames[iChannel], sizeof(mal_int16), framesRead, pFile);
|
||||
fwrite(ppDeinterleavedFrames[iChannel], sizeof(mal_int16), framesRead, pFile);
|
||||
fclose(pFile);
|
||||
}
|
||||
}
|
||||
@@ -1164,13 +1164,13 @@ int do_format_converter_tests()
|
||||
return -1;
|
||||
}
|
||||
|
||||
float separatedFrames[MAL_MAX_CHANNELS][1024];
|
||||
void* ppSeparatedFrames[MAL_MAX_CHANNELS];
|
||||
float deinterleavedFrames[MAL_MAX_CHANNELS][1024];
|
||||
void* ppDeinterleavedFrames[MAL_MAX_CHANNELS];
|
||||
for (mal_uint32 iChannel = 0; iChannel < converter.config.channels; iChannel += 1) {
|
||||
ppSeparatedFrames[iChannel] = &separatedFrames[iChannel];
|
||||
ppDeinterleavedFrames[iChannel] = &deinterleavedFrames[iChannel];
|
||||
}
|
||||
|
||||
mal_uint64 framesRead = mal_format_converter_read_frames_separated(&converter, 1024, ppSeparatedFrames);
|
||||
mal_uint64 framesRead = mal_format_converter_read_frames_deinterleaved(&converter, 1024, ppDeinterleavedFrames);
|
||||
if (framesRead != 1024) {
|
||||
printf("Failed to read interleaved data from converter.\n");
|
||||
return -1;
|
||||
@@ -1187,7 +1187,7 @@ int do_format_converter_tests()
|
||||
return -1;
|
||||
}
|
||||
|
||||
fwrite(ppSeparatedFrames[iChannel], sizeof(float), framesRead, pFile);
|
||||
fwrite(ppDeinterleavedFrames[iChannel], sizeof(float), framesRead, pFile);
|
||||
fclose(pFile);
|
||||
}
|
||||
}
|
||||
@@ -1195,7 +1195,7 @@ int do_format_converter_tests()
|
||||
// Deinterleaved/Interleaved f32 to f32.
|
||||
{
|
||||
mal_sine_wave_init(amplitude, periodsPerSecond, sampleRate, &sineWave);
|
||||
result = mal_format_converter_init_separated(&config, converter_test_separated_callback, &sineWave, &converter);
|
||||
result = mal_format_converter_init_deinterleaved(&config, converter_test_deinterleaved_callback, &sineWave, &converter);
|
||||
if (result != MAL_SUCCESS) {
|
||||
printf("Failed to initialize converter.\n");
|
||||
return -1;
|
||||
@@ -1221,19 +1221,19 @@ int do_format_converter_tests()
|
||||
// Deinterleaved/Deinterleaved f32 to f32.
|
||||
{
|
||||
mal_sine_wave_init(amplitude, periodsPerSecond, sampleRate, &sineWave);
|
||||
result = mal_format_converter_init_separated(&config, converter_test_separated_callback, &sineWave, &converter);
|
||||
result = mal_format_converter_init_deinterleaved(&config, converter_test_deinterleaved_callback, &sineWave, &converter);
|
||||
if (result != MAL_SUCCESS) {
|
||||
printf("Failed to initialize converter.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
float separatedFrames[MAL_MAX_CHANNELS][1024];
|
||||
void* ppSeparatedFrames[MAL_MAX_CHANNELS];
|
||||
float deinterleavedFrames[MAL_MAX_CHANNELS][1024];
|
||||
void* ppDeinterleavedFrames[MAL_MAX_CHANNELS];
|
||||
for (mal_uint32 iChannel = 0; iChannel < converter.config.channels; iChannel += 1) {
|
||||
ppSeparatedFrames[iChannel] = &separatedFrames[iChannel];
|
||||
ppDeinterleavedFrames[iChannel] = &deinterleavedFrames[iChannel];
|
||||
}
|
||||
|
||||
mal_uint64 framesRead = mal_format_converter_read_frames_separated(&converter, 1024, ppSeparatedFrames);
|
||||
mal_uint64 framesRead = mal_format_converter_read_frames_deinterleaved(&converter, 1024, ppDeinterleavedFrames);
|
||||
if (framesRead != 1024) {
|
||||
printf("Failed to read interleaved data from converter.\n");
|
||||
return -1;
|
||||
@@ -1250,7 +1250,7 @@ int do_format_converter_tests()
|
||||
return -1;
|
||||
}
|
||||
|
||||
fwrite(ppSeparatedFrames[iChannel], sizeof(float), framesRead, pFile);
|
||||
fwrite(ppDeinterleavedFrames[iChannel], sizeof(float), framesRead, pFile);
|
||||
fclose(pFile);
|
||||
}
|
||||
}
|
||||
@@ -1288,7 +1288,7 @@ int do_channel_routing_tests()
|
||||
mal_get_standard_channel_map(mal_standard_channel_map_microsoft, routerConfig.channelsOut, routerConfig.channelMapOut);
|
||||
|
||||
mal_channel_router router;
|
||||
mal_result result = mal_channel_router_init_separated(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
mal_result result = mal_channel_router_init_deinterleaved(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
if (result == MAL_SUCCESS) {
|
||||
if (!router.isPassthrough) {
|
||||
printf("Failed to init router as passthrough.\n");
|
||||
@@ -1327,7 +1327,7 @@ int do_channel_routing_tests()
|
||||
}
|
||||
}
|
||||
|
||||
mal_channel_router_init_separated(&routerConfig, channel_router_callback__passthrough_test, ppTestData, &router);
|
||||
mal_channel_router_init_deinterleaved(&routerConfig, channel_router_callback__passthrough_test, ppTestData, &router);
|
||||
|
||||
float outputA[MAL_MAX_CHANNELS][100];
|
||||
float outputB[MAL_MAX_CHANNELS][100];
|
||||
@@ -1339,7 +1339,7 @@ int do_channel_routing_tests()
|
||||
}
|
||||
|
||||
// With optimizations.
|
||||
mal_uint64 framesRead = mal_channel_router_read_frames_separated(&router, 100, (void**)ppOutputA);
|
||||
mal_uint64 framesRead = mal_channel_router_read_frames_deinterleaved(&router, 100, (void**)ppOutputA);
|
||||
if (framesRead != 100) {
|
||||
printf("Returned frame count for optimized incorrect.");
|
||||
hasError = MAL_TRUE;
|
||||
@@ -1348,7 +1348,7 @@ int do_channel_routing_tests()
|
||||
// Without optimizations.
|
||||
router.isPassthrough = MAL_FALSE;
|
||||
router.isSimpleShuffle = MAL_FALSE;
|
||||
framesRead = mal_channel_router_read_frames_separated(&router, 100, (void**)ppOutputB);
|
||||
framesRead = mal_channel_router_read_frames_deinterleaved(&router, 100, (void**)ppOutputB);
|
||||
if (framesRead != 100) {
|
||||
printf("Returned frame count for unoptimized path incorrect.");
|
||||
hasError = MAL_TRUE;
|
||||
@@ -1386,7 +1386,7 @@ int do_channel_routing_tests()
|
||||
}
|
||||
|
||||
mal_channel_router router;
|
||||
mal_result result = mal_channel_router_init_separated(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
mal_result result = mal_channel_router_init_deinterleaved(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
if (result == MAL_SUCCESS) {
|
||||
if (router.isPassthrough) {
|
||||
printf("Router incorrectly configured as a passthrough.\n");
|
||||
@@ -1429,7 +1429,7 @@ int do_channel_routing_tests()
|
||||
}
|
||||
}
|
||||
|
||||
mal_channel_router_init_separated(&routerConfig, channel_router_callback__passthrough_test, ppTestData, &router);
|
||||
mal_channel_router_init_deinterleaved(&routerConfig, channel_router_callback__passthrough_test, ppTestData, &router);
|
||||
|
||||
float outputA[MAL_MAX_CHANNELS][100];
|
||||
float outputB[MAL_MAX_CHANNELS][100];
|
||||
@@ -1441,7 +1441,7 @@ int do_channel_routing_tests()
|
||||
}
|
||||
|
||||
// With optimizations.
|
||||
mal_uint64 framesRead = mal_channel_router_read_frames_separated(&router, 100, (void**)ppOutputA);
|
||||
mal_uint64 framesRead = mal_channel_router_read_frames_deinterleaved(&router, 100, (void**)ppOutputA);
|
||||
if (framesRead != 100) {
|
||||
printf("Returned frame count for optimized incorrect.");
|
||||
hasError = MAL_TRUE;
|
||||
@@ -1450,7 +1450,7 @@ int do_channel_routing_tests()
|
||||
// Without optimizations.
|
||||
router.isPassthrough = MAL_FALSE;
|
||||
router.isSimpleShuffle = MAL_FALSE;
|
||||
framesRead = mal_channel_router_read_frames_separated(&router, 100, (void**)ppOutputB);
|
||||
framesRead = mal_channel_router_read_frames_deinterleaved(&router, 100, (void**)ppOutputB);
|
||||
if (framesRead != 100) {
|
||||
printf("Returned frame count for unoptimized path incorrect.");
|
||||
hasError = MAL_TRUE;
|
||||
@@ -1486,7 +1486,7 @@ int do_channel_routing_tests()
|
||||
mal_get_standard_channel_map(mal_standard_channel_map_microsoft, routerConfig.channelsOut, routerConfig.channelMapOut);
|
||||
|
||||
mal_channel_router router;
|
||||
mal_result result = mal_channel_router_init_separated(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
mal_result result = mal_channel_router_init_deinterleaved(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
if (result == MAL_SUCCESS) {
|
||||
if (router.isPassthrough) {
|
||||
printf("Router incorrectly configured as a passthrough.\n");
|
||||
@@ -1532,7 +1532,7 @@ int do_channel_routing_tests()
|
||||
mal_get_standard_channel_map(mal_standard_channel_map_microsoft, routerConfig.channelsOut, routerConfig.channelMapOut);
|
||||
|
||||
mal_channel_router router;
|
||||
mal_result result = mal_channel_router_init_separated(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
mal_result result = mal_channel_router_init_deinterleaved(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
if (result == MAL_SUCCESS) {
|
||||
if (router.isPassthrough) {
|
||||
printf("Router incorrectly configured as a passthrough.\n");
|
||||
@@ -1589,7 +1589,7 @@ int do_channel_routing_tests()
|
||||
routerConfig.channelMapOut[7] = MAL_CHANNEL_SIDE_RIGHT;
|
||||
|
||||
mal_channel_router router;
|
||||
mal_result result = mal_channel_router_init_separated(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
mal_result result = mal_channel_router_init_deinterleaved(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
if (result == MAL_SUCCESS) {
|
||||
if (router.isPassthrough) {
|
||||
printf("Router incorrectly configured as a passthrough.\n");
|
||||
@@ -1645,7 +1645,7 @@ int do_channel_routing_tests()
|
||||
ppTestData[1][iFrame] = +1;
|
||||
}
|
||||
|
||||
mal_channel_router_init_separated(&routerConfig, channel_router_callback__passthrough_test, ppTestData, &router);
|
||||
mal_channel_router_init_deinterleaved(&routerConfig, channel_router_callback__passthrough_test, ppTestData, &router);
|
||||
|
||||
float output[MAL_MAX_CHANNELS][100];
|
||||
float* ppOutput[MAL_MAX_CHANNELS];
|
||||
@@ -1653,7 +1653,7 @@ int do_channel_routing_tests()
|
||||
ppOutput[iChannel] = output[iChannel];
|
||||
}
|
||||
|
||||
mal_uint64 framesRead = mal_channel_router_read_frames_separated(&router, 100, (void**)ppOutput);
|
||||
mal_uint64 framesRead = mal_channel_router_read_frames_deinterleaved(&router, 100, (void**)ppOutput);
|
||||
if (framesRead != 100) {
|
||||
printf("Returned frame count for optimized incorrect.\n");
|
||||
hasError = MAL_TRUE;
|
||||
@@ -1704,7 +1704,7 @@ int do_channel_routing_tests()
|
||||
routerConfig.channelMapOut[1] = MAL_CHANNEL_FRONT_RIGHT;
|
||||
|
||||
mal_channel_router router;
|
||||
mal_result result = mal_channel_router_init_separated(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
mal_result result = mal_channel_router_init_deinterleaved(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
if (result == MAL_SUCCESS) {
|
||||
if (router.isPassthrough) {
|
||||
printf("Router incorrectly configured as a passthrough.\n");
|
||||
@@ -1769,7 +1769,7 @@ int do_channel_routing_tests()
|
||||
routerConfig.channelMapOut[3] = MAL_CHANNEL_LFE;
|
||||
|
||||
mal_channel_router router;
|
||||
mal_result result = mal_channel_router_init_separated(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
mal_result result = mal_channel_router_init_deinterleaved(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
if (result == MAL_SUCCESS) {
|
||||
if (router.isPassthrough) {
|
||||
printf("Router incorrectly configured as a passthrough.\n");
|
||||
@@ -1822,7 +1822,7 @@ int do_channel_routing_tests()
|
||||
routerConfig.channelMapOut[0] = MAL_CHANNEL_MONO;
|
||||
|
||||
mal_channel_router router;
|
||||
mal_result result = mal_channel_router_init_separated(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
mal_result result = mal_channel_router_init_deinterleaved(&routerConfig, channel_router_callback__passthrough_test, NULL, &router);
|
||||
if (result == MAL_SUCCESS) {
|
||||
if (router.isPassthrough) {
|
||||
printf("Router incorrectly configured as a passthrough.\n");
|
||||
|
||||
Reference in New Issue
Block a user