00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2011 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 15. December 2011 00005 * $Revision: V2.0.0 00006 * 00007 * Project: Cortex-R DSP Library 00008 * Title: arm_cmplx_conj_q31.c 00009 * 00010 * Description: Q31 complex conjugate. 00011 * 00012 * Target Processor: Cortex-R4/R5 00013 * 00014 * Version 1.0.0 2011/03/08 00015 * Alpha release. 00016 * 00017 * Version 1.0.1 2011/09/30 00018 * Beta release. 00019 * 00020 * Version 2.0.0 2011/12/15 00021 * Final release. 00022 * 00023 * ---------------------------------------------------------------------------- */ 00024 #include "arm_math.h" 00025 00048 void arm_cmplx_conj_q31( 00049 q31_t * pSrc, 00050 q31_t * pDst, 00051 uint32_t numSamples) 00052 { 00053 uint32_t blkCnt; /* loop counter */ 00054 q31_t in; /* Input value */ 00055 q31_t inR1, inR2, inR3, inR4; /* Temporary real variables */ 00056 q31_t inI1, inI2, inI3, inI4; /* Temporary imaginary variables */ 00057 00058 /*loop Unrolling */ 00059 blkCnt = numSamples >> 2u; 00060 00061 /* First part of the processing with loop unrolling. Compute 4 outputs at a time. 00062 ** a second loop below computes the remaining 1 to 3 samples. */ 00063 while(blkCnt > 0u) 00064 { 00065 /* C[0]+jC[1] = A[0]+ j (-1) A[1] */ 00066 /* Calculate Complex Conjugate and then store the results in the destination buffer. */ 00067 /* Saturated to 0x7fffffff if the input is -1(0x80000000)*/ 00068 /* read real input sample */ 00069 inR1 = pSrc[0]; 00070 /* store real input sample */ 00071 pDst[0] = inR1; 00072 00073 /* read imaginary input sample */ 00074 inI1 = pSrc[1]; 00075 00076 /* read real input sample */ 00077 inR2 = pSrc[2]; 00078 /* store real input sample */ 00079 pDst[2] = inR2; 00080 00081 /* read imaginary input sample */ 00082 inI2 = pSrc[3]; 00083 00084 /* negate imaginary input sample */ 00085 inI1 = __QSUB(0, inI1); 00086 00087 /* read real input sample */ 00088 inR3 = pSrc[4]; 00089 /* store real input sample */ 00090 pDst[4] = inR3; 00091 00092 /* read imaginary input sample */ 00093 inI3 = pSrc[5]; 00094 00095 /* negate imaginary input sample */ 00096 inI2 = __QSUB(0, inI2); 00097 00098 /* read real input sample */ 00099 inR4 = pSrc[6]; 00100 /* store real input sample */ 00101 pDst[6] = inR4; 00102 00103 /* negate imaginary input sample */ 00104 inI3 = __QSUB(0, inI3); 00105 00106 /* store imaginary input sample */ 00107 inI4 = pSrc[7]; 00108 00109 /* store imaginary input samples */ 00110 pDst[1] = inI1; 00111 00112 /* negate imaginary input sample */ 00113 inI4 = __QSUB(0, inI4); 00114 00115 /* store imaginary input samples */ 00116 pDst[3] = inI2; 00117 00118 /* increment source pointer by 8 to proecess next samples */ 00119 pSrc += 8u; 00120 00121 /* store imaginary input samples */ 00122 pDst[5] = inI3; 00123 pDst[7] = inI4; 00124 00125 /* increment destination pointer by 8 to process next samples */ 00126 pDst += 8u; 00127 00128 /* Decrement the loop counter */ 00129 blkCnt--; 00130 } 00131 00132 /* If the numSamples is not a multiple of 4, compute any remaining output samples here. 00133 ** No loop unrolling is used. */ 00134 blkCnt = numSamples % 0x4u; 00135 00136 while(blkCnt > 0u) 00137 { 00138 /* C[0]+jC[1] = A[0]+ j (-1) A[1] */ 00139 /* Calculate Complex Conjugate and then store the results in the destination buffer. */ 00140 /* Saturated to 0x7fffffff if the input is -1(0x80000000)*/ 00141 *pDst++ = *pSrc++; 00142 in = *pSrc++; 00143 *pDst++ = (in == 0x80000000) ? 0x7fffffff : -in; 00144 00145 /* Decrement the loop counter */ 00146 blkCnt--; 00147 } 00148 } 00149