28 #if defined(TEMPLATE_RESAMPLE_DBL)
30 # define RENAME(N) N ## _double
31 # define FILTER_SHIFT 0
34 # define FELEM2 double
35 # define OUT(d, v) d = v
37 #elif defined(TEMPLATE_RESAMPLE_FLT)
39 # define RENAME(N) N ## _float
40 # define FILTER_SHIFT 0
44 # define OUT(d, v) d = v
46 #elif defined(TEMPLATE_RESAMPLE_S32)
48 # define RENAME(N) N ## _int32
49 # define FILTER_SHIFT 30
50 # define DELEM int32_t
51 # define FELEM int32_t
52 # define FELEM2 int64_t
53 # define FELEM_MAX INT32_MAX
54 # define FELEM_MIN INT32_MIN
55 # define OUT(d, v) (v) = ((v) + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;\
56 (d) = av_clipl_int32(v)
58 #elif defined(TEMPLATE_RESAMPLE_S16)
60 # define RENAME(N) N ## _int16
61 # define FILTER_SHIFT 15
62 # define DELEM int16_t
63 # define FELEM int16_t
64 # define FELEM2 int32_t
65 # define FELEML int64_t
66 # define FELEM_MAX INT16_MAX
67 # define FELEM_MIN INT16_MIN
68 # define OUT(d, v) (v) = ((v) + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;\
69 (d) = av_clip_int16(v)
74 int dst_size, int64_t index2, int64_t incr)
77 const DELEM *
src = source;
80 for (dst_index = 0; dst_index < dst_size; dst_index++) {
81 dst[dst_index] = src[index2 >> 32];
87 void *dest,
const void *source,
88 int n,
int update_ctx)
91 const DELEM *
src = source;
97 while (index >=
c->phase_count) {
99 index -=
c->phase_count;
102 for (dst_index = 0; dst_index <
n; dst_index++) {
107 for (i = 0; i <
c->filter_length; i++) {
108 val += src[sample_index + i] * (
FELEM2)filter[i];
110 OUT(dst[dst_index], val);
112 frac +=
c->dst_incr_mod;
113 index +=
c->dst_incr_div;
114 if (frac >=
c->src_incr) {
119 while (index >=
c->phase_count) {
121 index -=
c->phase_count;
134 void *dest,
const void *source,
135 int n,
int update_ctx)
138 const DELEM *
src = source;
142 int sample_index = 0;
143 #if FILTER_SHIFT == 0
144 double inv_src_incr = 1.0 /
c->src_incr;
147 while (index >=
c->phase_count) {
149 index -=
c->phase_count;
152 for (dst_index = 0; dst_index <
n; dst_index++) {
157 for (i = 0; i <
c->filter_length; i++) {
158 val += src[sample_index + i] * (
FELEM2)filter[i];
159 v2 += src[sample_index + i] * (
FELEM2)filter[i +
c->filter_alloc];
162 val += (v2 -
val) * (
FELEML) frac /
c->src_incr;
164 # if FILTER_SHIFT == 0
165 val += (v2 -
val) * inv_src_incr * frac;
167 val += (v2 -
val) /
c->src_incr * frac;
170 OUT(dst[dst_index], val);
172 frac +=
c->dst_incr_mod;
173 index +=
c->dst_incr_div;
174 if (frac >=
c->src_incr) {
179 while (index >=
c->phase_count) {
181 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, uint8_t 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)