1 /* ----------------------------------------------------------------------------
2 * Copyright (C) 2010 ARM Limited. All rights reserved.
7 * Project: CMSIS DSP Library
8 * Title: arm_q31_to_q7.c
10 * Description: Converts the elements of the Q31 vector to Q7 vector.
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
14 * Version 1.0.10 2011/7/15
15 * Big Endian support added and Merged M0 and M3/M4 Source code.
17 * Version 1.0.3 2010/11/29
18 * Re-organized the CMSIS folders and updated documentation.
20 * Version 1.0.2 2010/11/11
21 * Documentation updated.
23 * Version 1.0.1 2010/10/05
24 * Production release and review comments incorporated.
26 * Version 1.0.0 2010/09/20
27 * Production release and review comments incorporated.
28 * ---------------------------------------------------------------------------- */
33 * @ingroup groupSupport
37 * @addtogroup q31_to_x
42 * @brief Converts the elements of the Q31 vector to Q7 vector.
43 * @param[in] *pSrc points to the Q31 input vector
44 * @param[out] *pDst points to the Q7 output vector
45 * @param[in] blockSize length of the input vector
50 * The equation used for the conversion process is:
53 * pDst[n] = (q7_t) pSrc[n] >> 24; 0 <= n < blockSize.
64 q31_t *pIn = pSrc; /* Src pointer */
65 uint32_t blkCnt; /* loop counter */
69 /* Run the below code for Cortex-M4 and Cortex-M3 */
72 blkCnt = blockSize >> 2u;
74 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
75 ** a second loop below computes the remaining 1 to 3 samples. */
78 /* C = (q7_t) A >> 24 */
79 /* convert from q31 to q7 and then store the results in the destination buffer */
80 *pDst++ = (q7_t) (*pIn++ >> 24);
81 *pDst++ = (q7_t) (*pIn++ >> 24);
82 *pDst++ = (q7_t) (*pIn++ >> 24);
83 *pDst++ = (q7_t) (*pIn++ >> 24);
85 /* Decrement the loop counter */
89 /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
90 ** No loop unrolling is used. */
91 blkCnt = blockSize % 0x4u;
95 /* Run the below code for Cortex-M0 */
97 /* Loop over blockSize number of values */
100 #endif /* #ifndef ARM_MATH_CM0 */
104 /* C = (q7_t) A >> 24 */
105 /* convert from q31 to q7 and then store the results in the destination buffer */
106 *pDst++ = (q7_t) (*pIn++ >> 24);
108 /* Decrement the loop counter */
115 * @} end of q31_to_x group