Mercurial > hg > aim92
view model/interp.c @ 0:5242703e91d3 tip
Initial checkin for AIM92 aimR8.2 (last updated May 1997).
author | tomwalters |
---|---|
date | Fri, 20 May 2011 15:19:45 +0100 |
parents | |
children |
line wrap: on
line source
/* Copyright (c) Applied Psychology Unit, Medical Research Council. 1988, 1989 =========================================================================== Permission to use, copy, modify, and distribute this software without fee is hereby granted for research purposes, provided that this copyright notice appears in all copies and in all supporting documentation, and that the software is not redistributed for any fee (except for a nominal shipping charge). Anyone wanting to incorporate all or part of this software in a commercial product must obtain a license from the Medical Research Council. The MRC makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* interp.c ======== Some types of interpolation of short arrays for multiplexed filters linterp() performs fast linear interpolations from n points to n*2-1 points repeatedly till the number of points required is reached. interp() performs a slower but hopefully smoother (in the first differential) interpolation from n points to n*2-1 points. Author : John Holdsworth Written : 11th March, 1989. Edited : */ #ifndef lint static char *sccs_id = "@(#)interp.c 1.4 J. Holdsworth (MRC-APU) 11/21/89" ; #endif /* linear interpolation */ int linterp( input, output, points, newpoints ) short *input, *output ; int points, newpoints ; { register int store ; register short *optr, *end, *iptr ; register int nextpoints ; nextpoints = points ; end = input + 1 ; do { iptr = end - 1 + nextpoints - 1 ; nextpoints = nextpoints * 2 - 1 ; optr = output + nextpoints ; end = output + 1 ; do { *--optr = store = * iptr ; *--optr = store + *--iptr >> 1 ; } while( optr > end ) ; } while ( nextpoints < newpoints ) ; *--optr = *iptr ; return ; } /* simple 2nd orderish interpolation - preserves slopes */ int interp( input, output, points, newpoints ) short *input, *output ; int points, newpoints ; { register short *optr, *end, *iptr ; register int nextnum, bignum, oldbignum, oldput ; iptr = input ; optr = output ; end = output + newpoints ; #ifdef lint points ; #endif nextnum = *(iptr+1) ; oldbignum = ( *iptr << 2 ) + *iptr ; oldput = ( *iptr << 1 ) - nextnum ; while( optr < end ) { *optr++ = *iptr++ ; if( optr < end ) { bignum = ( nextnum << 2 ) + nextnum ; if( optr < end - 2 ) nextnum = *(iptr+1) ; else nextnum = ( *iptr << 1 ) - *(iptr-1) ; *optr++ = ( oldbignum + bignum - oldput - nextnum + 4 ) >> 3 ; oldbignum = bignum ; oldput = *(iptr-1) ; } } return ; }