Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/audio/asrc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause

add_local_sources(sof asrc.c asrc_farrow.c asrc_farrow_generic.c
asrc_farrow_hifi3.c)
asrc_farrow_hifi3.c asrc_farrow_hifi5.c)

if(CONFIG_IPC_MAJOR_3)
add_local_sources(sof asrc_ipc3.c)
Expand Down
5 changes: 3 additions & 2 deletions src/audio/asrc/asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,11 @@ static int asrc_initialize_buffers(struct asrc_farrow *src_obj)

/* Set buffer_length to filter_length * 2 to compensate for
* missing element wise wrap around while loading but allowing
* aligned loads.
* aligned loads. FIR delay line write is initialized to last
* position of first copy block for reverse direction write.
*/
src_obj->buffer_length = src_obj->filter_length * 2;
src_obj->buffer_write_position = src_obj->filter_length;
src_obj->buffer_write_position = src_obj->filter_length - 1;

if (src_obj->bit_depth == 32) {
buffer_size = src_obj->buffer_length * sizeof(int32_t);
Expand Down
62 changes: 54 additions & 8 deletions src/audio/asrc/asrc_farrow.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,51 @@ static const struct asrc_filter_params c_filter_params[CR_NUM] = {
* coefficients will be attached to the _Src_farrow struct via the
* initialise_filter function.
*/

#if SOF_USE_MIN_HIFI(5, ASRC)
#include "coef/asrc_farrow_coeff_4x_44100Hz_to_48000Hz.h"
#include "coef/asrc_farrow_coeff_4x_48000Hz_to_48000Hz.h"

#if (CONFIG_ASRC_SUPPORT_CONVERSION_24000_TO_08000)
#include "coef/asrc_farrow_coeff_4x_24000Hz_to_08000Hz.h"
#endif

#if (CONFIG_ASRC_SUPPORT_CONVERSION_24000_TO_16000)
#include "coef/asrc_farrow_coeff_4x_24000Hz_to_16000Hz.h"
#endif

#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_08000)
#include "coef/asrc_farrow_coeff_4x_48000Hz_to_08000Hz.h"
#endif

#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_11025)
#include "coef/asrc_farrow_coeff_4x_48000Hz_to_11025Hz.h"
#endif

#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_12000)
#include "coef/asrc_farrow_coeff_4x_48000Hz_to_12000Hz.h"
#endif

#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_16000)
#include "coef/asrc_farrow_coeff_4x_48000Hz_to_16000Hz.h"
#endif

#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_22050)
#include "coef/asrc_farrow_coeff_4x_48000Hz_to_22050Hz.h"
#endif

#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_24000)
#include "coef/asrc_farrow_coeff_4x_48000Hz_to_24000Hz.h"
#endif

#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_32000)
#include "coef/asrc_farrow_coeff_4x_48000Hz_to_32000Hz.h"
#endif

#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_44100)
#include "coef/asrc_farrow_coeff_4x_48000Hz_to_44100Hz.h"
#endif
#else
#include "coef/asrc_farrow_coeff_44100Hz_to_48000Hz.h"

#include "coef/asrc_farrow_coeff_48000Hz_to_48000Hz.h"
Expand Down Expand Up @@ -188,6 +233,7 @@ static const struct asrc_filter_params c_filter_params[CR_NUM] = {
#if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_44100)
#include "coef/asrc_farrow_coeff_48000Hz_to_44100Hz.h"
#endif
#endif

/*
* FUNCTION DECLARATIONS
Expand Down Expand Up @@ -836,11 +882,11 @@ void asrc_write_to_ring_buffer16(struct asrc_farrow *src_obj,
int m;

/* update the buffer_write_position */
(src_obj->buffer_write_position)++;
(src_obj->buffer_write_position)--;

/* since it's a ring buffer we need a wrap around */
if (src_obj->buffer_write_position >= src_obj->buffer_length)
src_obj->buffer_write_position -= (src_obj->buffer_length >> 1);
if (src_obj->buffer_write_position < 0)
src_obj->buffer_write_position += (src_obj->buffer_length >> 1);

/* handle input format */
if (src_obj->input_format == ASRC_IOF_INTERLEAVED)
Expand All @@ -850,7 +896,7 @@ void asrc_write_to_ring_buffer16(struct asrc_farrow *src_obj,

/* write data to each channel */
j = src_obj->buffer_write_position;
k = j - (src_obj->buffer_length >> 1);
k = j + (src_obj->buffer_length >> 1);
for (ch = 0; ch < src_obj->num_channels; ch++) {
/*
* Since we want the filter function to load 64 bit of
Expand Down Expand Up @@ -878,11 +924,11 @@ void asrc_write_to_ring_buffer32(struct asrc_farrow *src_obj,
int m;

/* update the buffer_write_position */
(src_obj->buffer_write_position)++;
(src_obj->buffer_write_position)--;

/* since it's a ring buffer we need a wrap around */
if (src_obj->buffer_write_position >= src_obj->buffer_length)
src_obj->buffer_write_position -= (src_obj->buffer_length >> 1);
if (src_obj->buffer_write_position < 0)
src_obj->buffer_write_position += (src_obj->buffer_length >> 1);

/* handle input format */
if (src_obj->input_format == ASRC_IOF_INTERLEAVED)
Expand All @@ -892,7 +938,7 @@ void asrc_write_to_ring_buffer32(struct asrc_farrow *src_obj,

/* write data to each channel */
j = src_obj->buffer_write_position;
k = j - (src_obj->buffer_length >> 1);
k = j + (src_obj->buffer_length >> 1);
for (ch = 0; ch < src_obj->num_channels; ch++) {
/*
* Since we want the filter function to load 64 bit of
Expand Down
4 changes: 2 additions & 2 deletions src/audio/asrc/asrc_farrow_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void asrc_fir_filter16(struct asrc_farrow *src_obj, int16_t **output_buffers,
* Data is Q1.15, coefficients are Q1.30. Prod will be Qx.45.
*/
for (n = 0; n < src_obj->filter_length; n++)
prod += (int64_t)(*buffer_p--) * (*filter_p++);
prod += (int64_t)(*buffer_p++) * (*filter_p++);

/* Shift left after accumulation, because interim
* results might saturate during filtering prod = prod
Expand Down Expand Up @@ -96,7 +96,7 @@ void asrc_fir_filter32(struct asrc_farrow *src_obj, int32_t **output_buffers,
* quality. The product is Qx.54.
*/
for (n = 0; n < src_obj->filter_length; n++)
prod += (int64_t)(*buffer_p--) * (*filter_p++ >> 8);
prod += (int64_t)(*buffer_p++) * (*filter_p++ >> 8);

/* Shift left after accumulation, because interim
* results might saturate during filtering prod = prod
Expand Down
8 changes: 4 additions & 4 deletions src/audio/asrc/asrc_farrow_hifi3.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2012-2019 Intel Corporation. All rights reserved.
// Copyright(c) 2012-2025 Intel Corporation.

#include <sof/common.h>

#if SOF_USE_HIFI(3, ASRC) || SOF_USE_HIFI(4, ASRC) || SOF_USE_HIFI(5, ASRC)
#if SOF_USE_HIFI(3, ASRC) || SOF_USE_HIFI(4, ASRC)

#include "asrc_farrow.h"
#include <xtensa/tie/xt_hifi3.h>
Expand Down Expand Up @@ -56,7 +56,7 @@ void asrc_fir_filter16(struct asrc_farrow *src_obj, int16_t **output_buffers,
/* Iterate over the filter bins */
for (n = 0; n < n_limit; n++) {
/* Read four buffered samples at once */
AE_LA16X4_RIP(buffer0123, align_buffer, buffer_p);
AE_LA16X4_IP(buffer0123, align_buffer, buffer_p);

/* Store four bins of the impulse response */
AE_LA32X2_IP(filter01, align_filter, filter_p);
Expand Down Expand Up @@ -141,7 +141,7 @@ void asrc_fir_filter32(struct asrc_farrow *src_obj, int32_t **output_buffers,
/* Iterate over the filter bins */
for (n = 0; n < n_limit; n++) {
/* Read two buffered samples at once */
AE_LA32X2_RIP(buffer01, align_buffer, buffer_p);
AE_LA32X2_IP(buffer01, align_buffer, buffer_p);

/* Store two bins of the impulse response */
AE_LA32X2_IP(filter01, align_filter, filter_p);
Expand Down
Loading
Loading