before merging master
[inav.git] / lib / main / CMSIS / DSP / Source / SupportFunctions / arm_q7_to_q15.c
blob53481943abc681dfbc3f505be52feb87072466a0
1 /* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_q7_to_q15.c
4 * Description: Converts the elements of the Q7 vector to Q15 vector
6 * $Date: 27. January 2017
7 * $Revision: V.1.5.1
9 * Target Processor: Cortex-M cores
10 * -------------------------------------------------------------------- */
12 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
14 * SPDX-License-Identifier: Apache-2.0
16 * Licensed under the Apache License, Version 2.0 (the License); you may
17 * not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
20 * www.apache.org/licenses/LICENSE-2.0
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
29 #include "arm_math.h"
31 /**
32 * @ingroup groupSupport
35 /**
36 * @addtogroup q7_to_x
37 * @{
43 /**
44 * @brief Converts the elements of the Q7 vector to Q15 vector.
45 * @param[in] *pSrc points to the Q7 input vector
46 * @param[out] *pDst points to the Q15 output vector
47 * @param[in] blockSize length of the input vector
48 * @return none.
50 * \par Description:
52 * The equation used for the conversion process is:
54 * <pre>
55 * pDst[n] = (q15_t) pSrc[n] << 8; 0 <= n < blockSize.
56 * </pre>
61 void arm_q7_to_q15(
62 q7_t * pSrc,
63 q15_t * pDst,
64 uint32_t blockSize)
66 q7_t *pIn = pSrc; /* Src pointer */
67 uint32_t blkCnt; /* loop counter */
69 #if defined (ARM_MATH_DSP)
70 q31_t in;
71 q31_t in1, in2;
72 q31_t out1, out2;
74 /* Run the below code for Cortex-M4 and Cortex-M3 */
76 /*loop Unrolling */
77 blkCnt = blockSize >> 2U;
79 /* First part of the processing with loop unrolling. Compute 4 outputs at a time.
80 ** a second loop below computes the remaining 1 to 3 samples. */
81 while (blkCnt > 0U)
83 /* C = (q15_t) A << 8 */
84 /* convert from q7 to q15 and then store the results in the destination buffer */
85 in = *__SIMD32(pIn)++;
87 /* rotatate in by 8 and extend two q7_t values to q15_t values */
88 in1 = __SXTB16(__ROR(in, 8));
90 /* extend remainig two q7_t values to q15_t values */
91 in2 = __SXTB16(in);
93 in1 = in1 << 8U;
94 in2 = in2 << 8U;
96 in1 = in1 & 0xFF00FF00;
97 in2 = in2 & 0xFF00FF00;
99 #ifndef ARM_MATH_BIG_ENDIAN
101 out2 = __PKHTB(in1, in2, 16);
102 out1 = __PKHBT(in2, in1, 16);
104 #else
106 out1 = __PKHTB(in1, in2, 16);
107 out2 = __PKHBT(in2, in1, 16);
109 #endif
111 *__SIMD32(pDst)++ = out1;
112 *__SIMD32(pDst)++ = out2;
114 /* Decrement the loop counter */
115 blkCnt--;
118 /* If the blockSize is not a multiple of 4, compute any remaining output samples here.
119 ** No loop unrolling is used. */
120 blkCnt = blockSize % 0x4U;
122 #else
124 /* Run the below code for Cortex-M0 */
126 /* Loop over blockSize number of values */
127 blkCnt = blockSize;
129 #endif /* #if defined (ARM_MATH_DSP) */
131 while (blkCnt > 0U)
133 /* C = (q15_t) A << 8 */
134 /* convert from q7 to q15 and then store the results in the destination buffer */
135 *pDst++ = (q15_t) * pIn++ << 8;
137 /* Decrement the loop counter */
138 blkCnt--;
144 * @} end of q7_to_x group