28 #if defined(TEMPLATE_RESAMPLE_DBL)
30 # define RENAME(N) N ## _double
31 # define FILTER_SHIFT 0
34 # define FELEM2 double
36 # define OUT(d, v) d = v
38 #elif defined(TEMPLATE_RESAMPLE_FLT)
40 # define RENAME(N) N ## _float
41 # define FILTER_SHIFT 0
46 # define OUT(d, v) d = v
48 #elif defined(TEMPLATE_RESAMPLE_S32)
50 # define RENAME(N) N ## _int32
51 # define FILTER_SHIFT 30
52 # define DELEM int32_t
53 # define FELEM int32_t
54 # define FELEM2 int64_t
55 # define FELEM_MAX INT32_MAX
56 # define FELEM_MIN INT32_MIN
57 # define FOFFSET (1<<(FILTER_SHIFT-1))
58 # define OUT(d, v) (d) = av_clipl_int32((v)>>FILTER_SHIFT)
60 #elif defined(TEMPLATE_RESAMPLE_S16)
62 # define RENAME(N) N ## _int16
63 # define FILTER_SHIFT 15
64 # define DELEM int16_t
65 # define FELEM int16_t
66 # define FELEM2 int32_t
67 # define FELEML int64_t
68 # define FELEM_MAX INT16_MAX
69 # define FELEM_MIN INT16_MIN
70 # define FOFFSET (1<<(FILTER_SHIFT-1))
71 # define OUT(d, v) (d) = av_clip_int16((v)>>FILTER_SHIFT)
76 int dst_size, int64_t index2, int64_t incr)
79 const DELEM *
src = source;
82 for (dst_index = 0; dst_index < dst_size; dst_index++) {
83 dst[dst_index] = src[index2 >> 32];
89 void *dest,
const void *source,
90 int n,
int update_ctx)
93 const DELEM *
src = source;
99 while (index >=
c->phase_count) {
101 index -=
c->phase_count;
104 for (dst_index = 0; dst_index <
n; dst_index++) {
110 for (i = 0; i + 1 <
c->filter_length; i+=2) {
111 val += src[sample_index + i ] * (
FELEM2)filter[i ];
112 val2 += src[sample_index + i + 1] * (
FELEM2)filter[i + 1];
115 val += src[sample_index + i ] * (
FELEM2)filter[i ];
119 OUT(dst[dst_index], val + val2);
122 frac +=
c->dst_incr_mod;
123 index +=
c->dst_incr_div;
124 if (frac >=
c->src_incr) {
129 while (index >=
c->phase_count) {
131 index -=
c->phase_count;
144 void *dest,
const void *source,
145 int n,
int update_ctx)
148 const DELEM *
src = source;
152 int sample_index = 0;
153 #if FILTER_SHIFT == 0
154 double inv_src_incr = 1.0 /
c->src_incr;
157 while (index >=
c->phase_count) {
159 index -=
c->phase_count;
162 for (dst_index = 0; dst_index <
n; dst_index++) {
167 for (i = 0; i <
c->filter_length; i++) {
168 val += src[sample_index + i] * (
FELEM2)filter[i];
169 v2 += src[sample_index + i] * (
FELEM2)filter[i +
c->filter_alloc];
172 val += (v2 -
val) * (
FELEML) frac /
c->src_incr;
174 # if FILTER_SHIFT == 0
175 val += (v2 -
val) * inv_src_incr * frac;
177 val += (v2 -
val) /
c->src_incr * frac;
180 OUT(dst[dst_index], val);
182 frac +=
c->dst_incr_mod;
183 index +=
c->dst_incr_div;
184 if (frac >=
c->src_incr) {
189 while (index >=
c->phase_count) {
191 index -=
c->phase_count;
const char const char void * val
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, int clip)
static void SET_TYPE() resample_linear(ResampleContext *c, void *dst0, int dst_index, const void *src0, unsigned int index, int frac)
static void SET_TYPE() resample_one(ResampleContext *c, void *dst0, int dst_index, const void *src0, unsigned int index, int frac)
int(* resample_common)(struct ResampleContext *c, void *dst, const void *src, int n, int update_ctx)