00001 /*This file has been prepared for Doxygen automatic documentation generation.*/ 00016 /* Copyright (c) 2009 Atmel Corporation. All rights reserved. 00017 * 00018 * Redistribution and use in source and binary forms, with or without 00019 * modification, are permitted provided that the following conditions are met: 00020 * 00021 * 1. Redistributions of source code must retain the above copyright notice, this 00022 * list of conditions and the following disclaimer. 00023 * 00024 * 2. Redistributions in binary form must reproduce the above copyright notice, 00025 * this list of conditions and the following disclaimer in the documentation 00026 * and/or other materials provided with the distribution. 00027 * 00028 * 3. The name of Atmel may not be used to endorse or promote products derived 00029 * from this software without specific prior written permission. 00030 * 00031 * 4. This software may only be redistributed and used in connection with an Atmel 00032 * AVR product. 00033 * 00034 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00035 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00036 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00037 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 00038 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00039 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00040 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00041 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00042 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00043 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00044 * 00045 */ 00046 00047 #include "dsp.h" 00048 00049 #if defined(FORCE_ALL_GENERICS) || \ 00050 defined(FORCE_GENERIC_FILT16_INTERPOLATION_COEFSORT) || \ 00051 !defined(TARGET_SPECIFIC_FILT16_INTERPOLATION_COEFSORT) 00052 00053 inline static int get_new_index(int cur_index, int n_tap, int interpolation_ratio) 00054 { 00055 return n_tap * cur_index + (1 - n_tap * interpolation_ratio) * (cur_index / interpolation_ratio); 00056 } 00057 00058 void dsp16_filt_interpolation_coefsort(dsp16_t *fir_coefs, int n_tap, int interpolation_ratio) 00059 { 00060 int start_index, new_index, cur_index; 00061 int temp1, temp2; 00062 int size; 00063 00064 size = n_tap * interpolation_ratio; 00065 00066 // Uses the LSB of each data as a marker. 00067 // This will avoid a lot of computation time 00068 // or memory requierment. 00069 for(temp1=1; temp1<size-1; temp1++) 00070 fir_coefs[temp1] &= 0xFFFE; 00071 00072 for(start_index = 1; start_index < size - 1; start_index++) 00073 { 00074 // If marker set, means item already proceeded. 00075 if (fir_coefs[start_index] & 0x0001) 00076 continue; 00077 00078 new_index = start_index + 1; 00079 cur_index = start_index; 00080 temp1 = fir_coefs[cur_index]; 00081 00082 while(start_index != new_index) 00083 { 00084 new_index = get_new_index(cur_index, n_tap, interpolation_ratio); 00085 temp2 = fir_coefs[new_index]; 00086 fir_coefs[new_index] = temp1 | 0x0001; 00087 temp1 = temp2; 00088 cur_index = new_index; 00089 } 00090 } 00091 } 00092 00093 #endif