diff --git a/driver/MTConvert.c b/driver/MTConvert.c index c94bc03..75063a1 100644 --- a/driver/MTConvert.c +++ b/driver/MTConvert.c @@ -2097,6 +2097,95 @@ void MTConvertBigEndianInt24ToMappedInt32DeInterleave( void* input_buffer, }*/ +void MTConvertMappedInt32ToBigEndianInt32Interleave(void** input_buffer, + const uint32_t offset_input_buf, + void* output_buffer, + const uint32_t nb_channels, + const uint32_t nb_samples_in) +{ + + uint32_t i, ch; + uint8_t* out = (uint8_t*)output_buffer; + const unsigned int stride_in = 4; + unsigned int in_pos = offset_input_buf * stride_in; + for(i = offset_input_buf; i < offset_input_buf + nb_samples_in; ++i) + { + if(Arch_is_big_endian()) + { + for(ch = 0; ch < nb_channels; ++ch) + { + const uint8_t* in = (uint8_t*)input_buffer[ch] + in_pos; + out[0] = in[0]; + out[1] = in[1]; + out[2] = in[2]; + out[3] = in[3]; + out += 4; + } + } + else + { + for(ch = 0; ch < nb_channels; ++ch) + { + const uint8_t* in = (uint8_t*)input_buffer[ch] + in_pos; + out[0] = in[3]; + out[1] = in[2]; + out[2] = in[1]; + out[3] = in[0]; + out += 4; + } + } + in_pos += stride_in; + } +} + + + +/////////////////////////////////////////////////////////////////////////////// +// Convert from an interleave buffer to N non-interleave buffers +// i.e. [A0.B0.A1.B1...A(dwNbOfSamplesByChannels-1).B(dwNbOfSamplesByChannels-1)] -> [A0..A(dwNbOfSamplesByChannels-1)][B0..B(dwNbOfSamplesByChannels-1)] +void MTConvertBigEndianInt32ToMappedInt32DeInterleave( void* input_buffer, + void** output_buffer, + uint32_t offset_output_buf, + uint32_t nb_channels, + uint32_t nb_samples) +{ + uint32_t i, ch; + const unsigned int stride_in = 4 * nb_channels, stride_out = 4; + const unsigned int out_pos = offset_output_buf * stride_out; + for(ch = 0; ch < nb_channels; ++ch) + { + uint8_t* in = (uint8_t*)input_buffer + 4 * ch; + uint8_t* out = (uint8_t*)output_buffer[ch] + out_pos; + + if(Arch_is_big_endian()) + { + for(i = 0; i < nb_samples; ++i) + { + out[0] = in[0]; + out[1] = in[1]; + out[2] = in[2]; + out[3] = in[3]; + + in += stride_in; + out += stride_out; + } + } + else + { + for(i = 0; i < nb_samples; ++i) + { + out[0] = in[3]; + out[1] = in[2]; + out[2] = in[1]; + out[3] = in[0]; + + in += stride_in; + out += stride_out; + } + } + } +} + /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// diff --git a/driver/MTConvert.h b/driver/MTConvert.h index 54bc90e..483f1c6 100644 --- a/driver/MTConvert.h +++ b/driver/MTConvert.h @@ -121,6 +121,8 @@ void MTConvertMappedInt24ToBigEndianInt24Interleave(void** ppi24Uninterleave, co void MTConvertBigEndianInt24ToMappedInt24DeInterleave(void* pbyBigEndianInterleave, void** ppi24Uninterleave, uint32_t dwOffsetInUninterleaveBuffer, uint32_t dwNbOfChannels, uint32_t dwNbOfSamplesByChannels); void MTConvertMappedInt32ToBigEndianInt24Interleave(void** ppi32Uninterleave, const uint32_t dwOffsetInUninterleaveBuffer, void* pbyBigEndianInterleave, const uint32_t dwNbOfChannels, const uint32_t dwNbOfSamplesByChannels); void MTConvertBigEndianInt24ToMappedInt32DeInterleave(void* pbyBigEndianInterleave, void** ppi32Uninterleave, uint32_t dwOffsetInUninterleaveBuffer, uint32_t dwNbOfChannels, uint32_t dwNbOfSamplesByChannels); +void MTConvertMappedInt32ToBigEndianInt32Interleave(void** ppi32Uninterleave, const uint32_t dwOffsetInUninterleaveBuffer, void* pbyBigEndianInterleave, const uint32_t dwNbOfChannels, const uint32_t dwNbOfSamplesByChannels); +void MTConvertBigEndianInt32ToMappedInt32DeInterleave(void* pbyBigEndianInterleave, void** ppi32Uninterleave, uint32_t dwOffsetInUninterleaveBuffer, uint32_t dwNbOfChannels, uint32_t dwNbOfSamplesByChannels); // DSD void MTConvertMappedFloatToBigEndianDSD64Interleave(void** ppfUninterleave, const uint32_t dwOffsetInUninterleaveBuffer, void* pvBigEndianInterleave, const uint32_t dwNbOfChannels, const uint32_t dwNbOfSamplesByChannels); diff --git a/driver/RTP_audio_stream.c b/driver/RTP_audio_stream.c index 5a160e4..403a51a 100644 --- a/driver/RTP_audio_stream.c +++ b/driver/RTP_audio_stream.c @@ -170,6 +171,10 @@ int Create(TRTP_audio_stream* self, TRTP_stream_info* pRTP_stream_info, rtp_audi { self->m_pfnMTConvertMappedToInterleave = &MTConvertMappedInt32ToBigEndianInt24Interleave; } + else if(strcmp(pRTP_stream_info->m_cCodec, "AM824") == 0) + { + self->m_pfnMTConvertMappedToInterleave = &MTConvertMappedInt32ToBigEndianInt32Interleave; + } else if(strcmp(pRTP_stream_info->m_cCodec, "DSD64_32") == 0 || strcmp(pRTP_stream_info->m_cCodec, "DSD128_32") == 0 || strcmp(pRTP_stream_info->m_cCodec, "DSD256") == 0) { self->m_pfnMTConvertMappedToInterleave = &MTConvertMappedFloatToBigEndianDSD256Interleave; @@ -300,6 +305,10 @@ int Create(TRTP_audio_stream* self, TRTP_stream_info* pRTP_stream_info, rtp_audi { self->m_pfnMTConvertInterleaveToMapped = &MTConvertBigEndianInt24ToMappedInt32DeInterleave; } + else if(strcmp(pRTP_stream_info->m_cCodec, "AM824") == 0) + { + self->m_pfnMTConvertInterleaveToMapped = &MTConvertBigEndianInt32ToMappedInt32DeInterleave; + } else { MTAL_DP("CRTP_audio_stream::Init: invalid Codec\n"); diff --git a/driver/RTP_stream_info.c b/driver/RTP_stream_info.c index ac65bbb..83ee967 100644 --- a/driver/RTP_stream_info.c +++ b/driver/RTP_stream_info.c @@ -168,7 +168,7 @@ int is_valid(TRTP_stream_info* rtp_stream_info) { char* cCodec = rtp_stream_info->m_cCodec; if (strcmp(cCodec, "L16") && strcmp(cCodec, "L24") && strcmp(cCodec, "L2432") - && strcmp(cCodec, "DSD64_32") && strcmp(cCodec, "DSD128_32") + && strcmp(cCodec, "AM824") && strcmp(cCodec, "DSD64_32") && strcmp(cCodec, "DSD128_32") && strcmp(cCodec, "DSD64") && strcmp(cCodec, "DSD128") && strcmp(cCodec, "DSD256")) { MTAL_DP("CRTP_stream_info::IsValid: wrong codec = %s\n", cCodec); @@ -252,6 +252,10 @@ unsigned char get_codec_word_lenght(const char* cCodec) { return 4; } + else if (strcmp(cCodec, "AM824") == 0) + { + return 4; + } else if (strcmp(cCodec, "DSD64") == 0) { return 1;