diff --git a/src/audio/asrc/asrc.c b/src/audio/asrc/asrc.c index ea72e50bf92d..c90669d48696 100644 --- a/src/audio/asrc/asrc.c +++ b/src/audio/asrc/asrc.c @@ -321,6 +321,7 @@ static int asrc_free(struct processing_module *mod) rfree(cd->buf); asrc_release_buffers(cd->asrc_obj); + asrc_free_polyphase_filter(cd->asrc_obj); rfree(cd->asrc_obj); rfree(cd); return 0; @@ -851,6 +852,7 @@ static int asrc_reset(struct processing_module *mod) /* Free the allocations those were done in prepare() */ asrc_release_buffers(cd->asrc_obj); + asrc_free_polyphase_filter(cd->asrc_obj); rfree(cd->asrc_obj); rfree(cd->buf); cd->asrc_obj = NULL; diff --git a/src/audio/asrc/asrc_farrow.c b/src/audio/asrc/asrc_farrow.c index dbe1edbe2aaa..5e26c610d6bd 100644 --- a/src/audio/asrc/asrc_farrow.c +++ b/src/audio/asrc/asrc_farrow.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include "asrc_farrow.h" @@ -506,6 +508,31 @@ enum asrc_error_code asrc_set_output_format(struct comp_dev *dev, return ASRC_EC_OK; } +static const int32_t *__get_polyphase_filter(const int32_t *filter, size_t size) +{ +#if CONFIG_FAST_GET + return fast_get(filter, size); +#else + return filter; +#endif +} + +#define get_polyphase_filter(f) __get_polyphase_filter(f, sizeof(f)) + +static void put_polyphase_filter(const int32_t *filter) +{ +#if CONFIG_FAST_GET + fast_put(filter); +#endif +} + +void asrc_free_polyphase_filter(struct asrc_farrow *src_obj) +{ + if (src_obj && src_obj->polyphase_filters) { + put_polyphase_filter(src_obj->polyphase_filters); + src_obj->polyphase_filters = NULL; + } +} /* * FILTER FUNCTIONS @@ -533,7 +560,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev, /* Reset coefficients for possible exit with error. */ src_obj->filter_length = 0; src_obj->num_filters = 0; - src_obj->polyphase_filters = NULL; + asrc_free_polyphase_filter(src_obj); if (fs_in == 0 || fs_out == 0) { /* Avoid possible divisions by zero. */ @@ -549,7 +576,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev, c_filter_params[CR_48000TO48000].filter_length; src_obj->num_filters = c_filter_params[CR_48000TO48000].num_filters; - src_obj->polyphase_filters = &coeff48000to48000[0]; + src_obj->polyphase_filters = get_polyphase_filter(coeff48000to48000); } else if (fs_in <= fs_out) { /* All upsampling use cases can share the same set of * filter coefficients. @@ -558,7 +585,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev, c_filter_params[CR_44100TO48000].filter_length; src_obj->num_filters = c_filter_params[CR_44100TO48000].num_filters; - src_obj->polyphase_filters = &coeff44100to48000[0]; + src_obj->polyphase_filters = get_polyphase_filter(coeff44100to48000); } else if (fs_in == 48000) { switch (fs_out) { #if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_08000) @@ -567,7 +594,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev, c_filter_params[CR_48000TO08000].filter_length; src_obj->num_filters = c_filter_params[CR_48000TO08000].num_filters; - src_obj->polyphase_filters = &coeff48000to08000[0]; + src_obj->polyphase_filters = get_polyphase_filter(coeff48000to08000); break; #endif #if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_11025) @@ -576,7 +603,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev, c_filter_params[CR_48000TO11025].filter_length; src_obj->num_filters = c_filter_params[CR_48000TO11025].num_filters; - src_obj->polyphase_filters = &coeff48000to11025[0]; + src_obj->polyphase_filters = get_polyphase_filter(coeff48000to11025); break; #endif #if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_12000) @@ -585,7 +612,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev, c_filter_params[CR_48000TO12000].filter_length; src_obj->num_filters = c_filter_params[CR_48000TO12000].num_filters; - src_obj->polyphase_filters = &coeff48000to12000[0]; + src_obj->polyphase_filters = get_polyphase_filter(coeff48000to12000); break; #endif #if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_16000) @@ -594,7 +621,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev, c_filter_params[CR_48000TO16000].filter_length; src_obj->num_filters = c_filter_params[CR_48000TO16000].num_filters; - src_obj->polyphase_filters = &coeff48000to16000[0]; + src_obj->polyphase_filters = get_polyphase_filter(coeff48000to16000); break; #endif #if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_22050) @@ -603,7 +630,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev, c_filter_params[CR_48000TO22050].filter_length; src_obj->num_filters = c_filter_params[CR_48000TO22050].num_filters; - src_obj->polyphase_filters = &coeff48000to22050[0]; + src_obj->polyphase_filters = get_polyphase_filter(coeff48000to22050); break; #endif #if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_24000) @@ -612,7 +639,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev, c_filter_params[CR_48000TO24000].filter_length; src_obj->num_filters = c_filter_params[CR_48000TO24000].num_filters; - src_obj->polyphase_filters = &coeff48000to24000[0]; + src_obj->polyphase_filters = get_polyphase_filter(coeff48000to24000); break; #endif #if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_32000) @@ -621,7 +648,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev, c_filter_params[CR_48000TO32000].filter_length; src_obj->num_filters = c_filter_params[CR_48000TO32000].num_filters; - src_obj->polyphase_filters = &coeff48000to32000[0]; + src_obj->polyphase_filters = get_polyphase_filter(coeff48000to32000); break; #endif #if (CONFIG_ASRC_SUPPORT_CONVERSION_48000_TO_44100) @@ -630,7 +657,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev, c_filter_params[CR_48000TO44100].filter_length; src_obj->num_filters = c_filter_params[CR_48000TO44100].num_filters; - src_obj->polyphase_filters = &coeff48000to44100[0]; + src_obj->polyphase_filters = get_polyphase_filter(coeff48000to44100); break; #endif default: @@ -646,7 +673,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev, c_filter_params[CR_24000TO08000].filter_length; src_obj->num_filters = c_filter_params[CR_24000TO08000].num_filters; - src_obj->polyphase_filters = &coeff24000to08000[0]; + src_obj->polyphase_filters = get_polyphase_filter(coeff24000to08000); break; #endif #if (CONFIG_ASRC_SUPPORT_CONVERSION_24000_TO_16000) @@ -655,7 +682,7 @@ static enum asrc_error_code initialise_filter(struct comp_dev *dev, c_filter_params[CR_24000TO16000].filter_length; src_obj->num_filters = c_filter_params[CR_24000TO16000].num_filters; - src_obj->polyphase_filters = &coeff24000to16000[0]; + src_obj->polyphase_filters = get_polyphase_filter(coeff24000to16000); break; #endif default: diff --git a/src/audio/asrc/asrc_farrow.h b/src/audio/asrc/asrc_farrow.h index 4a7eca8bf480..766ead172d58 100644 --- a/src/audio/asrc/asrc_farrow.h +++ b/src/audio/asrc/asrc_farrow.h @@ -281,6 +281,13 @@ enum asrc_error_code asrc_initialise(struct comp_dev *dev, enum asrc_control_mode control_mode, enum asrc_operation_mode operation_mode); +/* + * @brief Free polyphase filters + * + * @param[in] src_obj Pointer to the ias_src_farrow. + */ +void asrc_free_polyphase_filter(struct asrc_farrow *src_obj); + /* * @brief Process the sample rate converter for one frame; the frame * consists of @p input_num_frames samples within @p num_channels diff --git a/src/audio/asrc/coef/asrc_farrow_coeff_24000Hz_to_08000Hz.h b/src/audio/asrc/coef/asrc_farrow_coeff_24000Hz_to_08000Hz.h index fe089c50c082..149fd5669778 100644 --- a/src/audio/asrc/coef/asrc_farrow_coeff_24000Hz_to_08000Hz.h +++ b/src/audio/asrc/coef/asrc_farrow_coeff_24000Hz_to_08000Hz.h @@ -6,7 +6,7 @@ /* Conversion from 24000 Hz to 8000 Hz */ /* NUM_FILTERS=4, FILTER_LENGTH=128, alpha=6.200000, gamma=0.454000 */ -static const int32_t coeff24000to08000[] = { +__cold_rodata static const int32_t coeff24000to08000[] = { /* Filter #4, conversion from 24000 Hz to 8000 Hz */ CONVERT_COEFF(-10830), /* Filter:4, Coefficient: 1 */ diff --git a/src/audio/asrc/coef/asrc_farrow_coeff_24000Hz_to_16000Hz.h b/src/audio/asrc/coef/asrc_farrow_coeff_24000Hz_to_16000Hz.h index 351c238d5dac..9f0070a48928 100644 --- a/src/audio/asrc/coef/asrc_farrow_coeff_24000Hz_to_16000Hz.h +++ b/src/audio/asrc/coef/asrc_farrow_coeff_24000Hz_to_16000Hz.h @@ -6,7 +6,7 @@ /* Conversion from 24000 Hz to 16000 Hz */ /* NUM_FILTERS=6, FILTER_LENGTH=80, alpha=6.800000, gamma=0.460000 */ -static const int32_t coeff24000to16000[] = { +__cold_rodata static const int32_t coeff24000to16000[] = { /* Filter #6, conversion from 24000 Hz to 16000 Hz */ CONVERT_COEFF(-26295), /* Filter:6, Coefficient: 1 */ diff --git a/src/audio/asrc/coef/asrc_farrow_coeff_44100Hz_to_48000Hz.h b/src/audio/asrc/coef/asrc_farrow_coeff_44100Hz_to_48000Hz.h index 28ff9ae7834d..fca60d5d6b2c 100644 --- a/src/audio/asrc/coef/asrc_farrow_coeff_44100Hz_to_48000Hz.h +++ b/src/audio/asrc/coef/asrc_farrow_coeff_44100Hz_to_48000Hz.h @@ -6,7 +6,7 @@ /* Conversion from 44100 Hz to 48000 Hz */ /* NUM_FILTERS=7, FILTER_LENGTH=64, alpha=7.800000, gamma=0.459000 */ -static const int32_t coeff44100to48000[] = { +__cold_rodata static const int32_t coeff44100to48000[] = { /* Filter #7, conversion from 44100 Hz to 48000 Hz */ CONVERT_COEFF(-36104), /* Filter:7, Coefficient: 1 */ diff --git a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_08000Hz.h b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_08000Hz.h index c4affd499b39..8db0161ae75d 100644 --- a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_08000Hz.h +++ b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_08000Hz.h @@ -6,7 +6,7 @@ /* Conversion from 48000 Hz to 8000 Hz */ /* NUM_FILTERS=4, FILTER_LENGTH=128, alpha=5.600000, gamma=0.415500 */ -static const int32_t coeff48000to08000[] = { +__cold_rodata static const int32_t coeff48000to08000[] = { /* Filter #4, conversion from 48000 Hz to 8000 Hz */ CONVERT_COEFF(-3301), /* Filter:4, Coefficient: 1 */ diff --git a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_11025Hz.h b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_11025Hz.h index 0488065745d3..50c25bd2490d 100644 --- a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_11025Hz.h +++ b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_11025Hz.h @@ -6,7 +6,7 @@ /* Conversion from 48000 Hz to 11025 Hz */ /* NUM_FILTERS=4, FILTER_LENGTH=96, alpha=5.700000, gamma=0.417000 */ -static const int32_t coeff48000to11025[] = { +__cold_rodata static const int32_t coeff48000to11025[] = { /* Filter #4, conversion from 48000 Hz to 11025 Hz */ CONVERT_COEFF(-5276), /* Filter:4, Coefficient: 1 */ diff --git a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_12000Hz.h b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_12000Hz.h index b527b30a982d..69ae4fbd550d 100644 --- a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_12000Hz.h +++ b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_12000Hz.h @@ -6,7 +6,7 @@ /* Conversion from 48000 Hz to 12000 Hz */ /* NUM_FILTERS=4, FILTER_LENGTH=96, alpha=5.700000, gamma=0.424000 */ -static const int32_t coeff48000to12000[] = { +__cold_rodata static const int32_t coeff48000to12000[] = { /* Filter #4, conversion from 48000 Hz to 12000 Hz */ CONVERT_COEFF(9466), /* Filter:4, Coefficient: 1 */ diff --git a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_16000Hz.h b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_16000Hz.h index e085df9d34c5..a26687c4afd0 100644 --- a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_16000Hz.h +++ b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_16000Hz.h @@ -6,7 +6,7 @@ /* Conversion from 48000 Hz to 16000 Hz */ /* NUM_FILTERS=5, FILTER_LENGTH=96, alpha=5.700000, gamma=0.443000 */ -static const int32_t coeff48000to16000[] = { +__cold_rodata static const int32_t coeff48000to16000[] = { /* Filter #5, conversion from 48000 Hz to 16000 Hz */ CONVERT_COEFF(6003), /* Filter:5, Coefficient: 1 */ diff --git a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_22050Hz.h b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_22050Hz.h index 71daa2c2adae..3ab3c3fc2605 100644 --- a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_22050Hz.h +++ b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_22050Hz.h @@ -6,7 +6,7 @@ /* Conversion from 48000 Hz to 22050 Hz */ /* NUM_FILTERS=5, FILTER_LENGTH=80, alpha=6.900000, gamma=0.440000 */ -static const int32_t coeff48000to22050[] = { +__cold_rodata static const int32_t coeff48000to22050[] = { /* Filter #5, conversion from 48000 Hz to 22050 Hz */ CONVERT_COEFF(7662), /* Filter:5, Coefficient: 1 */ diff --git a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_24000Hz.h b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_24000Hz.h index 2d075beb243f..9eed3d92451a 100644 --- a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_24000Hz.h +++ b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_24000Hz.h @@ -6,7 +6,7 @@ /* Conversion from 48000 Hz to 24000 Hz */ /* NUM_FILTERS=5, FILTER_LENGTH=80, alpha=7.500000, gamma=0.440000 */ -static const int32_t coeff48000to24000[] = { +__cold_rodata static const int32_t coeff48000to24000[] = { /* Filter #5, conversion from 48000 Hz to 24000 Hz */ CONVERT_COEFF(-13838), /* Filter:5, Coefficient: 1 */ diff --git a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_32000Hz.h b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_32000Hz.h index 7dfe46d76bcf..7f798a829ae7 100644 --- a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_32000Hz.h +++ b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_32000Hz.h @@ -6,7 +6,7 @@ /* Conversion from 48000 Hz to 32000 Hz */ /* NUM_FILTERS=6, FILTER_LENGTH=80, alpha=8.000000, gamma=0.452000 */ -static const int32_t coeff48000to32000[] = { +__cold_rodata static const int32_t coeff48000to32000[] = { /* Filter #6, conversion from 48000 Hz to 32000 Hz */ CONVERT_COEFF(-11561), /* Filter:6, Coefficient: 1 */ diff --git a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_44100Hz.h b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_44100Hz.h index ef40e3bf690f..505708746f60 100644 --- a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_44100Hz.h +++ b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_44100Hz.h @@ -6,7 +6,7 @@ /* Conversion from 48000 Hz to 44100 Hz */ /* NUM_FILTERS=7, FILTER_LENGTH=64, alpha=8.150000, gamma=0.456000 */ -static const int32_t coeff48000to44100[] = { +__cold_rodata static const int32_t coeff48000to44100[] = { /* Filter #7, conversion from 48000 Hz to 44100 Hz */ CONVERT_COEFF(-34608), /* Filter:7, Coefficient: 1 */ diff --git a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_48000Hz.h b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_48000Hz.h index c9e0d9b2f671..953a9adbdab3 100644 --- a/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_48000Hz.h +++ b/src/audio/asrc/coef/asrc_farrow_coeff_48000Hz_to_48000Hz.h @@ -6,7 +6,7 @@ /* Conversion from 48000 Hz to 48000 Hz */ /* NUM_FILTERS=7, FILTER_LENGTH=48, alpha=7.150000, gamma=0.458000 */ -static const int32_t coeff48000to48000[] = { +__cold_rodata static const int32_t coeff48000to48000[] = { /* Filter #7, conversion from 48000 Hz to 48000 Hz */ CONVERT_COEFF(201584), /* Filter:7, Coefficient: 1 */