2
* Purpose: Resampling routines for GRC3
4
* GRC library version 3.1
8
* This file is part of Open Sound System.
10
* Copyright (C) 4Front Technologies 1996-2008.
12
* This this source file is released under GPL v2 license (no other versions).
13
* See the COPYING file included in the main directory of this source
14
* distribution for the license terms and conditions.
18
static __inline__ int32_t SUFFIX (grc3_upsample_) (grc3state_t * grc,
20
TYPEOUT * dst, uint32_t sz,
25
GRCvreg uint32_t ptr = grc->ptr;
26
uint32_t srcrate = grc->srcrate;
27
uint32_t dstrate = grc->dstrate;
28
GRCvreg int32_t *history = grc->historyptr;
29
uint32_t filtfactor = grc->filtfactor;
44
DOCLAMP (QSUFFIX (_conv31_)
45
(history, _grc_sat6 (ptr, filtfactor))));
56
if (history >= (grc->history + GRC3_MAXHISTORY * 2))
57
history -= GRC3_MAXHISTORY;
59
history[0] = history[-GRC3_MAXHISTORY] = IN (((*src)));
73
grc->historyptr = history;
77
return (int32_t) dstsz;
80
__inline__ int32_t SUFFIX (grc3_dnsample_) (grc3state_t * grc, TYPEIN * src,
81
TYPEOUT * dst, uint32_t sz,
82
uint32_t bufsz, int32_t inc,
85
GRCvreg uint32_t ptr = grc->ptr;
86
uint32_t srcrate = grc->srcrate;
87
uint32_t dstrate = grc->dstrate;
88
uint32_t sat = grc->sat;
89
GRCvreg int32_t *history = grc->historyptr;
90
uint32_t filtfactor = grc->filtfactor;
100
while (ptr >= srcrate)
106
DOCLAMP (QSUFFIX (_conv31d_)
107
(history, _grc_sat6 (ptr, filtfactor),
118
if (history >= (grc->history + GRC3_MAXHISTORY * 2))
119
history -= GRC3_MAXHISTORY;
121
/* TODO: for better quality multiplier is worth moving to output cascade */
122
history[0] = history[-GRC3_MAXHISTORY] =
123
_grc_sat31 (IN (((*src))), sat);
137
grc->historyptr = history;
141
return (int32_t) dstsz;
144
static __inline__ int32_t SUFFIX (grc3_resample_) (grc3state_t * grc,
145
void *src, void *dst,
151
if (grc->srcrate <= grc->dstrate)
152
return SUFFIX (grc3_upsample_) (grc, (TYPEIN *) src, (TYPEOUT *) dst, sz,
155
return SUFFIX (grc3_dnsample_) (grc, (TYPEIN *) src, (TYPEOUT *) dst, sz,