summaryrefslogtreecommitdiff
path: root/DSP/Source/TransformFunctions/arm_dct4_q31.c
diff options
context:
space:
mode:
authorrihab kouki <rihab.kouki@st.com>2020-07-28 11:24:49 +0100
committerrihab kouki <rihab.kouki@st.com>2020-07-28 11:24:49 +0100
commit96d6da4e252b06dcfdc041e7df23e86161c33007 (patch)
treea262f59bb1db7ec7819acae435f5049cbe5e2354 /DSP/Source/TransformFunctions/arm_dct4_q31.c
parent9f95ff5b6ba01db09552b84a0ab79607060a2666 (diff)
downloadst-cmsis-core-lowfat-master.tar.gz
st-cmsis-core-lowfat-master.tar.bz2
st-cmsis-core-lowfat-master.zip
Official ARM version: v5.6.0HEADmaster
Diffstat (limited to 'DSP/Source/TransformFunctions/arm_dct4_q31.c')
-rw-r--r--DSP/Source/TransformFunctions/arm_dct4_q31.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/DSP/Source/TransformFunctions/arm_dct4_q31.c b/DSP/Source/TransformFunctions/arm_dct4_q31.c
index 0569778..369a5c3 100644
--- a/DSP/Source/TransformFunctions/arm_dct4_q31.c
+++ b/DSP/Source/TransformFunctions/arm_dct4_q31.c
@@ -3,13 +3,13 @@
* Title: arm_dct4_q31.c
* Description: Processing function of DCT4 & IDCT4 Q31
*
- * $Date: 27. January 2017
- * $Revision: V.1.5.1
+ * $Date: 18. March 2019
+ * $Revision: V1.6.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
/*
- * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
+ * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -29,36 +29,38 @@
#include "arm_math.h"
/**
- * @addtogroup DCT4_IDCT4
- * @{
+ @addtogroup DCT4_IDCT4
+ @{
*/
/**
- * @brief Processing function for the Q31 DCT4/IDCT4.
- * @param[in] *S points to an instance of the Q31 DCT4 structure.
- * @param[in] *pState points to state buffer.
- * @param[in,out] *pInlineBuffer points to the in-place input and output buffer.
- * @return none.
- * \par Input an output formats:
- * Input samples need to be downscaled by 1 bit to avoid saturations in the Q31 DCT process,
- * as the conversion from DCT2 to DCT4 involves one subtraction.
- * Internally inputs are downscaled in the RFFT process function to avoid overflows.
- * Number of bits downscaled, depends on the size of the transform.
- * The input and output formats for different DCT sizes and number of bits to upscale are mentioned in the table below:
- *
- * \image html dct4FormatsQ31Table.gif
+ @brief Processing function for the Q31 DCT4/IDCT4.
+ @param[in] S points to an instance of the Q31 DCT4 structure.
+ @param[in] pState points to state buffer.
+ @param[in,out] pInlineBuffer points to the in-place input and output buffer.
+ @return none
+
+ @par Input an output formats
+ Input samples need to be downscaled by 1 bit to avoid saturations in the Q31 DCT process,
+ as the conversion from DCT2 to DCT4 involves one subtraction.
+ Internally inputs are downscaled in the RFFT process function to avoid overflows.
+ Number of bits downscaled, depends on the size of the transform.
+ The input and output formats for different DCT sizes and number of bits to upscale are
+ mentioned in the table below:
+
+ \image html dct4FormatsQ31Table.gif
*/
void arm_dct4_q31(
const arm_dct4_instance_q31 * S,
- q31_t * pState,
- q31_t * pInlineBuffer)
+ q31_t * pState,
+ q31_t * pInlineBuffer)
{
- uint16_t i; /* Loop counter */
- q31_t *weights = S->pTwiddle; /* Pointer to the Weights table */
- q31_t *cosFact = S->pCosFactor; /* Pointer to the cos factors table */
- q31_t *pS1, *pS2, *pbuff; /* Temporary pointers for input buffer and pState buffer */
- q31_t in; /* Temporary variable */
+ const q31_t *weights = S->pTwiddle; /* Pointer to the Weights table */
+ const q31_t *cosFact = S->pCosFactor; /* Pointer to the cos factors table */
+ q31_t *pS1, *pS2, *pbuff; /* Temporary pointers for input buffer and pState buffer */
+ q31_t in; /* Temporary variable */
+ uint32_t i; /* Loop counter */
/* DCT4 computation involves DCT2 (which is calculated using RFFT)
@@ -80,10 +82,10 @@ void arm_dct4_q31(
* (d) Multiplying the output with the normalizing factor sqrt(2/N).
*/
- /*-------- Pre-processing ------------*/
+ /*-------- Pre-processing ------------*/
/* Multiplying input with cos factor i.e. r(n) = 2 * x(n) * cos(pi*(2*n+1)/(4*n)) */
- arm_mult_q31(pInlineBuffer, cosFact, pInlineBuffer, S->N);
- arm_shift_q31(pInlineBuffer, 1, pInlineBuffer, S->N);
+ arm_mult_q31 (pInlineBuffer, cosFact, pInlineBuffer, S->N);
+ arm_shift_q31 (pInlineBuffer, 1, pInlineBuffer, S->N);
/* ----------------------------------------------------------------
* Step1: Re-ordering of even and odd elements as
@@ -100,9 +102,8 @@ void arm_dct4_q31(
/* pbuff initialized to input buffer */
pbuff = pInlineBuffer;
-#if defined (ARM_MATH_DSP)
- /* Run the below code for Cortex-M4 and Cortex-M3 */
+#if defined (ARM_MATH_LOOPUNROLL)
/* Initializing the loop counter to N/2 >> 2 for loop unrolling by 4 */
i = S->Nby2 >> 2U;
@@ -126,7 +127,7 @@ void arm_dct4_q31(
*pS1++ = *pbuff++;
*pS2-- = *pbuff++;
- /* Decrement the loop counter */
+ /* Decrement loop counter */
i--;
} while (i > 0U);
@@ -158,16 +159,16 @@ void arm_dct4_q31(
* Step2: Calculate RFFT for N-point input
* ---------------------------------------------------------- */
/* pInlineBuffer is real input of length N , pState is the complex output of length 2N */
- arm_rfft_q31(S->pRfft, pInlineBuffer, pState);
+ arm_rfft_q31 (S->pRfft, pInlineBuffer, pState);
/*----------------------------------------------------------------------
* Step3: Multiply the FFT output with the weights.
*----------------------------------------------------------------------*/
- arm_cmplx_mult_cmplx_q31(pState, weights, pState, S->N);
+ arm_cmplx_mult_cmplx_q31 (pState, weights, pState, S->N);
/* The output of complex multiplication is in 3.29 format.
* Hence changing the format of N (i.e. 2*N elements) complex numbers to 1.31 format by shifting left by 2 bits. */
- arm_shift_q31(pState, 2, pState, S->N * 2);
+ arm_shift_q31 (pState, 2, pState, S->N * 2);
/* ----------- Post-processing ---------- */
/* DCT-IV can be obtained from DCT-II by the equation,
@@ -229,15 +230,16 @@ void arm_dct4_q31(
/* pState pointer (pS1) is incremented twice as the real values are located alternatively in the array */
in = *pS1++ - in;
*pbuff++ = in;
+
/* points to the next real value */
pS1++;
- /* Decrement the loop counter */
+ /* Decrement loop counter */
i--;
}
- /*------------ Normalizing the output by multiplying with the normalizing factor ----------*/
+ /*------------ Normalizing the output by multiplying with the normalizing factor ----------*/
/* Initializing the loop counter to N/4 instead of N for loop unrolling */
i = S->N >> 2U;
@@ -261,15 +263,13 @@ void arm_dct4_q31(
in = *pbuff;
*pbuff++ = ((q31_t) (((q63_t) in * S->normalize) >> 31));
- /* Decrement the loop counter */
+ /* Decrement loop counter */
i--;
} while (i > 0U);
#else
- /* Run the below code for Cortex-M0 */
-
/* Initializing the loop counter to N/2 */
i = S->Nby2;
@@ -308,12 +308,12 @@ void arm_dct4_q31(
* Step2: Calculate RFFT for N-point input
* ---------------------------------------------------------- */
/* pInlineBuffer is real input of length N , pState is the complex output of length 2N */
- arm_rfft_q31(S->pRfft, pInlineBuffer, pState);
+ arm_rfft_q31 (S->pRfft, pInlineBuffer, pState);
/*----------------------------------------------------------------------
* Step3: Multiply the FFT output with the weights.
*----------------------------------------------------------------------*/
- arm_cmplx_mult_cmplx_q31(pState, weights, pState, S->N);
+ arm_cmplx_mult_cmplx_q31 (pState, weights, pState, S->N);
/* The output of complex multiplication is in 3.29 format.
* Hence changing the format of N (i.e. 2*N elements) complex numbers to 1.31 format by shifting left by 2 bits. */
@@ -348,20 +348,20 @@ void arm_dct4_q31(
/* pState pointer (pS1) is incremented twice as the real values are located alternatively in the array */
in = *pS1++ - in;
*pbuff++ = in;
+
/* points to the next real value */
pS1++;
- /* Decrement the loop counter */
+ /* Decrement loop counter */
i--;
}
+ /*------------ Normalizing the output by multiplying with the normalizing factor ----------*/
- /*------------ Normalizing the output by multiplying with the normalizing factor ----------*/
-
- /* Initializing the loop counter */
+ /* Initializing loop counter */
i = S->N;
- /* pbuff initialized to the pInlineBuffer(now contains the output values) */
+ /* pbuff initialized to the pInlineBuffer (now contains the output values) */
pbuff = pInlineBuffer;
do
@@ -370,14 +370,14 @@ void arm_dct4_q31(
in = *pbuff;
*pbuff++ = ((q31_t) (((q63_t) in * S->normalize) >> 31));
- /* Decrement the loop counter */
+ /* Decrement loop counter */
i--;
} while (i > 0U);
-#endif /* #if defined (ARM_MATH_DSP) */
+#endif /* #if defined (ARM_MATH_LOOPUNROLL) */
}
/**
- * @} end of DCT4_IDCT4 group
- */
+ @} end of DCT4_IDCT4 group
+ */